Search in sources :

Example 1 with CQLKeyColumnValueStore

use of org.janusgraph.diskstorage.cql.CQLKeyColumnValueStore in project janusgraph by JanusGraph.

the class CQLSimpleMutateManyUnloggedFunction method mutate.

@Override
protected Optional<Throwable> mutate(DistributedStoreManager.MaskedTimestamp commitTime, Map<String, Map<StaticBuffer, KCVMutation>> mutations, StoreTransaction txh) {
    List<CompletableFuture<AsyncResultSet>> resultList = new LinkedList<>();
    mutations.forEach((tableName, tableMutations) -> {
        final CQLKeyColumnValueStore columnValueStore = getColumnValueStore(tableName);
        tableMutations.forEach((key, keyMutations) -> toGroupedBatchableStatementsSequenceIterator(commitTime, keyMutations, columnValueStore, key).forEach(group -> {
            CompletableFuture<AsyncResultSet> completableFuture = execAsyncUnlogged(group, txh);
            resultList.add(completableFuture);
        }));
    });
    for (CompletableFuture<AsyncResultSet> resultPart : resultList) {
        try {
            resultPart.get();
        } catch (InterruptedException | ExecutionException e) {
            return Optional.of(e);
        }
    }
    return Optional.empty();
}
Also used : KCVMutation(org.janusgraph.diskstorage.keycolumnvalue.KCVMutation) DistributedStoreManager(org.janusgraph.diskstorage.common.DistributedStoreManager) TimestampProvider(org.janusgraph.diskstorage.util.time.TimestampProvider) CompletableFuture(java.util.concurrent.CompletableFuture) ExecutionException(java.util.concurrent.ExecutionException) AsyncResultSet(com.datastax.oss.driver.api.core.cql.AsyncResultSet) List(java.util.List) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Map(java.util.Map) StaticBuffer(org.janusgraph.diskstorage.StaticBuffer) CQLKeyColumnValueStore(org.janusgraph.diskstorage.cql.CQLKeyColumnValueStore) Optional(java.util.Optional) ConsumerWithBackendException(org.janusgraph.diskstorage.cql.function.ConsumerWithBackendException) LinkedList(java.util.LinkedList) StoreTransaction(org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction) CompletableFuture(java.util.concurrent.CompletableFuture) CQLKeyColumnValueStore(org.janusgraph.diskstorage.cql.CQLKeyColumnValueStore) AsyncResultSet(com.datastax.oss.driver.api.core.cql.AsyncResultSet) ExecutionException(java.util.concurrent.ExecutionException) LinkedList(java.util.LinkedList)

Example 2 with CQLKeyColumnValueStore

use of org.janusgraph.diskstorage.cql.CQLKeyColumnValueStore 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

DistributedStoreManager (org.janusgraph.diskstorage.common.DistributedStoreManager)2 CQLKeyColumnValueStore (org.janusgraph.diskstorage.cql.CQLKeyColumnValueStore)2 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 AsyncResultSet (com.datastax.oss.driver.api.core.cql.AsyncResultSet)1 BatchStatementBuilder (com.datastax.oss.driver.api.core.cql.BatchStatementBuilder)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)1 ConsumerWithBackendException (org.janusgraph.diskstorage.cql.function.ConsumerWithBackendException)1 KCVMutation (org.janusgraph.diskstorage.keycolumnvalue.KCVMutation)1 StoreTransaction (org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction)1 TimestampProvider (org.janusgraph.diskstorage.util.time.TimestampProvider)1