Search in sources :

Example 6 with BackendStore

use of com.baidu.hugegraph.backend.store.BackendStore in project incubator-hugegraph by apache.

the class StoreStateMachine method applyCommand.

private Object applyCommand(StoreType type, StoreAction action, BytesBuffer buffer, boolean forwarded) {
    E.checkState(type != StoreType.ALL, "Can't apply command for all store at one time");
    BackendStore store = this.store(type);
    switch(action) {
        case CLEAR:
            boolean clearSpace = buffer.read() > 0;
            store.clear(clearSpace);
            this.context.clearCache();
            break;
        case TRUNCATE:
            store.truncate();
            this.context.clearCache();
            break;
        case SNAPSHOT:
            assert store == null;
            this.node().snapshot();
            break;
        case BEGIN_TX:
            store.beginTx();
            break;
        case COMMIT_TX:
            List<BackendMutation> mutations = StoreSerializer.readMutations(buffer);
            // RaftBackendStore doesn't write raft log for beginTx
            store.beginTx();
            for (BackendMutation mutation : mutations) {
                store.mutate(mutation);
                this.context.updateCacheIfNeeded(mutation, forwarded);
            }
            store.commitTx();
            break;
        case ROLLBACK_TX:
            store.rollbackTx();
            break;
        case INCR_COUNTER:
            // Do increase counter
            IncrCounter counter = StoreSerializer.readIncrCounter(buffer);
            store.increaseCounter(counter.type(), counter.increment());
            break;
        default:
            throw new IllegalArgumentException("Invalid action " + action);
    }
    return null;
}
Also used : BackendMutation(com.baidu.hugegraph.backend.store.BackendMutation) IncrCounter(com.baidu.hugegraph.backend.store.raft.RaftBackendStore.IncrCounter) BackendStore(com.baidu.hugegraph.backend.store.BackendStore)

Example 7 with BackendStore

use of com.baidu.hugegraph.backend.store.BackendStore in project incubator-hugegraph by apache.

the class ScyllaDBStoreProvider method loadSchemaStore.

@Override
public BackendStore loadSchemaStore(HugeConfig config, String name) {
    LOG.debug("ScyllaDBStoreProvider load SchemaStore '{}'", name);
    if (!this.stores.containsKey(name)) {
        BackendStore s = new ScyllaDBSchemaStore(this, keyspace(), name);
        this.stores.putIfAbsent(name, s);
    }
    BackendStore store = this.stores.get(name);
    E.checkNotNull(store, "store");
    E.checkState(store instanceof ScyllaDBSchemaStore, "SchemaStore must be an instance of ScyllaDBSchemaStore");
    return store;
}
Also used : BackendStore(com.baidu.hugegraph.backend.store.BackendStore)

Example 8 with BackendStore

use of com.baidu.hugegraph.backend.store.BackendStore in project incubator-hugegraph by apache.

the class ScyllaDBStoreProvider method loadGraphStore.

@Override
public BackendStore loadGraphStore(HugeConfig config, String name) {
    LOG.debug("ScyllaDBStoreProvider load GraphStore '{}'", name);
    if (!this.stores.containsKey(name)) {
        BackendStore s = new ScyllaDBGraphStore(this, keyspace(), name);
        this.stores.putIfAbsent(name, s);
    }
    BackendStore store = this.stores.get(name);
    E.checkNotNull(store, "store");
    E.checkState(store instanceof ScyllaDBGraphStore, "GraphStore must be an instance of ScyllaDBGraphStore");
    return store;
}
Also used : BackendStore(com.baidu.hugegraph.backend.store.BackendStore)

Aggregations

BackendStore (com.baidu.hugegraph.backend.store.BackendStore)8 Query (com.baidu.hugegraph.backend.query.Query)1 BackendEntry (com.baidu.hugegraph.backend.store.BackendEntry)1 BackendMutation (com.baidu.hugegraph.backend.store.BackendMutation)1 IncrCounter (com.baidu.hugegraph.backend.store.raft.RaftBackendStore.IncrCounter)1