### Question:
HashedColumnStore extends AbstractColumnStore { public ColumnIterator getRows(SimpleColumnCombination activeColumns) { FileInputStream[] in = new FileInputStream[activeColumns.getColumns().length]; int i = 0; for (int col : activeColumns.getColumns()) { try { in[i++] = new FileInputStream(columnFiles[col]); } catch (FileNotFoundException e) { throw new RuntimeException(e); } } return new HashedColumnStore.ColumnIterator(in); } HashedColumnStore(int numColumns, int sampleGoal, boolean isReuseColumnFiles); List<long[]> getSampleFile(); ColumnIterator getRows(SimpleColumnCombination activeColumns); static HashedColumnStore[] create(RelationalInputGenerator[] fileInputGenerators, int sampleGoal,
                                             boolean isReuseColumnFiles, boolean isCloseConnectionsRigorously);  }### Answer:
@Test public void testGetRows() throws Exception { rb.setHeader("col1", "col2", "col3") .addRow("a", "a", "b") .addRow("1", "2", "2"); HashedColumnStore cs = createColumnStore(rb.build().generateNewCopy()); ColumnIterator rows = cs.getRows(); long[] row = rows.next(); assertThat(row[0], equalTo(row[1])); assertThat(row[0], not(equalTo(row[2]))); row = rows.next(); assertThat(row[0], not(equalTo(row[1]))); assertThat(row[1], equalTo(row[2])); assertThat(rows.hasNext(), is(false)); }
@Test public void testHasNextTwice() throws Exception { rb.setHeader("col1", "col2").addRow("a", "a"); HashedColumnStore cs = createColumnStore(rb.build().generateNewCopy()); ColumnIterator rows = cs.getRows(); assertThat(rows.hasNext(), is(true)); assertThat(rows.hasNext(), is(true)); long[] row = rows.next(); assertThat(row[0], equalTo(row[1])); assertThat(rows.hasNext(), is(false)); assertThat(rows.hasNext(), is(false)); assertThat(rows.hasNext(), is(false)); }
@Test public void testHashCache() throws Exception { rb.setHeader("col1").addRow("a").addRow("a"); HashedColumnStore cs = createColumnStore(rb.build().generateNewCopy()); ColumnIterator rows = cs.getRows(); assertThat(rows.hasNext(), is(true)); long[] row1 = rows.next().clone(); assertThat(rows.hasNext(), is(true)); long[] row2 = rows.next().clone(); assertThat(row1[0], equalTo(row2[0])); assertThat(rows.hasNext(), is(false)); }
@Test public void testGetLongRows() throws Exception { int count = 500_000; rb.setHeader("long_col"); for (int i = 0; i < count; i++) { rb.addRow(Integer.toString(i)); } HashedColumnStore cs = createColumnStore(rb.build().generateNewCopy()); ColumnIterator rows = cs.getRows(); HashFunction hashFunction = Hashing.murmur3_128(); int i = 0; while (rows.hasNext()) { long[] row = rows.next(); long hash = hashFunction.hashString(Integer.toString(i), Charsets.UTF_8).asLong(); assertThat("rowindex: " + i, row[0], equalTo(hash)); i++; } assertThat(i, equalTo(count)); }