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