GTSEncoder implements Cloneable { public void safeDelta() { this.noDeltaMetaTimestamp = true; this.noDeltaMetaLocation = true; this.noDeltaMetaElevation = true; this.noDeltaValue = true; } GTSEncoder();  GTSEncoder(long baseTimestamp, byte[] key, byte[] content);  GTSEncoder(long baseTimestamp);  GTSEncoder(long baseTimestamp, byte[] key);  GTSEncoder(long baseTimestamp, byte[] key, int size); synchronized int addValue(long timestamp, long location, long elevation, Object value); void setWrappingKey(byte[] key); byte[] getBytes(); int size(); long getCount(); synchronized void encode(GeoTimeSerie gts); synchronized void encodeOptimized(GeoTimeSerie gts); static Object optimizeValue(Object value); synchronized GTSDecoder getDecoder(boolean safeMetadata); GTSDecoder getDecoder(); synchronized GTSDecoder getUnsafeDecoder(boolean blockWrites); synchronized void reset(GTSEncoder encoder); synchronized void reset(long baseTS); synchronized void resize(int target); synchronized void merge(GTSEncoder encoder); long getBaseTimestamp(); long getClassId(); void setClassId(long classId); long getLabelsId(); void setLabelsId(long labelsId); String getName(); void setName(String name); Map<String, String> getLabels(); void setLabels(Map<String, String> labels); void setLabel(String key, String value); void setMetadata(Metadata metadata); void safeSetMetadata(Metadata metadata); Metadata getMetadata(); Metadata getRawMetadata(); long getLastTimestamp(); void safeDelta(); synchronized void setCount(long count); synchronized void flush(); byte[] toBlock(boolean compress); void writeTo(OutputStream out); GTSEncoder cloneEmpty(); GTSEncoder clone(); static final byte FLAGS_ENCRYPTED; }
@Test public void testSafeDelta() throws Exception { GTSEncoder encoder = new GTSEncoder(0L); encoder.addValue(1L, 2L, 3L, 4L); byte[] bytes = encoder.getBytes(); encoder = new GTSEncoder(0L, null, bytes); Assert.assertEquals(13, encoder.size()); encoder.addValue(2L, GeoTimeSerie.NO_LOCATION, GeoTimeSerie.NO_ELEVATION, 4L); Assert.assertEquals(23, encoder.size()); encoder.addValue(3L, 4L, GeoTimeSerie.NO_ELEVATION, 4L); Assert.assertEquals(34, encoder.size()); encoder.addValue(4L, GeoTimeSerie.NO_LOCATION, 4L, 4L); Assert.assertEquals(38, encoder.size()); encoder.addValue(5L, 6L, 4L, 9L); Assert.assertEquals(50, encoder.size()); encoder.addValue(6L, 4L, 4L, 9L); Assert.assertEquals(54, encoder.size()); encoder.addValue(7L, 4L, 4L, 9L); Assert.assertEquals(57, encoder.size()); GTSDecoder decoder = encoder.getDecoder(); Assert.assertTrue(decoder.next()); Assert.assertEquals(1L, decoder.getTimestamp()); Assert.assertEquals(2L, decoder.getLocation()); Assert.assertEquals(3L, decoder.getElevation()); Assert.assertEquals(4L, decoder.getValue()); Assert.assertTrue(decoder.next()); Assert.assertEquals(2L, decoder.getTimestamp()); Assert.assertEquals(GeoTimeSerie.NO_LOCATION, decoder.getLocation()); Assert.assertEquals(GeoTimeSerie.NO_ELEVATION, decoder.getElevation()); Assert.assertEquals(4L, decoder.getValue()); Assert.assertTrue(decoder.next()); Assert.assertEquals(3L, decoder.getTimestamp()); Assert.assertEquals(4L, decoder.getLocation()); Assert.assertEquals(GeoTimeSerie.NO_ELEVATION, decoder.getElevation()); Assert.assertEquals(4L, decoder.getValue()); Assert.assertTrue(decoder.next()); Assert.assertEquals(4L, decoder.getTimestamp()); Assert.assertEquals(GeoTimeSerie.NO_LOCATION, decoder.getLocation()); Assert.assertEquals(4L, decoder.getElevation()); Assert.assertEquals(4L, decoder.getValue()); Assert.assertTrue(decoder.next()); Assert.assertEquals(5L, decoder.getTimestamp()); Assert.assertEquals(6L, decoder.getLocation()); Assert.assertEquals(4L, decoder.getElevation()); Assert.assertEquals(9L, decoder.getValue()); Assert.assertTrue(decoder.next()); Assert.assertEquals(6L, decoder.getTimestamp()); Assert.assertEquals(4L, decoder.getLocation()); Assert.assertEquals(4L, decoder.getElevation()); Assert.assertEquals(9L, decoder.getValue()); Assert.assertTrue(decoder.next()); Assert.assertEquals(7L, decoder.getTimestamp()); Assert.assertEquals(4L, decoder.getLocation()); Assert.assertEquals(4L, decoder.getElevation()); Assert.assertEquals(9L, decoder.getValue()); }