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);
}
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();
}
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);
}
Aggregations