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


Java ValueMap类代码示例

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


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

示例1: queryGSI

import com.amazonaws.services.dynamodbv2.document.utils.ValueMap; //导入依赖的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.utils.ValueMap; //导入依赖的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: findRepliesUsingAFilterExpression

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

示例4: loadByKey

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

示例5: loadFeatures

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

示例6: retrieveRecordsForProvince

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

示例7: main

import com.amazonaws.services.dynamodbv2.document.utils.ValueMap; //导入依赖的package包/类
public static void main(String[] args)  {

        AmazonDynamoDBClient client = new AmazonDynamoDBClient();
        client.setEndpoint("http://localhost:8000");
        DynamoDB dynamoDB = new DynamoDB(client);

        Table table = dynamoDB.getTable("Movies");
                
        // Conditional delete (will fail)
        
        DeleteItemSpec deleteItemSpec = new DeleteItemSpec()
            .withPrimaryKey(new PrimaryKey("year", 2015, "title", "The Big New Movie"))
            .withConditionExpression("info.rating <= :val")
            .withValueMap(new ValueMap()
                   .withNumber(":val", 5.0));
        
        System.out.println("Attempting a conditional delete...");
        try {
            table.deleteItem(deleteItemSpec);
            System.out.println("DeleteItem succeeded");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("DeleteItem failed");
        }

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

示例8: main

import com.amazonaws.services.dynamodbv2.document.utils.ValueMap; //导入依赖的package包/类
public static void main(String[] args) {

        AmazonDynamoDBClient client = new AmazonDynamoDBClient();
        client.setEndpoint("http://localhost:8000");
        DynamoDB dynamoDB = new DynamoDB(client);
   
        Table table = dynamoDB.getTable("Movies");
        
        ScanSpec scanSpec = new ScanSpec()
            .withProjectionExpression("#yr, title, info.rating")
            .withFilterExpression("#yr between :start_yr and :end_yr")
            .withNameMap(new NameMap().with("#yr",  "year"))
            .withValueMap(new ValueMap().withNumber(":start_yr", 1950).withNumber(":end_yr", 1959));
        
        ItemCollection<ScanOutcome> items = table.scan(scanSpec);
        
        Iterator<Item> iter = items.iterator();
        while (iter.hasNext()) {
            Item item = iter.next();
            System.out.println(item.toString());
        }
    }
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:23,代码来源:MoviesScan.java

示例9: deleteItem

import com.amazonaws.services.dynamodbv2.document.utils.ValueMap; //导入依赖的package包/类
private static void deleteItem() {

        Table table = dynamoDB.getTable(tableName);

        try {

            DeleteItemSpec deleteItemSpec = new DeleteItemSpec()
            .withPrimaryKey("Id", 120)
            .withConditionExpression("#ip = :val")
            .withNameMap(new NameMap()
                .with("#ip", "InPublication"))
            .withValueMap(new ValueMap()
            .withBoolean(":val", false))
            .withReturnValues(ReturnValue.ALL_OLD);

            DeleteItemOutcome outcome = table.deleteItem(deleteItemSpec);

            // Check the response.
            System.out.println("Printing item that was deleted...");
            System.out.println(outcome.getItem().toJSONPretty());

        } catch (Exception e) {
            System.err.println("Error deleting item in " + tableName);
            System.err.println(e.getMessage());
        }
    }
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:27,代码来源:DocumentAPIItemCRUDExample.java

示例10: announce

import com.amazonaws.services.dynamodbv2.document.utils.ValueMap; //导入依赖的package包/类
@Override
public void announce(long stateVersion) {
    Table table = dynamoDB.getTable(tableName);

    UpdateItemSpec updateItemSpec = new UpdateItemSpec()
            .withPrimaryKey("namespace", blobNamespace)
            .withUpdateExpression("set #version = :ver")
            .withNameMap(new NameMap().with("#version", "version"))
            .withValueMap(new ValueMap().withNumber(":ver", stateVersion));

    table.updateItem(updateItemSpec);
}
 
开发者ID:Netflix,项目名称:hollow-reference-implementation,代码行数:13,代码来源:DynamoDBAnnouncer.java

示例11: main

import com.amazonaws.services.dynamodbv2.document.utils.ValueMap; //导入依赖的package包/类
public static void main(String[] args)  {

        AmazonDynamoDBClient client = new AmazonDynamoDBClient();
        client.setEndpoint("http://localhost:8000");
        DynamoDB dynamoDB = new DynamoDB(client);

        Table table = dynamoDB.getTable("Movies");
        
        int year = 2015;
        String title = "The Big New Movie";

        // Conditional update (will fail)

        UpdateItemSpec updateItemSpec = new UpdateItemSpec()
            .withPrimaryKey(new PrimaryKey("year", 2015, "title",  "The Big New Movie"))
            .withUpdateExpression("remove info.actors[0]")
            .withConditionExpression("size(info.actors) > :num")
            .withValueMap(new ValueMap().withNumber(":num", 3));

        System.out.println("Attempting a conditional update...");
        try {
            table.updateItem(updateItemSpec);
            System.out.println("UpdateItem succeeded: " + table.getItem("year", year, "title", title).toJSONPretty());
        } catch (ConditionalCheckFailedException e) {
            e.printStackTrace();
            System.out.println("UpdateItem failed");
        }

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

示例12: main

import com.amazonaws.services.dynamodbv2.document.utils.ValueMap; //导入依赖的package包/类
public static void main(String[] args)  {

        AmazonDynamoDBClient client = new AmazonDynamoDBClient();
        client.setEndpoint("http://localhost:8000");
        DynamoDB dynamoDB = new DynamoDB(client);

        Table table = dynamoDB.getTable("Movies");
        
        int year = 2015;
        String title = "The Big New Movie";
        
        UpdateItemSpec updateItemSpec = new UpdateItemSpec()
            .withPrimaryKey("year", year, "title", title)
            .withUpdateExpression("set info.rating = info.rating + :val")
            .withValueMap(new ValueMap()
                .withNumber(":val", 1));

        System.out.println("Incrementing an atomic counter...");
        try {
            table.updateItem(updateItemSpec);
            System.out.println("UpdateItem succeeded: " + table.getItem("year", year, "title", title).toJSONPretty());
        } catch (Exception e) {
            System.out.println("UpdateItem failed");
            e.printStackTrace();
        }

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

示例13: main

import com.amazonaws.services.dynamodbv2.document.utils.ValueMap; //导入依赖的package包/类
public static void main(String[] args)  {

        AmazonDynamoDBClient client = new AmazonDynamoDBClient();
        client.setEndpoint("http://localhost:8000");
        DynamoDB dynamoDB = new DynamoDB(client);

        Table table = dynamoDB.getTable("Movies");
        
        int year = 2015;
        String title = "The Big New Movie";

        UpdateItemSpec updateItemSpec = new UpdateItemSpec()
            .withPrimaryKey("year", year, "title", title)
            .withUpdateExpression("set info.rating = :r, info.plot=:p, info.actors=:a")
            .withValueMap(new ValueMap()
                .withNumber(":r", 5.5)
                .withString(":p", "Everything happens all at once.")
                .withList(":a", Arrays.asList("Larry","Moe","Curly")));

        System.out.println("Updating the item...");
        try {
            table.updateItem(updateItemSpec);
            System.out.println("UpdateItem succeeded: " + table.getItem("year", year, "title", title).toJSONPretty());
        } catch (Exception e) {
            System.out.println("UpdateItem failed");
            e.printStackTrace();
        }
                

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

示例14: findRepliesInLast15DaysWithConfig

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

示例15: updateAddNewAttribute

import com.amazonaws.services.dynamodbv2.document.utils.ValueMap; //导入依赖的package包/类
private static void updateAddNewAttribute() {
    Table table = dynamoDB.getTable(tableName);

    try {

        Map<String, String> expressionAttributeNames = new HashMap<String, String>();
        expressionAttributeNames.put("#na", "NewAttribute");

        UpdateItemSpec updateItemSpec = new UpdateItemSpec()
        .withPrimaryKey("Id", 121)
        .withUpdateExpression("set #na = :val1")
        .withNameMap(new NameMap()
            .with("#na", "NewAttribute"))
        .withValueMap(new ValueMap()
            .withString(":val1", "Some value"))
        .withReturnValues(ReturnValue.ALL_NEW);

        UpdateItemOutcome outcome =  table.updateItem(updateItemSpec);

        // Check the response.
        System.out.println("Printing item after adding new attribute...");
        System.out.println(outcome.getItem().toJSONPretty());           

    }   catch (Exception e) {
        System.err.println("Failed to add new attribute in " + tableName);
        System.err.println(e.getMessage());
    }        
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:29,代码来源:DocumentAPIItemCRUDExample.java


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