@Override public SliceQuery setLimit(int limit) { Preconditions.checkArgument(!hasLimit()); super.setLimit(limit); return this; }
private static String encodeQueries(List<SliceQuery> queries) { List<String> queryStrings = new ArrayList<>(queries.size()); for (SliceQuery query : queries) { String start = Hex.bytesToHex(query.getSliceStart().as(StaticBuffer.ARRAY_FACTORY)); String end = Hex.bytesToHex(query.getSliceEnd().as(StaticBuffer.ARRAY_FACTORY)); final int limit; if (query.hasLimit()) { limit = query.getLimit(); } else { limit = -1; } queryStrings.add(String.format("%s/%s/%d", start, end, limit)); } return Joiner.on(":").join(queryStrings); }
@Override public Iterator<Entry> iterator() { Iterator<Entry> iterator; //If there is a limit we need to wrap the basic iterator in a LimitAdjustingIterator which ensures the right number //of elements is returned. Otherwise we just return the basic iterator. if (sliceQuery.hasLimit() && sliceQuery.getLimit()!=query.getLimit()) { iterator = new LimitAdjustingIterator(); } else { iterator = getBasicIterator(); } return iterator; }
public boolean subsumes(SliceQuery oth) { Preconditions.checkNotNull(oth); if (this == oth) return true; if (oth.getLimit() > getLimit()) return false; else if (!hasLimit()) //the interval must be subsumed return sliceStart.compareTo(oth.sliceStart) <= 0 && sliceEnd.compareTo(oth.sliceEnd) >= 0; else //this the result might be cutoff due to limit, the start must be the same return sliceStart.compareTo(oth.sliceStart) == 0 && sliceEnd.compareTo(oth.sliceEnd) >= 0; }
public QueryWorker buildQueryWorker(final StaticBuffer hashKey, final SliceQuery query) { final QueryRequest request = createQueryRequest(hashKey, query); // Only enforce a limit when Titan tells us to if (query.hasLimit()) { final int limit = query.getLimit(); request.setLimit(limit); return new QueryWithLimitWorker(client.getDelegate(), request, hashKey, limit); } return new QueryWorker(client.getDelegate(), request, hashKey); }
public static Filter getFilter(SliceQuery query) { byte[] colStartBytes = query.getSliceStart().length() > 0 ? query.getSliceStart().as(StaticBuffer.ARRAY_FACTORY) : null; byte[] colEndBytes = query.getSliceEnd().length() > 0 ? query.getSliceEnd().as(StaticBuffer.ARRAY_FACTORY) : null; Filter filter = new ColumnRangeFilter(colStartBytes, true, colEndBytes, false); if (query.hasLimit()) { filter = new FilterList(FilterList.Operator.MUST_PASS_ALL, filter, new ColumnPaginationFilter(query.getLimit(), 0)); } logger.debug("Generated HBase Filter {}", filter); return filter; }
if (query.hasLimit()) { endIndex = Math.min(endIndex, query.getLimit() + lowestStartMatch);
if (query.hasLimit()) { endIndex = Math.min(endIndex, query.getLimit() + lowestStartMatch);