Search in sources :

Example 16 with EntryList

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;
}
Also used : EntryList(org.janusgraph.diskstorage.EntryList) Map(java.util.Map) HashMap(java.util.HashMap) SliceQuery(org.janusgraph.diskstorage.keycolumnvalue.SliceQuery)

Example 17 with EntryList

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();
}
Also used : StaticBuffer(org.janusgraph.diskstorage.StaticBuffer) EntryList(org.janusgraph.diskstorage.EntryList) CacheTransaction(org.janusgraph.diskstorage.keycolumnvalue.cache.CacheTransaction) KeySliceQuery(org.janusgraph.diskstorage.keycolumnvalue.KeySliceQuery)

Example 18 with EntryList

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();
}
Also used : StandardLockCleanerRunnable(org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerRunnable) Entry(org.janusgraph.diskstorage.Entry) Instant(java.time.Instant) EntryList(org.janusgraph.diskstorage.EntryList) Test(org.junit.Test)

Aggregations

EntryList (org.janusgraph.diskstorage.EntryList)18 Map (java.util.Map)4 Entry (org.janusgraph.diskstorage.Entry)4 Test (org.junit.Test)4 Instant (java.time.Instant)3 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)3 SliceQuery (org.janusgraph.diskstorage.keycolumnvalue.SliceQuery)3 StandardLockCleanerRunnable (org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerRunnable)3 LongArrayList (com.carrotsearch.hppc.LongArrayList)2 ArrayList (java.util.ArrayList)2 NonBlockingHashMapLong (org.cliffc.high_scale_lib.NonBlockingHashMapLong)2 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)2 KeySliceQuery (org.janusgraph.diskstorage.keycolumnvalue.KeySliceQuery)2 StoreTransaction (org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction)2 CacheTransaction (org.janusgraph.diskstorage.keycolumnvalue.cache.CacheTransaction)2 CacheVertex (org.janusgraph.graphdb.vertices.CacheVertex)2 PreloadedVertex (org.janusgraph.graphdb.vertices.PreloadedVertex)2 ImmutableList (com.google.common.collect.ImmutableList)1 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)1 Column (com.netflix.astyanax.model.Column)1