use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.
the class DseSchemaParser method parse.
@Override
public SchemaRefresh parse() {
ImmutableMap.Builder<CqlIdentifier, KeyspaceMetadata> keyspacesBuilder = ImmutableMap.builder();
for (AdminRow row : rows.keyspaces()) {
DseKeyspaceMetadata keyspace = parseKeyspace(row);
keyspacesBuilder.put(keyspace.getName(), keyspace);
}
for (AdminRow row : rows.virtualKeyspaces()) {
DseKeyspaceMetadata keyspace = parseVirtualKeyspace(row);
keyspacesBuilder.put(keyspace.getName(), keyspace);
}
SchemaRefresh refresh = new SchemaRefresh(keyspacesBuilder.build());
LOG.debug("[{}] Schema parsing took {}", logPrefix, NanoTime.formatTimeSince(startTimeNs));
return refresh;
}
use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.
the class DseTableParser method buildVertex.
private DseVertexMetadata buildVertex(CqlIdentifier tableId, Multimap<CqlIdentifier, AdminRow> keyspaceVertices) {
if (keyspaceVertices == null) {
return null;
}
Collection<AdminRow> tableVertices = keyspaceVertices.get(tableId);
if (tableVertices == null || tableVertices.isEmpty()) {
return null;
}
AdminRow row = tableVertices.iterator().next();
return new DefaultDseVertexMetadata(getLabel(row));
}
use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.
the class DseTableParser method buildEdge.
private DseEdgeMetadata buildEdge(CqlIdentifier tableId, Multimap<CqlIdentifier, AdminRow> keyspaceEdges, Multimap<CqlIdentifier, AdminRow> keyspaceVertices) {
if (keyspaceEdges == null) {
return null;
}
Collection<AdminRow> tableEdges = keyspaceEdges.get(tableId);
if (tableEdges == null || tableEdges.isEmpty()) {
return null;
}
AdminRow row = tableEdges.iterator().next();
CqlIdentifier fromTable = CqlIdentifier.fromInternal(row.getString("from_table"));
CqlIdentifier toTable = CqlIdentifier.fromInternal(row.getString("to_table"));
return new DefaultDseEdgeMetadata(getLabel(row), fromTable, findVertexLabel(fromTable, keyspaceVertices, "incoming"), CqlIdentifiers.wrapInternal(row.getListOfString("from_partition_key_columns")), CqlIdentifiers.wrapInternal(row.getListOfString("from_clustering_columns")), toTable, findVertexLabel(toTable, keyspaceVertices, "outgoing"), CqlIdentifiers.wrapInternal(row.getListOfString("to_partition_key_columns")), CqlIdentifiers.wrapInternal(row.getListOfString("to_clustering_columns")));
}
use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.
the class DseTableParser method findVertexLabel.
// system_schema.edges only contains vertex table names. We also expose the labels in our metadata
// objects, so we need to look them up in system_schema.vertices.
private CqlIdentifier findVertexLabel(CqlIdentifier table, Multimap<CqlIdentifier, AdminRow> keyspaceVertices, String directionForErrorMessage) {
Collection<AdminRow> tableVertices = (keyspaceVertices == null) ? null : keyspaceVertices.get(table);
if (tableVertices == null || tableVertices.isEmpty()) {
throw new IllegalArgumentException(String.format("Missing vertex definition for %s table %s", directionForErrorMessage, table.asCql(true)));
}
AdminRow row = tableVertices.iterator().next();
return getLabel(row);
}
use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.
the class TableParserTest method should_parse_read_repair_and_additional_write_policy.
/**
* Covers two additional Cassandra 4.0 options added in JAVA-2090.
*/
@Test
public void should_parse_read_repair_and_additional_write_policy() {
AdminRow tableRow40 = mockModernTableRow("ks", "foo");
when(tableRow40.get("read_repair", TypeCodecs.TEXT)).thenReturn("NONE");
when(tableRow40.get("additional_write_policy", TypeCodecs.TEXT)).thenReturn("40p");
SchemaRows rows = modernRows(tableRow40, COLUMN_ROWS_3_0, INDEX_ROWS_3_0);
TableParser parser = new TableParser(rows, context);
TableMetadata table = parser.parseTable(tableRow40, KEYSPACE_ID, Collections.emptyMap());
checkTable(table);
assertThat(table.getOptions()).containsEntry(CqlIdentifier.fromInternal("read_repair"), "NONE").containsEntry(CqlIdentifier.fromInternal("additional_write_policy"), "40p");
}
Aggregations