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


Java DynamoDBScanExpression类代码示例

本文整理汇总了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);
}
 
开发者ID:querydsl,项目名称:querydsl-contrib,代码行数:24,代码来源:DynamodbSerializer.java

示例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);
}
 
开发者ID:querydsl,项目名称:querydsl-contrib,代码行数:32,代码来源:DynamoDBQueryTest.java

示例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);
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:22,代码来源:ObjectPersistenceQueryScanExample.java

示例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);
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:22,代码来源:ObjectPersistenceQueryScanExample.java

示例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);

}
 
开发者ID:michaellavelle,项目名称:spring-data-dynamodb,代码行数:24,代码来源:PartTreeDynamoDBQueryUnitTest.java

示例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);
}
 
开发者ID:satr,项目名称:aws-amazon-shopping-bot-lambda-func,代码行数:15,代码来源:UserRepositoryImpl.java

示例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;
}
 
开发者ID:milton0825,项目名称:plano,代码行数:20,代码来源:DynamoDBRepository.java

示例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);
}
 
开发者ID:tahamsaglam,项目名称:duckdns,代码行数:11,代码来源:AmazonDynamoDBDAO.java

示例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;
}
 
开发者ID:tahamsaglam,项目名称:duckdns,代码行数:9,代码来源:AmazonDynamoDBDAO.java

示例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;
}
 
开发者ID:tahamsaglam,项目名称:duckdns,代码行数:9,代码来源:AmazonDynamoDBDAO.java

示例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;
}
 
开发者ID:tahamsaglam,项目名称:duckdns,代码行数:9,代码来源:AmazonDynamoDBDAO.java

示例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;
}
 
开发者ID:tahamsaglam,项目名称:duckdns,代码行数:9,代码来源:AmazonDynamoDBDAO.java

示例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();
}
 
开发者ID:SungardAS,项目名称:enhanced-snapshots,代码行数:8,代码来源:InitConfigurationServiceImpl.java


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