Class BundleWriter


  • public class BundleWriter
    extends java.lang.Object
    Write an object bundle stream to a file channel. Bundle streams that add new columns are not supported.
    Since:
    0.5.5
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int INITIAL_BUFFER
      Initial buffer size.
      private static Logging LOG
      Class logger for the bundle writer.
      static int MAGIC
      Random magic number.
    • Constructor Summary

      Constructors 
      Constructor Description
      BundleWriter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.nio.ByteBuffer ensureBuffer​(int size, java.nio.ByteBuffer buffer, java.nio.channels.WritableByteChannel output)
      Ensure the buffer is large enough.
      private void flushBuffer​(java.nio.ByteBuffer buffer, java.nio.channels.WritableByteChannel output)
      Flush the current write buffer to disk.
      void writeBundleStream​(BundleStreamSource source, java.nio.channels.WritableByteChannel output)
      Write a bundle stream to a file output channel.
      private ByteBufferSerializer<?>[] writeHeader​(BundleStreamSource source, java.nio.ByteBuffer buffer, java.nio.channels.WritableByteChannel output)
      Write the header for the given stream to the stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final Logging LOG
        Class logger for the bundle writer.
      • INITIAL_BUFFER

        private static final int INITIAL_BUFFER
        Initial buffer size.
        See Also:
        Constant Field Values
    • Constructor Detail

      • BundleWriter

        public BundleWriter()
    • Method Detail

      • writeBundleStream

        public void writeBundleStream​(BundleStreamSource source,
                                      java.nio.channels.WritableByteChannel output)
                               throws java.io.IOException
        Write a bundle stream to a file output channel.
        Parameters:
        source - Data source
        output - Output channel
        Throws:
        java.io.IOException - on IO errors
      • flushBuffer

        private void flushBuffer​(java.nio.ByteBuffer buffer,
                                 java.nio.channels.WritableByteChannel output)
                          throws java.io.IOException
        Flush the current write buffer to disk.
        Parameters:
        buffer - Buffer to write
        output - Output channel
        Throws:
        java.io.IOException - on IO errors
      • ensureBuffer

        private java.nio.ByteBuffer ensureBuffer​(int size,
                                                 java.nio.ByteBuffer buffer,
                                                 java.nio.channels.WritableByteChannel output)
                                          throws java.io.IOException
        Ensure the buffer is large enough.
        Parameters:
        size - Required size to add
        buffer - Existing buffer
        output - Output channel
        Returns:
        Buffer, eventually resized
        Throws:
        java.io.IOException - on IO errors
      • writeHeader

        private ByteBufferSerializer<?>[] writeHeader​(BundleStreamSource source,
                                                      java.nio.ByteBuffer buffer,
                                                      java.nio.channels.WritableByteChannel output)
                                               throws java.io.IOException
        Write the header for the given stream to the stream.
        Parameters:
        source - Bundle stream
        buffer - Buffer to use for writing
        output - Output channel
        Returns:
        Array of serializers
        Throws:
        java.io.IOException - on IO errors