TableSlice extends Relation { @Override public Table first(int nRows) { int count = 0; PrimitiveIterator.OfInt it = sourceRowNumberIterator(); Table copy = table.emptyCopy(); while (it.hasNext() && count < nRows) { int row = it.nextInt(); copy.addRow(table.row(row)); count++; } return copy; } TableSlice(Table table, Selection rowSelection);  TableSlice(Table table); @Override Column<?> column(int columnIndex); @Override Column<?> column(String columnName); @Override int columnCount(); @Override int rowCount(); @Override List<Column<?>> columns(); @Override int columnIndex(Column<?> column); @Override Object get(int r, int c); @Override String name(); Table getTable(); @Override void clear(); void removeSort(); void removeSelection(); @Override List<String> columnNames(); @Override TableSlice addColumns(Column<?>... column); @Override TableSlice removeColumns(Column<?>... columns); @Override Table first(int nRows); @Override TableSlice setName(String name); Table asTable(); double reduce(String numberColumnName, NumericAggregateFunction function); @Override Iterator<Row> iterator(); int mappedRowNumber(int rowNumber); void sortOn(Sort key);  }
@Test public void first() { TableSlice slice = new TableSlice(source, Selection.withRange(2, 12)); Table first = slice.first(5); assertEquals(first.get(0, 1), slice.get(0, 1)); assertEquals(first.get(0, 1), source.get(2, 1)); }