Search in sources :

Example 1 with KeyColumnValueStoreManager

use of org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager in project janusgraph by JanusGraph.

the class CassandraScanJobIT method testSimpleScan.

@Test
public void testSimpleScan() throws InterruptedException, ExecutionException, IOException, BackendException {
    int keys = 1000;
    int cols = 40;
    String[][] values = KeyValueStoreUtil.generateData(keys, cols);
    // Make it only half the number of columns for every 2nd key
    for (int i = 0; i < values.length; i++) {
        if (i % 2 == 0)
            values[i] = Arrays.copyOf(values[i], cols / 2);
    }
    log.debug("Loading values: " + keys + "x" + cols);
    KeyColumnValueStoreManager mgr = new CassandraThriftStoreManager(GraphDatabaseConfiguration.buildGraphConfiguration());
    KeyColumnValueStore store = mgr.openDatabase("edgestore");
    StoreTransaction tx = mgr.beginTransaction(StandardBaseTransactionConfig.of(TimestampProviders.MICRO));
    KeyColumnValueStoreUtil.loadValues(store, tx, values);
    // noop on Cassandra, but harmless
    tx.commit();
    SimpleScanJobRunner runner = (ScanJob job, Configuration jobConf, String rootNSName) -> {
        try {
            return new CassandraHadoopScanRunner(job).scanJobConf(jobConf).scanJobConfRoot(rootNSName).partitionerOverride("org.apache.cassandra.dht.Murmur3Partitioner").run();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    };
    SimpleScanJob.runBasicTests(keys, cols, runner);
}
Also used : KeyColumnValueStore(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore) JanusGraphHadoopConfiguration(org.janusgraph.hadoop.config.JanusGraphHadoopConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) CassandraThriftStoreManager(org.janusgraph.diskstorage.cassandra.thrift.CassandraThriftStoreManager) StoreTransaction(org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction) KeyColumnValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager) CassandraHadoopScanRunner(org.janusgraph.hadoop.scan.CassandraHadoopScanRunner) ScanJob(org.janusgraph.diskstorage.keycolumnvalue.scan.ScanJob) Test(org.junit.Test) JanusGraphBaseTest(org.janusgraph.graphdb.JanusGraphBaseTest)

Example 2 with KeyColumnValueStoreManager

use of org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager in project janusgraph by JanusGraph.

the class JanusGraphIterativeBenchmark method testDataSequential.

@RepeatedTest(10)
public void testDataSequential() throws Exception {
    loadData(200000, 2);
    close();
    KeyColumnValueStoreManager manager = openStorageManager();
    KeyColumnValueStore store = manager.openDatabase(Backend.EDGESTORE_NAME);
    SliceQuery query = new SliceQuery(BufferUtil.zeroBuffer(8), BufferUtil.oneBuffer(8));
    query.setLimit(2);
    Stopwatch watch = Stopwatch.createStarted();
    StoreTransaction txh = manager.beginTransaction(StandardBaseTransactionConfig.of(TimestampProviders.MILLI));
    KeyIterator iterator = store.getKeys(query, txh);
    int numV = 0;
    while (iterator.hasNext()) {
        iterator.next();
        RecordIterator<Entry> entries = iterator.getEntries();
        assertEquals(2, Iterators.size(entries));
        numV++;
    }
    iterator.close();
    txh.commit();
    System.out.println("Time taken: " + watch.elapsed(TimeUnit.MILLISECONDS));
    System.out.println("Num Vertices: " + numV);
    store.close();
    manager.close();
}
Also used : Entry(org.janusgraph.diskstorage.Entry) KeyColumnValueStore(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore) KeyIterator(org.janusgraph.diskstorage.keycolumnvalue.KeyIterator) StoreTransaction(org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction) KeyColumnValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager) Stopwatch(com.google.common.base.Stopwatch) SliceQuery(org.janusgraph.diskstorage.keycolumnvalue.SliceQuery) RepeatedTest(org.junit.jupiter.api.RepeatedTest)

Example 3 with KeyColumnValueStoreManager

use of org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager in project janusgraph by JanusGraph.

the class KCVSConfigTest method getConfig.

@Override
public WriteConfiguration getConfig() {
    final KeyColumnValueStoreManager manager = new InMemoryStoreManager(Configuration.EMPTY);
    ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
    config.set(GraphDatabaseConfiguration.TIMESTAMP_PROVIDER, TimestampProviders.MICRO);
    try {
        return new KCVSConfiguration(new BackendOperation.TransactionalProvider() {

            @Override
            public StoreTransaction openTx() throws BackendException {
                return manager.beginTransaction(StandardBaseTransactionConfig.of(TimestampProviders.MICRO, manager.getFeatures().getKeyConsistentTxConfig()));
            }

            @Override
            public void close() throws BackendException {
                manager.close();
            }
        }, config, manager.openDatabase("janusgraph"), "general");
    } catch (BackendException e) {
        throw new RuntimeException(e);
    }
}
Also used : KCVSConfiguration(org.janusgraph.diskstorage.configuration.backend.KCVSConfiguration) StoreTransaction(org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction) KeyColumnValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager) InMemoryStoreManager(org.janusgraph.diskstorage.inmemory.InMemoryStoreManager) BackendOperation(org.janusgraph.diskstorage.util.BackendOperation) BackendException(org.janusgraph.diskstorage.BackendException)

Example 4 with KeyColumnValueStoreManager

use of org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager in project janusgraph by JanusGraph.

the class MetricInstrumentedStoreManagerTest method testGetHadoopManagerReturnsBaseHadoopManager.

@Test
public void testGetHadoopManagerReturnsBaseHadoopManager() throws BackendException {
    Object result = new Object();
    KeyColumnValueStoreManager mock = mock(KeyColumnValueStoreManager.class);
    when(mock.getHadoopManager()).thenReturn(result);
    MetricInstrumentedStoreManager metricInstrumentedStoreManager = new MetricInstrumentedStoreManager(mock, "", true, "");
    Object hadoopManager = metricInstrumentedStoreManager.getHadoopManager();
    verify(mock).getHadoopManager();
    assertEquals(result, hadoopManager);
}
Also used : KeyColumnValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager) Test(org.junit.jupiter.api.Test)

Example 5 with KeyColumnValueStoreManager

use of org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager in project janusgraph by JanusGraph.

the class Backend method getStorageManager.

public static KeyColumnValueStoreManager getStorageManager(Configuration storageConfig) {
    StoreManager manager = getImplementationClass(storageConfig, storageConfig.get(STORAGE_BACKEND), StandardStoreManager.getAllManagerClasses());
    if (manager instanceof OrderedKeyValueStoreManager) {
        Map<String, Integer> keyLength = new HashMap<>(3);
        keyLength.put(EDGESTORE_NAME, 8);
        keyLength.put(EDGESTORE_NAME + LOCK_STORE_SUFFIX, 8);
        keyLength.put(storageConfig.get(IDS_STORE_NAME), 8);
        keyLength = Collections.unmodifiableMap(keyLength);
        manager = new OrderedKeyValueStoreManagerAdapter((OrderedKeyValueStoreManager) manager, keyLength);
    }
    Preconditions.checkArgument(manager instanceof KeyColumnValueStoreManager, "Invalid storage manager: %s", manager.getClass());
    return (KeyColumnValueStoreManager) manager;
}
Also used : OrderedKeyValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManager) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) OrderedKeyValueStoreManagerAdapter(org.janusgraph.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManagerAdapter) KeyColumnValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager) OrderedKeyValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManager) StoreManager(org.janusgraph.diskstorage.keycolumnvalue.StoreManager) KeyColumnValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager) ExpectedValueCheckingStoreManager(org.janusgraph.diskstorage.locking.consistentkey.ExpectedValueCheckingStoreManager) MetricInstrumentedStoreManager(org.janusgraph.diskstorage.util.MetricInstrumentedStoreManager)

Aggregations

KeyColumnValueStoreManager (org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager)8 KeyColumnValueStore (org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore)4 StoreTransaction (org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction)4 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)3 Test (org.junit.jupiter.api.Test)3 Configuration (org.janusgraph.diskstorage.configuration.Configuration)2 SliceQuery (org.janusgraph.diskstorage.keycolumnvalue.SliceQuery)2 ScanJob (org.janusgraph.diskstorage.keycolumnvalue.scan.ScanJob)2 JanusGraphBaseTest (org.janusgraph.graphdb.JanusGraphBaseTest)2 JanusGraphHadoopConfiguration (org.janusgraph.hadoop.config.JanusGraphHadoopConfiguration)2 Stopwatch (com.google.common.base.Stopwatch)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 TimeUnit (java.util.concurrent.TimeUnit)1 JanusGraphBaseStoreFeaturesTest (org.janusgraph.JanusGraphBaseStoreFeaturesTest)1 BackendException (org.janusgraph.diskstorage.BackendException)1 Entry (org.janusgraph.diskstorage.Entry)1 SimpleScanJob (org.janusgraph.diskstorage.SimpleScanJob)1 SimpleScanJobRunner (org.janusgraph.diskstorage.SimpleScanJobRunner)1 CassandraThriftStoreManager (org.janusgraph.diskstorage.cassandra.thrift.CassandraThriftStoreManager)1