本文整理汇总了Java中com.amazonaws.services.dynamodbv2.document.Item.with方法的典型用法代码示例。如果您正苦于以下问题:Java Item.with方法的具体用法?Java Item.with怎么用?Java Item.with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.dynamodbv2.document.Item
的用法示例。
在下文中一共展示了Item.with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPrimaryAndSortKeySpecification
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testPrimaryAndSortKeySpecification() throws Exception {
String pk = "pk", sort = "sort";
Table table = createHashAndSortTable(pk, sort);
Item item = new Item();
item.with(pk, "p1");
item.with(sort, "s1");
item.with(COL1, "1");
table.putItem(item);
Item item2 = new Item();
item2.with(pk, "p1");
item2.with(sort, "s0");
item2.with(COL1, "2");
table.putItem(item2);
// should create a get
String query = selectStarWithPK("p1", "t", table) + " AND sort = 's1'";
verify(runAndReadResults(query), item);
validatePlanWithGets(query,
pkEquals("p1").and(create("equal", "sort", "s1")));
// should create a query
query = selectStarWithPK("p1", "t", table) + " AND sort >= 's1'";
verify(runAndReadResults(query), item);
validatePlanWithQueries(query, of(pkEquals("p1").and(
DynamoPlanValidationUtils.gte("sort", "s1")), null));
}
示例2: testWhereColumnEqualsNull
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testWhereColumnEqualsNull() throws Exception {
Item item = item();
item.with(COL1, null);
Table table = createTableWithItems(item);
String query =
selectStarWithPK("pk", "t", table) + " AND t." + COL1 + " = cast(null as varchar)";
verify(runAndReadResults(query), item);
ImmutablePair<DynamoFilterSpec, DynamoFilterSpec> spec =
of(pkEquals("pk"), DynamoPlanValidationUtils
.equals(COL1, null));
validatePlanWithQueries(query, spec);
// we return nulls are varchar b/c we can cast anything from varchar. Make sure that a
// boolean null cast also works
query = selectStarWithPK("pk", "t", table) + " AND t." + COL1 + " = cast(null as boolean)";
verify(runAndReadResults(query), item);
validatePlanWithQueries(query, spec);
}
示例3: testSimpleScan
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testSimpleScan() throws Exception {
Item item = item();
item.with(COL1, 1);
Table table = createTableWithItems(item);
String select = "SELECT *" + from(table) + "t WHERE t." + COL1 + " = 1";
verify(runAndReadResults(select), item);
DynamoFilterSpec spec = DynamoPlanValidationUtils.equals(COL1, 1);
validatePlanWithScan(select, spec);
Item item2 = new Item();
item2.with(PK, "pk2");
item2.with(COL1, 2);
table.putItem(item2);
verify(runAndReadResults(select), item);
// plan doesn't change as the table gets larger
validatePlanWithScan(select, spec);
}
示例4: testGetAndQuery
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testGetAndQuery() throws Exception {
Item item = item();
item.with(COL1, "1");
Item i2 = new Item();
i2.with(PK, "pk2");
i2.with(COL1, 2);
Table table = createTableWithItems(item, i2);
String query = "SELECT *" + from(table) + "t WHERE " +
"t." + PK + " = 'pk' OR " +
"t." + PK + " = 'pk2' AND t." + COL1 + " >= 2" +
"ORDER BY t." + PK + " ASC";
verify(runAndReadResults(query), item, i2);
validatePlan(query, null, null,
newArrayList(new DynamoQueryFilterSpec(pkEquals("pk2"),
DynamoPlanValidationUtils
.gte(COL1, 2)),
new DynamoGetFilterSpec(pkEquals("pk"))));
}
示例5: testQueryOrQuery
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testQueryOrQuery() throws Exception {
Item item = item();
item.with(COL1, 1);
Item i2 = new Item();
i2.with(PK, "pk2");
i2.with(COL1, 2);
Table table = createTableWithItems(item, i2);
String query = "SELECT *" + from(table) + "t WHERE " +
"t." + PK + " = 'pk' AND t." + COL1 + " = 1" +
" OR " +
"t." + PK + " = 'pk2' AND t." + COL1 + " >= 2" +
"ORDER BY t." + PK + " ASC";
verify(runAndReadResults(query), item, i2);
validatePlanWithQueries(query,
of(pkEquals("pk2"), DynamoPlanValidationUtils.gte(COL1, 2)),
of(pkEquals("pk"), DynamoPlanValidationUtils.equals(COL1, 1)));
}
示例6: testQueryAndQueryForcesScan
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testQueryAndQueryForcesScan() throws Exception {
Item item = item();
item.with(COL1, 1);
Item i2 = new Item();
i2.with(PK, "pk2");
i2.with(COL1, 2);
Table table = createTableWithItems(item, i2);
String query = "SELECT *" + from(table) + "t WHERE " +
"t." + PK + " = 'pk' AND t." + COL1 + " = 1" +
" AND " +
"t." + PK + " = 'pk2' AND t." + COL1 + " >= 2" +
"ORDER BY t." + PK + " ASC";
verify(runAndReadResults(query));
validatePlanWithScan(query,
pkEquals("pk").and(DynamoPlanValidationUtils.equals(COL1, 1)).and(
pkEquals("pk2")).and(DynamoPlanValidationUtils.gte(COL1, 2)));
}
示例7: testQueryOrAttributeForcesScan
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testQueryOrAttributeForcesScan() throws Exception {
Item item = item();
item.with(COL1, 1);
Item i2 = new Item();
i2.with(PK, "pk2");
i2.with(COL1, 2);
Table table = createTableWithItems(item, i2);
String query = "SELECT *" + from(table) + "t WHERE " +
"(t." + PK + " = 'pk' AND t." + COL1 + " = 1)" +
" OR " +
"t." + COL1 + " >= 2" +
"ORDER BY t." + PK + " ASC";
verify(runAndReadResults(query), item, i2);
validatePlanWithScan(query,
pkEquals("pk").and(DynamoPlanValidationUtils.equals(COL1, 1)).or(
DynamoPlanValidationUtils.gte(COL1, 2)));
}
示例8: testMultiRangeQuery
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testMultiRangeQuery() throws Exception {
Table table = createHashAndSortTable(PK, COL1);
Item item = item();
item.with(COL1, "1");
table.putItem(item);
Item i2 = item();
i2.with(COL1, "2");
table.putItem(i2);
String query = "SELECT *" + from(table) + "t WHERE " +
"t." + PK + " = 'pk'" + " AND (" +
"t." + COL1 + " = '1'" +
" AND " +
"t." + COL1 + " >= '2')";
verify(runAndReadResults(query));
validatePlanWithQueries(query, of(
pkEquals("pk").and(DynamoPlanValidationUtils.equals(COL1, "1")),
null),
of(pkEquals("pk").and(DynamoPlanValidationUtils.gte(COL1, "2")),
null));
// verify(runAndReadResults("SELECT *" + from(table) + "t WHERE " +
// "t." + PK + " = 'pk'" + " AND (" +
// "t." + COL1 + " = '1'" +
// " OR " +
// "t." + COL1 + " >= '2')"), item, i2);
}
示例9: testHashKeyMapping
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testHashKeyMapping() throws Exception {
Item item = new Item();
item.with(PK, "ab");
Table table = createTableWithItems(item);
updatePlugin(plugin -> {
Map<String, Object> args = new HashMap<>();
args.put("@class", LengthBasedTwoPartHashKeyMapper.class.getName());
args.put("length", 1);
DynamoKeyMapperSpec spec = new DynamoKeyMapperSpec(of("h1", "h2"), of("S", "S"), args);
plugin.setDynamoKeyMapperForTesting(table.getTableName(), spec);
});
Item expected = new Item();
expected.with("h1", "a");
expected.with("h2", "b");
expected.with(PK, "ab");
selectStar(table, true, expected);
}
示例10: decrypt
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
public Item decrypt(Item item) {
if ( null == item ) return null;
boolean hasKey = null != _keyProvider && _keyProvider.getKey(1) != null;
Item result = new Item();
for ( Map.Entry<String, Object> entry : item.asMap().entrySet() ) {
Object val = entry.getValue();
if ( hasKey && val instanceof byte[] ) {
// ALWAYS *try* to decrypt byte[] (in case this field was previously encrypted):
try {
val = decrypt((byte[])val, Object.class);
} catch ( Throwable ex ) {
if ( requiresEncryption(entry.getKey()) ) {
LOG.warn("Failed to decrypt '"+entry.getKey()+"'", ex);
}
}
}
result.with(entry.getKey(), val);
}
return result;
}
示例11: testPrimaryKeyFilterSpecifiedHashKey
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
/**
* Table with just a hash key has the hash key fully specified, which should cause a single Get
* request
*/
@Test
public void testPrimaryKeyFilterSpecifiedHashKey() throws Exception {
Item item = item();
item.with(COL1, "v1");
Item i2 = new Item();
i2.with(PK, "2");
i2.with(COL1, "pk");
Table table = createTableWithItems(item, i2);
String select = selectStarWithPK("2", "t", table);
verify(runAndReadResults(select), i2);
validatePlanWithGets(select, create("equal", PK, "2"));
}
示例12: testTwoPointGets
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testTwoPointGets() throws Exception {
Item item = item();
item.with(COL1, "1");
Item i2 = new Item();
i2.with(PK, "pk2");
i2.with(COL1, "2");
Table table = createTableWithItems(item, i2);
String query = "SELECT *" + from(table) + "t WHERE " +
"t." + PK + " = 'pk' OR " +
"t." + PK + " = 'pk2'" +
"ORDER BY t." + PK + " ASC";
verify(runAndReadResults(query), item, i2);
validatePlanWithGets(query, pkEquals("pk2"), pkEquals("pk"));
}
示例13: testPointGetWithRetainedFilterCausesQuery
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testPointGetWithRetainedFilterCausesQuery() throws Exception {
Item item = item();
item.with(COL1, "1");
Item i2 = new Item();
i2.with(PK, "pk2");
i2.with(COL1, "2");
Table table = createTableWithItems(item, i2);
String query = "SELECT *" + from(table) + "t WHERE " +
"t." + PK + " = 'pk2' AND " +
"t." + COL1 + " = '2'";
verify(runAndReadResults(query), i2);
validatePlanWithQueries(query,
of(pkEquals("pk2"), DynamoPlanValidationUtils.equals(COL1, "2")));
}
示例14: testBetweenScan
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testBetweenScan() throws Exception {
Item item = item();
item.with(COL1, "1");
Table table = createTableWithItems(item);
String query = "SELECT *" + from(table) + "t WHERE " +
"t." + COL1 + " BETWEEN '1' AND '2'";
verify(runAndReadResults(query), item);
validatePlanWithScan(query, create("between", COL1, "1", "2"));
}
示例15: testBetweenQuery
import com.amazonaws.services.dynamodbv2.document.Item; //导入方法依赖的package包/类
@Test
public void testBetweenQuery() throws Exception {
Item item = item();
item.with(COL1, 1);
Table table = createTableWithItems(item);
String query = selectStarWithPK("pk", "t", table) + " AND " +
"t." + COL1 + " BETWEEN 1 AND 2";
verify(runAndReadResults(query), item);
validatePlanWithQueries(query, of(
pkEquals("pk"), create("between", COL1, 1, 2)));
}