public class GTSEncoder
extends java.lang.Object
implements java.lang.Cloneable
| Modifier and Type | Field and Description |
|---|---|
static byte |
FLAGS_ENCRYPTED
Flag indicating encrypted data
|
| Constructor and Description |
|---|
GTSEncoder() |
GTSEncoder(long baseTimestamp)
Create an encoder using the given timestamp as its base.
|
GTSEncoder(long baseTimestamp,
byte[] key)
Create an encoder using the given base and AES wrapping key.
|
GTSEncoder(long baseTimestamp,
byte[] key,
byte[] content) |
GTSEncoder(long baseTimestamp,
byte[] key,
int size) |
| Modifier and Type | Method and Description |
|---|---|
int |
addValue(long timestamp,
long location,
long elevation,
java.lang.Object value) |
GTSEncoder |
clone() |
GTSEncoder |
cloneEmpty() |
void |
encode(GeoTimeSerie gts)
Encode the given GTS instance.
|
void |
encodeOptimized(GeoTimeSerie gts)
Encode the given GTS instance, converting doubles to BigDecimal to get a chance to
store them more efficiently
|
void |
flush()
Empty the output stream and disable delta encoding
|
long |
getBaseTimestamp() |
byte[] |
getBytes()
Return the bytes currently in this encoder.
|
long |
getClassId() |
long |
getCount()
Return the number of values encoded by this encoder.
|
GTSDecoder |
getDecoder() |
GTSDecoder |
getDecoder(boolean safeMetadata)
Return a decoder instance capable of decoding the encoded content of this
encoder.
|
java.util.Map<java.lang.String,java.lang.String> |
getLabels() |
long |
getLabelsId() |
long |
getLastTimestamp() |
Metadata |
getMetadata() |
java.lang.String |
getName() |
long |
getPessimisticSize()
Return an estimation of the 'exploded' size, i.e.
|
Metadata |
getRawMetadata()
Return the untouched Metadata associated with this encoder
|
GTSDecoder |
getUnsafeDecoder(boolean blockWrites)
Retrieve a GTSDecoder which uses the same metadata as
this GTSEncoder and has a ByteBuffer which wraps the current
byte array in this GTSEncoder's stream.
|
void |
merge(GTSEncoder encoder)
Merge data encoded in another encoder with this one.
|
static java.lang.Object |
optimizeValue(java.lang.Object value) |
void |
reset(GTSEncoder encoder)
Reset the state of this encoder with that of 'encoder'.
|
void |
reset(long baseTS) |
void |
resize(int target)
Resize the byte array backing 'stream'
|
void |
safeDelta()
Disable delta/identical encoding until the encoder has encountered a new
ts/lat/lon/elev and value from each type.
|
void |
safeSetMetadata(Metadata metadata)
Package protected version of the above method which reuses the Metadata verbatim
This version is targeted to GTSDecoder to speed up the call to getEncoder
|
void |
setClassId(long classId) |
void |
setCount(long count) |
void |
setLabel(java.lang.String key,
java.lang.String value) |
void |
setLabels(java.util.Map<java.lang.String,java.lang.String> labels) |
void |
setLabelsId(long labelsId) |
void |
setMetadata(Metadata metadata) |
void |
setName(java.lang.String name) |
void |
setWrappingKey(byte[] key) |
int |
size()
Return the current size of the encoded data.
|
byte[] |
toBlock(boolean compress)
Transform the current encoder into a storable block.
|
void |
writeTo(java.io.OutputStream out) |
public static final byte FLAGS_ENCRYPTED
public GTSEncoder()
public GTSEncoder(long baseTimestamp,
byte[] key,
byte[] content)
public GTSEncoder(long baseTimestamp)
baseTimestamp - Timestamp to use as base.public GTSEncoder(long baseTimestamp,
byte[] key)
baseTimestamp - Timestamp to use as base (to compute deltas)key - AES Wrapping key to use to encrypt encoded values.public GTSEncoder(long baseTimestamp,
byte[] key,
int size)
public int addValue(long timestamp,
long location,
long elevation,
java.lang.Object value)
throws java.io.IOException
java.io.IOExceptionpublic void setWrappingKey(byte[] key)
public byte[] getBytes()
public int size()
public long getCount()
public long getPessimisticSize()
public void encode(GeoTimeSerie gts) throws java.io.IOException
gts - java.io.IOExceptionpublic void encodeOptimized(GeoTimeSerie gts) throws java.io.IOException
gts - java.io.IOExceptionpublic static java.lang.Object optimizeValue(java.lang.Object value)
public GTSDecoder getDecoder(boolean safeMetadata)
safeMetadata - Is it safe to reuse the Metadata instance?public GTSDecoder getDecoder()
public GTSDecoder getUnsafeDecoder(boolean blockWrites)
public void reset(GTSEncoder encoder) throws java.io.IOException
encoder - java.io.IOExceptionpublic void reset(long baseTS)
throws java.io.IOException
java.io.IOExceptionpublic void resize(int target)
throws java.io.IOException
java.io.IOExceptionpublic void merge(GTSEncoder encoder) throws java.io.IOException
encoder - GTSEncoder instance containing the data to mergejava.io.IOExceptionpublic long getBaseTimestamp()
public long getClassId()
public void setClassId(long classId)
public long getLabelsId()
public void setLabelsId(long labelsId)
public java.lang.String getName()
public void setName(java.lang.String name)
public java.util.Map<java.lang.String,java.lang.String> getLabels()
public void setLabels(java.util.Map<java.lang.String,java.lang.String> labels)
public void setLabel(java.lang.String key,
java.lang.String value)
public void setMetadata(Metadata metadata)
public void safeSetMetadata(Metadata metadata)
metadata - public Metadata getMetadata()
public Metadata getRawMetadata()
public long getLastTimestamp()
public void safeDelta()
public void setCount(long count)
public void flush()
public byte[] toBlock(boolean compress)
throws java.io.IOException
java.io.IOExceptionpublic void writeTo(java.io.OutputStream out)
throws java.io.IOException
java.io.IOExceptionpublic GTSEncoder cloneEmpty()
public GTSEncoder clone()
clone in class java.lang.Object