Amazon DynamoDB 查询和扫描迭代
这个图书馆为整个DynamoDB自动巡回提供公用设施 通过查询或扫描操作返回的记录 同步可移动。 。 。 . 此软件包中包含的每个迭代和渐变自动轨道 DynamoDB 元数据,并支持在全数内从任何点恢复重迭 查询或扫描.
开始器
起动器是一种同步的可移动器,可以生成返回的每页结果
由迪纳摩DB公司制作 query 或者说 scan 操作。 对于相继起子,每个
援引 next 方法与援引基础
API 操作,直到没有其他页面可用为止.
查询辅助程序
获取一个 DynamoDB 的所有页面 query 以顺序.
示例用途
import { QueryPaginator } from '@aws/dynamodb-query-iterator';
import DynamoDB = require('aws-sdk/clients/dynamodb');
const paginator = new QueryPaginator(
new DynamoDB({region: 'us-west-2'}),
{
TableName: 'my_table',
KeyConditionExpression: 'partitionKey = :value',
ExpressionAttributeValues: {
':value': {S: 'foo'}
},
ReturnConsumedCapacity: 'INDEXES'
}
);
for await (const page of paginator) {
// do something with `page`
}
// Inspect the total number of items yielded
console.log(paginator.count);
// Inspect the total number of items scanned by this operation
console.log(paginator.scannedCount);
// Inspect the capacity consumed by this operation
// This will only be available if `ReturnConsumedCapacity` was set on the input
console.log(paginator.consumedCapacity);
暂停和恢复查询
您可以暂停任何运行中的查询 for 通过使用
break 关键词 如果还有页尚未取出
lastEvaluatedKey 将定义占卜器的属性。 这可以提供
作为 ExclusiveStartKey 用于另一个 QueryPaginator 实例:
import { QueryPaginator } from '@aws/dynamodb-query-iterator';
import { QueryInput } from 'aws-sdk/clients/dynamodb';
import DynamoDB = require('aws-sdk/clients/dynamodb');
const dynamoDb = new DynamoDB({region: 'us-west-2'});
const input: QueryInput = {
TableName: 'my_table',
KeyConditionExpression: 'partitionKey = :value',
ExpressionAttributeValues: {
':value': {S: 'foo'}
},
ReturnConsumedCapacity: 'INDEXES'
};
const paginator = new QueryPaginator(dynamoDb, input);
for await (const page of paginator) {
// do something with the first page of results
break
}
for await (const page of new QueryPaginator(dynamoDb, {
...input,
ExclusiveStartKey: paginator.lastEvaluatedKey
})) {
// do something with the remaining pages
}
不支持暂停和恢复同一比特实例.
扫描辅助器
获取一个 DynamoDB 的所有页面 scan 以顺序.
示例用途
import { ScanPaginator } from '@aws/dynamodb-query-iterator';
import DynamoDB = require('aws-sdk/clients/dynamodb');
const paginator = new ScanPaginator(
new DynamoDB({region: 'us-west-2'}),
{
TableName: 'my_table',
ReturnConsumedCapacity: 'INDEXES'
}
);
for await (const page of paginator) {
// do something with `page`
}
// Inspect the total number of items yielded
console.log(paginator.count);
// Inspect the total number of items scanned by this operation
console.log(paginator.scannedCount);
// Inspect the capacity consumed by this operation
// This will only be available if `ReturnConsumedCapacity` was set on the input
console.log(paginator.consumedCapacity);
暂停和恢复扫描
您可以中止任何运行中的扫描 for 通过使用 break
关键词 如果还有页尚未取出
lastEvaluatedKey 将定义占卜器的属性。 这可以提供
作为 ExclusiveStartKey 用于另一个 ScanPaginator 实例:
import { ScanPaginator } from '@aws/dynamodb-query-iterator';
import { ScanInput } from 'aws-sdk/clients/dynamodb';
import DynamoDB = require('aws-sdk/clients/dynamodb');
const dynamoDb = new DynamoDB({region: 'us-west-2'});
const input: ScanInput = {
TableName: 'my_table',
ReturnConsumedCapacity: 'INDEXES'
};
const paginator = new ScanPaginator(dynamoDb, input);
for await (const page of paginator) {
// do something with the first page of results
break
}
for await (const page of new ScanPaginator(dynamoDb, {
...input,
ExclusiveStartKey: paginator.lastEvaluatedKey
})) {
// do something with the remaining pages
}
不支持暂停和恢复同一比特实例.
并行扫描处理器
获取一个 DynamoDB 的所有页面 scan 使用可配置的扫描次数
平行运行的区段。 在进行平行扫描时,必须
指定您想要使用的片段的总数,而不是
ExclusiveStartKey 也没有 Segment 输入时可包含标识符
提供.
示例用途
import { ParallelScanPaginator } from '@aws/dynamodb-query-iterator';
import DynamoDB = require('aws-sdk/clients/dynamodb');
const paginator = new ParallelScanPaginator(
new DynamoDB({region: 'us-west-2'}),
{
TableName: 'my_table',
TotalSegments: 4,
ReturnConsumedCapacity: 'INDEXES'
}
);
for await (const page of paginator) {
// do something with `page`
}
// Inspect the total number of items yielded
console.log(paginator.count);
// Inspect the total number of items scanned by this operation
console.log(paginator.scannedCount);
// Inspect the capacity consumed by this operation
// This will only be available if `ReturnConsumedCapacity` was set on the input
console.log(paginator.consumedCapacity);
暂停和恢复平行扫描
您可以中止任何运行中的扫描 for 通过使用 break
关键词 如果还有页尚未取出 scanState
中断的起动器的属性可以提供给另一个起动器的构造者
ParallelScanPaginator 实例:
import {
ParallelScanInput,
ParallelScanPaginator,
} from '@aws/dynamodb-query-iterator';
import DynamoDB = require('aws-sdk/clients/dynamodb');
const client = new DynamoDB({region: 'us-west-2'});
const input: ParallelScanInput = {
TableName: 'my_table',
TotalSegments: 4,
ReturnConsumedCapacity: 'INDEXES'
};
const paginator = new ParallelScanPaginator(client, input);
for await (const page of paginator) {
// do something with the first page of results
break
}
for await (const page of new ParallelScanPaginator(
client,
input,
paginator.scanState
)) {
// do something with the remaining pages
}
不支持暂停和恢复同一比特实例.
显示器
传动器是一种同步的传动器,它使每个记录都通过一个
迪纳摩DB query 或者说 scan 操作。 每一援引 next 方法可能
引用基础的 API 操作,直到不再有所有页面.
查询器
检索 DynamoDB 的全部记录 query 以顺序.
示例用途
import { QueryIterator } from '@aws/dynamodb-query-iterator';
import DynamoDB = require('aws-sdk/clients/dynamodb');
const iterator = new QueryIterator(
new DynamoDB({region: 'us-west-2'}),
{
TableName: 'my_table',
KeyConditionExpression: 'partitionKey = :value',
ExpressionAttributeValues: {
':value': {S: 'foo'}
},
ReturnConsumedCapacity: 'INDEXES'
},
['partitionKey']
);
for await (const record of iterator) {
// do something with `record`
}
// Inspect the total number of items yielded
console.log(iterator.count);
// Inspect the total number of items scanned by this operation
console.log(iterator.scannedCount);
// Inspect the capacity consumed by this operation
// This will only be available if `ReturnConsumedCapacity` was set on the input
console.log(iterator.consumedCapacity);
扫描器
检索 DynamoDB 的全部记录 scan 以顺序.
示例用途
import { ScanIterator } from '@aws/dynamodb-query-iterator';
import DynamoDB = require('aws-sdk/clients/dynamodb');
const iterator = new ScanIterator(
new DynamoDB({region: 'us-west-2'}),
{
TableName: 'my_table',
ReturnConsumedCapacity: 'INDEXES'
},
['partitionKey', 'sortKey']
);
for await (const record of iterator) {
// do something with `record`
}
// Inspect the total number of items yielded
console.log(iterator.count);
// Inspect the total number of items scanned by this operation
console.log(iterator.scannedCount);
// Inspect the capacity consumed by this operation
// This will only be available if `ReturnConsumedCapacity` was set on the input
console.log(iterator.consumedCapacity);
平行扫描器
获取一个 DynamoDB 的所有页面 scan 使用可配置的扫描次数
平行运行的区段。 在进行平行扫描时,必须
指定您想要使用的片段的总数,而不是
ExclusiveStartKey 也没有 Segment 输入时可包含标识符
提供.
示例用途
import { ParallelScanIterator} from '@aws/dynamodb-query-iterator';
import DynamoDB = require('aws-sdk/clients/dynamodb');
const iterator = new ParallelScanIterator(
new DynamoDB({region: 'us-west-2'}),
{
TableName: 'my_table',
TotalSegments: 4,
ReturnConsumedCapacity: 'INDEXES'
},
['partitionKey']
);
for await (const record of iterator) {
// do something with `record`
}
// Inspect the total number of items yielded
console.log(iterator.count);
// Inspect the total number of items scanned by this operation
console.log(iterator.scannedCount);
// Inspect the capacity consumed by this operation
// This will only be available if `ReturnConsumedCapacity` was set on the input
console.log(iterator.consumedCapacity);