Class VersionedPropCodec
- java.lang.Object
-
- org.apache.accumulo.server.conf.codec.VersionedPropCodec
-
- Direct Known Subclasses:
VersionedPropGzipCodec
public abstract class VersionedPropCodec extends Object
Abstract class to provide encoding / decoding of versioned properties. This class handles the serialization of the metadata and subclasses are required to implementencodePayload(OutputStream, VersionedProperties, EncodingOptions)
anddecodePayload(InputStream, EncodingOptions)
to handle any specific implementation metadata (optional) and the property map according to the encoding scheme of the subclass.The basic encoding format:
- encoding metadata - specifies codec to be used
- version metadata - specifies property versioning information
- codec specific metadata (optional)
- the property map
-
-
Constructor Summary
Constructors Constructor Description VersionedPropCodec(EncodingOptions encodingOpts)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NonNull VersionedProperties
fromBytes(int version, byte[] bytes)
static VersionedPropCodec
getDefault()
EncodingOptions
getEncodingOpts()
The general encoding options that apply to all encodings.static int
getEncodingVersion(byte[] bytes)
Extracts the encoding version from the encoded byte array without fully decoding the payload.static Instant
readTimestamp(byte[] bytes)
Extracts the timestamp from the encoded byte array without fully decoding the payload.byte[]
toBytes(VersionedProperties vProps)
Serialize the versioned properties.
-
-
-
Constructor Detail
-
VersionedPropCodec
public VersionedPropCodec(EncodingOptions encodingOpts)
-
-
Method Detail
-
getDefault
public static VersionedPropCodec getDefault()
-
getEncodingOpts
public EncodingOptions getEncodingOpts()
The general encoding options that apply to all encodings.- Returns:
- the general options.
-
toBytes
public byte[] toBytes(VersionedProperties vProps) throws IOException
Serialize the versioned properties. The version information on the properties is updated if the data is successfully serialized.- Parameters:
vProps
- the versioned properties.- Returns:
- a byte array with the serialized properties.
- Throws:
IOException
-
fromBytes
public @NonNull VersionedProperties fromBytes(int version, byte[] bytes) throws IOException
- Parameters:
version
- the data version determined by the prop storebytes
- an array of bytes created using a PropCodec.- Returns:
- the versioned properties.
- Throws:
IOException
- if the an error occurs reading from the byte array.
-
getEncodingVersion
public static int getEncodingVersion(byte[] bytes)
Extracts the encoding version from the encoded byte array without fully decoding the payload. This is a convenience method if multiple encodings are present, and should only be required if upgrading / changing encodings, otherwise a single encoding should be in operation for an instance at any given time.- Parameters:
bytes
- serialized encoded versioned property byte array.- Returns:
- the encoding version used to serialize the properties.
-
readTimestamp
public static Instant readTimestamp(byte[] bytes)
Extracts the timestamp from the encoded byte array without fully decoding the payload. Normally the timestamp should be obtained from a fully decoded instance of the versioned properties.The cost of reading the byte array from the backing store should be considered verses the additional cost of decoding - with a goal of reducing data reads from the store preferred. Generally reading from the store will be followed by some sort of usage which would require the full decode operation anyway, so uses of this method should be narrow and limited.
- Parameters:
bytes
- serialized encoded versioned property byte array.- Returns:
- the timestamp used to serialize the properties.
-
-