@Override public RevObject read(ObjectId id, InputStream rawData) throws IOException { // decompress the stream LZFInputStream inflatedInputeStream = new LZFInputStream(CHUNK_DECODER, rawData); return factory.read(id, inflatedInputeStream); }
@Override public RevObject read(ObjectId id, InputStream rawData) throws IOException { // decompress the stream LZFInputStream inflatedInputeStream = new LZFInputStream(CHUNK_DECODER, rawData); return factory.read(id, inflatedInputeStream); }
@Nullable private InputStream getRaw(final ObjectId id, boolean failIfNotFound) throws IllegalArgumentException { InputStream in = getRawInternal(id, failIfNotFound); if (null == in) { return null; } try { return new LZFInputStream(in); } catch (IOException e) { throw Throwables.propagate(e); } }
/** * Tries to efficiently allocate the response string if the "Content-Length" * header is set. */ private String readResponseStream(InputStream responseStream, HttpURLConnection connection) throws IOException { LOGGER.debug("Reading response stream"); InputStream decodedStream = responseStream; if (compression == Compression.LZF && "lzf".equals(connection.getHeaderField("Content-Encoding"))) { LOGGER.debug("Decoding lzf"); decodedStream = new LZFInputStream(responseStream); } int contentLength = connection.getContentLength(); if (contentLength == 0) { return ""; } else { return new String(ByteStreams.toByteArray(decodedStream), UTF_8); } }
private static InputStream wrapInputStream(InputStream inputStream) throws IOException { switch (GZTYPE) { case 0: // no compression return inputStream; case 1: // LZF return new LZFInputStream(inputStream); case 2: // Snappy return new SnappyInputStream(inputStream); default: throw new RuntimeException("Unknown compression type: " + GZTYPE); } }
private RevObject fromBytes(ObjectId id, byte[] buffer) { ByteArrayInputStream byteStream = new ByteArrayInputStream(buffer); RevObject result; try { result = serializers.createObjectReader().read(id, new LZFInputStream(byteStream)); } catch (Exception e) { throw Throwables.propagate(e); } return result; }
public static InputStream uncompressingStream(InputStream in, Compression comp) throws IOException { if (comp != null) { switch (comp) { case NONE: break; case LZF: return new LZFInputStream(in); case GZIP: return new OptimizedGZIPInputStream(in); default: // sanity check throw new IllegalArgumentException("Unrecognized compression type: "+comp); } } return in; }
@Override public InputStream executeRequestGetStream(LightblueRequest request, String baseUri) throws LightblueHttpClientException { HttpURLConnection connection = prepareConnection(request,baseUri); try { InputStream stream=connection.getInputStream(); if (compression == Compression.LZF && "lzf".equals(connection.getHeaderField("Content-Encoding"))) { LOGGER.debug("Decoding lzf"); stream = new LZFInputStream(stream); } return stream; } catch (IOException e) { return new StringBufferInputStream(readErrorStream(connection,e)); } }
public static @Nonnull InputStream decompressInputStream(@Nonnull InputStream in, @Nonnull String name) throws IOException { if (name.endsWith(CompressionType.GZIP.suffix)) { in = new GZIPInputStreamX(in, BUFFER_SIZE); } else if (name.endsWith(CompressionType.LZF.suffix)) { in = new LZFInputStream(in); } else if (name.endsWith(CompressionType.SNAPPY.suffix)) { in = new SnappyInputStream(in); } else if (name.endsWith(CompressionType.BZIP2.suffix)) { in = new BZip2CompressorInputStream(in, true); } else if (name.endsWith(CompressionType.LZMA.suffix)) { in = new LZMAInputStream(in); } else if (name.endsWith(CompressionType.XZ.suffix)) { in = new XZInputStream(in); } return in; }
in = ByteStreams.limit(in, streamLimit); if (this.compress) { in = new LZFInputStream(in);
in = ByteStreams.limit(in, streamLimit); if (this.compress) { in = new LZFInputStream(in);
/** * Gets the raw input stream of the object with the given {@link ObjectId id}. * * @param id the id of the object to get * @return the input stream of the object */ @Override public final InputStream getRaw(final ObjectId id) throws IllegalArgumentException { InputStream in = getRawInternal(id, false); if (in != null) { try { return new LZFInputStream(in); } catch (IOException e) { throw Throwables.propagate(e); } } return repositoryDb.getRaw(id); }
public static void decompress(InputStream in, OutputStream out) throws IOException { LZFInputStream decompressor = null; try { decompressor = new LZFInputStream(in); byte[] buf = ThreadLocalByteBuffer.getBuffer(); int len; while ((len = decompressor.read(buf)) != -1) { out.write(buf, 0, len); } } finally { if (decompressor != null) { decompressor.close(); } } }
break; case 3: in = new LZFInputStream(in); break; case 4:
/** * Check if content encoding is LZF. * <p/>If encoding is LZF, wrap the InputStream for that message in LZFInputStream to decode it * @param context Context for HTTP request/response * @return context.proceed() * @throws IOException * @throws WebApplicationException */ public Object read(MessageBodyReaderContext context) throws IOException, WebApplicationException { Object encoding = context.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING); if (encoding != null && encoding.toString().equalsIgnoreCase("lzf")) { InputStream old = context.getInputStream(); LZFInputStream is = new LZFInputStream(old); context.setInputStream(is); try { return context.proceed(); } finally{ context.setInputStream(old); } } else { return context.proceed(); } } }
break; case 3: in = new LZFInputStream(in); break; case 4:
LZFInputStream lzfIn = new LZFInputStream(counter); try { lzfIn.readAndWrite(out);
cfs.getColumnFamilyName()); DataInputStream dis = new DataInputStream(new LZFInputStream(Channels.newInputStream(channel))); BytesReadTracker in = new BytesReadTracker(dis); SSTableWriter writer = null;
cfs.getColumnFamilyName()); TrackedInputStream in = new TrackedInputStream(new LZFInputStream(Channels.newInputStream(channel))); StreamDeserializer deserializer = new StreamDeserializer(cfs.metadata, in, inputVersion, getHeader(cfs.metadata), totalSize, session.planId());
cfs.getColumnFamilyName()); TrackedInputStream in = new TrackedInputStream(new LZFInputStream(Channels.newInputStream(channel))); StreamDeserializer deserializer = new StreamDeserializer(cfs.metadata, in, inputVersion, getHeader(cfs.metadata), totalSize, session.planId());