@Override public boolean put(ObjectId objectId, InputStream raw) { Preconditions.checkNotNull(objectId); Preconditions.checkNotNull(raw); Preconditions.checkArgument(!objectId.isNull(), "ObjectId is NULL"); ByteArrayOutputStream rawOut = new ByteArrayOutputStream(); LZFOutputStream cOut = new LZFOutputStream(rawOut); try { ByteStreams.copy(raw, cOut); cOut.flush(); cOut.close(); } catch (IOException e) { throw Throwables.propagate(e); } final byte[] rawData = rawOut.toByteArray(); final boolean inserted = putInternal(objectId, rawData); return inserted; }
@Override public void write(RevObject o, OutputStream out) throws IOException { // compress the stream LZFOutputStream deflatedOutputStream = new LZFOutputStream(out); deflatedOutputStream.setFinishBlockOnFlush(true); factory.write(o, deflatedOutputStream); deflatedOutputStream.flush(); }
@Override public void write(RevObject o, OutputStream out) throws IOException { // compress the stream LZFOutputStream deflatedOutputStream = new LZFOutputStream(out); deflatedOutputStream.setFinishBlockOnFlush(true); factory.write(o, deflatedOutputStream); deflatedOutputStream.flush(); }
protected void writeObject(RevObject object, OutputStream target) { ObjectWriter<RevObject> writer = serializationFactory.createObjectWriter(object.getType()); LZFOutputStream cOut = new LZFOutputStream(target); try { writer.write(object, cOut); } catch (IOException e) { throw Throwables.propagate(e); } finally { try { cOut.flush(); cOut.close(); } catch (Exception e) { throw Throwables.propagate(e); } } int size = ((ByteArrayOutputStream) target).size(); //System.err.printf("%d,%s,%s\n", size, object.getId(), object.getType()); }
context.proceed(); } finally { if (lzfOutputStream.getLzf() != null) lzfOutputStream.getLzf().flush(); context.setOutputStream(old);