private void assertKeys(RangeSlicesQuery query, int expected, String start, String end, SliceFilter<Row<String, Integer, Integer>> filter) { RangeSlicesIterator<String, Integer, Integer> iterator = new RangeSlicesIterator<String, Integer, Integer>(query, start, end).setFilter(filter); int total = 0; while(iterator.hasNext()) { iterator.next().getKey(); total ++; } assertEquals(expected, total); } }
@Override public boolean hasNext() { if (iterator == null) { // First time through iterator = Iterators.peekingIterator(query.execute().get().getList().iterator()); } else if (!iterator.hasNext() && rows == query.getRowCount()) { // only need to do another query if maximum rows were retrieved query.setKeys(startKey, endKey); iterator = Iterators.peekingIterator(query.execute().get().getList().iterator()); rows = 0; if (iterator.hasNext()) { // First element is startKey which was the last element on the previous query result - skip it next(); } } while(filter != null && iterator != null && iterator.hasNext() && !filter.accept(iterator.peek())) { next(); if(!iterator.hasNext() && rows == query.getRowCount()) { refresh(); } } return iterator.hasNext(); }
private void refresh() { query.setKeys(startKey, endKey); iterator = Iterators.peekingIterator(query.execute().get().getList().iterator()); rows = 0; if (iterator.hasNext()) { // First element is startKey which was the last element on the previous query result - skip it next(); } } }
/** * Creates a new iterator iterating over the results of the given query. * * @param query The query. * @param limit The maximum amount of results to return. * @param cf The column family to query. * @param keyspace The keyspace to use. * @param dictionary the CumulusRDF dictionary. * @param isPC True, if this is a PC query, false, if this is a C query. */ CAndPCSlicesQueryIterator( final RangeSlicesQuery<byte[], Composite, byte[]> query, final int limit, final String cf, final Keyspace keyspace, final ITopLevelDictionary dictionary, final boolean isPC) { _rows = new RangeSlicesIterator<byte[], Composite, byte[]>(query, new byte[0], new byte[0]); _limit = limit; _cf = cf; _keyspace = keyspace; _dictionary = dictionary; _isPC = isPC; }
private void refresh() { query.setKeys(startKey, endKey); iterator = Iterators.peekingIterator(query.execute().get().getList().iterator()); rows = 0; if (iterator.hasNext()) { // First element is startKey which was the last element on the previous query result - skip it next(); } } }
/** * Creates a new iterator iterating over the results of the given query. * * @param query The query. * @param limit The maximum amount of results to return. * @param cf The column family to query. * @param keyspace The keyspace to use. * @param dictionary the CumulusRDF dictionary. * @param isPC True, if this is a PC query, false, if this is a C query. */ CAndPCSlicesQueryIterator( final RangeSlicesQuery<byte[], Composite, byte[]> query, final int limit, final String cf, final Keyspace keyspace, final ITopLevelDictionary dictionary, final boolean isPC) { _rows = new RangeSlicesIterator<byte[], Composite, byte[]>(query, new byte[0], new byte[0]); _limit = limit; _cf = cf; _keyspace = keyspace; _dictionary = dictionary; _isPC = isPC; }
@Override public boolean hasNext() { if (iterator == null) { // First time through iterator = Iterators.peekingIterator(query.execute().get().getList().iterator()); } else if (!iterator.hasNext() && rows == query.getRowCount()) { // only need to do another query if maximum rows were retrieved query.setKeys(startKey, endKey); iterator = Iterators.peekingIterator(query.execute().get().getList().iterator()); rows = 0; if (iterator.hasNext()) { // First element is startKey which was the last element on the previous query result - skip it next(); } } while(filter != null && iterator != null && iterator.hasNext() && !filter.accept(iterator.peek())) { next(); if(!iterator.hasNext() && rows == query.getRowCount()) { refresh(); } } return iterator.hasNext(); }