Class AbstractPagedOutputView

    • Field Detail

      • segmentSize

        protected final int segmentSize
      • headerLength

        protected final int headerLength
    • Constructor Detail

      • AbstractPagedOutputView

        protected AbstractPagedOutputView​(MemorySegment initialSegment,
                                          int segmentSize,
                                          int headerLength)
        Creates a new output view that writes initially to the given initial segment. All segments in the view have to be of the given segmentSize. A header of length headerLength is left at the beginning of each segment.
        Parameters:
        initialSegment - The segment that the view starts writing to.
        segmentSize - The size of the memory segments.
        headerLength - The number of bytes to skip at the beginning of each segment for the header.
      • AbstractPagedOutputView

        protected AbstractPagedOutputView​(int segmentSize,
                                          int headerLength)
        Parameters:
        segmentSize - The size of the memory segments.
        headerLength - The number of bytes to skip at the beginning of each segment for the header.
    • Method Detail

      • nextSegment

        protected abstract MemorySegment nextSegment​(MemorySegment current,
                                                     int positionInCurrent)
                                              throws IOException
        This method must return a segment. If no more segments are available, it must throw an EOFException.
        Parameters:
        current - The current memory segment
        positionInCurrent - The position in the segment, one after the last valid byte.
        Returns:
        The next memory segment.
        Throws:
        IOException
      • getCurrentSegment

        public MemorySegment getCurrentSegment()
        Gets the segment that the view currently writes to.
        Returns:
        The segment the view currently writes to.
      • getCurrentPositionInSegment

        public int getCurrentPositionInSegment()
        Gets the current write position (the position where the next bytes will be written) in the current memory segment.
        Returns:
        The current write offset in the current memory segment.
      • getSegmentSize

        public int getSegmentSize()
        Gets the size of the segments used by this view.
        Returns:
        The memory segment size.
      • advance

        public void advance()
                     throws IOException
        Moves the output view to the next page. This method invokes internally the nextSegment(MemorySegment, int) method to give the current memory segment to the concrete subclass' implementation and obtain the next segment to write to. Writing will continue inside the new segment after the header.
        Throws:
        IOException - Thrown, if the current segment could not be processed or a new segment could not be obtained.
      • getHeaderLength

        public int getHeaderLength()
        Returns:
        header length.
      • seekOutput

        protected void seekOutput​(MemorySegment seg,
                                  int position)
        Sets the internal state to the given memory segment and the given position within the segment.
        Parameters:
        seg - The memory segment to write the next bytes to.
        position - The position to start writing the next bytes to.
      • skipBytesToWrite

        public void skipBytesToWrite​(int numBytes)
                              throws IOException
        Description copied from interface: DataOutputView
        Skips numBytes bytes memory. If some program reads the memory that was skipped over, the results are undefined.
        Specified by:
        skipBytesToWrite in interface DataOutputView
        Parameters:
        numBytes - The number of bytes to skip.
        Throws:
        IOException - Thrown, if any I/O related problem occurred such that the view could not be advanced to the desired position.
      • write

        public void write​(DataInputView source,
                          int numBytes)
                   throws IOException
        Description copied from interface: DataOutputView
        Copies numBytes bytes from the source to this view.
        Specified by:
        write in interface DataOutputView
        Parameters:
        source - The source to copy the bytes from.
        numBytes - The number of bytes to copy.
        Throws:
        IOException - Thrown, if any I/O related problem occurred, such that either the input view could not be read, or the output could not be written.
      • write

        public void write​(MemorySegment segment,
                          int off,
                          int len)
                   throws IOException
        Description copied from interface: MemorySegmentWritable
        Writes len bytes from memory segment segment starting at offset off, in order, to the output.
        Specified by:
        write in interface MemorySegmentWritable
        Parameters:
        segment - memory segment to copy the bytes from.
        off - the start offset in the memory segment.
        len - The number of bytes to copy.
        Throws:
        IOException - if an I/O error occurs.