Example usage for com.amazonaws.services.dynamodbv2.model GlobalSecondaryIndexDescription getIndexName

List of usage examples for com.amazonaws.services.dynamodbv2.model GlobalSecondaryIndexDescription getIndexName

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model GlobalSecondaryIndexDescription getIndexName.

Prototype


public String getIndexName() 

Source Link

Document

The name of the global secondary index.

Usage

From source file:com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbDelegate.java

License:Open Source License

private static boolean areGsisSameConfiguration(final GlobalSecondaryIndexDescription g1,
        final GlobalSecondaryIndexDescription g2) {
    if (g1 == null ^ g2 == null) {
        return false;
    }// w w  w.  j  av a2 s.  com
    if (g1 == g2) {
        return true;
    }
    final EqualsBuilder builder = new EqualsBuilder();
    builder.append(g1.getIndexName(), g2.getIndexName());
    builder.append(g1.getKeySchema(), g2.getKeySchema());
    builder.append(g1.getProjection().getProjectionType(), g2.getProjection().getProjectionType());
    builder.append(g1.getProvisionedThroughput().getReadCapacityUnits(),
            g2.getProvisionedThroughput().getReadCapacityUnits());
    builder.append(g1.getProvisionedThroughput().getWriteCapacityUnits(),
            g2.getProvisionedThroughput().getWriteCapacityUnits());

    final Set<String> projectionNonKeyAttributesG1 = new HashSet<>(
            Optional.ofNullable(g1.getProjection().getNonKeyAttributes()).orElse(Collections.emptyList()));
    final Set<String> projectionNonKeyAttributesG2 = new HashSet<>(
            Optional.ofNullable(g2.getProjection().getNonKeyAttributes()).orElse(Collections.emptyList()));
    builder.append(projectionNonKeyAttributesG1, projectionNonKeyAttributesG2);

    return builder.build();
}

From source file:com.rapid7.diskstorage.dynamodb.DynamoDBDelegate.java

License:Open Source License

public static boolean areGSIsSameConfiguration(GlobalSecondaryIndexDescription g1,
        GlobalSecondaryIndexDescription g2) {
    if (g1 == null ^ g2 == null) {
        return false;
    }/*from  w ww .  ja  v a2 s  .c o  m*/
    if (g1 == g2) {
        return true;
    }
    final EqualsBuilder builder = new EqualsBuilder();
    builder.append(g1.getIndexName(), g2.getIndexName());
    builder.append(g1.getKeySchema(), g2.getKeySchema());
    builder.append(g1.getProjection().getProjectionType(), g2.getProjection().getProjectionType());
    builder.append(g1.getProvisionedThroughput().getReadCapacityUnits(),
            g2.getProvisionedThroughput().getReadCapacityUnits());
    builder.append(g1.getProvisionedThroughput().getWriteCapacityUnits(),
            g2.getProvisionedThroughput().getWriteCapacityUnits());

    final Set<String> projectionNonKeyAttributesG1 = g1.getProjection().getNonKeyAttributes() == null
            ? Collections.<String>emptySet()
            : new HashSet<String>(g1.getProjection().getNonKeyAttributes());
    final Set<String> projectionNonKeyAttributesG2 = g2.getProjection().getNonKeyAttributes() == null
            ? Collections.<String>emptySet()
            : new HashSet<String>(g2.getProjection().getNonKeyAttributes());
    builder.append(projectionNonKeyAttributesG1, projectionNonKeyAttributesG2);

    return builder.isEquals();
}

From source file:org.apache.metamodel.dynamodb.DynamoDbDataContext.java

License:Apache License

@Override
protected Schema getMainSchema() throws MetaModelException {
    final Map<String, SimpleTableDef> tableDefs = new HashMap<>();
    for (final SimpleTableDef tableDef : _tableDefs) {
        tableDefs.put(tableDef.getName(), tableDef);
    }//from  ww w.  ja v a  2 s .c o m

    final MutableSchema schema = new MutableSchema(getMainSchemaName());
    final ListTablesResult tables = _dynamoDb.listTables();
    final List<String> tableNames = tables.getTableNames();
    for (final String tableName : tableNames) {
        final MutableTable table = new MutableTable(tableName, schema);
        schema.addTable(table);

        final DescribeTableResult descripeTableResult = _dynamoDb.describeTable(tableName);
        final TableDescription tableDescription = descripeTableResult.getTable();

        // add primary keys
        addColumnFromKeySchema("Primary index", tableDescription.getKeySchema(), table, true);

        // add attributes from global and local indices
        final List<GlobalSecondaryIndexDescription> globalSecondaryIndexes = tableDescription
                .getGlobalSecondaryIndexes();
        if (globalSecondaryIndexes != null) {
            for (final GlobalSecondaryIndexDescription globalSecondaryIndex : globalSecondaryIndexes) {
                addColumnFromKeySchema(globalSecondaryIndex.getIndexName(), globalSecondaryIndex.getKeySchema(),
                        table, false);
            }
        }
        final List<LocalSecondaryIndexDescription> localSecondaryIndexes = tableDescription
                .getLocalSecondaryIndexes();
        if (localSecondaryIndexes != null) {
            for (final LocalSecondaryIndexDescription localSecondaryIndex : localSecondaryIndexes) {
                addColumnFromKeySchema(localSecondaryIndex.getIndexName(), localSecondaryIndex.getKeySchema(),
                        table, false);
            }
        }

        // add top-level attribute definitions
        final List<AttributeDefinition> attributeDefinitions = tableDescription.getAttributeDefinitions();
        for (final AttributeDefinition attributeDefinition : attributeDefinitions) {
            final String attributeName = attributeDefinition.getAttributeName();
            MutableColumn column = (MutableColumn) table.getColumnByName(attributeName);
            if (column == null) {
                column = new MutableColumn(attributeName, table);
                table.addColumn(column);
            }
            final String attributeType = attributeDefinition.getAttributeType();
            column.setType(DynamoDbUtils.toColumnType(attributeName, attributeType));
            column.setIndexed(true);
            column.setNativeType(attributeType);
        }

        // add additional metadata from SimpleTableDefs if available
        final SimpleTableDef tableDef = tableDefs.get(tableName);
        if (tableDef != null) {
            final String[] columnNames = tableDef.getColumnNames();
            final ColumnType[] columnTypes = tableDef.getColumnTypes();
            for (int i = 0; i < columnNames.length; i++) {
                final String columnName = columnNames[i];
                final ColumnType columnType = columnTypes[i];
                MutableColumn column = (MutableColumn) table.getColumnByName(columnName);
                if (column == null) {
                    column = new MutableColumn(columnName, table);
                    table.addColumn(column);
                }
                if (column.getType() == null && columnType != null) {
                    column.setType(columnType);
                }
            }
        }

        // add additional attributes based on global and local indices
        if (globalSecondaryIndexes != null) {
            for (final GlobalSecondaryIndexDescription globalSecondaryIndex : globalSecondaryIndexes) {
                final List<String> nonKeyAttributes = globalSecondaryIndex.getProjection()
                        .getNonKeyAttributes();
                for (final String attributeName : nonKeyAttributes) {
                    addColumnFromNonKeyAttribute(globalSecondaryIndex.getIndexName(), table, attributeName);
                }
            }
        }
        if (localSecondaryIndexes != null) {
            for (final LocalSecondaryIndexDescription localSecondaryIndex : localSecondaryIndexes) {
                final List<String> nonKeyAttributes = localSecondaryIndex.getProjection().getNonKeyAttributes();
                for (final String attributeName : nonKeyAttributes) {
                    addColumnFromNonKeyAttribute(localSecondaryIndex.getIndexName(), table, attributeName);
                }
            }
        }
    }
    return schema;
}

From source file:org.xmlsh.aws.util.AWSDDBCommand.java

License:BSD License

private void writeGlobalSecondaryIndex(GlobalSecondaryIndexDescription index) throws XMLStreamException {

    startElement("global-secondary-index");
    attribute("index-name", index.getIndexName());
    attribute("index-size", index.getIndexSizeBytes());
    attribute("index-status", index.getIndexStatus());
    attribute("item-count", index.getItemCount());
    writeKeySchemaList(index.getKeySchema());
    writeProjection(index.getProjection());
    writeProvisionedThroughput(index.getProvisionedThroughput());
    endElement();/*from   w  ww . j a  v a 2s.c  o m*/

}