Java Code Examples for org.kitesdk.data.View#newReader()
The following examples show how to use
org.kitesdk.data.View#newReader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowRecordsCommand.java From kite with Apache License 2.0 | 5 votes |
@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; }
Example 2
Source File: TestInputFormatImportCommandCluster.java From kite with Apache License 2.0 | 5 votes |
/** * Copy records while materializing in case they are reused. */ private static Set<Measurement> materialize(View<Measurement> view) { Set<Measurement> measurements = Sets.newHashSet(); for (Measurement m : view.newReader()) { measurements.add(new Measurement(m)); } return measurements; }
Example 3
Source File: TestSimpleView.java From kite with Apache License 2.0 | 5 votes |
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); } }
Example 4
Source File: DatasetTestUtilities.java From kite with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: DaoViewTest.java From kite with Apache License 2.0 | 5 votes |
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); }