@Override public DatasetReader<E> newReader() { LOG.debug("Getting reader for dataset:{}", this); return asRefinableView().newReader(); }
@Override public void run() { oct.fromAfter("timestamp", later); } });
@Override public void run() { unbounded.fromAfter("timestamp", nov11Start).toBefore("timestamp", nov12Start).moveToTrash(); } });
@Override public void run() { unbounded.from("timestamp", oct12BadStart).to("timestamp", oct12End).moveToTrash(); } });
@Test public void testUnboundedView() { // test events Assert.assertTrue("Should include any StandardEvent", unbounded.includes(event)); Assert.assertTrue("Should include even null events", unbounded.includes(null)); Assert.assertTrue("Should include older event", unbounded.includes(sepEvent)); Assert.assertTrue("Should include event", unbounded.includes(octEvent)); Assert.assertTrue("Should include newer event", unbounded.includes(novEvent)); // test range limiting Assert.assertNotNull("from should succeed", unbounded.from("timestamp", now)); Assert.assertNotNull("fromAfter should succeed", unbounded.fromAfter("timestamp", now)); Assert.assertNotNull("to should succeed", unbounded.to("timestamp", now)); Assert.assertNotNull("toBefore should succeed", unbounded.toBefore("timestamp", now)); Assert.assertNotNull("with should succeed", unbounded.with("timestamp", now)); }
writer = unbounded.newWriter(); writer.write(sepEvent); writer.write(octEvent); unbounded.from("timestamp", decStart).deleteAll()); Assert.assertFalse("Delete should return false to indicate no changes", unbounded.from("timestamp", julStart).toBefore("timestamp", sepStart).deleteAll()); unbounded.to("timestamp", sep12End).deleteAll()); assertDirectoriesDoNotExist(fs, sep12, sep); assertDirectoriesExist(fs, root, y2013, oct, oct12, nov, nov11); Assert.assertFalse("Delete should return false to indicate no changes", unbounded.to("timestamp", sep12End).deleteAll()); assertDirectoriesDoNotExist(fs, sep12, sep); assertDirectoriesExist(fs, root, y2013, oct, oct12, nov, nov11); unbounded.from("timestamp", nov11Start).toBefore("timestamp", nov12Start).deleteAll()); assertDirectoriesDoNotExist(fs, sep12, sep, nov11, nov); assertDirectoriesExist(fs, root, y2013, oct, oct12); Assert.assertFalse("Delete should return false to indicate no changes", unbounded.from("timestamp", nov11Start).toBefore("timestamp", nov12Start).deleteAll()); assertDirectoriesDoNotExist(fs, sep12, sep, nov11, nov); assertDirectoriesExist(fs, root, y2013, oct, oct12); unbounded.from("timestamp", oct12Start).to("timestamp", oct12End).deleteAll()); assertDirectoriesDoNotExist(fs, y2013, sep12, sep, oct12, oct, nov11, nov); assertDirectoriesExist(fs, root); Assert.assertFalse("Delete should return false to indicate no changes", unbounded.from("timestamp", oct12Start).to("timestamp", oct12End).deleteAll());
writer = unbounded.newWriter(); writer.write(sepEvent); writer.write(octEvent); unbounded.from("timestamp", decStart).moveToTrash()); Assert.assertFalse("Delete should return false to indicate no changes", unbounded.from("timestamp", julStart).toBefore("timestamp", sepStart).moveToTrash()); unbounded.to("timestamp", sep12End).moveToTrash()); assertDirectoriesDoNotExist(fs, sep12, sep); assertDirectoriesInTrash(fs, trashPolicy, sep12, sep); assertDirectoriesExist(fs, root, y2013, oct, oct12, nov, nov11); Assert.assertFalse("Delete should return false to indicate no changes", unbounded.to("timestamp", sep12End).moveToTrash()); assertDirectoriesDoNotExist(fs, sep12, sep); assertDirectoriesExist(fs, root, y2013, oct, oct12, nov, nov11); unbounded.from("timestamp", nov11Start).toBefore("timestamp", nov12Start).moveToTrash()); assertDirectoriesDoNotExist(fs, sep12, sep, nov11, nov); assertDirectoriesExist(fs, root, y2013, oct, oct12); Assert.assertFalse("Delete should return false to indicate no changes", unbounded.from("timestamp", nov11Start).toBefore("timestamp", nov12Start).moveToTrash()); assertDirectoriesDoNotExist(fs, sep12, sep, nov11, nov); assertDirectoriesInTrash(fs, trashPolicy, sep12, sep, nov11, nov); unbounded.from("timestamp", oct12Start).to("timestamp", oct12End).moveToTrash()); assertDirectoriesDoNotExist(fs, y2013, sep12, sep, oct12, oct, nov11, nov); assertDirectoriesInTrash(fs, trashPolicy, y2013, sep12, sep, oct12, oct, nov11, nov); assertDirectoriesExist(fs, root);
@Override public void run() { afterSep.to("timestamp", instant); } });
@Override public void run() { withSpecificTimestamp.with("timestamp", later); } });
@Test public void testReaderWriterCompatibleSchema() throws IOException { DatasetWriter<TestValue> writer = null; try { writer = Datasets.load(testValueView.getUri(), TestValue.class).newWriter(); writer.write(testValue); } finally { Closeables.close(writer, false); } DatasetReader<Value> reader = null; try { reader = valueView.newReader(); Assert.assertEquals(Sets.newHashSet(defaultValue), Sets.newHashSet((Iterable<Value>) reader)); } finally { Closeables.close(reader, false); } }
@Override public void run() { oct.from("timestamp", later); } });
@Override public void run() { oct.toBefore("timestamp", later); } });
@Test public void testEmptyCheck() throws IOException { Assert.assertTrue("New dataset should be empty", unbounded.isEmpty()); // NOTE: this is an un-restricted write so all should succeed DatasetWriter<StandardEvent> writer = null; try { writer = unbounded.newWriter(); writer.write(sepEvent); } finally { Closeables.close(writer, false); } Assert.assertFalse("Should not be empty after write", unbounded.isEmpty()); Assert.assertFalse("Should find event in September", unbounded.with("timestamp", sepEvent.getTimestamp()).isEmpty()); Assert.assertTrue("Should not find event in October", unbounded.with("timestamp", octEvent.getTimestamp()).isEmpty()); }
@Test public void testBoundedRangeViews() { assertViewUriEquivalent("[a,b]", "view:file:/tmp/test_name?id=[a,b]", test.from("id", "a").to("id", "b")); assertViewUriEquivalent("[a,b)", "view:file:/tmp/test_name?id=[a,b)", test.from("id", "a").toBefore("id", "b")); assertViewUriEquivalent("(a,b]", "view:file:/tmp/test_name?id=(a,b]", test.fromAfter("id", "a").to("id", "b")); assertViewUriEquivalent("(a,b)", "view:file:/tmp/test_name?id=(a,b)", test.fromAfter("id", "a").toBefore("id", "b")); }