use of com.datastax.driver.core.schemabuilder.TableOptions in project scalardb by scalar-labs.
the class CassandraAdminTest method createTableInternal_ReservedKeywords_ShouldExecuteCreateTableStatementProperly.
@Test
public void createTableInternal_ReservedKeywords_ShouldExecuteCreateTableStatementProperly() throws ExecutionException {
// Arrange
String namespace = "keyspace";
String table = "table";
TableMetadata tableMetadata = TableMetadata.newBuilder().addPartitionKey("from").addPartitionKey("c7").addClusteringKey("two").addClusteringKey("c6", Order.DESC).addColumn("from", DataType.INT).addColumn("to", DataType.TEXT).addColumn("one", DataType.BLOB).addColumn("two", DataType.DOUBLE).addColumn("password", DataType.BIGINT).addColumn("c6", DataType.BOOLEAN).addColumn("c7", DataType.TEXT).addSecondaryIndex("to").addSecondaryIndex("two").build();
HashMap<String, String> options = new HashMap<>();
options.put(CassandraAdmin.COMPACTION_STRATEGY, CompactionStrategy.LCS.toString());
// Act
cassandraAdmin.createTableInternal(namespace, table, tableMetadata, options);
// Assert
TableOptions<Options> createTableStatement = SchemaBuilder.createTable(quote(namespace), quote(table)).addPartitionKey("\"from\"", com.datastax.driver.core.DataType.cint()).addPartitionKey("c7", com.datastax.driver.core.DataType.text()).addClusteringColumn("\"two\"", com.datastax.driver.core.DataType.cdouble()).addClusteringColumn("c6", com.datastax.driver.core.DataType.cboolean()).addColumn("\"to\"", com.datastax.driver.core.DataType.text()).addColumn("\"one\"", com.datastax.driver.core.DataType.blob()).addColumn("\"password\"", com.datastax.driver.core.DataType.bigint()).withOptions().clusteringOrder("\"two\"", Direction.ASC).clusteringOrder("c6", Direction.DESC).compactionOptions(SchemaBuilder.leveledStrategy());
verify(cassandraSession).execute(createTableStatement.getQueryString());
}
use of com.datastax.driver.core.schemabuilder.TableOptions in project scalardb by scalar-labs.
the class CassandraAdminTest method createTableInternal_WithLcsCompaction_ShouldExecuteCreateTableStatementWithLcsCompaction.
@Test
public void createTableInternal_WithLcsCompaction_ShouldExecuteCreateTableStatementWithLcsCompaction() throws ExecutionException {
// Arrange
String namespace = "sample_ns";
String table = "sample_table";
TableMetadata tableMetadata = TableMetadata.newBuilder().addPartitionKey("c1").addPartitionKey("c7").addClusteringKey("c4").addClusteringKey("c6", Order.DESC).addColumn("c1", DataType.INT).addColumn("c2", DataType.TEXT).addColumn("c3", DataType.BLOB).addColumn("c4", DataType.DOUBLE).addColumn("c5", DataType.BIGINT).addColumn("c6", DataType.BOOLEAN).addColumn("c7", DataType.TEXT).addSecondaryIndex("c2").addSecondaryIndex("c4").build();
HashMap<String, String> options = new HashMap<>();
options.put(CassandraAdmin.COMPACTION_STRATEGY, CompactionStrategy.LCS.toString());
// Act
cassandraAdmin.createTableInternal(namespace, table, tableMetadata, options);
// Assert
TableOptions<Options> createTableStatement = SchemaBuilder.createTable(namespace, table).addPartitionKey("c1", com.datastax.driver.core.DataType.cint()).addPartitionKey("c7", com.datastax.driver.core.DataType.text()).addClusteringColumn("c4", com.datastax.driver.core.DataType.cdouble()).addClusteringColumn("c6", com.datastax.driver.core.DataType.cboolean()).addColumn("c2", com.datastax.driver.core.DataType.text()).addColumn("c3", com.datastax.driver.core.DataType.blob()).addColumn("c5", com.datastax.driver.core.DataType.bigint()).withOptions().clusteringOrder("c4", Direction.ASC).clusteringOrder("c6", Direction.DESC).compactionOptions(SchemaBuilder.leveledStrategy());
verify(cassandraSession).execute(createTableStatement.getQueryString());
}
use of com.datastax.driver.core.schemabuilder.TableOptions in project scalardb by scalar-labs.
the class CassandraAdminTest method createTableInternal_WithoutSettingCompactionStrategy_ShouldExecuteCreateTableStatementWithStcs.
@Test
public void createTableInternal_WithoutSettingCompactionStrategy_ShouldExecuteCreateTableStatementWithStcs() throws ExecutionException {
// Arrange
String namespace = "sample_ns";
String table = "sample_table";
TableMetadata tableMetadata = TableMetadata.newBuilder().addPartitionKey("c1").addClusteringKey("c4").addColumn("c1", DataType.INT).addColumn("c2", DataType.TEXT).addColumn("c3", DataType.BLOB).addColumn("c4", DataType.INT).addColumn("c5", DataType.BOOLEAN).addSecondaryIndex("c2").addSecondaryIndex("c4").build();
// Act
cassandraAdmin.createTableInternal(namespace, table, tableMetadata, new HashMap<>());
// Assert
TableOptions<Options> createTableStatement = SchemaBuilder.createTable(namespace, table).addPartitionKey("c1", com.datastax.driver.core.DataType.cint()).addClusteringColumn("c4", com.datastax.driver.core.DataType.cint()).addColumn("c2", com.datastax.driver.core.DataType.text()).addColumn("c3", com.datastax.driver.core.DataType.blob()).addColumn("c5", com.datastax.driver.core.DataType.cboolean()).withOptions().clusteringOrder("c4", Direction.ASC).compactionOptions(SchemaBuilder.sizedTieredStategy());
verify(cassandraSession).execute(createTableStatement.getQueryString());
}
Aggregations