Search in sources :

Example 6 with KeyColumnValueStoreManager

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

the class CQLScanJobIT 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 CQLStoreManager(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 CQLHadoopScanRunner(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) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) JanusGraphHadoopConfiguration(org.janusgraph.hadoop.config.JanusGraphHadoopConfiguration) Configuration(org.janusgraph.diskstorage.configuration.Configuration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) StoreTransaction(org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction) CQLHadoopScanRunner(org.janusgraph.hadoop.scan.CQLHadoopScanRunner) CQLStoreManager(org.janusgraph.diskstorage.cql.CQLStoreManager) SimpleScanJobRunner(org.janusgraph.diskstorage.SimpleScanJobRunner) KeyColumnValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager) SimpleScanJob(org.janusgraph.diskstorage.SimpleScanJob) ScanJob(org.janusgraph.diskstorage.keycolumnvalue.scan.ScanJob) Test(org.junit.jupiter.api.Test) JanusGraphBaseTest(org.janusgraph.graphdb.JanusGraphBaseTest)

Example 7 with KeyColumnValueStoreManager

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

the class KeyColumnValueStoreTest method testStoreTTL.

@Test
public void testStoreTTL() throws Exception {
    KeyColumnValueStoreManager storeManager = manager;
    // @see TTLKCVSManager
    if (storeManager.getFeatures().hasCellTTL() && !storeManager.getFeatures().hasStoreTTL()) {
        storeManager = new TTLKCVSManager(storeManager);
    } else if (!storeManager.getFeatures().hasStoreTTL()) {
        return;
    }
    assertTrue(storeManager.getFeatures().hasStoreTTL());
    final TimeUnit sec = TimeUnit.SECONDS;
    final int storeTTLSeconds = (int) TestGraphConfigs.getTTL(sec);
    StoreMetaData.Container opts = new StoreMetaData.Container();
    opts.put(StoreMetaData.TTL, storeTTLSeconds);
    KeyColumnValueStore storeWithTTL = storeManager.openDatabase("testStore_with_TTL", opts);
    populateDBWith100Keys(storeWithTTL);
    tx.commit();
    tx = startTx();
    final StaticBuffer key = KeyColumnValueStoreUtil.longToByteBuffer(2);
    StaticBuffer start = KeyColumnValueStoreUtil.stringToByteBuffer("a");
    StaticBuffer end = KeyColumnValueStoreUtil.stringToByteBuffer("d");
    EntryList results = storeWithTTL.getSlice(new KeySliceQuery(key, new SliceQuery(start, end)), tx);
    assertEquals(3, results.size());
    Thread.sleep(TimeUnit.MILLISECONDS.convert((long) Math.ceil(storeTTLSeconds * 1.25), sec));
    tx.commit();
    tx = startTx();
    results = storeWithTTL.getSlice(new KeySliceQuery(key, new SliceQuery(start, end)), tx);
    // should be empty if TTL was applied properly
    assertEquals(0, results.size());
    storeWithTTL.close();
}
Also used : KeyColumnValueStore(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore) TTLKCVSManager(org.janusgraph.diskstorage.keycolumnvalue.ttl.TTLKCVSManager) KeyColumnValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager) TimeUnit(java.util.concurrent.TimeUnit) SliceQuery(org.janusgraph.diskstorage.keycolumnvalue.SliceQuery) KeySliceQuery(org.janusgraph.diskstorage.keycolumnvalue.KeySliceQuery) KeySliceQuery(org.janusgraph.diskstorage.keycolumnvalue.KeySliceQuery) Test(org.junit.jupiter.api.Test) JanusGraphBaseStoreFeaturesTest(org.janusgraph.JanusGraphBaseStoreFeaturesTest)

Example 8 with KeyColumnValueStoreManager

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

the class GraphDatabaseConfigurationBuilder method build.

public GraphDatabaseConfiguration build(ReadConfiguration localConfig) {
    Preconditions.checkNotNull(localConfig);
    BasicConfiguration localBasicConfiguration = new BasicConfiguration(ROOT_NS, localConfig, BasicConfiguration.Restriction.NONE);
    ModifiableConfiguration overwrite = new ModifiableConfiguration(ROOT_NS, new CommonsConfiguration(), BasicConfiguration.Restriction.NONE);
    final KeyColumnValueStoreManager storeManager = Backend.getStorageManager(localBasicConfiguration);
    final StoreFeatures storeFeatures = storeManager.getFeatures();
    final ReadConfiguration globalConfig = new ReadConfigurationBuilder().buildGlobalConfiguration(localConfig, localBasicConfiguration, overwrite, storeManager, new ModifiableConfigurationBuilder(), new KCVSConfigurationBuilder());
    // Copy over local config options
    ModifiableConfiguration localConfiguration = new ModifiableConfiguration(ROOT_NS, new CommonsConfiguration(), BasicConfiguration.Restriction.LOCAL);
    localConfiguration.setAll(getLocalSubset(localBasicConfiguration.getAll()));
    Configuration combinedConfig = new MixedConfiguration(ROOT_NS, globalConfig, localConfig);
    // Compute unique instance id
    String uniqueGraphId = UniqueInstanceIdRetriever.getInstance().getOrGenerateUniqueInstanceId(combinedConfig);
    overwrite.set(UNIQUE_INSTANCE_ID, uniqueGraphId);
    checkAndOverwriteTransactionLogConfiguration(combinedConfig, overwrite, storeFeatures);
    checkAndOverwriteSystemManagementLogConfiguration(combinedConfig, overwrite);
    MergedConfiguration configuration = new MergedConfiguration(overwrite, combinedConfig);
    return new GraphDatabaseConfiguration(localConfig, localConfiguration, uniqueGraphId, configuration);
}
Also used : StoreFeatures(org.janusgraph.diskstorage.keycolumnvalue.StoreFeatures) KCVSConfigurationBuilder(org.janusgraph.diskstorage.configuration.backend.builder.KCVSConfigurationBuilder) MergedConfiguration(org.janusgraph.diskstorage.configuration.MergedConfiguration) MergedConfiguration(org.janusgraph.diskstorage.configuration.MergedConfiguration) MixedConfiguration(org.janusgraph.diskstorage.configuration.MixedConfiguration) Configuration(org.janusgraph.diskstorage.configuration.Configuration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) BasicConfiguration(org.janusgraph.diskstorage.configuration.BasicConfiguration) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) ReadConfiguration(org.janusgraph.diskstorage.configuration.ReadConfiguration) MixedConfiguration(org.janusgraph.diskstorage.configuration.MixedConfiguration) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) ReadConfiguration(org.janusgraph.diskstorage.configuration.ReadConfiguration) ModifiableConfigurationBuilder(org.janusgraph.diskstorage.configuration.builder.ModifiableConfigurationBuilder) KeyColumnValueStoreManager(org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager) ReadConfigurationBuilder(org.janusgraph.diskstorage.configuration.builder.ReadConfigurationBuilder) BasicConfiguration(org.janusgraph.diskstorage.configuration.BasicConfiguration)

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