Created
November 11, 2022 10:47
-
-
Save vladholubiev/ef8795e868656dcc6db6e53ef9811af9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const {parallelScanAsStream} = require('@shelf/dynamodb-parallel-scan'); | |
(async () => { | |
const stream = await parallelScanAsStream( | |
{ | |
TableName: 'files', | |
FilterExpression: 'attribute_exists(#fileSize)', | |
ExpressionAttributeNames: { | |
'#fileSize': 'fileSize', | |
}, | |
ProjectionExpression: 'fileSize', | |
}, | |
{concurrency: 1000, chunkSize: 10000, highWaterMark: 10000} | |
); | |
for await (const items of stream) { | |
console.log(items); // 10k items here | |
// do some async processing to offload data from memory | |
// and move on to cosuming the next chunk | |
// scanning will be paused for that time | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment