@Override public Object decode(ByteBuf buf, State state) throws IOException { String str = (String) LongCodec.super.getValueDecoder().decode(buf, state); return Long.valueOf(str); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { String str = (String) IntegerCodec.super.getValueDecoder().decode(buf, state); return Integer.valueOf(str); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { String str = (String) IntegerCodec.super.getValueDecoder().decode(buf, state); return Integer.valueOf(str); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { String str = (String) DoubleCodec.super.getValueDecoder().decode(buf, state); return Double.valueOf(str); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { String str = (String) LongCodec.super.getValueDecoder().decode(buf, state); return Long.valueOf(str); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { String str = (String) DoubleCodec.super.getValueDecoder().decode(buf, state); return Double.valueOf(str); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { String id = (String) StringCodec.INSTANCE.getValueDecoder().decode(buf, state); String[] parts = id.toString().split("-"); return new StreamMessageId(Long.valueOf(parts[0]), Long.valueOf(parts[1])); }
@Override public Object decode(ByteBuf buf, State state) throws IOException { String id = (String) StringCodec.INSTANCE.getValueDecoder().decode(buf, state); String[] parts = id.toString().split("-"); return new StreamMessageId(Long.valueOf(parts[0]), Long.valueOf(parts[1])); }
@Override public Object resolveId(String name) { String decode = name.substring(name.indexOf("{") + 1, name.indexOf("}")); ByteBuf b = Unpooled.wrappedBuffer(ByteBufUtil.decodeHexDump(decode)); try { return codec.getMapKeyDecoder().decode(b, new State(false)); } catch (IOException ex) { throw new IllegalStateException("Unable to decode [" + decode + "] into object", ex); } finally { b.release(); } }
@Override public Object resolveId(String name) { String decode = name.substring(name.indexOf("{") + 1, name.indexOf("}")); ByteBuf b = Unpooled.wrappedBuffer(ByteBufUtil.decodeHexDump(decode)); try { return codec.getMapKeyDecoder().decode(b, new State(false)); } catch (IOException ex) { throw new IllegalStateException("Unable to decode [" + decode + "] into object", ex); } finally { b.release(); } }
@Override public Object decode(ByteBuf buf, State state) throws IOException { ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); try { while (buf.isReadable()) { int chunkSize = buf.readInt(); ByteBuf chunk = buf.readSlice(chunkSize); snappyDecoder.get().decode(chunk, out); snappyDecoder.get().reset(); } return innerCodec.getValueDecoder().decode(out, state); } finally { snappyDecoder.get().reset(); out.release(); } } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); try { while (buf.isReadable()) { int chunkSize = buf.readInt(); ByteBuf chunk = buf.readSlice(chunkSize); snappyDecoder.get().decode(chunk, out); snappyDecoder.get().reset(); } return innerCodec.getValueDecoder().decode(out, state); } finally { snappyDecoder.get().reset(); out.release(); } } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { int decompressSize = buf.readInt(); ByteBuf out = ByteBufAllocator.DEFAULT.buffer(decompressSize); try { LZ4SafeDecompressor decompressor = factory.safeDecompressor(); ByteBuffer outBuffer = out.internalNioBuffer(out.writerIndex(), out.writableBytes()); int pos = outBuffer.position(); decompressor.decompress(buf.internalNioBuffer(buf.readerIndex(), buf.readableBytes()), outBuffer); int compressedLength = outBuffer.position() - pos; out.writerIndex(compressedLength); return innerCodec.getValueDecoder().decode(out, state); } finally { out.release(); } } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { int decompressSize = buf.readInt(); ByteBuf out = ByteBufAllocator.DEFAULT.buffer(decompressSize); try { LZ4SafeDecompressor decompressor = factory.safeDecompressor(); ByteBuffer outBuffer = out.internalNioBuffer(out.writerIndex(), out.writableBytes()); int pos = outBuffer.position(); decompressor.decompress(buf.internalNioBuffer(buf.readerIndex(), buf.readableBytes()), outBuffer); int compressedLength = outBuffer.position() - pos; out.writerIndex(compressedLength); return innerCodec.getValueDecoder().decode(out, state); } finally { out.release(); } } };
private Object decode(ByteBuf buf, State state, Decoder<?> decoder) throws IOException { int keyLen; if (isWindows) { keyLen = buf.readIntLE(); } else { keyLen = (int) buf.readLongLE(); } ByteBuf keyBuf = buf.readSlice(keyLen); Object key = decoder.decode(keyBuf, state); return key; }
private Object decode(ByteBuf buf, State state, Decoder<?> decoder) throws IOException { int keyLen; if (isWindows) { keyLen = buf.readIntLE(); } else { keyLen = (int) buf.readLongLE(); } ByteBuf keyBuf = buf.readSlice(keyLen); Object key = decoder.decode(keyBuf, state); return key; }
@Test(groups = "fast") public void testDefaultPlanRulesExternalizable() throws IOException { final Codec codec = new SerializationCodec(); final ByteBuf byteBuf = codec.getValueEncoder().encode(vc.getVersions().get(0).getPlanRules()); final DefaultPlanRules planRules = (DefaultPlanRules) codec.getValueDecoder().decode(byteBuf, null); Assert.assertEquals(planRules, vc.getVersions().get(0).getPlanRules()); }
@Test(groups = "fast") public void testCatalogEntityCollectionProductExternalizable() throws IOException { final Codec codec = new SerializationCodec(); final ByteBuf byteBuf = codec.getValueEncoder().encode(vc.getVersions().get(0).getCatalogEntityCollectionProduct()); final Collection products = (CatalogEntityCollection) codec.getValueDecoder().decode(byteBuf, null); Assert.assertEquals(products, vc.getVersions().get(0).getCatalogEntityCollectionProduct()); }