@Test public void selectColumns() { Multiset<Row> rows = ImmutableMultiset.of( Row.builder().put("col1", null).put("col2", 12).put("col3", 13).build(), Row.builder().put("col1", 41).put("col2", 24).put("col3", 32).build()); Multiset<Row> selectedRows = FilterTableAnswerer.selectColumns(ImmutableSet.of("col1"), rows); assertThat( selectedRows, equalTo( new ImmutableMultiset.Builder<Row>() .add(Row.builder().put("col1", 41).build()) .add(Row.builder().put("col1", null).build()) .build())); }
@VisibleForTesting static Multiset<Row> selectColumns(Set<String> columns, Multiset<Row> inputRows) { return inputRows.stream() .map(row -> Row.builder().putAll(row, columns).build()) .collect(ImmutableMultiset.toImmutableMultiset()); }
FilterTableAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> selectColumns(Set<String> columns, Multiset<Row> inputRows) { return inputRows.stream() .map(row -> Row.builder().putAll(row, columns).build()) .collect(ImmutableMultiset.toImmutableMultiset()); } }
FilterTableAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> selectColumns(Set<String> columns, Multiset<Row> inputRows) { return inputRows.stream() .map(row -> Row.builder().putAll(row, columns).build()) .collect(ImmutableMultiset.toImmutableMultiset()); } FilterTableAnswerer(Question question, IBatfish batfish); }
FilterTableAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> selectColumns(Set<String> columns, Multiset<Row> inputRows) { return inputRows.stream() .map(row -> Row.builder().putAll(row, columns).build()) .collect(ImmutableMultiset.toImmutableMultiset()); } FilterTableAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); }
FilterTableAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> selectColumns(Set<String> columns, Multiset<Row> inputRows) { return inputRows.stream() .map(row -> Row.builder().putAll(row, columns).build()) .collect(ImmutableMultiset.toImmutableMultiset()); } FilterTableAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot);  }