use of org.janusgraph.diskstorage.EntryList in project janusgraph by JanusGraph.
the class CacheVertex method loadRelations.
@Override
public EntryList loadRelations(final SliceQuery query, final Retriever<SliceQuery, EntryList> lookup) {
if (isNew())
return EntryList.EMPTY_LIST;
EntryList result;
synchronized (queryCache) {
result = queryCache.get(query);
}
if (result == null) {
// First check for super
Map.Entry<SliceQuery, EntryList> superset = getSuperResultSet(query);
if (superset == null) {
result = lookup.get(query);
} else {
result = query.getSubset(superset.getKey(), superset.getValue());
}
addToQueryCache(query, result);
}
return result;
}
use of org.janusgraph.diskstorage.EntryList in project janusgraph by JanusGraph.
the class ExpirationCacheTest method verifyResults.
private void verifyResults(StaticBuffer key, List<StaticBuffer> keys, SliceQuery query, int expectedResults) throws Exception {
CacheTransaction tx = getCacheTx();
assertEquals(expectedResults, cache.getSlice(new KeySliceQuery(key, query), tx).size());
Map<StaticBuffer, EntryList> results = cache.getSlice(keys, query, tx);
assertEquals(keys.size(), results.size());
assertEquals(expectedResults, results.get(key).size());
tx.commit();
}
use of org.janusgraph.diskstorage.EntryList in project janusgraph by JanusGraph.
the class LockCleanerRunnableTest method testPreservesLocksAtOrAfterCutoff.
/**
* Locks with timestamps equal to or numerically greater than the cleaner
* cutoff timestamp must be preserved. Test that the cleaner reads locks by
* slicing the store and then does <b>not</b> attempt to write.
*/
@Test
public void testPreservesLocksAtOrAfterCutoff() throws BackendException {
final Instant cutoff = Instant.ofEpochMilli(10L);
Entry currentLock = StaticArrayEntry.of(codec.toLockCol(cutoff, defaultLockRid, TimestampProviders.MILLI), BufferUtil.getIntBuffer(0));
Entry futureLock = StaticArrayEntry.of(codec.toLockCol(cutoff.plusMillis(1), defaultLockRid, TimestampProviders.MILLI), BufferUtil.getIntBuffer(0));
EntryList locks = StaticArrayEntryList.of(currentLock, futureLock);
// Don't increment cutoff: lockCol is exactly at the cutoff timestamp
del = new StandardLockCleanerRunnable(store, kc, tx, codec, cutoff, TimestampProviders.MILLI);
expect(store.getSlice(eq(ksq), eq(tx))).andReturn(locks);
ctrl.replay();
del.run();
}
Aggregations