@Override public KeyIterator getKeys(KeyRangeQuery query, StoreTransaction txh) throws BackendException { return store.getKeys(query,txh); }
@Override public KeyIterator getKeys(SliceQuery query, StoreTransaction txh) throws BackendException { return store.getKeys(query,txh); }
@Override public KeyIterator getKeys(KeyRangeQuery keyQuery, StoreTransaction txh) throws BackendException { return store.getKeys(keyQuery, unwrapTx(txh)); }
@Override public KeyIterator getKeys(SliceQuery columnQuery, StoreTransaction txh) throws BackendException { return store.getKeys(columnQuery, unwrapTx(txh)); }
public static KeyIterator getKeys(KeyColumnValueStore store, SliceQuery slice, StoreFeatures features, int keyLength, StoreTransaction txh) throws BackendException { if (features.hasUnorderedScan()) { return store.getKeys(slice, txh); } else if (features.hasOrderedScan()) { return store.getKeys(new KeyRangeQuery(BufferUtil.zeroBuffer(1), BufferUtil.oneBuffer(keyLength), slice), txh); } else throw new UnsupportedOperationException("Provided stores does not support scan operations: " + store); }
@Override public KeyIterator getKeys(final KeyRangeQuery query, final StoreTransaction txh) throws BackendException { return runWithMetrics(txh, metricsStoreName, M_GET_KEYS, () -> { final KeyIterator ki = backend.getKeys(query, txh); if (txh.getConfiguration().hasGroupName()) { return MetricInstrumentedIterator.of(ki, txh.getConfiguration().getGroupName(), metricsStoreName, M_GET_KEYS, M_ITERATOR); } else { return ki; } }); }
@Override public KeyIterator getKeys(final SliceQuery query, final StoreTransaction txh) throws BackendException { return runWithMetrics(txh, metricsStoreName, M_GET_KEYS, () -> { final KeyIterator ki = backend.getKeys(query, txh); if (txh.getConfiguration().hasGroupName()) { return MetricInstrumentedIterator.of(ki, txh.getConfiguration().getGroupName(), metricsStoreName, M_GET_KEYS, M_ITERATOR); } else { return ki; } }); }
@Test @Category({UnorderedKeyStoreTests.class}) public void testGetKeysWithSliceQuery() throws Exception { if (!manager.getFeatures().hasUnorderedScan()) { log.warn("Can't test key-unordered features on incompatible store. " + "This warning could indicate reduced test coverage and " + "a broken JUnit configuration. Skipping test {}.", name.getMethodName()); return; } populateDBWith100Keys(); tx.commit(); tx = startTx(); KeyIterator keyIterator = store.getKeys( new SliceQuery(new ReadArrayBuffer("b".getBytes()), new ReadArrayBuffer("c".getBytes())), tx); examineGetKeysResults(keyIterator, 0, 100); }
@Test @Category({OrderedKeyStoreTests.class}) public void testGetKeysWithKeyRange() throws Exception { if (!manager.getFeatures().hasOrderedScan()) { log.warn("Can't test ordered scans on incompatible store. " + "This warning could indicate reduced test coverage and " + "shouldn't happen in an ideal JUnit configuration. " + "Skipping test {}.", name.getMethodName()); return; } populateDBWith100Keys(); tx.commit(); tx = startTx(); KeyIterator keyIterator = store.getKeys(new KeyRangeQuery( KeyColumnValueStoreUtil.longToByteBuffer(10), // key start KeyColumnValueStoreUtil.longToByteBuffer(40), // key end new ReadArrayBuffer("b".getBytes()), // column start new ReadArrayBuffer("c".getBytes())), tx); examineGetKeysResults(keyIterator, 10, 40); }
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(); }
keys = store.getKeys(new KeyRangeQuery(BufferUtil.getLongBuffer(minKey), BufferUtil.getLongBuffer(maxKey), columnSlice), tx); assertEquals(expectedKeyCount, KeyValueStoreUtil.count(keys)); keys = store.getKeys(new KeyRangeQuery(BufferUtil.getLongBuffer(minKey), BufferUtil.getLongBuffer(maxKey), columnSlice), tx); assertEquals(expectedKeyCount, KeyValueStoreUtil.count(keys));