@Override public InterruptibleIterator skvIterator(SamplerConfigurationImpl samplerConfig) { if (samplerConfig != null) throw new SampleNotPresentException(); if (map == null) throw new IllegalStateException(); return new SortedMapIterator(map); }
@Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { if (interruptFlag != null && interruptFlag.get()) throw new IterationInterruptedException(); this.range = range; Key key = range.getStartKey(); if (key == null) { key = new Key(); } iter = map.tailMap(key).entrySet().iterator(); if (iter.hasNext()) { entry = iter.next(); if (range.afterEndKey(entry.getKey())) { entry = null; } } else entry = null; while (hasTop() && range.beforeStartKey(getTopKey())) { next(); } }
public static SortedKeyValueIterator<Key,Value> createSource(IteratorTestInput input) { return new SimpleKVReusingIterator( new ColumnFamilySkippingIterator(new SortedMapIterator(requireNonNull(input).getInput()))); } }
@Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { if (interruptFlag != null && interruptFlag.get()) throw new IterationInterruptedException(); this.range = range; Key key = range.getStartKey(); if (key == null) { key = new Key(); } iter = map.tailMap(key).entrySet().iterator(); if (iter.hasNext()) { entry = iter.next(); if (range.afterEndKey(entry.getKey())) { entry = null; } } else entry = null; while (hasTop() && range.beforeStartKey(getTopKey())) { next(); } }
@Override public SortedMapIterator deepCopy(IteratorEnvironment env) { if (env != null && env.isSamplingEnabled()) { throw new SampleNotPresentException(); } return new SortedMapIterator(map, interruptFlag); }
public synchronized InterruptibleIterator skvIterator() { if (map == null) throw new IllegalStateException(); return new SortedMapIterator(map); }
@Override protected SortedKeyValueIterator<Key,Value> buildTopIterators(SortedKeyValueIterator<Key,Value> topIter, Configuration conf) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { return new SortedMapIterator(keys); } };
@Override public InterruptibleIterator skvIterator(SamplerConfigurationImpl samplerConfig) { if (samplerConfig != null) throw new SampleNotPresentException(); if (map == null) throw new IllegalStateException(); return new SortedMapIterator(map); }
@Override protected SortedKeyValueIterator<Key,Value> buildTopIterators(SortedKeyValueIterator<Key,Value> topIter, Configuration conf) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { return new SortedMapIterator(keys); } };
@Override protected SortedKeyValueIterator<Key,Value> buildTopIterators(SortedKeyValueIterator<Key,Value> topIter, Configuration conf) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { return new SortedMapIterator(keys); } };
public static SortedKeyValueIterator<Key,Value> createSource(IteratorTestInput input) { return new SimpleKVReusingIterator( new ColumnFamilySkippingIterator(new SortedMapIterator(requireNonNull(input).getInput()))); } }
@Override public SortedMapIterator deepCopy(IteratorEnvironment env) { if (env != null && env.isSamplingEnabled()) { throw new SampleNotPresentException(); } return new SortedMapIterator(map, interruptFlag); }
private static SortedKeyValueIterator<Key,Value> createScanIterator(KeyExtent ke, Collection<SortedKeyValueIterator<Key,Value>> mapfiles, Authorizations authorizations, byte[] defaultLabels, HashSet<Column> columnSet, List<IterInfo> ssiList, Map<String,Map<String,String>> ssio, boolean useTableIterators, TableConfiguration conf) throws IOException { SortedMapIterator smi = new SortedMapIterator(new TreeMap<Key,Value>()); List<SortedKeyValueIterator<Key,Value>> iters = new ArrayList<>(mapfiles.size() + 1); iters.addAll(mapfiles); iters.add(smi); MultiIterator multiIter = new MultiIterator(iters, ke); DeletingIterator delIter = new DeletingIterator(multiIter, false); ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(delIter); SortedKeyValueIterator<Key,Value> colFilter = ColumnQualifierFilter.wrap(cfsi, columnSet); SortedKeyValueIterator<Key,Value> visFilter = VisibilityFilter.wrap(colFilter, authorizations, defaultLabels); if (useTableIterators) return IteratorUtil.loadIterators(IteratorScope.scan, visFilter, ke, conf, ssiList, ssio, null); return visFilter; }
@Override public Iterator<Entry<Key,Value>> iterator() { SortedKeyValueIterator<Key,Value> i = new SortedMapIterator(table.table); try { i = new RangeFilter(createFilter(i), range); i.seek(range, createColumnBSS(fetchedColumns), !fetchedColumns.isEmpty()); return new IteratorAdapter(i); } catch (IOException e) { throw new RuntimeException(e); } }
@SuppressWarnings("unchecked") @Override public Iterator<Entry<Key,Value>> iterator() { if (ranges == null) { throw new IllegalStateException("ranges not set"); } IteratorChain chain = new IteratorChain(); for (Range range : ranges) { SortedKeyValueIterator<Key,Value> i = new SortedMapIterator(table.table); try { i = createFilter(i); i.seek(range, createColumnBSS(fetchedColumns), !fetchedColumns.isEmpty()); chain.addIterator(new IteratorAdapter(i)); } catch (IOException e) { throw new RuntimeException(e); } } return chain; }
@Before public void setup() throws ParseException, IOException { data = new SortedMapIterator(createTestData()); counter = new SourceCounter(); Map<String,String> options = Maps.newHashMap(); counter.init(data, options, new MockIteratorEnvironment()); }
@Test public void apply_testNormal() throws IOException { TreeMap<Key,Value> treeMap = Maps.newTreeMap(); treeMap.put(getFi("123", "FIELD1", "VALUE1", "dataType1", "123.345.456", 10), new Value()); treeMap.put(getFi("123", "FIELD1", "VALUE1", "dataType1", "123.345.456.1", 10), new Value()); treeMap.put(getFi("123", "FIELD1", "VALUE1", "dataType1", "123.345.456.2", 10), new Value()); treeMap.put(getFi("123", "FIELD1", "VALUE1", "dataType1", "123.345.456.3", 10), new Value()); SortedKeyValueIterator<Key,Value> itr = new SortedMapIterator(treeMap); itr.seek(new Range(), null, true); Key result = aggregator.apply(itr); assertFalse(itr.hasTop()); itr.seek(new Range(), null, true); Key result2 = aggregator.apply(itr, new Range(), null, false); assertFalse(itr.hasTop()); assertEquals(result, result2); }
@Test public void apply_testNormal() throws IOException { TreeMap<Key,Value> treeMap = Maps.newTreeMap(); treeMap.put(getTF("123", "FIELD1", "VALUE1", "dataType1", "123.345.456", 10), new Value()); SortedKeyValueIterator<Key,Value> itr = new SortedMapIterator(treeMap); itr.seek(new Range(), null, true); Key result = aggregator.apply(itr); assertFalse(itr.hasTop()); itr.seek(new Range(), null, true); Key result2 = aggregator.apply(itr, new Range(), null, false); assertFalse(itr.hasTop()); assertEquals(result, result2); }
@Test public void apply_testNormal() throws IOException { TreeMap<Key,Value> treeMap = Maps.newTreeMap(); treeMap.put(getFi("123", "FIELD1", "VALUE1", "dataType1", "123.345.456", 10), new Value()); SortedKeyValueIterator<Key,Value> itr = new SortedMapIterator(treeMap); itr.seek(new Range(), null, true); Key result = aggregator.apply(itr); assertFalse(itr.hasTop()); itr.seek(new Range(), null, true); Key result2 = aggregator.apply(itr, new Range(), null, false); assertFalse(itr.hasTop()); assertEquals(result, result2); }
itr.init(new SortedMapIterator(data), null, null); Range range = new Range(new Key("t", "v", "20130325"), true, new Key("t", "v", "20130325_\uffff"), false); itr.seek(range, Collections.emptySet(), false);