当前位置: 首页>>代码示例>>Java>>正文


Java IteratorSupport类代码示例

本文整理汇总了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();
}
 
开发者ID:dehora,项目名称:outland,代码行数:28,代码来源:DefaultGroupStorage.java

示例2: MAVLinkRecordIterable

import com.amazonaws.services.dynamodbv2.document.internal.IteratorSupport; //导入依赖的package包/类
public MAVLinkRecordIterable(IteratorSupport<Item, QueryOutcome> it) {
    this.itemIterator = it;
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:4,代码来源:MAVLinkMessagesTable.java

示例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());
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:43,代码来源:DynamoDocumentStoreTemplateTest.java

示例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());
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:45,代码来源:DynamoDocumentStoreTemplateTest.java

示例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());
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:45,代码来源:DynamoDocumentStoreTemplateTest.java


注:本文中的com.amazonaws.services.dynamodbv2.document.internal.IteratorSupport类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。