Class KryoMemoryWriter<T>

java.lang.Object
com.linkedin.dagli.objectio.kryo.KryoMemoryWriter<T>
Type Parameters:
T - the type of element in the iterable
All Implemented Interfaces:
ObjectWriter<T>, it.unimi.dsi.fastutil.Size64, java.lang.AutoCloseable

public class KryoMemoryWriter<T>
extends java.lang.Object
A writer that writes Kryo-serialized objects to memory.
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected com.linkedin.dagli.objectio.kryo.AbstractKryoWriter.Config _config  
    protected com.esotericsoftware.kryo.kryo5.io.Output _output  
    protected com.linkedin.dagli.objectio.kryo.AbstractKryoWriter.ManuallyFlushedOutputStream _proximateOutputStream  
  • Constructor Summary

    Constructors
    Constructor Description
    KryoMemoryWriter()
    Creates an instance that will use memory as its backing store.
    KryoMemoryWriter​(com.linkedin.dagli.objectio.kryo.AbstractKryoWriter.Config config)
    Creates an instance that will use memory as its backing store.
  • Method Summary

    Modifier and Type Method Description
    void close()
    Called when no more items will be appended.
    ObjectReader<T> createReader()
    Creates a reader that can read the data written by this writer, once the writer is closed.
    long size64()
    Gets the number of elements that have been written to this ObjectWriter.
    void write​(T obj)
    Appends a single item to this ObjectWriter
    protected void writeCount​(long count)
    Stores the total number of objects written to this writer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.linkedin.dagli.objectio.ObjectWriter

    write, write, writeAll, writeAll

    Methods inherited from interface it.unimi.dsi.fastutil.Size64

    size
  • Field Details

    • _output

      protected com.esotericsoftware.kryo.kryo5.io.Output _output
    • _proximateOutputStream

      protected com.linkedin.dagli.objectio.kryo.AbstractKryoWriter.ManuallyFlushedOutputStream _proximateOutputStream
    • _config

      protected com.linkedin.dagli.objectio.kryo.AbstractKryoWriter.Config _config
  • Constructor Details

    • KryoMemoryWriter

      public KryoMemoryWriter()
      Creates an instance that will use memory as its backing store.
    • KryoMemoryWriter

      public KryoMemoryWriter​(com.linkedin.dagli.objectio.kryo.AbstractKryoWriter.Config config)
      Creates an instance that will use memory as its backing store.
      Parameters:
      config - the config to use
  • Method Details

    • writeCount

      protected void writeCount​(long count)
      Stores the total number of objects written to this writer. This is only called by AbstractKryoWriter once, when the writer is closed.
      Parameters:
      count - the number of objects written
    • createReader

      public ObjectReader<T> createReader()
      Description copied from interface: ObjectWriter
      Creates a reader that can read the data written by this writer, once the writer is closed. If called before the writer is closed and the writer does not support retrieving a "partial" reader, an IllegalStateException should be thrown. If a reader is returned, it must be able to read all the elements written thus far; whether or not the reader can read elements written subsequently is implementation-dependent.
      Returns:
      an ObjectReader that can read all the elements written thus far
    • write

      public void write​(T obj)
      Description copied from interface: ObjectWriter
      Appends a single item to this ObjectWriter
      Specified by:
      write in interface ObjectWriter<T>
      Parameters:
      obj - the item to be appended
    • close

      public void close()
      Description copied from interface: ObjectWriter
      Called when no more items will be appended. Further operations on this ObjectWriter, except for calls to createReader, are undefined.
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface ObjectWriter<T>
    • size64

      public long size64()
      Description copied from interface: ObjectWriter
      Gets the number of elements that have been written to this ObjectWriter. For ObjectWriters that are appending to data not written by this instance, this should include the number of pre-existing items, too. In other words, the returned size should match the size64() of the ObjectReader that would be returned by ObjectWriter.createReader().
      Specified by:
      size64 in interface ObjectWriter<T>
      Specified by:
      size64 in interface it.unimi.dsi.fastutil.Size64
      Returns:
      the number of elements written