【发布时间】:2015-08-27 07:52:48
【问题描述】:
我为我的发电机表设置了流。我正在按照文档中的示例程序从流中读取数据(http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.LowLevel.Walkthrough.CompleteProgram.html)。但是我有一个问题- 在遍历分片时,似乎检查分片迭代器是否为空并不是退出循环的充分条件。我的代码进入无限循环。在示例程序中,计算更改次数并用于退出循环-->
while (nextItr != null && numChanges > 0) {
// Use the iterator to read the data records from the shard
GetRecordsResult getRecordsResult =
streamsClient.getRecords(new GetRecordsRequest().
withShardIterator(nextItr));
List<Record> records = getRecordsResult.getRecords();
System.out.println("Getting records...");
for (Record record : records) {
System.out.println(record);
numChanges--;
}
nextItr = getRecordsResult.getNextShardIterator();
}
但在真实环境中,我确信维护更改列表是不切实际的。设计是否意味着无限循环?为什么 shardIterator 不会变成 null?
【问题讨论】:
标签: amazon-web-services amazon-dynamodb