Class UnsafeBufferWriter<S>

java.lang.Object
com.jozufozu.flywheel.backend.struct.BufferWriter<S>
com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter<S>
All Implemented Interfaces:
StructWriter<S>
Direct Known Subclasses:
BasicWriterUnsafe

public abstract class UnsafeBufferWriter<S> extends BufferWriter<S>
This class copied/adapted from jellysquid's An unsafe BufferWriter implementation which uses direct memory operations to enable fast blitting of data into memory buffers. Only available on JVMs which support Unsafe, but generally produces much better optimized code than other implementations. The implementation does not check for invalid memory accesses, meaning that errors can corrupt process memory.
  • Field Details

    • writePointer

      protected long writePointer
      The write pointer into the buffer storage. This is advanced by the stride every time advance() is called.
  • Constructor Details

    • UnsafeBufferWriter

      protected UnsafeBufferWriter(VecBuffer backingBuffer, StructType<S> vertexType)
  • Method Details

    • seek

      public void seek(int pos)
      Description copied from interface: StructWriter
      Seek to the given position. The next write will occur there.
      Specified by:
      seek in interface StructWriter<S>
      Overrides:
      seek in class BufferWriter<S>
    • advance

      protected void advance()
      Description copied from class: BufferWriter
      Advances the write pointer forward by the stride of one vertex. This will always be called after a struct is written, implementors need not call it themselves.
      Specified by:
      advance in class BufferWriter<S>
      See Also: