DiscardedRowsFilter implements Function<String[], Boolean> { @Override public Boolean call(String[] tokens) { Boolean keep = true; for (Integer index : indices) { if (index >= tokens.length || MLConstants.MISSING_VALUES.contains(tokens[index])) { keep = false; break; } } return keep; } private  DiscardedRowsFilter(Builder builder); @Override Boolean call(String[] tokens);  }
@Test public void testDiscardedRowsFilterWithNonDiscardedRows() { DiscardedRowsFilter discardedRowsFilter = new DiscardedRowsFilter.Builder().indices(discardedIndices).build(); boolean shouldKeep = discardedRowsFilter.call(new String[] { "1.2", "2", "hi", "na", "4.21" }); Assert.assertEquals(shouldKeep, true); shouldKeep = discardedRowsFilter.call(new String[] { "1.2", "?", "hi", "na", "4.21" }); Assert.assertEquals(shouldKeep, false); shouldKeep = discardedRowsFilter.call(new String[] { "1.2", "2.11", "NA", "na", "4.21" }); Assert.assertEquals(shouldKeep, false); shouldKeep = discardedRowsFilter.call(new String[] { "1.2", "1.112", "hi", "", "4.21" }); Assert.assertEquals(shouldKeep, false); }