本文整理汇总了Java中com.amazonaws.services.dynamodbv2.document.internal.IteratorSupport类的典型用法代码示例。如果您正苦于以下问题:Java IteratorSupport类的具体用法?Java IteratorSupport怎么用?Java IteratorSupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IteratorSupport类属于com.amazonaws.services.dynamodbv2.document.internal包,在下文中一共展示了IteratorSupport类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadByKey
import com.amazonaws.services.dynamodbv2.document.internal.IteratorSupport; //导入依赖的package包/类
@Override public Optional<Group> loadByKey(String key) {
Table table = dynamoDB.getTable(this.groupTableName);
QuerySpec querySpec = new QuerySpec()
.withKeyConditionExpression(HASH_KEY + " = :k_app_key")
.withValueMap(new ValueMap()
.withString(":k_app_key", key)
)
.withMaxResultSize(1)
.withConsistentRead(true);
DynamoDbCommand<ItemCollection<QueryOutcome>> cmd = new DynamoDbCommand<>("loadByKey",
() -> queryTable(table, querySpec),
() -> {
throw new RuntimeException("loadByKey");
},
dynamodbNamespaceGraphQueryHystrix,
metrics);
final ItemCollection<QueryOutcome> items = cmd.execute();
final IteratorSupport<Item, QueryOutcome> iterator = items.iterator();
if (iterator.hasNext()) {
return Optional.of(GroupSupport.toGroup(iterator.next().getString("json")));
}
return Optional.empty();
}
示例2: MAVLinkRecordIterable
import com.amazonaws.services.dynamodbv2.document.internal.IteratorSupport; //导入依赖的package包/类
public MAVLinkRecordIterable(IteratorSupport<Item, QueryOutcome> it) {
this.itemIterator = it;
}
示例3: shouldQueryIndex_withAttributeQueryOnHashPartOfCompoundIndex
import com.amazonaws.services.dynamodbv2.document.internal.IteratorSupport; //导入依赖的package包/类
@Test
public void shouldQueryIndex_withAttributeQueryOnHashPartOfCompoundIndex() {
// Given
final ItemId itemId = new ItemId(randomId());
final ItemConfiguration itemConfiguration = new ItemConfiguration(StubWithGlobalSecondaryIndexItem.class,
tableName);
itemConfiguration.registerIndexes((Arrays.asList(new CompoundIndexDefinition("gsi", "gsiSupportingValue"))));
final Collection<ItemConfiguration> itemConfigurations = Arrays.asList(itemConfiguration);
when(mockDatabaseSchemaHolder.itemConfigurations()).thenReturn(itemConfigurations);
final Table mockTable = mock(Table.class);
when(mockDynamoDBClient.getTable(any(String.class))).thenReturn(mockTable);
final DynamoDocumentStoreTemplate dynamoDocumentStoreTemplate = new DynamoDocumentStoreTemplate(
mockDatabaseSchemaHolder);
dynamoDocumentStoreTemplate.initialize(mockAmazonDynamoDbClient);
final Index mockIndex = mock(Index.class);
when(mockTable.getIndex(anyString())).thenReturn(mockIndex);
final ItemCollection<QueryOutcome> mockOutcome = mock(ItemCollection.class);
when(mockIndex.query(any(QuerySpec.class))).thenReturn(mockOutcome);
final IteratorSupport<Item, QueryOutcome> mockIterator = mock(IteratorSupport.class);
final Item mockItem = new Item();
mockItem.withString(randomString(), randomString());
when(mockOutcome.iterator()).thenReturn(mockIterator);
when(mockIterator.hasNext()).thenReturn(true, false);
when(mockIterator.next()).thenReturn(mockItem);
// When
final Collection<StubWithGlobalSecondaryIndexItem> stubWithGlobalSecondaryIndexItemCollection = dynamoDocumentStoreTemplate
.fetch(new AttributeQuery("gsi", new Condition(Operators.EQUALS, itemId.value())),
StubWithGlobalSecondaryIndexItem.class);
// Then
assertTrue(stubWithGlobalSecondaryIndexItemCollection.size() == 1);
final ArgumentCaptor<QuerySpec> querySpecCaptor = ArgumentCaptor.forClass(QuerySpec.class);
verify(mockIndex).query(querySpecCaptor.capture());
}
示例4: shouldQueryIndex_withCompoundAttributeQuery
import com.amazonaws.services.dynamodbv2.document.internal.IteratorSupport; //导入依赖的package包/类
@Test
public void shouldQueryIndex_withCompoundAttributeQuery() {
// Given
final ItemId itemId = new ItemId(randomId());
final ItemConfiguration itemConfiguration = new ItemConfiguration(StubWithGlobalSecondaryIndexItem.class,
tableName);
itemConfiguration.registerIndexes((Arrays.asList(new CompoundIndexDefinition("gsi", "gsiSupportingValue"))));
final Collection<ItemConfiguration> itemConfigurations = Arrays.asList(itemConfiguration);
when(mockDatabaseSchemaHolder.itemConfigurations()).thenReturn(itemConfigurations);
final Table mockTable = mock(Table.class);
when(mockDynamoDBClient.getTable(any(String.class))).thenReturn(mockTable);
final DynamoDocumentStoreTemplate dynamoDocumentStoreTemplate = new DynamoDocumentStoreTemplate(
mockDatabaseSchemaHolder);
dynamoDocumentStoreTemplate.initialize(mockAmazonDynamoDbClient);
final Index mockIndex = mock(Index.class);
when(mockTable.getIndex(anyString())).thenReturn(mockIndex);
final ItemCollection<QueryOutcome> mockOutcome = mock(ItemCollection.class);
when(mockIndex.query(any(QuerySpec.class))).thenReturn(mockOutcome);
final IteratorSupport<Item, QueryOutcome> mockIterator = mock(IteratorSupport.class);
final Item mockItem = new Item();
mockItem.withString(randomString(), randomString());
when(mockOutcome.iterator()).thenReturn(mockIterator);
when(mockIterator.hasNext()).thenReturn(true, false);
when(mockIterator.next()).thenReturn(mockItem);
// When
final Collection<StubWithGlobalSecondaryIndexItem> stubWithGlobalSecondaryIndexItemCollection = dynamoDocumentStoreTemplate
.fetch(new CompoundAttributeQuery("gsi", new Condition(Operators.EQUALS, itemId.value()),
"gsiSupportingValue", new Condition(Operators.EQUALS, String.valueOf(randomInt(10)))),
StubWithGlobalSecondaryIndexItem.class);
// Then
assertTrue(stubWithGlobalSecondaryIndexItemCollection.size() == 1);
final ArgumentCaptor<QuerySpec> querySpecCaptor = ArgumentCaptor.forClass(QuerySpec.class);
verify(mockIndex).query(querySpecCaptor.capture());
assertNotNull(querySpecCaptor.getValue().getRangeKeyCondition());
}
示例5: ItemId
import com.amazonaws.services.dynamodbv2.document.internal.IteratorSupport; //导入依赖的package包/类
@Test
public void shouldQueryIndex_withACompoundAttributeQueryOnACompoundGSIWithAHashValueTheSameAsThePrimaryKeyDefinition() {
// Given
final ItemId itemId = new ItemId(randomId());
final ItemConfiguration itemConfiguration = new ItemConfiguration(StubWithGlobalSecondaryIndexItem.class,
tableName, new PrimaryKeyDefinition("gsi"));
itemConfiguration.registerIndexes((Arrays.asList(new CompoundIndexDefinition("gsi", "gsiSupportingValue"))));
final Collection<ItemConfiguration> itemConfigurations = Arrays.asList(itemConfiguration);
when(mockDatabaseSchemaHolder.itemConfigurations()).thenReturn(itemConfigurations);
final Table mockTable = mock(Table.class);
when(mockDynamoDBClient.getTable(any(String.class))).thenReturn(mockTable);
final DynamoDocumentStoreTemplate dynamoDocumentStoreTemplate = new DynamoDocumentStoreTemplate(
mockDatabaseSchemaHolder);
dynamoDocumentStoreTemplate.initialize(mockAmazonDynamoDbClient);
final Index mockIndex = mock(Index.class);
when(mockTable.getIndex(anyString())).thenReturn(mockIndex);
final ItemCollection<QueryOutcome> mockOutcome = mock(ItemCollection.class);
when(mockIndex.query(any(QuerySpec.class))).thenReturn(mockOutcome);
final IteratorSupport<Item, QueryOutcome> mockIterator = mock(IteratorSupport.class);
final Item mockItem = new Item();
mockItem.withString(randomString(), randomString());
when(mockOutcome.iterator()).thenReturn(mockIterator);
when(mockIterator.hasNext()).thenReturn(true, false);
when(mockIterator.next()).thenReturn(mockItem);
// When
final Collection<StubWithGlobalSecondaryIndexItem> stubWithGlobalSecondaryIndexItemCollection = dynamoDocumentStoreTemplate
.fetch(new CompoundAttributeQuery("gsi", new Condition(Operators.EQUALS, itemId.value()),
"gsiSupportingValue", new Condition(Operators.EQUALS, String.valueOf(randomInt(10)))),
StubWithGlobalSecondaryIndexItem.class);
// Then
assertTrue(stubWithGlobalSecondaryIndexItemCollection.size() == 1);
final ArgumentCaptor<QuerySpec> querySpecCaptor = ArgumentCaptor.forClass(QuerySpec.class);
verify(mockIndex).query(querySpecCaptor.capture());
assertNotNull(querySpecCaptor.getValue().getRangeKeyCondition());
}