public BinaryGetCommand(String key, byte[] keyBytes, CommandType cmdType, CountDownLatch latch, OpCode opCode, boolean noreply) { super(key, keyBytes, cmdType, latch, 0, 0, null, noreply, null); this.opCode = opCode; this.responseValue = new CachedData(); }
@SuppressWarnings("unchecked") protected CachedData encodeValue() { final CachedData data = this.transcoder.encode(this.value); return data; }
public TokyoTyrantTranscoder() { serializingTranscoder = new SerializingTranscoder(); serializingTranscoder.setPackZeros(false); }
public final CachedData encode(Object o) { CachedData result = serializingTranscoder.encode(o); byte[] realData = result.getData(); int flag = result.getFlag(); byte[] flagBytes = serializingTranscoder.getTranscoderUtils().encodeInt(flag); byte[] compisiteData = new byte[4 + realData.length]; System.arraycopy(flagBytes, 0, compisiteData, 0, 4); System.arraycopy(realData, 0, compisiteData, 4, realData.length); result.setData(compisiteData); return result; }
protected int getValueLength(final CachedData data) { return data.getData().length; }
/** * Compress the given array of bytes. */ public final byte[] compress(byte[] in) { switch (this.compressMode) { case GZIP: return gzipCompress(in); case ZIP: return zipCompress(in); default: return gzipCompress(in); } }
public int remainingCapacity() { if (getCapacity() < 0) { return -1; } int remainingCapacity = getCapacity() - getSize(); return remainingCapacity; } }
private byte[] encodeInteger(Integer value) { byte[] b = encodeNum(value, 4); b[0] = SPECIAL_INTEGER; return b; }
public boolean isPackZeros() { return this.transcoderUtils.isPackZeros(); }
public final byte[] encodeLong(long l) { return encodeNum(l, 8); }
@Override public void setPackZeros(boolean packZeros) { this.tu.setPackZeros(packZeros); }
public void setCompressionMode(CompressionMode compressMode) { this.serializingTranscoder.setCompressionMode(compressMode); }
public boolean isPackZeros() { return serializingTranscoder.isPackZeros(); }
private byte[] encodeLong(Long value) { return encodeLong(value, SPECIAL_LONG); }
public final int decodeInt(byte[] in) { assert in.length <= 4 : "Too long to be an int (" + in.length + ") bytes"; return (int) decodeLong(in); }
public void setPrimitiveAsString(boolean primitiveAsString) { this.transcoder.setPrimitiveAsString(primitiveAsString); }
public TokyoTyrantTranscoder(int maxSize) { serializingTranscoder = new SerializingTranscoder(maxSize); serializingTranscoder.setPackZeros(false); }
private byte[] encodeLong(Long value, int type) { byte[] b = encodeNum(value, 8); b[0] = (byte) type; return b; }
public boolean isPackZeros() { return this.tu.isPackZeros(); }
public final byte[] encodeInt(int in) { return encodeNum(in, 4); }