GTSEncoder implements Cloneable { public synchronized GTSDecoder getDecoder(boolean safeMetadata) { GTSDecoder decoder = new GTSDecoder(this.baseTimestamp, this.wrappingKey, ByteBuffer.wrap(this.stream.toByteArray())); if (!safeMetadata) { decoder.setMetadata(this.getMetadata()); } else { decoder.safeSetMetadata(this.getMetadata()); } decoder.initialize( this.initialTimestamp, this.initialGeoXPPoint, this.initialElevation, this.initialLongValue, this.initialDoubleValue, this.initialBDValue, this.initialStringValue); decoder.setCount(this.getCount()); return decoder; } 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 testGetDecoder() throws Exception { long now = System.currentTimeMillis() * 1000L; byte[] key = new byte[32]; GTSEncoder encoder = new GTSEncoder(now - 1000000L, key); encoder.addValue(now, 111L, 11L, new BigDecimal("1.11")); encoder.addValue(now + 1000000L, 222L, 22L, new BigDecimal("2.22")); GTSDecoder decoder = encoder.getDecoder(); Assert.assertTrue(decoder.next()); Assert.assertEquals(now, decoder.getTimestamp()); Assert.assertEquals(111L, decoder.getLocation()); Assert.assertEquals(11L, decoder.getElevation()); Assert.assertEquals(new BigDecimal("1.11"), decoder.getValue()); Assert.assertTrue(decoder.next()); Assert.assertEquals(now + 1000000L, decoder.getTimestamp()); Assert.assertEquals(222L, decoder.getLocation()); Assert.assertEquals(22L, decoder.getElevation()); Assert.assertEquals(new BigDecimal("2.22"), decoder.getValue()); Assert.assertFalse(decoder.next()); }
@Test public void testWARP50() throws Exception { GTSEncoder encoder = new GTSEncoder(0L); encoder = GTSHelper.parse(encoder, "0 encoder = GTSHelper.parse(encoder, "0 encoder = GTSHelper.parse(encoder, "0 encoder = GTSHelper.parse(encoder, "0 GTSDecoder decoder = encoder.getDecoder(); Assert.assertTrue(decoder.next()); Assert.assertTrue(decoder.getValue() instanceof BigDecimal); Assert.assertEquals(10000000.0D, ((BigDecimal) decoder.getValue()).doubleValue(), 0.01D); Assert.assertTrue(decoder.next()); Assert.assertTrue(decoder.getValue() instanceof Double); Assert.assertEquals(-20000000.0D, ((Double) decoder.getValue()).doubleValue(), 0.01D); Assert.assertTrue(decoder.next()); Assert.assertTrue(decoder.getValue() instanceof BigDecimal); Assert.assertEquals(10000000.0D, ((BigDecimal) decoder.getValue()).doubleValue(), 0.01D); Assert.assertTrue(decoder.next()); Assert.assertTrue(decoder.getValue() instanceof Double); Assert.assertEquals(-20000000.0D, ((Double) decoder.getValue()).doubleValue(), 0.01D); }