@Override public Iterable<E> read(Configuration configuration) throws IOException { // TODO: what to do with Configuration? create new view? return view.newReader(); // TODO: who calls close? }
@Override public Iterable<E> read(TaskInputOutputContext<?, ?, ?, ?> context) throws IOException { return view.newReader(); } };
@Override @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="NP_NULL_ON_SOME_PATH", justification="Null case checked by precondition") public int run() throws IOException { Preconditions.checkArgument( datasets != null && !datasets.isEmpty(), "Missing dataset name"); Preconditions.checkArgument(datasets.size() == 1, "Only one dataset name can be given"); View<Object> dataset = load(datasets.get(0), Object.class); DatasetReader<Object> reader = null; boolean threw = true; try { reader = dataset.newReader(); int i = 0; for (Object record : reader) { if (i >= numRecords) { break; } console.info(record.toString()); i += 1; } threw = false; } finally { Closeables.close(reader, threw); } return 0; }
public static <E> void assertContentEquals(Set<E> expected, View<E> view) throws IOException { DatasetReader<E> reader = null; try { reader = view.newReader(); Assert.assertEquals(expected, Sets.newHashSet((Iterable<E>) reader)); } finally { Closeables.close(reader, false); } }
public static <E> void assertContentEquals(Set<E> expected, View<E> view) throws IOException { DatasetReader<E> reader = null; try { reader = view.newReader(); Assert.assertEquals(expected, Sets.newHashSet((Iterable<E>) reader)); } finally { Closeables.close(reader, false); } }
public static <E> Set<E> materialize(View<E> ds) { Set<E> records = Sets.newHashSet(); DatasetReader<E> reader = null; try { reader = ds.newReader(); for (E record : reader) { records.add(record); } } finally { if (reader != null) { reader.close(); } } return records; }
private void validRange(View<TestEntity> range, int startIdx, int endIdx) { int cnt = startIdx; DatasetReader<TestEntity> reader = range.newReader(); try { for (TestEntity entity : reader) { Assert.assertEquals(Integer.toString(cnt), entity.getPart1()); Assert.assertEquals(Integer.toString(cnt), entity.getPart2()); cnt++; } } finally { reader.close(); } Assert.assertEquals(endIdx, cnt); } }