Search in sources :

Example 1 with BatchStatementBuilder

use of com.datastax.oss.driver.api.core.cql.BatchStatementBuilder in project janusgraph by JanusGraph.

the class AbstractCQLMutateManyLoggedFunction method mutateMany.

// Use a single logged batch
@Override
public void mutateMany(Map<String, Map<StaticBuffer, KCVMutation>> mutations, StoreTransaction txh) throws BackendException {
    final DistributedStoreManager.MaskedTimestamp commitTime = createMaskedTimestampFunction.apply(txh);
    BatchStatementBuilder builder = BatchStatement.builder(DefaultBatchType.LOGGED);
    builder.setConsistencyLevel(getTransaction(txh).getWriteConsistencyLevel());
    mutations.forEach((tableName, tableMutations) -> {
        final CQLKeyColumnValueStore columnValueStore = getColumnValueStore(tableName);
        tableMutations.forEach((key, keyMutations) -> {
            deletionsFunction.getBatchableStatementsForColumnOperation(commitTime, keyMutations, columnValueStore, key).forEach(builder::addStatement);
            additionsFunction.getBatchableStatementsForColumnOperation(commitTime, keyMutations, columnValueStore, key).forEach(builder::addStatement);
        });
    });
    execute(builder.build());
    sleepAfterWriteFunction.accept(commitTime);
}
Also used : CQLKeyColumnValueStore(org.janusgraph.diskstorage.cql.CQLKeyColumnValueStore) DistributedStoreManager(org.janusgraph.diskstorage.common.DistributedStoreManager) BatchStatementBuilder(com.datastax.oss.driver.api.core.cql.BatchStatementBuilder)

Aggregations

BatchStatementBuilder (com.datastax.oss.driver.api.core.cql.BatchStatementBuilder)1 DistributedStoreManager (org.janusgraph.diskstorage.common.DistributedStoreManager)1 CQLKeyColumnValueStore (org.janusgraph.diskstorage.cql.CQLKeyColumnValueStore)1