com.datastax.driver.core.schemabuilder.Create Java Examples
The following examples show how to use
com.datastax.driver.core.schemabuilder.Create.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CassandraModule.java From james-project with Apache License 2.0 | 5 votes |
public Builder statement(Function<Create, Create> toCreateStatement) { Preconditions.checkState(comment.isPresent(), "`comment` is compulsory"); Create createStatement = toCreateStatement.apply( SchemaBuilder.createTable(tableName) .ifNotExists()); return originalBuilderReference.addTable( new CassandraTable(tableName, options.orElse(Function.identity()) .apply(createStatement.withOptions().comment(comment.get())))); }
Example #2
Source File: CassandraOperations.java From geowave with Apache License 2.0 | 5 votes |
@Override public MetadataWriter createMetadataWriter(final MetadataType metadataType) { final String tableName = getMetadataTableName(metadataType); // this checks for existence prior to create synchronized (CREATE_TABLE_MUTEX) { try { if (!indexExists(tableName)) { // create table final Create create = getCreateTable(tableName); create.addPartitionKey(CassandraMetadataWriter.PRIMARY_ID_KEY, DataType.blob()); if (MetadataType.STATS.equals(metadataType) || MetadataType.INTERNAL_ADAPTER.equals(metadataType)) { create.addClusteringColumn(CassandraMetadataWriter.SECONDARY_ID_KEY, DataType.blob()); create.addClusteringColumn( CassandraMetadataWriter.TIMESTAMP_ID_KEY, DataType.timeuuid()); if (MetadataType.STATS.equals(metadataType)) { create.addColumn(CassandraMetadataWriter.VISIBILITY_KEY, DataType.blob()); } } create.addColumn(CassandraMetadataWriter.VALUE_KEY, DataType.blob()); executeCreateTable(create, tableName); } } catch (final IOException e) { LOGGER.warn("Unable to check if table exists", e); } } return new CassandraMetadataWriter(this, tableName); }
Example #3
Source File: CassandraOperations.java From geowave with Apache License 2.0 | 4 votes |
private Create getCreateTable(final String safeTableName) { return SchemaBuilder.createTable(gwNamespace, safeTableName).ifNotExists(); }
Example #4
Source File: CassandraOperations.java From geowave with Apache License 2.0 | 4 votes |
private void executeCreateTable(final Create create, final String safeTableName) { session.execute(create); state.tableExistsCache.put(safeTableName, true); }
Example #5
Source File: CassandraRow.java From geowave with Apache License 2.0 | 4 votes |
private ColumnType(final BiConsumer<Create, Pair<String, DataType>> createFunction) { this.createFunction = createFunction; }
Example #6
Source File: CassandraRow.java From geowave with Apache License 2.0 | 4 votes |
public void addColumn(final Create create) { columnType.createFunction.accept(create, Pair.of(fieldName, dataType)); }