This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: block index migration script (#1)
Provides 2 commands - clis.js: scan the source dynamo table. for each record transform it to the new format and see if it exists in the destination table. If not, write the record to disk as ndjson - write-cli.js: takes an ndjson file of indexes as input and writes them in batches to the destination table. Writes any operations to disk as ndjson for retrying. _these would be a single command, but I am in the middle of running the read side of things and didn't want to break it, so the write side lives in separate files. If we care we can merge them later_ Dynamo table scans let us split up the results into segments. You tell it how many segments to divide the result set into, and a current segment, and the scan command will fetch all the results for that segment only. This is nice, as it makes it easier to divide the work up across workers. License: MIT --------- Signed-off-by: Oli Evans <[email protected]> Co-authored-by: Alan Shaw <[email protected]>
- Loading branch information
Showing
14 changed files
with
12,165 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Test | ||
description: 'Setup and test' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-node@v3 | ||
with: | ||
registry-url: 'https://registry.npmjs.org' | ||
node-version: 18 | ||
cache: 'npm' | ||
- run: npm ci | ||
shell: bash | ||
- run: npm test | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Test | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
migrate-block-index-* | ||
write-unprocessed-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env node | ||
|
||
import ora from 'ora' | ||
import { todo } from './migrate.js' | ||
import { DynamoDBClient } from '@aws-sdk/client-dynamodb' | ||
|
||
const src = process.argv.at(2) ?? exit('plz pass source table name') | ||
const dst = process.argv.at(3) ?? exit('plz pass destination table name') | ||
const totalSegments = parseInt(process.argv.at(4) ?? exit('plz pass totalSegments')) | ||
const segment = parseInt(process.argv.at(5) ?? exit('plz pass segment')) | ||
const client = new DynamoDBClient() | ||
|
||
const spinner = ora({ | ||
text: `Migrating: ${src} -> ${dst}` | ||
}).start() | ||
|
||
// await migrate(src, dst, client, spinner) | ||
await todo(src, dst, segment, totalSegments, client, spinner) | ||
|
||
function exit (msg) { | ||
console.error(msg) | ||
process.exit(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"Responses": { | ||
"prod-ep-v1-blocks-cars-position": [ | ||
{ | ||
"blockmultihash": { | ||
"S": "z2Drjgb6bW26vwjB44f8gHTeFUKFUofvRVxHerEWp7twXxxxxxx" | ||
}, | ||
"offset": { | ||
"N": "3317501" | ||
}, | ||
"length": { | ||
"N": "2765" | ||
}, | ||
"carpath": { | ||
"S": "region/bucket/raw/QmXLdJm1icGsm8PYtfUPHpXbZdWQRWZcmSQyLixxxxxxxx/3153187342xxxxxxxx/ciqhzffo5jf6ei5spizagdqyegetvxj35rxfkadhwgastaqxxxxxxxx.car" | ||
} | ||
} | ||
] | ||
}, | ||
"UnprocessedKeys": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"prod-ep-v1-blocks-cars-position": { | ||
"Keys": [ | ||
{ | ||
"blockmultihash": { | ||
"S": "z2Drjgb6bW26vwjB44f8gHTeFUKFUofvRVxHerEWp7txxxxxxxx" | ||
}, | ||
"carpath": { | ||
"S": "region/bucket/raw/QmXLdJm1icGsm8PYtfUPHpXbZdWQRWZcmSQyLixxxxxxxx/3153187342xxxxxxxx/ciqhzffo5jf6ei5spizagdqyegetvxj35rxfkadhwgastaqxxxxxxxx.car" | ||
} | ||
}, | ||
{ | ||
"blockmultihash": { | ||
"S": "nope" | ||
}, | ||
"carpath": { | ||
"S": "region/bucket/raw/QmXLdJm1icGsm8PYtfUPHpXbZdWQRWZcmSQyLixxxxxxxx/3153187342xxxxxxxx/ciqhzffo5jf6ei5spizagdqyegetvxj35rxfkadhwgastaqxxxxxxxx.car" | ||
} | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.