KeyOnlyFilter extends ResultFilter { @Override public SeekingCurrentIterator getResultIterator() { SeekingCurrentIterator iter = super.getResultIterator(); return new RowIdIterator(iter); } KeyOnlyFilter();  KeyOnlyFilter(Constraint subconstraint, CRange range,
      CColumn... column);  KeyOnlyFilter(TableAdapter primaryTable, CRange range,
      CColumn... columns);  KeyOnlyFilter(Constraint subConstraint, CRange range);  KeyOnlyFilter(Constraint subConstraint, CColumn... columns);  KeyOnlyFilter(TableAdapter primaryTable, CColumn... columns);  KeyOnlyFilter(TableAdapter primaryTable, CRange range);  KeyOnlyFilter(TableAdapter primaryTable); @Override SeekingCurrentIterator getResultIterator();  }
@Test public void testSimpleSelection() { TableAdapter table = new InMemoryTable(); List<CKeyValue> values = new ArrayList<CKeyValue>(); values.add(new CKeyValue(new byte[] { 1 })); values.add(new CKeyValue(new byte[] { 2 }, new byte[] { 3 }, new byte[] { 4 })); values.add(new CKeyValue(new byte[] { 3 }, new byte[] { 4 }, new byte[] { 5 }, 0, new byte[] { 6 })); table.put(new Put(values)); KeyOnlyFilter rows = new KeyOnlyFilter(table); Iterator<Result> results = rows.getResultIterator(); int count = 0; while (results.hasNext()) { count++; results.next(); } assertEquals(3, count); rows = new KeyOnlyFilter(table, new CRange(new byte[] { 2 }, new byte[0])); results = rows.getResultIterator(); count = 0; while (results.hasNext()) { count++; results.next(); } assertEquals(2, count); rows = new KeyOnlyFilter(table, new CRange(new byte[] { 2 })); results = rows.getResultIterator(); count = 0; while (results.hasNext()) { count++; results.next(); } assertEquals(1, count); }
@Test public void testWithColumnsSelected() { TableAdapter table = new InMemoryTable(); List<CKeyValue> values = new ArrayList<CKeyValue>(); values.add(new CKeyValue(new byte[] { 1 })); values.add(new CKeyValue(new byte[] { 2 }, new byte[] { 3 }, new byte[] { 4 })); values.add(new CKeyValue(new byte[] { 3 }, new byte[] { 4 }, new byte[] { 5 }, 0, new byte[] { 6 })); table.put(new Put(values)); KeyOnlyFilter rows = new KeyOnlyFilter(table, new CColumn(new byte[] { 3 })); Iterator<Result> results = rows.getResultIterator(); int count = 0; while (results.hasNext()) { count++; results.next(); } assertEquals(1, count); rows = new KeyOnlyFilter(table, new CColumn(new byte[] { 3 }), new CColumn( new byte[] { 4 })); results = rows.getResultIterator(); count = 0; while (results.hasNext()) { count++; results.next(); } assertEquals(2, count); }