Amazon dynamodb DynamoDB映射器“;batchLoad();输入
我只是在使用dynamoDB的batchLoad函数。这里,这个 函数的一部分表示,它需要的输入是Amazon dynamodb DynamoDB映射器“;batchLoad();输入,amazon-dynamodb,Amazon Dynamodb,我只是在使用dynamoDB的batchLoad函数。这里,这个 函数的一部分表示,它需要的输入是List。但是当我使用KeyPair对象时,它抛出了一个错误,即参数应该是dynamodb注释类 我可以使用DynamoDB类,其中我只设置类的hashKey和rangeKey属性,并将它们作为参数传递。但是现在我的用例是类(DynamoDB注释),我使用的是has@NonNull字段。如果我必须为此传递参数,我必须在其中设置垃圾值,这显然是不可取的。有什么帮助/建议吗? 谢谢 以下是工作示例 摘要
List
。但是当我使用KeyPair对象时,它抛出了一个错误,即参数应该是dynamodb注释类
我可以使用DynamoDB类,其中我只设置类的hashKey和rangeKey
属性,并将它们作为参数传递。但是现在我的用例是类(DynamoDB注释),我使用的是has@NonNull
字段。如果我必须为此传递参数,我必须在其中设置垃圾值,这显然是不可取的。有什么帮助/建议吗?
谢谢 以下是工作示例 摘要:-
Map<Class<?>, List<KeyPair>> keyPairForTable = new HashMap<>();
keyPairForTable.put(Movies.class, keyPairList);
public Boolean batchLoadMoviesUsingKeyPair() {
DynamoDBMapper dynamoDBMapper = new DynamoDBMapper(dynamoDBClient);
KeyPair keyPair1 = new KeyPair();
keyPair1.withHashKey(1991);
keyPair1.withRangeKey("Movie with map attribute");
KeyPair keyPair2 = new KeyPair();
keyPair2.withHashKey(2010);
keyPair2.withRangeKey("The Big New Movie 2010");
List<KeyPair> keyPairList = new ArrayList<>();
keyPairList.add(keyPair1);
keyPairList.add(keyPair2);
Map<Class<?>, List<KeyPair>> keyPairForTable = new HashMap<>();
keyPairForTable.put(Movies.class, keyPairList);
Map<String, List<Object>> batchResults = dynamoDBMapper.batchLoad(keyPairForTable);
for (Map.Entry<String, List<Object>> entry : batchResults.entrySet()) {
System.out.println(entry.getKey());
System.out.println(entry.getValue());
}
return true;
}
- 模型类-应该是map的关键
- keyPairList-要检索的密钥对列表
Map<Class<?>, List<KeyPair>> keyPairForTable = new HashMap<>();
keyPairForTable.put(Movies.class, keyPairList);
public Boolean batchLoadMoviesUsingKeyPair() {
DynamoDBMapper dynamoDBMapper = new DynamoDBMapper(dynamoDBClient);
KeyPair keyPair1 = new KeyPair();
keyPair1.withHashKey(1991);
keyPair1.withRangeKey("Movie with map attribute");
KeyPair keyPair2 = new KeyPair();
keyPair2.withHashKey(2010);
keyPair2.withRangeKey("The Big New Movie 2010");
List<KeyPair> keyPairList = new ArrayList<>();
keyPairList.add(keyPair1);
keyPairList.add(keyPair2);
Map<Class<?>, List<KeyPair>> keyPairForTable = new HashMap<>();
keyPairForTable.put(Movies.class, keyPairList);
Map<String, List<Object>> batchResults = dynamoDBMapper.batchLoad(keyPairForTable);
for (Map.Entry<String, List<Object>> entry : batchResults.entrySet()) {
System.out.println(entry.getKey());
System.out.println(entry.getValue());
}
return true;
}
Map,List>keyPairForTable=newhashmap();
KeyPairPortable.put(Movies.class,keyPairList);
映射batchResults=dynamoDBMapper.batchLoad(keyPairForTable);
对于(Map.Entry:batchResults.entrySet()){
System.out.println(entry.getKey());
System.out.println(entry.getValue());
}
返回true;
}
非常感谢!我已经弄明白了,我的错,我使用的是公共映射批处理加载(IterableGood,谢谢!我在这里有一个小疑问。如果我的表没有范围键,我们是在密钥对中将范围键设置为null还是根本不设置它?