use of com.datastax.driver.core.TableMetadata in project cassandra-driver-mapping by valchkou.
the class SchemaSyncTest method testDoNotAddColumn.
@Test
public void testDoNotAddColumn() {
SyncOptions opt = SyncOptions.withOptions().add(SyncOptionTypes.DoNotAddColumns);
SchemaSync.drop(keyspace, session, EntityWithIndexes.class);
SchemaSync.sync(keyspace, session, EntityWithIndexes.class);
SchemaSync.sync(keyspace, session, EntityWithIndexesV2.class, opt);
EntityTypeMetadata entityMetadata = EntityTypeParser.getEntityMetadata(EntityWithIndexes.class);
TableMetadata tableMetadata = cluster.getMetadata().getKeyspace(keyspace).getTable(entityMetadata.getTableName());
// column counter2 should not be added
ColumnMetadata columnMetadata = tableMetadata.getColumn("counter2");
assertNull(columnMetadata);
// column counter should have been dropped
columnMetadata = tableMetadata.getColumn("counter");
assertNull(columnMetadata);
}
use of com.datastax.driver.core.TableMetadata in project cassandra-driver-mapping by valchkou.
the class SchemaSyncTest method testDrop.
@Test
public void testDrop() {
SchemaSync.sync(keyspace, session, EntityWithIndexes.class);
SchemaSync.drop(keyspace, session, EntityWithIndexes.class);
EntityTypeMetadata entityMetadata = EntityTypeParser.getEntityMetadata(EntityWithIndexes.class);
TableMetadata tableMetadata = cluster.getMetadata().getKeyspace(keyspace).getTable(entityMetadata.getTableName());
assertNull(tableMetadata);
}
use of com.datastax.driver.core.TableMetadata in project cassandra-driver-mapping by valchkou.
the class SchemaSyncTest method testDoNotDropColumn.
@Test
public void testDoNotDropColumn() {
SyncOptions opt = SyncOptions.withOptions().add(SyncOptionTypes.DoNotDropColumns);
SchemaSync.drop(keyspace, session, EntityWithIndexes.class);
SchemaSync.sync(keyspace, session, EntityWithIndexes.class);
SchemaSync.sync(keyspace, session, EntityWithIndexesV2.class, opt);
EntityTypeMetadata entityMetadata = EntityTypeParser.getEntityMetadata(EntityWithIndexes.class);
TableMetadata tableMetadata = cluster.getMetadata().getKeyspace(keyspace).getTable(entityMetadata.getTableName());
// column counter2 should not be added
ColumnMetadata columnMetadata = tableMetadata.getColumn("counter2");
assertNull(columnMetadata);
// column counter should have been dropped
columnMetadata = tableMetadata.getColumn("counter");
assertNotNull(columnMetadata);
}
use of com.datastax.driver.core.TableMetadata in project cassandra by apache.
the class StressProfile method maybeLoadSchemaInfo.
private void maybeLoadSchemaInfo(StressSettings settings) {
if (tableMetaData == null) {
JavaDriverClient client = settings.getJavaDriverClient();
synchronized (client) {
if (tableMetaData != null)
return;
TableMetadata metadata = client.getCluster().getMetadata().getKeyspace(keyspaceName).getTable(quoteIdentifier(tableName));
if (metadata == null)
throw new RuntimeException("Unable to find table " + keyspaceName + "." + tableName);
//Fill in missing column configs
for (com.datastax.driver.core.ColumnMetadata col : metadata.getColumns()) {
if (columnConfigs.containsKey(col.getName()))
continue;
columnConfigs.put(col.getName(), new GeneratorConfig(seedStr + col.getName(), null, null, null));
}
tableMetaData = metadata;
}
}
}
use of com.datastax.driver.core.TableMetadata in project presto by prestodb.
the class NativeCassandraSession method getAllTables.
@Override
public List<String> getAllTables(String schema) throws SchemaNotFoundException {
KeyspaceMetadata meta = getCheckedKeyspaceMetadata(schema);
ImmutableList.Builder<String> builder = ImmutableList.builder();
for (TableMetadata tableMeta : meta.getTables()) {
builder.add(tableMeta.getName());
}
return builder.build();
}
Aggregations