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;
}
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;
}
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);
}
}
Aggregations