@Test public void fileIteratorRandomizedTest() throws Exception { Set<String> added = newHashSet(); for (int i = 0; i < 100; i++) { added.add(getRandomTestString()); } File f = assertWrite(added.iterator(), true, added.size()); BurnOnCloseFileIterator iterator = new BurnOnCloseFileIterator<String>(FileUtils.lineIterator(f, UTF_8.toString()), f, new Function<String, String>() { @Nullable @Override public String apply(@Nullable String input) { return unescapeLineBreaks(input); } }); assertEquals(added, Sets.newHashSet(iterator)); assertTrue(!f.exists()); }
/** * Returns an iterator on the tracked blob ids. * * @return record iterator * @throws IOException */ protected Iterator<String> getRecords() throws IOException { try { // Get a temp file path String path = createTempFile("temp", null).getAbsolutePath(); return wrap(lineIterator(getRecords(path)), new File(path)); } catch (IOException e) { LOG.error("Error in retrieving blob records iterator", e); throw e; } }
@Test public void fileIteratorLineBreakTest() throws IOException { Set<String> added = newHashSet(getLineBreakStrings()); File f = assertWrite(added.iterator(), true, added.size()); BurnOnCloseFileIterator iterator = new BurnOnCloseFileIterator<String>(FileUtils.lineIterator(f, UTF_8.toString()), f, new Function<String, String>() { @Nullable @Override public String apply(@Nullable String input) { return unescapeLineBreaks(input); } }); assertEquals(added, Sets.newHashSet(iterator)); assertTrue(!f.exists()); }
/** * Returns an iterator on the tracked blob ids. * * @return record iterator * @throws IOException */ protected Iterator<String> getRecords() throws IOException { try { // Get a temp file path String path = createTempFile("temp", null).getAbsolutePath(); return wrap(lineIterator(getRecords(path)), new File(path)); } catch (IOException e) { LOG.error("Error in retrieving blob records iterator", e); throw e; } }
/** * Returns an iterator on the tracked blob ids. * * @return record iterator * @throws IOException */ protected Iterator<String> getRecords() throws IOException { try { // Get a temp file path String path = createTempFile("temp", null).getAbsolutePath(); return wrap(lineIterator(getRecords(path)), new File(path)); } catch (IOException e) { LOG.error("Error in retrieving blob records iterator", e); throw e; } }
public static BurnOnCloseFileIterator<String> wrap(LineIterator iter) { return new BurnOnCloseFileIterator<String>(iter, new Function<String, String>() { public String apply(String s) { return s; } }); }
public static BurnOnCloseFileIterator<String> wrap(LineIterator iter, File backingFile) { return new BurnOnCloseFileIterator<String>(iter, backingFile, new Function<String, String>() { public String apply(String s) { return s; } }); } }
public static BurnOnCloseFileIterator<String> wrap(LineIterator iter) { return new BurnOnCloseFileIterator<String>(iter, new Function<String, String>() { public String apply(String s) { return s; } }); }
public static BurnOnCloseFileIterator<String> wrap(LineIterator iter) { return new BurnOnCloseFileIterator<String>(iter, new Function<String, String>() { public String apply(String s) { return s; } }); }
public static BurnOnCloseFileIterator<String> wrap(LineIterator iter, File backingFile) { return new BurnOnCloseFileIterator<String>(iter, backingFile, new Function<String, String>() { public String apply(String s) { return s; } }); } }
@Test public void fileIteratorBurnTest() throws Exception { Set<String> added = newHashSet("a", "z", "e", "b"); File f = assertWrite(added.iterator(), false, added.size()); BurnOnCloseFileIterator iterator = BurnOnCloseFileIterator.wrap(FileUtils.lineIterator(f, UTF_8.toString()), f); assertEquals(added, Sets.newHashSet(iterator)); assertTrue(!f.exists()); }
@Test public void fileIteratorTest() throws Exception { Set<String> added = newHashSet("a", "z", "e", "b"); File f = assertWrite(added.iterator(), false, added.size()); BurnOnCloseFileIterator iterator = BurnOnCloseFileIterator.wrap(FileUtils.lineIterator(f, UTF_8.toString())); assertEquals(added, Sets.newHashSet(iterator)); assertTrue(f.exists()); }
public static BurnOnCloseFileIterator<String> wrap(LineIterator iter, File backingFile) { return new BurnOnCloseFileIterator<String>(iter, backingFile, new Function<String, String>() { public String apply(String s) { return s; } }); } }