• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LocalSecondaryIndex类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createTable

import com.amazonaws.services.dynamodbv2.model.LocalSecondaryIndex; //导入依赖的package包/类
private CreateTableResult createTable() {
    final List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
    attributeDefinitions.add(new AttributeDefinition(RESOURCE_NAME_ATT, ScalarAttributeType.S));
    attributeDefinitions.add(new AttributeDefinition(RDF_TRIPLE_ATT, ScalarAttributeType.S));
    attributeDefinitions.add(new AttributeDefinition(RDF_PREDICATE_ATT, ScalarAttributeType.S));
    attributeDefinitions.add(new AttributeDefinition(RDF_OBJECT_ATT, ScalarAttributeType.S));

    final List<KeySchemaElement> keySchema = new ArrayList<>();
    keySchema.add(new KeySchemaElement(RESOURCE_NAME_ATT, KeyType.HASH));
    keySchema.add(new KeySchemaElement(RDF_TRIPLE_ATT, KeyType.RANGE));

    final ProvisionedThroughput provisionedthroughput =
        new ProvisionedThroughput(10L, 10L);

    final LocalSecondaryIndex predicateIndex = new LocalSecondaryIndex()
        .withIndexName(PREDICATE_INDEX_NAME)
        .withKeySchema(new KeySchemaElement(RESOURCE_NAME_ATT, KeyType.HASH))
        .withKeySchema(new KeySchemaElement(RDF_PREDICATE_ATT, KeyType.RANGE))
        .withProjection(new Projection().withNonKeyAttributes(RDF_SUBJECT_ATT, RDF_OBJECT_ATT)
                                        .withProjectionType(ProjectionType.INCLUDE));

    final GlobalSecondaryIndex objectIndex = new GlobalSecondaryIndex()
        .withIndexName(OBJECT_INDEX_NAME)
        .withKeySchema(new KeySchemaElement(RDF_OBJECT_ATT, KeyType.HASH))
        .withKeySchema(new KeySchemaElement(RDF_PREDICATE_ATT, KeyType.RANGE))
        .withProjection(new Projection().withNonKeyAttributes(RDF_SUBJECT_ATT)
                                        .withProjectionType(ProjectionType.INCLUDE))
        .withProvisionedThroughput(new ProvisionedThroughput(10L, 10L));

    final CreateTableRequest request =
        new CreateTableRequest()
            .withTableName(TABLE_NAME)
            .withAttributeDefinitions(attributeDefinitions)
            .withKeySchema(keySchema)
            .withProvisionedThroughput(provisionedthroughput)
            .withLocalSecondaryIndexes(predicateIndex)
            .withGlobalSecondaryIndexes(objectIndex);

    return dynamodbClient.createTable(request);
}
 
开发者ID:duraspace,项目名称:lambdora,代码行数:41,代码来源:IntegrationTestBase.java


示例2: createTableRequest

import com.amazonaws.services.dynamodbv2.model.LocalSecondaryIndex; //导入依赖的package包/类
/***
 * Create the Table Request
 * @param table
 * @return createTableRequest
 */
private CreateTableRequest createTableRequest(final Table table) {
	
	final ProvisionedThroughput throughput = this.createProvisionedThroughput(table.getReadCapacityUnits(), table.getWriteCapacityUnits());
	final List<KeySchemaElement> keys = this.createKeySchemaElements(table.getKeys());


	final CreateTableRequest tableRequest = new CreateTableRequest(table.getName(), keys)
		.withProvisionedThroughput(throughput);

	/***
	 * Set Indexes
	 */
	final List<LocalSecondaryIndex> localSecondaryIndexes = this.createLocalSecondaryIndexes(table.getLocalSecondaryIndexes());
	final List<GlobalSecondaryIndex> globalSecondaryIndexes = this.createGlobalSecondaryIndexes(table.getGlobalSecondaryIndexes());
	
	
	/** Local Secondary Indexes **/
	if(localSecondaryIndexes!=null){
		tableRequest.withLocalSecondaryIndexes(localSecondaryIndexes);
	}
	
	/** Global Secondary Indexes **/
	if(globalSecondaryIndexes!=null){
		tableRequest.withGlobalSecondaryIndexes(globalSecondaryIndexes);
	}
	
	/** Set Attribute Definitions **/
	final List<AttributeDefinition> attributeDefinitions = this.createAttributeDefinitions(table.getAttributeDefinitions());
	tableRequest.withAttributeDefinitions(attributeDefinitions);
	return tableRequest;
}
 
开发者ID:shagwood,项目名称:micro-genie,代码行数:37,代码来源:DynamoAdmin.java


示例3: createLocalSecondaryIndexes

import com.amazonaws.services.dynamodbv2.model.LocalSecondaryIndex; //导入依赖的package包/类
/***
 * Create Local Secondary Indexes
 * @param localSecondaryIndexes
 * @return localIndexList
 */
private List<LocalSecondaryIndex> createLocalSecondaryIndexes(List<io.microgenie.aws.config.DynamoDbConfig.LocalSecondaryIndex> localSecondaryIndexes) {
	List<LocalSecondaryIndex>  indexes = null;
	if(localSecondaryIndexes!=null){
		indexes = new ArrayList<LocalSecondaryIndex>();	
		for(DynamoDbConfig.LocalSecondaryIndex configIndex : localSecondaryIndexes){
			LocalSecondaryIndex index = new LocalSecondaryIndex()
			.withIndexName(configIndex.getName())
			.withProjection(this.createProjection(configIndex.getProjection()))
			.withKeySchema(this.createKeySchemaElements(configIndex.getKeys()));
			indexes.add(index);
		}
	}
	return indexes;
}
 
开发者ID:shagwood,项目名称:micro-genie,代码行数:20,代码来源:DynamoAdmin.java


示例4: getCreateTableRequest

import com.amazonaws.services.dynamodbv2.model.LocalSecondaryIndex; //导入依赖的package包/类
/**
 * <p>
 * Construct a create table request object based on GeoDataManagerConfiguration. The users can update any aspect of
 * the request and call it.
 * </p>
 * Example:
 * 
 * <pre>
 * AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(new ClasspathPropertiesFileCredentialsProvider());
 * Region usWest2 = Region.getRegion(Regions.US_WEST_2);
 * ddb.setRegion(usWest2);
 * 
 * CreateTableRequest createTableRequest = GeoTableUtil.getCreateTableRequest(config);
 * CreateTableResult createTableResult = ddb.createTable(createTableRequest);
 * </pre>
 * 
 * @return Generated create table request.
 */
public static CreateTableRequest getCreateTableRequest(GeoDataManagerConfiguration config) {
	CreateTableRequest createTableRequest = new CreateTableRequest()
			.withTableName(config.getTableName())
			.withProvisionedThroughput(
					new ProvisionedThroughput().withReadCapacityUnits(10L).withWriteCapacityUnits(5L))
			.withKeySchema(
					new KeySchemaElement().withKeyType(KeyType.HASH).withAttributeName(
							config.getHashKeyAttributeName()),
					new KeySchemaElement().withKeyType(KeyType.RANGE).withAttributeName(
							config.getRangeKeyAttributeName()))
			.withAttributeDefinitions(
					new AttributeDefinition().withAttributeType(ScalarAttributeType.N).withAttributeName(
							config.getHashKeyAttributeName()),
					new AttributeDefinition().withAttributeType(ScalarAttributeType.S).withAttributeName(
							config.getRangeKeyAttributeName()),
					new AttributeDefinition().withAttributeType(ScalarAttributeType.N).withAttributeName(
							config.getGeohashAttributeName()))
			.withLocalSecondaryIndexes(
					new LocalSecondaryIndex()
							.withIndexName(config.getGeohashIndexName())
							.withKeySchema(
									new KeySchemaElement().withKeyType(KeyType.HASH).withAttributeName(
											config.getHashKeyAttributeName()),
									new KeySchemaElement().withKeyType(KeyType.RANGE).withAttributeName(
											config.getGeohashAttributeName()))
							.withProjection(new Projection().withProjectionType(ProjectionType.ALL)));

	return createTableRequest;
}
 
开发者ID:awslabs,项目名称:dynamodb-geo,代码行数:48,代码来源:GeoTableUtil.java


示例5: createTable

import com.amazonaws.services.dynamodbv2.model.LocalSecondaryIndex; //导入依赖的package包/类
public void createTable() {

    final AttributeDefinition nsKey =
        new AttributeDefinition().withAttributeName(HASH_KEY).withAttributeType(
            ScalarAttributeType.S);

    final AttributeDefinition featureKey =
        new AttributeDefinition().withAttributeName(RANGE_KEY)
            .withAttributeType(ScalarAttributeType.S);

    final AttributeDefinition id =
        new AttributeDefinition().withAttributeName(ATTR_ID)
            .withAttributeType(ScalarAttributeType.S);

    final ArrayList<AttributeDefinition>
        tableAttributeDefinitions = Lists.newArrayList(nsKey, featureKey, id);
    final ArrayList<KeySchemaElement> tableKeySchema = Lists.newArrayList();

    tableKeySchema.add(
        new KeySchemaElement().withAttributeName(HASH_KEY).withKeyType(KeyType.HASH));
    tableKeySchema.add(
        new KeySchemaElement().withAttributeName(RANGE_KEY).withKeyType(KeyType.RANGE));

    final ProvisionedThroughput tableProvisionedThroughput =
        new ProvisionedThroughput()
            .withReadCapacityUnits(10L)
            .withWriteCapacityUnits(10L);

    final ArrayList<KeySchemaElement> indexKeySchema = new ArrayList<>();
    indexKeySchema.add(
        new KeySchemaElement().withAttributeName(HASH_KEY).withKeyType(KeyType.HASH));
    indexKeySchema.add(
        new KeySchemaElement().withAttributeName(ATTR_ID).withKeyType(KeyType.RANGE));

    final Projection projection = new Projection().withProjectionType(ProjectionType.INCLUDE);
    final ArrayList<String> indexColumns = new ArrayList<>();
    indexColumns.add("json");
    indexColumns.add("v");
    projection.setNonKeyAttributes(indexColumns);

    final LocalSecondaryIndex localSecondaryIndex = new LocalSecondaryIndex()
        .withIndexName("feature_by_ns_key_and_id_lsi_idx")
        .withKeySchema(indexKeySchema)
        .withProjection(projection);

    final ArrayList<LocalSecondaryIndex> secondaryIndices = new ArrayList<>();
    secondaryIndices.add(localSecondaryIndex);

    final CreateTableRequest createTableRequest =
        new CreateTableRequest()
            .withTableName(tableName)
            .withKeySchema(tableKeySchema)
            .withAttributeDefinitions(tableAttributeDefinitions)
            .withProvisionedThroughput(tableProvisionedThroughput)
            .withLocalSecondaryIndexes(secondaryIndices);

    final TableDescription tableDescription =
        amazonDynamoDB.createTable(createTableRequest).getTableDescription();

    logger.info("created_table {}", tableDescription);

    final DescribeTableRequest describeTableRequest =
        new DescribeTableRequest().withTableName(tableName);

    final TableDescription description =
        amazonDynamoDB.describeTable(describeTableRequest).getTable();

    logger.info("table_description: " + description);
  }
 
开发者ID:dehora,项目名称:outland,代码行数:70,代码来源:DynamoCreateFeatureTableTask.java


示例6: createTable

import com.amazonaws.services.dynamodbv2.model.LocalSecondaryIndex; //导入依赖的package包/类
@Override
protected void createTable(TableDescription table) {
    List<GlobalSecondaryIndex> gsis = new ArrayList<>();
    List<LocalSecondaryIndex> lsis = new ArrayList<>();
    ProvisionedThroughput mainThroughtput = null;
    List<KeySchemaElement> mainKeySchema = null;

    Map<String, AttrType> attrTypes = new HashMap<>();

    for ( IndexDescription index : table.getIndexes() ) {
        addAttrType(table.getTableName(), index.getIndexName(), attrTypes, index.getHashKey());
        addAttrType(table.getTableName(), index.getIndexName(), attrTypes, index.getRangeKey());
        ProvisionedThroughput throughput = new ProvisionedThroughput()
            .withReadCapacityUnits(index.getReadCapacity())
            .withWriteCapacityUnits(index.getWriteCapacity());
        switch ( index.getIndexType() ) {
        case MAIN_INDEX:
            mainThroughtput = throughput;
            mainKeySchema = toKeySchema(table.getTableName(), index);
            break;
        case LOCAL_SECONDARY_INDEX:
            lsis.add(
                new LocalSecondaryIndex()
                .withProjection(
                    new Projection().withProjectionType(ProjectionType.ALL))
                .withIndexName(index.getIndexName())
                .withKeySchema(toKeySchema(table.getTableName(), index)));
            break;
        case GLOBAL_SECONDARY_INDEX:
            gsis.add(
                new GlobalSecondaryIndex()
                .withIndexName(index.getIndexName())
                .withKeySchema(toKeySchema(table.getTableName(), index))
                .withProjection(
                    new Projection().withProjectionType(ProjectionType.ALL))
                .withProvisionedThroughput(throughput));
            break;
        default:
            throw new UnsupportedOperationException(
                "Unsupported indexType="+index.getIndexType()+" for table name "+
                table.getTableName()+" index="+index.getIndexName());
        }
    }

    String tableName = getTableName(table.getTableName());
    for ( int retry=0;; retry++ ) {
        try {
            _dynamodb.createTable(
                new CreateTableRequest()
                .withKeySchema(mainKeySchema)
                .withProvisionedThroughput(mainThroughtput)
                .withAttributeDefinitions(toAttributeDefinitions(attrTypes))
                .withLocalSecondaryIndexes(lsis.size() == 0 ? null : lsis)
                .withGlobalSecondaryIndexes(gsis.size() == 0 ? null : gsis)
                .withTableName(tableName));
            break;
        } catch ( LimitExceededException ex ) {
            long secs = (retry < 6) ? (long)Math.pow(2, retry) : 60L;
            LOG.info("Waiting {} seconds to create {} due to: {}", secs, tableName, ex.getMessage());
            try {
                Thread.sleep(1000*secs);
            } catch ( InterruptedException interruptedEx ) {
                Thread.currentThread().interrupt();
                return;
            }
        }
    }
}
 
开发者ID:Distelli,项目名称:java-persistence,代码行数:69,代码来源:DdbSchema.java


示例7: createTable

import com.amazonaws.services.dynamodbv2.model.LocalSecondaryIndex; //导入依赖的package包/类
private static void createTable(
    String tableName, long readCapacityUnits, long writeCapacityUnits, 
    String hashKeyName, String hashKeyType, 
    String rangeKeyName, String rangeKeyType) {

    try {

        ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
        keySchema.add(new KeySchemaElement()
            .withAttributeName(hashKeyName)
            .withKeyType(KeyType.HASH));
        
        ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
        attributeDefinitions.add(new AttributeDefinition()
            .withAttributeName(hashKeyName)
            .withAttributeType(hashKeyType));

        if (rangeKeyName != null) {
            keySchema.add(new KeySchemaElement()
                .withAttributeName(rangeKeyName)
                .withKeyType(KeyType.RANGE));
            attributeDefinitions.add(new AttributeDefinition()
                .withAttributeName(rangeKeyName)
                .withAttributeType(rangeKeyType));
        }

        CreateTableRequest request = new CreateTableRequest()
                .withTableName(tableName)
                .withKeySchema(keySchema)
                .withProvisionedThroughput( new ProvisionedThroughput()
                    .withReadCapacityUnits(readCapacityUnits)
                    .withWriteCapacityUnits(writeCapacityUnits));

        // If this is the Reply table, define a local secondary index
        if (replyTableName.equals(tableName)) {
            
            attributeDefinitions.add(new AttributeDefinition()
                .withAttributeName("PostedBy")
                .withAttributeType("S"));

            ArrayList<LocalSecondaryIndex> localSecondaryIndexes = new ArrayList<LocalSecondaryIndex>();
            localSecondaryIndexes.add(new LocalSecondaryIndex()
                .withIndexName("PostedBy-Index")
                .withKeySchema(
                    new KeySchemaElement().withAttributeName(hashKeyName).withKeyType(KeyType.HASH), 
                    new KeySchemaElement() .withAttributeName("PostedBy") .withKeyType(KeyType.RANGE))
                .withProjection(new Projection() .withProjectionType(ProjectionType.KEYS_ONLY)));

            request.setLocalSecondaryIndexes(localSecondaryIndexes);
        }

        request.setAttributeDefinitions(attributeDefinitions);

        System.out.println("Issuing CreateTable request for " + tableName);
        Table table = dynamoDB.createTable(request);
        System.out.println("Waiting for " + tableName
            + " to be created...this may take a while...");
        table.waitForActive();

    } catch (Exception e) {
        System.err.println("CreateTable request failed for " + tableName);
        System.err.println(e.getMessage());
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:65,代码来源:CreateTablesLoadData.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExamplesTableFactory类代码示例发布时间:2022-05-23
下一篇:
Java VmPolicy类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap