本文整理汇总了Java中com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression类的典型用法代码示例。如果您正苦于以下问题:Java DynamoDBScanExpression类的具体用法?Java DynamoDBScanExpression怎么用?Java DynamoDBScanExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DynamoDBScanExpression类属于com.amazonaws.services.dynamodbv2.datamodeling包,在下文中一共展示了DynamoDBScanExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateScanExpression
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
private void populateScanExpression(List<Expression<?>> expressions, Condition condition,
DynamoDBScanExpression scanExpression) {
List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
String attributeName = null;
for (Expression<?> expression : expressions) {
Object result = expression.accept(this, scanExpression);
if (result instanceof String) {
if (attributeName != null) {
throw new RuntimeException("Already in use");
}
attributeName = (String) result;
} else if (result instanceof AttributeValue) {
attributeValueList.add((AttributeValue) result);
} else {
throw new UnsupportedOperationException("Invalid result: " + result);
}
}
condition.setAttributeValueList(attributeValueList);
scanExpression.addFilterCondition(attributeName, condition);
}
示例2: fillTable
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
public static void fillTable() throws UnknownHostException {
ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput();
provisionedThroughput.setReadCapacityUnits(1L);
provisionedThroughput.setWriteCapacityUnits(1L);
if (!client.listTables().getTableNames().contains("User")) {
CreateTableRequest createTableRequest = new CreateTableRequest()
.withTableName("User")
.withKeySchema(
new KeySchemaElement().withAttributeName("id")
.withKeyType(KeyType.HASH))
.withProvisionedThroughput(provisionedThroughput)
.withAttributeDefinitions(
new AttributeDefinition().withAttributeName("id").withAttributeType(
ScalarAttributeType.S));
client.createTable(createTableRequest);
} else {
DynamoDBScanExpression scan = new DynamoDBScanExpression();
PaginatedScanList<User> users = mapper.scan(User.class, scan);
for (User user : users) {
Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
key.put("id", new AttributeValue().withS(user.getId()));
client.deleteItem(new DeleteItemRequest("User", key));
}
}
u1 = addUser("Jaakko", "Jantunen", 20, Gender.MALE, null);
u2 = addUser("Jaakki", "Jantunen", 30, Gender.FEMALE, "One detail");
u3 = addUser("Jaana", "Aakkonen", 40, Gender.MALE, "No details");
u4 = addUser("Jaana", "BeekkoNen", 50, Gender.FEMALE, null);
}
示例3: FindBooksPricedLessThanSpecifiedValue
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
private static void FindBooksPricedLessThanSpecifiedValue(
DynamoDBMapper mapper,
String value) throws Exception {
System.out.println("FindBooksPricedLessThanSpecifiedValue: Scan ProductCatalog.");
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
scanExpression.addFilterCondition("Price",
new Condition()
.withComparisonOperator(ComparisonOperator.LT)
.withAttributeValueList(new AttributeValue().withN(value)));
scanExpression.addFilterCondition("ProductCategory",
new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue().withS("Book")));
List<Book> scanResult = mapper.scan(Book.class, scanExpression);
for (Book book : scanResult) {
System.out.println(book);
}
}
示例4: FindBicyclesOfSpecificTypeWithMultipleThreads
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
private static void FindBicyclesOfSpecificTypeWithMultipleThreads(
DynamoDBMapper mapper,
int numberOfThreads,
String bicycleType) throws Exception {
System.out.println("FindBicyclesOfSpecificTypeWithMultipleThreads: Scan ProductCatalog With Multiple Threads.");
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
scanExpression.addFilterCondition("ProductCategory",
new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue().withS("Bicycle")));
scanExpression.addFilterCondition("BicycleType",
new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue().withS(bicycleType)));
List<Bicycle> scanResult = mapper.parallelScan(Bicycle.class, scanExpression, numberOfThreads);
for (Bicycle bicycle : scanResult) {
System.out.println(bicycle);
}
}
示例5: buildScanExpression
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
public DynamoDBScanExpression buildScanExpression() {
if (sort != null) {
throw new UnsupportedOperationException("Sort not supported for scan expressions");
}
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
if (isHashKeySpecified()) {
scanExpression.addFilterCondition(
getHashKeyAttributeName(),
createSingleValueCondition(getHashKeyPropertyName(), ComparisonOperator.EQ, getHashKeyAttributeValue(),
getHashKeyAttributeValue().getClass(), true));
}
for (Map.Entry<String, List<Condition>> conditionEntry : attributeConditions.entrySet()) {
for (Condition condition : conditionEntry.getValue()) {
scanExpression.addFilterCondition(conditionEntry.getKey(), condition);
}
}
return scanExpression;
}
开发者ID:michaellavelle,项目名称:spring-data-dynamodb,代码行数:22,代码来源:DynamoDBEntityWithHashKeyOnlyCriteria.java
示例6: buildScanExpression
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
public DynamoDBScanExpression buildScanExpression() {
if (sort != null) {
throw new UnsupportedOperationException("Sort not supported for scan expressions");
}
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
if (isHashKeySpecified()) {
scanExpression.addFilterCondition(
getHashKeyAttributeName(),
createSingleValueCondition(getHashKeyPropertyName(), ComparisonOperator.EQ, getHashKeyAttributeValue(),
getHashKeyAttributeValue().getClass(), true));
}
if (isRangeKeySpecified()) {
scanExpression.addFilterCondition(
getRangeKeyAttributeName(),
createSingleValueCondition(getRangeKeyPropertyName(), ComparisonOperator.EQ, getRangeKeyAttributeValue(),
getRangeKeyAttributeValue().getClass(), true));
}
for (Map.Entry<String, List<Condition>> conditionEntry : attributeConditions.entrySet()) {
for (Condition condition : conditionEntry.getValue()) {
scanExpression.addFilterCondition(conditionEntry.getKey(), condition);
}
}
return scanExpression;
}
开发者ID:michaellavelle,项目名称:spring-data-dynamodb,代码行数:26,代码来源:DynamoDBEntityWithHashAndRangeKeyCriteria.java
示例7:
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test(expected=IllegalArgumentException.class)
public void testExecute_WhenFinderMethodIsCountingEntityWithCompositeIdList_WhenFindingByRangeKeyOnly_ScanCountDisabled() {
setupCommonMocksForThisRepositoryMethod(mockPlaylistEntityMetadata, mockDynamoDBPlaylistQueryMethod,
Playlist.class, "countByPlaylistName", 1, "userName", "playlistName");
Mockito.when(mockDynamoDBPlaylistQueryMethod.isCollectionQuery()).thenReturn(false);
Mockito.when(mockDynamoDBPlaylistQueryMethod.isScanCountEnabled()).thenReturn(false);
// Mock out specific DynamoDBOperations behavior expected by this method
ArgumentCaptor<DynamoDBScanExpression> scanCaptor = ArgumentCaptor.forClass(DynamoDBScanExpression.class);
@SuppressWarnings("rawtypes")
ArgumentCaptor<Class> classCaptor = ArgumentCaptor.forClass(Class.class);
Mockito.when(mockDynamoDBOperations.count(classCaptor.capture(), scanCaptor.capture())).thenReturn(
100);
// Execute the query
Object[] parameters = new Object[] { "somePlaylistName" };
partTreeDynamoDBQuery.execute(parameters);
}
示例8: getUserByName
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
@Override
public List<User> getUserByName(String firstName, String lastName) {
String attrValueFirstName = ":v_first_name";
String attrValueLastName = ":v_last_name";
String filterExpression = String.format("%s=%s and %s=%s", Attr.FirstName, attrValueFirstName,
Attr.LastName, attrValueLastName);
Map<String, AttributeValue> expressionValueMap = new HashMap<>();
expressionValueMap.put(attrValueFirstName, new AttributeValue().withS(firstName));
expressionValueMap.put(attrValueLastName, new AttributeValue().withS(lastName));
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression()
.withFilterExpression(filterExpression)
.withExpressionAttributeValues(expressionValueMap);
return dbMapper.scan(User.class, scanExpression);
}
示例9: findNextRequest
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
private DynamoDBPlanoRequest findNextRequest() throws PlanoException {
AttributeValue currentTime = DateToStringMarshaller.instance().marshall(new Date());
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression()
.withFilterExpression("ExecutionTime < :currentTime and LockExpireTime < :currentTime")
.addExpressionAttributeValuesEntry(":currentTime", currentTime)
.withConsistentRead(true)
.withLimit(1);
List<DynamoDBPlanoRequest> dynamoDBPlanoRequests =
dynamoDBMapper.scan(DynamoDBPlanoRequest.class, scanExpression);
if (dynamoDBPlanoRequests == null || dynamoDBPlanoRequests.isEmpty()) {
throw new PlanoException("Can not find next PlanoRequest to execute.");
}
DynamoDBPlanoRequest dynamoDBPlanoRequest = dynamoDBPlanoRequests.get(0);
return dynamoDBPlanoRequest;
}
示例10: sessionsCleanUpOldSessions
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
public void sessionsCleanUpOldSessions() {
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
scanExpression.addFilterCondition("lastHit",
new Condition()
.withComparisonOperator(ComparisonOperator.LT.toString())
.withAttributeValueList(new AttributeValue().withN(""+(System.currentTimeMillis()-(Session.TTL_SESSIONS_SECONDS * 1000))))
);
PaginatedScanList<Session> result = mapper.scan(Session.class, scanExpression);
mapper.batchDelete(result);
}
示例11: getAllDonatedAccounts
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
public PaginatedScanList<Account> getAllDonatedAccounts() {
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
scanExpression.addFilterCondition("accountType",new Condition()
.withComparisonOperator(ComparisonOperator.EQ.toString())
.withAttributeValueList(new AttributeValue[] { new AttributeValue().withS(Account.ACCOUNT_DONATE) }));
PaginatedScanList<Account> accounts = mapper.scan(Account.class,scanExpression);
return accounts;
}
示例12: getAllFriendsAccounts
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
public PaginatedScanList<Account> getAllFriendsAccounts() {
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
scanExpression.addFilterCondition("accountType",new Condition()
.withComparisonOperator(ComparisonOperator.EQ.toString())
.withAttributeValueList(new AttributeValue[] { new AttributeValue().withS(Account.ACCOUNT_FRIENDS_OF_DUCK) }));
PaginatedScanList<Account> accounts = mapper.scan(Account.class,scanExpression);
return accounts;
}
示例13: getAllRedditAccounts
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
public PaginatedScanList<Account> getAllRedditAccounts() {
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
scanExpression.addFilterCondition("email",new Condition()
.withComparisonOperator(ComparisonOperator.CONTAINS.toString())
.withAttributeValueList(new AttributeValue[] { new AttributeValue().withS("@reddit") }));
PaginatedScanList<Account> accounts = mapper.scan(Account.class,scanExpression);
return accounts;
}
示例14: getAllFacebookAccounts
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
public PaginatedScanList<Account> getAllFacebookAccounts() {
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
scanExpression.addFilterCondition("email",new Condition()
.withComparisonOperator(ComparisonOperator.CONTAINS.toString())
.withAttributeValueList(new AttributeValue[] { new AttributeValue().withS("#facebook") }));
PaginatedScanList<Account> accounts = mapper.scan(Account.class,scanExpression);
return accounts;
}
示例15: adminExist
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; //导入依赖的package包/类
private boolean adminExist() {
DynamoDBScanExpression expression = new DynamoDBScanExpression()
.withFilterConditionEntry("role",
new Condition().withComparisonOperator(EQ.toString()).withAttributeValueList(new AttributeValue("admin")));
List<User> users = mapper.scan(User.class, expression);
return !users.isEmpty();
}