• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java QuerySpec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.dynamodbv2.document.spec.QuerySpec的典型用法代码示例。如果您正苦于以下问题:Java QuerySpec类的具体用法?Java QuerySpec怎么用?Java QuerySpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



QuerySpec类属于com.amazonaws.services.dynamodbv2.document.spec包,在下文中一共展示了QuerySpec类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: queryGSI

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
private static Page<Item, QueryOutcome> queryGSI(String appid, Pager p) {
	Pager pager = (p != null) ? p : new Pager();
	Index index = getSharedIndex();
	QuerySpec spec = new QuerySpec().
			withMaxPageSize(pager.getLimit()).
			withMaxResultSize(pager.getLimit()).
			withKeyConditionExpression(Config._APPID + " = :aid").
			withValueMap(new ValueMap().withString(":aid", appid));

	if (!StringUtils.isBlank(pager.getLastKey())) {
		spec = spec.withExclusiveStartKey(new KeyAttribute(Config._APPID, appid),	// HASH/PARTITION KEY
				new KeyAttribute(Config._ID, pager.getLastKey()), // RANGE/SORT KEY
				new KeyAttribute(Config._KEY, getKeyForAppid(pager.getLastKey(), appid))); // TABLE PRIMARY KEY
	}
	return index != null ? index.query(spec).firstPage() : null;
}
 
开发者ID:Erudika,项目名称:para,代码行数:17,代码来源:AWSDynamoUtils.java


示例2: queryRelationExists

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
@Override public boolean queryRelationExists(String relationHashKey, String relationRangeKey) {

    Table table = dynamoDB.getTable(this.groupGraphTableName);

    QuerySpec querySpec = new QuerySpec()
        .withKeyConditionExpression("subject = :k_subject and object_relation = :k_object_relation")
        .withValueMap(new ValueMap()
            .withString(":k_subject", relationHashKey)
            .withString(":k_object_relation", relationRangeKey)
        )
        .withMaxResultSize(1)
        .withConsistentRead(true);

    DynamoDbCommand<ItemCollection<QueryOutcome>> cmd = new DynamoDbCommand<>("queryRelation",
        () -> queryTable(table, querySpec),
        () -> {
          throw new RuntimeException("queryRelation");
        },
        dynamodbNamespaceGraphQueryHystrix,
        metrics);

    // can't use getLastLowLevelResult directly; it's false unless the outcome is iterated first :|
    return cmd.execute().iterator().hasNext();
  }
 
开发者ID:dehora,项目名称:outland,代码行数:25,代码来源:DefaultGroupStorage.java


示例3: query

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
private QueryOutcome query(Object hk, QuerySpec querySpec, PageIterator pageIterator) {
    if ( null == _convertMarker ) {
        throw new IllegalStateException("Index must first be initialized with ConvertMarker");
    }
    if ( pageIterator.getPageSize() <= 0 ) {
        return new QueryOutcome(new QueryResult());
    }
    ItemCollection<QueryOutcome> itemCollection =
        maybeBackoff(true, () ->
                     _query.query(withMarker(querySpec.withHashKey(_hkName, hk), pageIterator, hk)));

    if ( null != itemCollection ) {
        Iterator<Page<Item, QueryOutcome>> iterator = itemCollection.pages().iterator();
        if ( iterator.hasNext() ) {
            QueryOutcome outcome = maybeBackoff(true, () -> iterator.next().getLowLevelResult());
            QueryResult result = outcome.getQueryResult();
            if ( null != pageIterator.getMarker() && null != result.getItems() && result.getItems().size() > 0 ) {
                pageIterator.setPrevMarker(toMarker(result.getItems().get(0), true));
            } else {
                pageIterator.setPrevMarker(null);
            }
            Map<String,AttributeValue> lastKey = result.getLastEvaluatedKey();
            if ( null != lastKey && ! lastKey.isEmpty() ) {
                pageIterator.setMarker(toMarker(lastKey, true));
            } else {
                pageIterator.setMarker(null);
            }
            return outcome;
        }
    }
    pageIterator.setPrevMarker(null);
    pageIterator.setMarker(null);
    return new QueryOutcome(new QueryResult());
}
 
开发者ID:Distelli,项目名称:java-persistence,代码行数:35,代码来源:DdbIndex.java


示例4: findRepliesUsingAFilterExpression

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
private static void findRepliesUsingAFilterExpression(String forumName, String threadSubject) {

        Table table = dynamoDB.getTable(tableName);
        
        String replyId = forumName + "#" + threadSubject;

        QuerySpec spec = new QuerySpec()
            .withProjectionExpression("Message, ReplyDateTime, PostedBy")
            .withKeyConditionExpression("Id = :v_id")
            .withFilterExpression("PostedBy = :v_postedby")
            .withValueMap(new ValueMap()
                .withString(":v_id", replyId)
                .withString(":v_postedby", "User B"));
        
        ItemCollection<QueryOutcome> items = table.query(spec);

        System.out.println("\nfindRepliesUsingAFilterExpression results:");
        Iterator<Item> iterator = items.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next().toJSONPretty());
        }    
     }
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:23,代码来源:DocumentAPIQuery.java


示例5: loadByKey

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的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


示例6: loadFeatures

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
@Override public List<Feature> loadFeatures(String group) {
  logger.info("{}", kvp("op", "loadFeatures", "group", group));
  List<Feature> features = Lists.newArrayList();

  Table table = dynamoDB.getTable(featureTableName);

  QuerySpec querySpec = new QuerySpec()
      .withKeyConditionExpression(HASH_KEY + " = :k_" + HASH_KEY)
      .withValueMap(new ValueMap().withString(":k_" + HASH_KEY, group))
      .withConsistentRead(true);

  DynamoDbCommand<ItemCollection<QueryOutcome>> cmd = new DynamoDbCommand<>("loadFeatures",
      () -> queryTable(table, querySpec),
      () -> {
        throw new RuntimeException("loadFeatureById");
      },
      hystrixReadConfiguration,
      metrics);

  ItemCollection<QueryOutcome> items = cmd.execute();

  for (Page<Item, QueryOutcome> page : items.pages()) {
    page.forEach(item -> features.add(FeatureSupport.toFeature(item.getString("json"))));
  }

  return features;
}
 
开发者ID:dehora,项目名称:outland,代码行数:28,代码来源:DefaultFeatureStorage.java


示例7: queryItems

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
@Override
public QueryItemsBuilder<T> queryItems(Object hk, PageIterator pageIterator) {
    if ( null == _convertMarker ) {
        throw new IllegalStateException("Index must first be initialized with ConvertMarker");
    }
    QuerySpec spec = withMarker(new QuerySpec().withHashKey(_hkName, hk), pageIterator, hk);
    return new QueryItemsBuilderImpl<T>(spec, _rkName, pageIterator, this::countItems, this::listItems, _clazz, _encryption);
}
 
开发者ID:Distelli,项目名称:java-persistence,代码行数:9,代码来源:DdbIndex.java


示例8: withMarker

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
private QuerySpec withMarker(QuerySpec spec, PageIterator pageIterator, Object hk) {
    if ( null != pageIterator.getMarker() ) {
        spec.withExclusiveStartKey(fromMarker(hk, pageIterator.getMarker()));
    }
    int pageSize = pageIterator.getPageSize();
    if ( pageSize != Integer.MAX_VALUE ) {
        spec.withMaxPageSize(pageSize);
    }
    return spec.withScanIndexForward(pageIterator.isForward());
}
 
开发者ID:Distelli,项目名称:java-persistence,代码行数:11,代码来源:DdbIndex.java


示例9: QueryItemsBuilderImpl

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
public QueryItemsBuilderImpl(QuerySpec spec, String rangeKeyName, PageIterator iter, CountItems countItems, ListItems listItems, Class<T> clazz, DDBEncryption encryption) {
    _spec = spec;
    _rkName = rangeKeyName;
    _iter = iter;
    _countItems = countItems;
    _listItems = listItems;
    _clazz = clazz;
    _encryption = encryption;
}
 
开发者ID:Distelli,项目名称:java-persistence,代码行数:10,代码来源:QueryItemsBuilderImpl.java


示例10: retrieveRecordsForProvince

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
@Override
public List<String> retrieveRecordsForProvince(String dataSetLabel, String infoSetTag, Province province, Locale locale) {
    if (!useDynamoDirect) {
        URI uriToCall = baseBuilder()
                .path("/records/{dataset}/{infoSet}")
                .queryParam("province", province.toString())
                .queryParam("locale", locale.toLanguageTag())
                .buildAndExpand(dataSetLabel, infoSetTag).toUri();

        log.info("assembled URI to get records = {}", uriToCall.toString());

        return getFromUri(uriToCall);
    } else {
        DynamoDB dynamoDB = new DynamoDB(dynamoDBClient);
        Table geoApiTable = dynamoDB.getTable("geo_" + dataSetLabel.toLowerCase());
        log.info("querying from table, name: {}, number of rows: {}",
                "geo_" + dataSetLabel.toLowerCase(), geoApiTable.describe().toString());
        log.info("looking for province, with name: {}, on infoSet: {}", province.name(), infoSetTag);

        Index provinceIndex = geoApiTable.getIndex("lowestGeoInfo"); // figure out how to adapt when province != lowest
        QuerySpec querySpec = new QuerySpec()
                .withKeyConditionExpression("province = :prv and infoTag = :info")
                .withValueMap(new ValueMap()
                        .withString(":prv", province.name())
                        .withString(":info", infoSetTag));

        try {
            ItemCollection<QueryOutcome> records = provinceIndex.query(querySpec);
            List<String> result = new ArrayList<>();
            records.iterator().forEachRemaining(i -> result.add(i.getString("description")));
            log.info("iterated through the results, number of results: {}", result.size());
            return result;
        } catch (Exception e) {
            log.error("Error!", e);
            throw new IllegalArgumentException("No results for that dataset, province and field");
        }
    }
}
 
开发者ID:grassrootza,项目名称:grassroot-platform,代码行数:39,代码来源:LocationInfoBrokerImpl.java


示例11: addRangeKeyConditionToQuerySpec

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
private static <T extends Item> void addRangeKeyConditionToQuerySpec(final QuerySpec querySpec,
        final CompoundAttributeQuery compoundAttributeQuery, final Class<T> itemClass) {
    final String supportingConditionStringValue = compoundAttributeQuery.getSupportingCondition().getValues().iterator()
            .next();
    final Operators comparisonOperator = compoundAttributeQuery.getSupportingCondition().getComparisonOperator();
    final Class<?> supportingAttributeType = compoundAttributeQuery.getSupportingAttributeType(itemClass);

    try {
        final Object supportingConditionValue = supportingAttributeType.getConstructor(String.class).newInstance(supportingConditionStringValue);

        final RangeKeyCondition rangeKeyCondition = RangeKeyConditionBuilder
                .build(compoundAttributeQuery.getSupportingAttributeName(), supportingConditionValue, comparisonOperator);
        querySpec.withRangeKeyCondition(rangeKeyCondition);
    } catch (final Exception e) {
        throw new PersistenceResourceFailureException(
                String.format("Could not add range key condition for query: %s on item %s.", compoundAttributeQuery,
                        itemClass.getSimpleName()),
                e);
    }
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:21,代码来源:QuerySpecBuilder.java


示例12: shouldBuild_withAttributeQuery

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
@Test
public void shouldBuild_withAttributeQuery() {
    // Given
    final String attributeName = randomString(10);
    final Condition mockCondition = randomCondition(1);
    final String expectedValue = mockCondition.getValues().iterator().next();
    final AttributeQuery mockAttributeQuery = mock(AttributeQuery.class);

    when(mockAttributeQuery.getAttributeName()).thenReturn(attributeName);
    when(mockAttributeQuery.getCondition()).thenReturn(mockCondition);

    // When
    final QuerySpec querySpec = QuerySpecBuilder.build(mockAttributeQuery, StubItem.class);

    // Then
    assertEquals(attributeName, querySpec.getHashKey().getName());
    assertEquals(expectedValue, querySpec.getHashKey().getValue());
    assertNull(querySpec.getRangeKeyCondition());
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:20,代码来源:QuerySpecBuilderTest.java


示例13: shouldQueryTable

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
@Test
public void shouldQueryTable() {
    // Given
    final ItemId itemId = new ItemId(randomId());

    final ItemConfiguration itemConfiguration = new ItemConfiguration(StubItem.class, tableName);
    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 ItemCollection<QueryOutcome> outcome = mock(ItemCollection.class);
    when(mockTable.query(any(QuerySpec.class))).thenReturn(outcome);
    // when
    dynamoDocumentStoreTemplate.fetch(new AttributeQuery("id", new Condition(Operators.EQUALS, itemId.value())),
            StubItem.class);
    // then
    verify(mockTable.query(any(QuerySpec.class)));
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:25,代码来源:DynamoDocumentStoreTemplateTest.java


示例14: build

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
public static <T extends Item> QuerySpec build(final AttributeQuery attributeQuery, final Class<T> itemClass) {
    if (CompoundAttributeQuery.class.isAssignableFrom(attributeQuery.getClass())) {
        final CompoundAttributeQuery compoundAttributeQuery = (CompoundAttributeQuery) attributeQuery;
        return buildWithHashAndRangeKey(compoundAttributeQuery, itemClass);
    }

    return buildWithHashKey(attributeQuery);
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:9,代码来源:QuerySpecBuilder.java


示例15: buildWithHashAndRangeKey

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
private static <T extends Item> QuerySpec buildWithHashAndRangeKey(
        final CompoundAttributeQuery compoundAttributeQuery, final Class<T> itemClass) {
    final Set<String> supportingConditionValues = compoundAttributeQuery.getSupportingCondition().getValues();
    validateSupportingConditionValues(supportingConditionValues);

    final QuerySpec querySpec = buildWithHashKey(compoundAttributeQuery);
    addRangeKeyConditionToQuerySpec(querySpec, compoundAttributeQuery, itemClass);

    return querySpec;
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:11,代码来源:QuerySpecBuilder.java


示例16: shouldBuild_withCompoundAttributeQuery

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
@Test
public void shouldBuild_withCompoundAttributeQuery() {
    // Given
    final String attributeName = randomString(10);
    final String supportingAttributeName = randomString(10);
    final Condition condition = randomCondition(1);
    final Condition supportingCondition = randomCondition(1);
    final CompoundAttributeQuery compoundAttributeQuery = mock(CompoundAttributeQuery.class);
    final RangeKeyCondition mockRangeKeyCondition = mock(RangeKeyCondition.class);
    final String expectedValue = condition.getValues().iterator().next();
    final String expectedSupportingValue = supportingCondition.getValues().iterator().next();
    final Operators expectedSupportingComparisonOperator = supportingCondition.getComparisonOperator();

    when(compoundAttributeQuery.getAttributeName()).thenReturn(attributeName);
    when(compoundAttributeQuery.getCondition()).thenReturn(condition);
    when(compoundAttributeQuery.getSupportingCondition()).thenReturn(supportingCondition);
    Mockito.<Class<?>> when(compoundAttributeQuery.getSupportingAttributeType(any())).thenReturn(String.class);
    when(compoundAttributeQuery.getSupportingAttributeName()).thenReturn(supportingAttributeName);
    when(RangeKeyConditionBuilder.build(supportingAttributeName, expectedSupportingValue,
            expectedSupportingComparisonOperator)).thenReturn(mockRangeKeyCondition);

    // When
    final QuerySpec querySpec = QuerySpecBuilder.build(compoundAttributeQuery,
            StubWithGlobalSecondaryIndexItem.class);

    // Then
    assertEquals(attributeName, querySpec.getHashKey().getName());
    assertEquals(expectedValue, querySpec.getHashKey().getValue());
    assertEquals(mockRangeKeyCondition, querySpec.getRangeKeyCondition());
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:31,代码来源:QuerySpecBuilderTest.java


示例17: shouldQueryIndex_withAttributeQuery

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
@Test
public void shouldQueryIndex_withAttributeQuery() {
    // Given
    final ItemId itemId = new ItemId(randomId());

    final ItemConfiguration itemConfiguration = new ItemConfiguration(StubItem.class, tableName);
    itemConfiguration.registerIndexes(Arrays.asList(new IndexDefinition("stringProperty")));
    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> outcome = mock(ItemCollection.class);
    when(mockIndex.query(any(QuerySpec.class))).thenReturn(outcome);

    // when
    dynamoDocumentStoreTemplate.fetch(
            new AttributeQuery("stringProperty", new Condition(Operators.EQUALS, itemId.value())), StubItem.class);

    // then
    verify(mockIndex.query(any(QuerySpec.class)));
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:31,代码来源:DynamoDocumentStoreTemplateTest.java


示例18: findRepliesInLast15DaysWithConfig

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
private static void findRepliesInLast15DaysWithConfig(
    String tableName, String forumName, String threadSubject) {

    String replyId = forumName + "#" + threadSubject;
    long twoWeeksAgoMilli = (new Date()).getTime()
        - (15L * 24L * 60L * 60L * 1000L);
    Date twoWeeksAgo = new Date();
    twoWeeksAgo.setTime(twoWeeksAgoMilli);
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    String twoWeeksAgoStr = df.format(twoWeeksAgo);

    Table table = dynamoDB.getTable(tableName);

    QuerySpec querySpec = new QuerySpec()
        .withKeyConditionExpression("Id = :v1 and ReplyDateTime > :v2")
        .withValueMap(new ValueMap()
            .withString(":v1", replyId)
            .withString(":v2", twoWeeksAgoStr))
        .withProjectionExpression("Message, ReplyDateTime, PostedBy");

    ItemCollection<QueryOutcome> items = table.query(querySpec);
    Iterator<Item> iterator = items.iterator();

    System.out.println("Query: printing results...");

    while (iterator.hasNext()) {
        System.out.println(iterator.next().toJSONPretty());
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:30,代码来源:GettingStartedTryQuery.java


示例19: findRepliesForAThreadSpecifyOptionalLimit

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
private static void findRepliesForAThreadSpecifyOptionalLimit(String forumName, String threadSubject) {

        Table table = dynamoDB.getTable(tableName);
        
        String replyId = forumName + "#" + threadSubject;   
               
        QuerySpec spec = new QuerySpec()
            .withKeyConditionExpression("Id = :v_id")
            .withValueMap(new ValueMap()
                .withString(":v_id", replyId))
            .withMaxPageSize(1);

        ItemCollection<QueryOutcome> items = table.query(spec);
        
        System.out.println("\nfindRepliesForAThreadSpecifyOptionalLimit results:");

        // Process each page of results
        int pageNum = 0;
        for (Page<Item, QueryOutcome> page : items.pages()) {
            
            System.out.println("\nPage: " + ++pageNum);

            // Process each item on the current page
            Iterator<Item> item = page.iterator();
            while (item.hasNext()) {
                System.out.println(item.next().toJSONPretty());
            }
        }
    }
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:30,代码来源:DocumentAPIQuery.java


示例20: findRepliesInLast15DaysWithConfig

import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec; //导入依赖的package包/类
private static void findRepliesInLast15DaysWithConfig(String forumName, String threadSubject) {

        Table table = dynamoDB.getTable(tableName);

        long twoWeeksAgoMilli = (new Date()).getTime() - (15L*24L*60L*60L*1000L);
        Date twoWeeksAgo = new Date();
        twoWeeksAgo.setTime(twoWeeksAgoMilli);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        String twoWeeksAgoStr = df.format(twoWeeksAgo);
        
        String replyId = forumName + "#" + threadSubject;

        QuerySpec spec = new QuerySpec()
            .withProjectionExpression("Message, ReplyDateTime, PostedBy")
            .withKeyConditionExpression("Id = :v_id and ReplyDateTime <= :v_reply_dt_tm")
            .withValueMap(new ValueMap()
                .withString(":v_id", replyId)
                .withString(":v_reply_dt_tm", twoWeeksAgoStr));
        
        ItemCollection<QueryOutcome> items = table.query(spec);

        System.out.println("\nfindRepliesInLast15DaysWithConfig results:");
        Iterator<Item> iterator = items.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next().toJSONPretty());
        }

    }
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:29,代码来源:DocumentAPIQuery.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TWSDLExtensionHandler类代码示例发布时间:2022-05-23
下一篇:
Java JoinPredecessorExpression类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap