use of net.jpountz.lz4.LZ4FastDecompressor in project druid by druid-io.
the class LZ4Transcoder method decompress.
@Override
protected byte[] decompress(byte[] in) {
byte[] out = null;
if (in != null) {
LZ4FastDecompressor decompressor = lz4Factory.fastDecompressor();
int size = ByteBuffer.wrap(in).getInt();
out = new byte[size];
decompressor.decompress(in, Ints.BYTES, out, 0, out.length);
}
return out == null ? null : out;
}
use of net.jpountz.lz4.LZ4FastDecompressor in project cassandra by apache.
the class IncomingTcpConnection method receiveMessages.
// Not closing constructed DataInputPlus's as the stream needs to remain open.
@SuppressWarnings("resource")
private void receiveMessages() throws IOException {
// handshake (true) endpoint versions
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
// if this version is < the MS version the other node is trying
// to connect with, the other node will disconnect
out.writeInt(MessagingService.current_version);
out.flush();
DataInputPlus in = new DataInputStreamPlus(socket.getInputStream());
int maxVersion = in.readInt();
// outbound side will reconnect if necessary to upgrade version
assert version <= MessagingService.current_version;
from = CompactEndpointSerializationHelper.deserialize(in);
// record the (true) version of the endpoint
MessagingService.instance().setVersion(from, maxVersion);
logger.trace("Set version for {} to {} (will use {})", from, maxVersion, MessagingService.instance().getVersion(from));
if (compressed) {
logger.trace("Upgrading incoming connection to be compressed");
LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
Checksum checksum = XXHashFactory.fastestInstance().newStreamingHash32(OutboundTcpConnection.LZ4_HASH_SEED).asChecksum();
in = new DataInputStreamPlus(new LZ4BlockInputStream(socket.getInputStream(), decompressor, checksum));
} else {
ReadableByteChannel channel = socket.getChannel();
in = new NIODataInputStream(channel != null ? channel : Channels.newChannel(socket.getInputStream()), BUFFER_SIZE);
}
while (true) {
MessagingService.validateMagic(in.readInt());
receiveMessage(in, version);
}
}
use of net.jpountz.lz4.LZ4FastDecompressor in project SilverKing by Morgan-Stanley.
the class LZ4 method decompress.
public byte[] decompress(byte[] value, int offset, int length, int uncompressedLength) throws IOException {
LZ4FastDecompressor decompressor;
byte[] restored;
decompressor = factory.fastDecompressor();
restored = new byte[uncompressedLength];
decompressor.decompress(value, offset, restored, 0, uncompressedLength);
return restored;
}
use of net.jpountz.lz4.LZ4FastDecompressor in project vespa by vespa-engine.
the class NormalSketch method onDeserialize.
@Override
protected void onDeserialize(Deserializer buf) {
super.onDeserialize(buf);
int length = buf.getInt(null);
int compressedLength = buf.getInt(null);
Preconditions.checkState(length == data.length, "Size of serialized sketch does not match expected value. Expected %s, actual %s.", data.length, length);
if (length == compressedLength) {
deserializeDataArray(data, length, buf);
} else {
LZ4FastDecompressor c = LZ4Factory.safeInstance().fastDecompressor();
byte[] compressedData = buf.getBytes(null, compressedLength);
c.decompress(compressedData, data);
}
}
use of net.jpountz.lz4.LZ4FastDecompressor in project druid by druid-io.
the class LZ4Transcoder method decompress.
@Override
protected byte[] decompress(byte[] in) {
byte[] out = null;
if (in != null) {
LZ4FastDecompressor decompressor = lz4Factory.fastDecompressor();
int size = ByteBuffer.wrap(in).getInt();
out = new byte[size];
decompressor.decompress(in, Integer.BYTES, out, 0, out.length);
}
return out == null ? null : out;
}
Aggregations