public abstract class Compressor extends Object
Okuyamaの値として保管する際は、マジックコードとして1バイト目、2バイト目として 0xAC 0xEE を 設定し、更に3バイト目に圧縮に使用したCompressor具象クラスのIDを格納する。これにより、値を参照した 際に圧縮の有無を判定し、展開に必要なCompressorを選択して透過的に値の参照ができるようになっている。
ただし、この格納形式はOkuyamaサーバに同梱のOkuyamaClientの圧縮方式とは互換性がない。オリジナルのOkuyamaClientは 値が圧縮されているかどうかを判定できないため、取得側で全てを圧縮するか、圧縮しないかを決める必要がある。
| コンストラクタと説明 |
|---|
Compressor() |
| 修飾子とタイプ | メソッドと説明 |
|---|---|
abstract ByteBuffer |
compress(byte[] serialized) |
abstract ByteBuffer |
compress(byte[] serialized,
int offset,
int length) |
abstract ByteBuffer |
decompress(byte[] b,
int offset,
int length) |
static Compressor |
getAppliedCompressor(byte[] data,
int offset,
int length)
独自仕様:圧縮されたバイト列はマジックコード 0xac 0xee で始めることとする。
|
static Compressor |
getCompressor(int compressorId) |
abstract int |
getCompressorId() |
static void |
registerCompressor(Compressor compressor) |
protected void |
writeMagicBytes(byte[] buf) |
public static Compressor getAppliedCompressor(byte[] data, int offset, int length) throws IllegalStateException
data - データストアから取得したペイロードが格納されたバッファoffset - 参照するバッファのオフセットlength - バッファのサイズIllegalStateException - 圧縮されたペイロードだが該当するCompressorが登録されていない。registerCompressor(Compressor)を初期化時に実行しておく必要がある。public static Compressor getCompressor(int compressorId)
public static void registerCompressor(Compressor compressor)
protected void writeMagicBytes(byte[] buf)
public abstract int getCompressorId()
public abstract ByteBuffer compress(byte[] serialized)
public abstract ByteBuffer compress(byte[] serialized, int offset, int length)
public abstract ByteBuffer decompress(byte[] b, int offset, int length) throws OperationFailedException
Copyright © 2013–2016. All rights reserved.