RetrieveColumns extends Constraint { @Override public SeekingCurrentIterator getResultIterator() { SeekingCurrentIterator results = this.subConstraint.getResultIterator(); return new RetrieveColumnsIterator(results, this.table, this.columns); } RetrieveColumns();  RetrieveColumns(Constraint subConstraint, TableAdapter primaryTable);  RetrieveColumns(Constraint subConstraint, TableAdapter primaryTable,
      CColumn... columns); @Override void readFields(DataInput in); @Override void write(DataOutput out); @Override SeekingCurrentIterator getResultIterator();  }
@Test public void testRetrieveAllColumns() throws Exception { List<CKeyValue> values = new ArrayList<CKeyValue>(); values.add(new CKeyValue(new byte[] { 1 }, new byte[] { 2 }, new byte[] { 3 }, new byte[] { 4 })); values.add(new CKeyValue(new byte[] { 2 }, new byte[] { 2 }, new byte[] { 3 }, new byte[] { 5 })); values.add(new CKeyValue(new byte[] { 3 }, new byte[] { 2 }, new byte[] { 3 }, new byte[] { 6 })); values.add(new CKeyValue(new byte[] { 4 }, new byte[] { 2 }, new byte[] { 3 }, new byte[] { 7 })); InMemoryTable t1 = new InMemoryTable(); t1.put(new Put(values)); SeekingCurrentIterator iter = new RetrieveColumns(new KeyOnlyFilter(t1), t1) .getResultIterator(); assertTrue(iter.hasNext()); assertCount(iter, 4, 4); }
@Test public void testRetrieveSpecificColumns() throws Exception { List<CKeyValue> values = new ArrayList<CKeyValue>(); values.add(new CKeyValue(new byte[] { 1 }, new byte[] { 2 }, new byte[] { 3 }, 0, new byte[] { 4 })); values.add(new CKeyValue(new byte[] { 2 }, new byte[] { 3 }, new byte[] { 3 }, 1, new byte[] { 5 })); values.add(new CKeyValue(new byte[] { 3 }, new byte[] { 4 }, new byte[] { 3 }, 2, new byte[] { 6 })); values.add(new CKeyValue(new byte[] { 4 }, new byte[] { 4 }, new byte[] { 4 }, 3, new byte[] { 7 })); InMemoryTable t1 = new InMemoryTable(); t1.put(new Put(values)); SeekingCurrentIterator iter = new RetrieveColumns(new KeyOnlyFilter(t1, new CColumn(new byte[] { 2 }), new CColumn(new byte[] { 3 })), t1) .getResultIterator(); assertTrue(iter.hasNext()); assertCount(iter, 2, 2); iter = new RetrieveColumns(new KeyOnlyFilter(t1, new CColumn( new byte[] { 2 }), new CColumn(new byte[] { 3 })), t1, new CColumn( new byte[] { 3 })).getResultIterator(); assertTrue(iter.hasNext()); assertCount(iter, 1, 1); iter = new RetrieveColumns(new KeyOnlyFilter(t1, new CColumn( new byte[] { 4 })), t1).getResultIterator(); assertTrue(iter.hasNext()); assertCount(iter, 2, 2); }