@Override public List<String> getCaseSensitiveTableNames(String caseInsensitiveSchemaName) throws SchemaNotFoundException { KeyspaceMetadata keyspace = getKeyspaceByCaseInsensitiveName(caseInsensitiveSchemaName); ImmutableList.Builder<String> builder = ImmutableList.builder(); for (TableMetadata table : keyspace.getTables()) { builder.add(table.getName()); } for (MaterializedViewMetadata materializedView : keyspace.getMaterializedViews()) { builder.add(materializedView.getName()); } return builder.build(); }
void add(TableMetadata tm) { tables.put(tm.getName(), tm); }
@Override public int hashCode() { return MoreObjects.hashCode( name, id, partitionKey, clusteringColumns, columns, options, clusteringOrder, baseTable.getName(), includeAllColumns); } }
public TableMetadataAssert hasName(String name) { assertThat(actual.getName()).isEqualTo(name); return this; }
Insert(TableMetadata table) { this( Metadata.quoteIfNecessary(table.getKeyspace().getName()), Metadata.quoteIfNecessary(table.getName()), Arrays.asList(new Object[table.getPartitionKey().size()]), table.getPartitionKey()); }
Delete(TableMetadata table, List<Selector> columns) { this( Metadata.quoteIfNecessary(table.getKeyspace().getName()), Metadata.quoteIfNecessary(table.getName()), Arrays.asList(new Object[table.getPartitionKey().size()]), table.getPartitionKey(), columns); }
Update(TableMetadata table) { this( Metadata.quoteIfNecessary(table.getKeyspace().getName()), Metadata.quoteIfNecessary(table.getName()), Arrays.asList(new Object[table.getPartitionKey().size()]), table.getPartitionKey()); }
Truncate(TableMetadata table) { this( Metadata.quoteIfNecessary(table.getKeyspace().getName()), Metadata.quoteIfNecessary(table.getName()), Arrays.asList(new Object[table.getPartitionKey().size()]), table.getPartitionKey()); }
Select(TableMetadata table, List<Object> columnNames, boolean isDistinct, boolean isJson) { this( Metadata.quoteIfNecessary(table.getKeyspace().getName()), Metadata.quoteIfNecessary(table.getName()), Arrays.asList(new Object[table.getPartitionKey().size()]), table.getPartitionKey(), columnNames, isDistinct, isJson); }
String baseTableName = Metadata.quoteIfNecessary(baseTable.getName()); String viewName = Metadata.quoteIfNecessary(name);
@Override public boolean equals(Object other) { if (other == this) return true; if (!(other instanceof MaterializedViewMetadata)) return false; MaterializedViewMetadata that = (MaterializedViewMetadata) other; return MoreObjects.equal(this.name, that.name) && MoreObjects.equal(this.id, that.id) && MoreObjects.equal(this.partitionKey, that.partitionKey) && MoreObjects.equal(this.clusteringColumns, that.clusteringColumns) && MoreObjects.equal(this.columns, that.columns) && MoreObjects.equal(this.options, that.options) && MoreObjects.equal(this.clusteringOrder, that.clusteringOrder) && MoreObjects.equal(this.baseTable.getName(), that.baseTable.getName()) && this.includeAllColumns == that.includeAllColumns; }
cassandraVersion, cluster); tables.put(table.getName(), table); } catch (RuntimeException e) {
/** * Returns a CQL query representing this index. * * <p>This method returns a single 'CREATE INDEX' query corresponding to this index definition. * * @return the 'CREATE INDEX' query corresponding to this index. */ public String asCQLQuery() { String keyspaceName = Metadata.quoteIfNecessary(table.getKeyspace().getName()); String tableName = Metadata.quoteIfNecessary(table.getName()); String indexName = Metadata.quoteIfNecessary(this.name); return isCustomIndex() ? String.format( "CREATE CUSTOM INDEX %s ON %s.%s (%s) USING '%s' %s;", indexName, keyspaceName, tableName, getTarget(), getIndexClassName(), getOptionsAsCql()) : String.format( "CREATE INDEX %s ON %s.%s (%s);", indexName, keyspaceName, tableName, getTarget()); }
assertThat(tm.getName()).isEqualTo("clients"); assertThat(tm.isVirtual()).isTrue(); assertThat(tm.getColumns().size()).isEqualTo(12);
@Override public int hashCode() { return MoreObjects.hashCode(name, id, partitionKey, clusteringColumns, columns, options, clusteringOrder, baseTable.getName(), includeAllColumns); } }
private static void cleanDataWithNativeDriver(String keyspace, String... excludedTables) { HashSet<String> excludedTableList = new HashSet<>(Arrays.asList(excludedTables)); cluster.getMetadata().getKeyspace(keyspace).getTables().stream() .map(table -> table.getName()) .filter(tableName -> !excludedTableList.contains(tableName)) .map(tableName -> keyspace + "." + tableName) .forEach(CqlOperations.truncateTable(session)); }
private static void cleanDataWithNativeDriver(String keyspace, String... excludedTables) { HashSet<String> excludedTableList = new HashSet<>(Arrays.asList(excludedTables)); cluster.getMetadata().getKeyspace(keyspace).getTables().stream() .map(table -> table.getName()) .filter(tableName -> !excludedTableList.contains(tableName)) .map(tableName -> keyspace + "." + tableName) .forEach(CqlOperations.truncateTable(session)); }
private static void cleanDataWithNativeDriver(String keyspace, String... excludedTables) { HashSet<String> excludedTableList = new HashSet<>(Arrays.asList(excludedTables)); cluster.getMetadata().getKeyspace(keyspace).getTables().stream() .map(table -> table.getName()) .filter(tableName -> !excludedTableList.contains(tableName)) .map(tableName -> keyspace + "." + tableName) .forEach(CqlOperations.truncateTable(session)); }
private List<String> generateTableList() { List<String> tableList = new ArrayList<>(); for (TableMetadata tableMetadata : this.session.getCluster().getMetadata().getKeyspace(this.keyspace) .getTables()) { tableList.add(tableMetadata.getName()); } return tableList; }