@Test public void testComputeEmptyColumns() { String fullColumn = "full"; String partialColumn = "partial"; String emptyColumn = "empty"; String val = "val"; Map<String, ColumnMetadata> columnMetadata = ImmutableMap.of( fullColumn, new ColumnMetadata(fullColumn, Schema.STRING, fullColumn), partialColumn, new ColumnMetadata(partialColumn, Schema.STRING, partialColumn), emptyColumn, new ColumnMetadata(emptyColumn, Schema.STRING, emptyColumn)); TableAnswerElement table = new TableAnswerElement( new TableMetadata( columnMetadata.values().stream().collect(ImmutableList.toImmutableList()))); table.addRow(Row.builder(columnMetadata).put(fullColumn, val).put(partialColumn, val).build()); table.addRow(Row.builder(columnMetadata).put(fullColumn, val).build()); assertThat( AnswerMetadataUtil.computeEmptyColumns(table), equalTo(ImmutableSet.of(emptyColumn))); }
@VisibleForTesting static Set<String> computeEmptyColumns(TableAnswerElement table) { return table.getMetadata().toColumnMap().keySet().stream() .filter(column -> table.getRowsList().stream().allMatch(row -> !row.hasNonNull(column))) .collect(ImmutableSet.toImmutableSet()); }
AnswerMetadataUtil { @VisibleForTesting static Set<String> computeEmptyColumns(TableAnswerElement table) { return table.getMetadata().toColumnMap().keySet().stream() .filter(column -> table.getRowsList().stream().allMatch(row -> !row.hasNonNull(column))) .collect(ImmutableSet.toImmutableSet()); } }
AnswerMetadataUtil { @VisibleForTesting static Set<String> computeEmptyColumns(TableAnswerElement table) { return table.getMetadata().toColumnMap().keySet().stream() .filter(column -> table.getRowsList().stream().allMatch(row -> !row.hasNonNull(column))) .collect(ImmutableSet.toImmutableSet()); } private  AnswerMetadataUtil(); }
AnswerMetadataUtil { @VisibleForTesting static Set<String> computeEmptyColumns(TableAnswerElement table) { return table.getMetadata().toColumnMap().keySet().stream() .filter(column -> table.getRowsList().stream().allMatch(row -> !row.hasNonNull(column))) .collect(ImmutableSet.toImmutableSet()); } private  AnswerMetadataUtil(); static @Nonnull AnswerMetadata computeAnswerMetadata(
      @Nonnull Answer answer, @Nonnull BatfishLogger logger); }
AnswerMetadataUtil { @VisibleForTesting static Set<String> computeEmptyColumns(TableAnswerElement table) { return table.getMetadata().toColumnMap().keySet().stream() .filter(column -> table.getRowsList().stream().allMatch(row -> !row.hasNonNull(column))) .collect(ImmutableSet.toImmutableSet()); } private  AnswerMetadataUtil(); static @Nonnull AnswerMetadata computeAnswerMetadata(
      @Nonnull Answer answer, @Nonnull BatfishLogger logger);  }