Search in sources :

Example 11 with KeySliceQuery

use of com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery in project titan by thinkaurelius.

the class ConsistentKeyLockerTest method recordLockGetSlice.

private void recordLockGetSlice(EntryList returnedEntries) throws BackendException {
    final KeySliceQuery ksq = new KeySliceQuery(defaultLockKey, LOCK_COL_START, LOCK_COL_END);
    expect(store.getSlice(eq(ksq), eq(defaultTx))).andReturn(returnedEntries);
}
Also used : KeySliceQuery(com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery)

Example 12 with KeySliceQuery

use of com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery in project titan by thinkaurelius.

the class IndexSerializer method processSingleCondition.

private List<Object> processSingleCondition(ElementType resultType, PredicateCondition pc, final int limit, BackendTransaction tx) {
    Preconditions.checkArgument(resultType == ElementType.EDGE || resultType == ElementType.VERTEX);
    Preconditions.checkArgument(pc.getPredicate() == Cmp.EQUAL, "Only equality index retrievals are supported on standard index");
    Preconditions.checkNotNull(pc.getValue());
    Preconditions.checkArgument(limit >= 0);
    TitanKey key = (TitanKey) pc.getKey();
    Preconditions.checkArgument(key.hasIndex(Titan.Token.STANDARD_INDEX, resultType.getElementType()), "Cannot retrieve for given property key - it does not have an index [%s]", key.getName());
    Object value = pc.getValue();
    StaticBuffer column = getUniqueIndexColumn(key);
    KeySliceQuery sq = new KeySliceQuery(getIndexKey(value), column, SliceQuery.pointRange(column), ((InternalType) key).isStatic(Direction.IN)).setLimit(limit);
    List<Entry> r;
    if (resultType == ElementType.VERTEX) {
        r = tx.vertexIndexQuery(sq);
    } else {
        r = tx.edgeIndexQuery(sq);
    }
    List<Object> results = new ArrayList<Object>(r.size());
    for (Entry entry : r) {
        ReadBuffer entryValue = entry.getReadValue();
        if (resultType == ElementType.VERTEX) {
            results.add(VariableLong.readPositive(entryValue));
        } else {
            results.add(bytebuffer2RelationId(entryValue));
        }
    }
    Preconditions.checkArgument(!(resultType == ElementType.VERTEX && key.isUnique(Direction.IN)) || results.size() <= 1);
    return results;
}
Also used : InternalType(com.thinkaurelius.titan.graphdb.internal.InternalType) StaticBufferEntry(com.thinkaurelius.titan.diskstorage.keycolumnvalue.StaticBufferEntry) Entry(com.thinkaurelius.titan.diskstorage.keycolumnvalue.Entry) KeySliceQuery(com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery)

Example 13 with KeySliceQuery

use of com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery in project titan by thinkaurelius.

the class ConsistentKeyLockerTest method recordLockGetSlice.

private void recordLockGetSlice(List<Entry> returnedEntries) throws StorageException {
    final StaticBuffer lower = ByteBufferUtil.zeroBuffer(9);
    final StaticBuffer upper = ByteBufferUtil.oneBuffer(9);
    final KeySliceQuery ksq = new KeySliceQuery(defaultLockKey, lower, upper);
    expect(store.getSlice(eq(ksq), eq(defaultTx))).andReturn(returnedEntries);
}
Also used : StaticBuffer(com.thinkaurelius.titan.diskstorage.StaticBuffer) KeySliceQuery(com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery)

Aggregations

KeySliceQuery (com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery)13 StaticBuffer (com.thinkaurelius.titan.diskstorage.StaticBuffer)6 ArrayList (java.util.ArrayList)4 EntryList (com.thinkaurelius.titan.diskstorage.EntryList)2 Entry (com.thinkaurelius.titan.diskstorage.keycolumnvalue.Entry)2 StoreTransaction (com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction)2 CacheTransaction (com.thinkaurelius.titan.diskstorage.keycolumnvalue.cache.CacheTransaction)2 KeyColumn (com.thinkaurelius.titan.diskstorage.util.KeyColumn)2 StaticArrayEntry (com.thinkaurelius.titan.diskstorage.util.StaticArrayEntry)2 List (java.util.List)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Entry (com.thinkaurelius.titan.diskstorage.Entry)1 KCVMutation (com.thinkaurelius.titan.diskstorage.keycolumnvalue.KCVMutation)1 SliceQuery (com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery)1 StaticBufferEntry (com.thinkaurelius.titan.diskstorage.keycolumnvalue.StaticBufferEntry)1 TemporaryLockingException (com.thinkaurelius.titan.diskstorage.locking.TemporaryLockingException)1 IDPoolExhaustedException (com.thinkaurelius.titan.graphdb.database.idassigner.IDPoolExhaustedException)1 InternalType (com.thinkaurelius.titan.graphdb.internal.InternalType)1