public void write(double lat, double lon) { try { if (currentWriter == null) currentWriter = new VLongStorage(entriesPerSegment * approxBytesPerEntry); long latlon = algo.encode(new GHPoint(lat, lon)); // we cannot use delta encoding as vlong does not support negative numbers // but compression of vlong is much more efficient than directly storing the integers currentWriter.writeVLong(latlon); currentEntry++; if (currentEntry >= entriesPerSegment) { flush(); } } catch (Exception ex) { throw new RuntimeException(ex); } }
@Test public void testWrite() { VLongStorage store = new VLongStorage(); store.seek(0); store.writeVLong(1); store.writeVLong(7); assertEquals(2, store.getPosition()); store.writeVLong(777666555); assertEquals(7, store.getPosition()); store.seek(0); assertEquals(1L, store.readVLong()); assertEquals(7L, store.readVLong()); assertEquals(777666555L, store.readVLong()); }
@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 write(double lat, double lon) { try { if (currentWriter == null) currentWriter = new VLongStorage(entriesPerSegment * approxBytesPerEntry); long latlon = algo.encode(new GHPoint(lat, lon)); // we cannot use delta encoding as vlong does not support negative numbers // but compression of vlong is much more efficient than directly storing the integers currentWriter.writeVLong(latlon); currentEntry++; if (currentEntry >= entriesPerSegment) { flush(); } } catch (Exception ex) { throw new RuntimeException(ex); } }
public void write(double lat, double lon) { try { if (currentWriter == null) currentWriter = new VLongStorage(entriesPerSegment * approxBytesPerEntry); long latlon = algo.encode(new GHPoint(lat, lon)); // we cannot use delta encoding as vlong does not support negative numbers // but compression of vlong is much more efficient than directly storing the integers currentWriter.writeVLong(latlon); currentEntry++; if (currentEntry >= entriesPerSegment) { flush(); } } catch (Exception ex) { throw new RuntimeException(ex); } }
public void write( double lat, double lon ) { try { if (currentWriter == null) currentWriter = new VLongStorage(entriesPerSegment * approxBytesPerEntry); long latlon = algo.encode(new GHPoint(lat, lon)); // we cannot use delta encoding as vlong does not support negative numbers // but compression of vlong is much more efficient than directly storing the integers currentWriter.writeVLong(latlon); currentEntry++; if (currentEntry >= entriesPerSegment) { flush(); } } catch (Exception ex) { throw new RuntimeException(ex); } }