@Test public void testIterator() throws IOException { final Array<Row> rows = Array.rangeClosed(1, 100).map(idx -> { final Row row = mock(Row.class); when(row.getBytes("key")).thenReturn(ByteBuffer.wrap(Integer.toString(idx / 5).getBytes())); when(row.getBytes("column1")).thenReturn(ByteBuffer.wrap(Integer.toString(idx % 5).getBytes())); when(row.getBytes("value")).thenReturn(ByteBuffer.wrap(Integer.toString(idx).getBytes())); return row; }); final ResultSet resultSet = mock(ResultSet.class); when(resultSet.iterator()).thenReturn(rows.iterator()); final CQLColValGetter getter = new CQLColValGetter(new EntryMetaData[0]); try (final CQLResultSetKeyIterator resultSetKeyIterator = new CQLResultSetKeyIterator(ALL_COLUMNS, getter, resultSet)) { int i = 0; while (resultSetKeyIterator.hasNext()) { final StaticBuffer next = resultSetKeyIterator.next(); final RecordIterator<Entry> entries = resultSetKeyIterator.getEntries(); while (entries.hasNext()) { final Row row = rows.get(i++); final Entry entry = entries.next(); assertEquals(row.getBytes("key"), next.asByteBuffer()); assertEquals(row.getBytes("column1"), entry.getColumn().asByteBuffer()); assertEquals(row.getBytes("value"), entry.getValue().asByteBuffer()); } } } }
@Override public RecordIterator<Entry> getEntries() { return new EntryRecordIterator(this.sliceQuery, this.getter, Iterator.of(this.currentRow).concat(this.iterator), this.currentKey); }
CQLResultSetKeyIterator extends AbstractIterator<StaticBuffer> implements KeyIterator { @Override public RecordIterator<Entry> getEntries() { return new EntryRecordIterator(this.sliceQuery, this.getter, Iterator.of(this.currentRow).concat(this.iterator), this.currentKey); } }
CQLResultSetKeyIterator extends AbstractIterator<StaticBuffer> implements KeyIterator { @Override public RecordIterator<Entry> getEntries() { return new EntryRecordIterator(this.sliceQuery, this.getter, Iterator.of(this.currentRow).concat(this.iterator), this.currentKey); } CQLResultSetKeyIterator(final SliceQuery sliceQuery, final CQLColValGetter getter, final Iterable<Row> resultSet); }
CQLResultSetKeyIterator extends AbstractIterator<StaticBuffer> implements KeyIterator { @Override public RecordIterator<Entry> getEntries() { return new EntryRecordIterator(this.sliceQuery, this.getter, Iterator.of(this.currentRow).concat(this.iterator), this.currentKey); } CQLResultSetKeyIterator(final SliceQuery sliceQuery, final CQLColValGetter getter, final Iterable<Row> resultSet); @Override RecordIterator<Entry> getEntries(); @Override void close(); }
CQLResultSetKeyIterator extends AbstractIterator<StaticBuffer> implements KeyIterator { @Override public RecordIterator<Entry> getEntries() { return new EntryRecordIterator(this.sliceQuery, this.getter, Iterator.of(this.currentRow).concat(this.iterator), this.currentKey); } CQLResultSetKeyIterator(final SliceQuery sliceQuery, final CQLColValGetter getter, final Iterable<Row> resultSet); @Override RecordIterator<Entry> getEntries(); @Override void close();  }