Search in sources :

Example 41 with AdminRow

use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.

the class SchemaParserTestBase method mockLegacyColumnRow.

protected static AdminRow mockLegacyColumnRow(String keyspaceName, String tableName, String name, String kind, String dataType, int position, String indexName, String indexType, String indexOptions) {
    AdminRow row = mock(AdminRow.class);
    when(row.contains("validator")).thenReturn(true);
    when(row.getString("keyspace_name")).thenReturn(keyspaceName);
    when(row.getString("columnfamily_name")).thenReturn(tableName);
    when(row.getString("column_name")).thenReturn(name);
    when(row.getString("type")).thenReturn(kind);
    when(row.getString("validator")).thenReturn(dataType);
    when(row.getInteger("component_index")).thenReturn(position);
    when(row.getString("index_name")).thenReturn(indexName);
    when(row.getString("index_type")).thenReturn(indexType);
    when(row.getString("index_options")).thenReturn(indexOptions);
    return row;
}
Also used : AdminRow(com.datastax.oss.driver.internal.core.adminrequest.AdminRow)

Example 42 with AdminRow

use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.

the class SchemaParserTestBase method mockIndexRow.

protected static AdminRow mockIndexRow(String keyspaceName, String tableName, String name, String kind, ImmutableMap<String, String> options) {
    AdminRow row = mock(AdminRow.class);
    when(row.getString("keyspace_name")).thenReturn(keyspaceName);
    when(row.getString("table_name")).thenReturn(tableName);
    when(row.getString("index_name")).thenReturn(name);
    when(row.getString("kind")).thenReturn(kind);
    when(row.getMapOfStringToString("options")).thenReturn(options);
    return row;
}
Also used : AdminRow(com.datastax.oss.driver.internal.core.adminrequest.AdminRow)

Example 43 with AdminRow

use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.

the class UserDefinedTypeParser method parse.

/**
 * Contrary to other element parsers, this one processes all the types of a keyspace in one go.
 * UDTs can depend on each other, but the system table returns them in alphabetical order. In
 * order to properly build the definitions, we need to do a topological sort of the rows first, so
 * that each type is parsed after its dependencies.
 */
public Map<CqlIdentifier, UserDefinedType> parse(Collection<AdminRow> typeRows, CqlIdentifier keyspaceId) {
    if (typeRows.isEmpty()) {
        return Collections.emptyMap();
    } else {
        Map<CqlIdentifier, UserDefinedType> types = new LinkedHashMap<>();
        for (AdminRow row : topologicalSort(typeRows, keyspaceId)) {
            UserDefinedType type = parseType(row, keyspaceId, types);
            types.put(type.getName(), type);
        }
        return ImmutableMap.copyOf(types);
    }
}
Also used : DefaultUserDefinedType(com.datastax.oss.driver.internal.core.type.DefaultUserDefinedType) UserDefinedType(com.datastax.oss.driver.api.core.type.UserDefinedType) CqlIdentifier(com.datastax.oss.driver.api.core.CqlIdentifier) AdminRow(com.datastax.oss.driver.internal.core.adminrequest.AdminRow) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

AdminRow (com.datastax.oss.driver.internal.core.adminrequest.AdminRow)43 Test (org.junit.Test)12 CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)7 Optional (java.util.Optional)6 ImmutableMap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap)5 UnknownHostException (java.net.UnknownHostException)3 UUID (java.util.UUID)3 ClusteringOrder (com.datastax.oss.driver.api.core.metadata.schema.ClusteringOrder)2 ColumnMetadata (com.datastax.oss.driver.api.core.metadata.schema.ColumnMetadata)2 IndexMetadata (com.datastax.oss.driver.api.core.metadata.schema.IndexMetadata)2 KeyspaceMetadata (com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata)2 TableMetadata (com.datastax.oss.driver.api.core.metadata.schema.TableMetadata)2 DataType (com.datastax.oss.driver.api.core.type.DataType)2 SchemaRefresh (com.datastax.oss.driver.internal.core.metadata.schema.refresh.SchemaRefresh)2 ImmutableList (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 InetSocketAddress (java.net.InetSocketAddress)2 DseColumnMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseColumnMetadata)1 DseIndexMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseIndexMetadata)1 DseKeyspaceMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseKeyspaceMetadata)1