public void flush() { if (currentWriter == null) { return; } try { currentWriter.trimToSize(); byte[] input = currentWriter.getBytes(); segments.add(compress(input, 0, input.length, compressionLevel)); currentWriter = null; currentEntry = 0; } catch (Exception ex) { throw new RuntimeException(ex); } }
@Test public void testWriteWithTrim() { VLongStorage store = new VLongStorage(); store.seek(0); store.writeVLong(1); store.trimToSize(); assertEquals(1, store.getPosition()); store.writeVLong(7); store.trimToSize(); assertEquals(2, store.getPosition()); store.writeVLong(777666555); store.trimToSize(); assertEquals(7, store.getPosition()); store.seek(0); assertEquals(1L, store.readVLong()); assertEquals(7L, store.readVLong()); assertEquals(777666555L, store.readVLong()); } }
public void flush() { if (currentWriter == null) { return; } try { currentWriter.trimToSize(); byte[] input = currentWriter.getBytes(); segments.add(compress(input, 0, input.length, compressionLevel)); currentWriter = null; currentEntry = 0; } catch (Exception ex) { throw new RuntimeException(ex); } }
public void flush() { if (currentWriter == null) { return; } try { currentWriter.trimToSize(); byte[] input = currentWriter.getBytes(); segments.add(compress(input, 0, input.length, compressionLevel)); currentWriter = null; currentEntry = 0; } catch (Exception ex) { throw new RuntimeException(ex); } }
public void flush() { if (currentWriter == null) { return; } try { currentWriter.trimToSize(); byte[] input = currentWriter.getBytes(); segments.add(compress(input, 0, input.length, compressionLevel)); currentWriter = null; currentEntry = 0; } catch (Exception ex) { throw new RuntimeException(ex); } }