use of com.datastax.oss.driver.api.core.metadata.schema.TableMetadata in project janusgraph by JanusGraph.
the class CQLStoreManager method getSpeculativeRetry.
@VisibleForTesting
String getSpeculativeRetry(final String name) throws BackendException {
TableMetadata tableMetadata = getTableMetadata(name);
Object res = tableMetadata.getOptions().get(CqlIdentifier.fromCql("speculative_retry"));
return (String) res;
}
use of com.datastax.oss.driver.api.core.metadata.schema.TableMetadata in project janusgraph by JanusGraph.
the class CQLStoreManager method getGcGraceSeconds.
@VisibleForTesting
Integer getGcGraceSeconds(final String name) throws BackendException {
TableMetadata tableMetadata = getTableMetadata(name);
Object gcGraceSeconds = tableMetadata.getOptions().get(CqlIdentifier.fromCql("gc_grace_seconds"));
return (Integer) gcGraceSeconds;
}
use of com.datastax.oss.driver.api.core.metadata.schema.TableMetadata in project janusgraph by JanusGraph.
the class CQLStoreManager method getCompressionOptions.
@VisibleForTesting
Map<String, String> getCompressionOptions(final String name) throws BackendException {
TableMetadata tableMetadata = getTableMetadata(name);
Object compressionOptions = tableMetadata.getOptions().get(CqlIdentifier.fromCql("compression"));
return (Map<String, String>) compressionOptions;
}
use of com.datastax.oss.driver.api.core.metadata.schema.TableMetadata in project janusgraph by JanusGraph.
the class CQLStoreTest method testExistTableOpenDatabase.
@Test
public void testExistTableOpenDatabase() throws BackendException {
// arrange
String someTableName = "foo";
Metadata metadata = mock(Metadata.class);
KeyspaceMetadata keyspaceMetadata = mock(KeyspaceMetadata.class);
TableMetadata tableMetadata = mock(TableMetadata.class);
when(keyspaceMetadata.getTable(someTableName)).thenReturn(Optional.of(tableMetadata));
when(session.getMetadata()).thenReturn(metadata);
when(metadata.getKeyspace(mockManager.getKeyspaceName())).thenReturn(Optional.of(keyspaceMetadata));
// act
mockManager.openDatabase(someTableName, null);
// assert
verify(session, never()).execute(any(Statement.class));
}
use of com.datastax.oss.driver.api.core.metadata.schema.TableMetadata in project thingsboard by thingsboard.
the class CassandraDbHelper method loadCf.
public static void loadCf(KeyspaceMetadata ks, GuavaSession session, String cfName, String[] columns, Path sourceFile, boolean parseHeader) throws Exception {
TableMetadata tableMetadata = ks.getTable(cfName).get();
PreparedStatement prepared = session.prepare(createInsertStatement(cfName, columns));
CSVFormat csvFormat = CSV_DUMP_FORMAT;
if (parseHeader) {
csvFormat = csvFormat.withFirstRecordAsHeader();
} else {
csvFormat = CSV_DUMP_FORMAT.withHeader(columns);
}
try (CSVParser csvParser = new CSVParser(Files.newBufferedReader(sourceFile), csvFormat)) {
csvParser.forEach(record -> {
BoundStatementBuilder boundStatementBuilder = new BoundStatementBuilder(prepared.bind());
for (String column : columns) {
setColumnValue(tableMetadata, column, record, boundStatementBuilder);
}
session.execute(boundStatementBuilder.build());
});
}
}
Aggregations