public void write(OutputStream out, T object) { KryoContext kryoContext = KRYOS.get(); OutputChunked output = kryoContext.getOutputChunked(); output.setOutputStream(out); writeObject(kryoContext.getKryo(), output, object); output.endChunks(); output.flush(); }
/** Marks the end of some data that may have been written by any number of chunks. These chunks can then be skipped when * reading. */ public void endChunks () { flush(); // Flush any partial chunk. if (TRACE) trace("kryo", "End chunks."); try { getOutputStream().write(0); // Zero length chunk. } catch (IOException ex) { throw new KryoException(ex); } } }
public void flush () throws KryoException { if (position() > 0) { try { writeChunkSize(); } catch (IOException ex) { throw new KryoException(ex); } } super.flush(); }
public void write (Kryo kryo, Output output, Object object) { Deflater deflater = new Deflater(compressionLevel, noHeaders); OutputChunked outputChunked = new OutputChunked(output, 256); DeflaterOutputStream deflaterStream = new DeflaterOutputStream(outputChunked, deflater); Output deflaterOutput = new Output(deflaterStream, 256); kryo.writeObject(deflaterOutput, object, serializer); deflaterOutput.flush(); try { deflaterStream.finish(); } catch (IOException ex) { throw new KryoException(ex); } outputChunked.endChunks(); }
private void writeChunkSize () throws IOException { int size = position(); if (TRACE) trace("kryo", "Write chunk: " + size); OutputStream outputStream = getOutputStream(); if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; outputStream.write(size); }
protected KryoContext initialValue() { Kryo kryo = newKryoInstance(); OutputChunked output = new OutputChunked(BUFFER_SIZE); InputChunked input = new InputChunked(BUFFER_SIZE); return new KryoContext(kryo, input, output); } };
/** * Initialize reusable objects for writing into given DataOutput. * * @param out Output stream */ private void setDataOutput(DataOutput out) { dataOutputWrapperStream.setDataOutput(out); output.setOutputStream(dataOutputWrapperStream); }
public void write (Kryo kryo, Output output, Object object) { OutputChunked outputChunked = new OutputChunked(output, 256); Deflater deflater = new Deflater(compressionLevel, noHeaders); try { DeflaterOutputStream deflaterStream = new DeflaterOutputStream(outputChunked, deflater); Output deflaterOutput = new Output(deflaterStream, 256); serializer.write(kryo, deflaterOutput, object); deflaterOutput.flush(); deflaterStream.finish(); } catch (IOException ex) { throw new KryoException(ex); } finally { deflater.end(); } outputChunked.endChunks(); }
private void writeChunkSize () throws IOException { int size = position(); if (TRACE) trace("kryo", "Write chunk: " + size); OutputStream outputStream = getOutputStream(); if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; outputStream.write(size); }
public void write (Kryo kryo, Output output, Object object) { OutputChunked outputChunked = new OutputChunked(output, 256); Deflater deflater = new Deflater(compressionLevel, noHeaders); try { DeflaterOutputStream deflaterStream = new DeflaterOutputStream(outputChunked, deflater); Output deflaterOutput = new Output(deflaterStream, 256); serializer.write(kryo, deflaterOutput, object); deflaterOutput.flush(); deflaterStream.finish(); } catch (IOException ex) { throw new KryoException(ex); } finally { deflater.end(); } outputChunked.endChunks(); }
/** Marks the end of some data that may have been written by any number of chunks. These chunks can then be skipped when * reading. */ public void endChunks () { flush(); // Flush any partial chunk. if (TRACE) trace("kryo", "End chunks."); try { getOutputStream().write(0); // Zero length chunk. } catch (IOException ex) { throw new KryoException(ex); } } }
public void flush () throws KryoException { if (position() > 0) { try { writeChunkSize(); } catch (IOException ex) { throw new KryoException(ex); } } super.flush(); }
private void writeChunkSize () throws IOException { int size = position(); if (TRACE) trace("kryo", "Write chunk: " + size); OutputStream outputStream = getOutputStream(); if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; outputStream.write(size); }
public void write (Kryo kryo, Output output, Object object) { Deflater deflater = new Deflater(compressionLevel, noHeaders); OutputChunked outputChunked = new OutputChunked(output, 256); DeflaterOutputStream deflaterStream = new DeflaterOutputStream(outputChunked, deflater); Output deflaterOutput = new Output(deflaterStream, 256); kryo.writeObject(deflaterOutput, object, serializer); deflaterOutput.flush(); try { deflaterStream.finish(); } catch (IOException ex) { throw new KryoException(ex); } outputChunked.endChunks(); }
/** Marks the end of some data that may have been written by any number of chunks. These chunks can then be skipped when * reading. */ public void endChunks () { flush(); // Flush any partial chunk. if (TRACE) trace("kryo", "End chunks."); try { getOutputStream().write(0); // Zero length chunk. } catch (IOException ex) { throw new KryoException(ex); } } }
public void flush () throws KryoException { if (position() > 0) { try { writeChunkSize(); super.flush(); } catch (IOException ex) { throw new KryoException(ex); } } super.flush(); }
private void writeChunkSize () throws IOException { int size = position(); if (TRACE) trace("kryo", "Write chunk: " + size); OutputStream outputStream = getOutputStream(); if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; if ((size & ~0x7F) == 0) { outputStream.write(size); return; } outputStream.write((size & 0x7F) | 0x80); size >>>= 7; outputStream.write(size); }
public void write (Kryo kryo, Output output, T object) { CachedField[] fields = getFields(); output.writeVarInt(writeFieldCount, true); // Can be used for null. OutputChunked outputChunked = null; // only instantiate if needed for (int i = 0, n = fields.length; i < n; i++) { if (deprecated[i]) continue; output.writeVarInt(tags[i], true); if (annexed[i]){ if (outputChunked == null) outputChunked = new OutputChunked(output, 1024); fields[i].write(outputChunked, object); outputChunked.endChunks(); } else { fields[i].write(output, object); } } }
/** Marks the end of some data that may have been written by any number of chunks. These chunks can then be skipped when * reading. */ public void endChunks () { flush(); // Flush any partial chunk. if (TRACE) trace("kryo", "End chunks."); try { getOutputStream().write(0); // Zero length chunk. } catch (IOException ex) { throw new KryoException(ex); } } }