Class BCF2Decoder


  • public final class BCF2Decoder
    extends Object
    • Constructor Detail

      • BCF2Decoder

        public BCF2Decoder()
      • BCF2Decoder

        protected BCF2Decoder​(byte[] recordBytes)
        Create a new decoder ready to read BCF2 data from the byte[] recordBytes, for testing purposes
        Parameters:
        recordBytes -
    • Method Detail

      • readNextBlock

        public void readNextBlock​(int blockSizeInBytes,
                                  InputStream stream)
        Reads the next record from input stream and prepare this decoder to decode values from it
        Parameters:
        stream -
      • skipNextBlock

        public void skipNextBlock​(int blockSizeInBytes,
                                  InputStream stream)
        Skips the next record from input stream, invalidating current block data
        Parameters:
        stream -
      • getRecordBytes

        public byte[] getRecordBytes()
        Returns the byte[] for the block of data we are currently decoding
        Returns:
      • getBlockSize

        public int getBlockSize()
        The size of the current block in bytes
        Returns:
      • blockIsFullyDecoded

        public boolean blockIsFullyDecoded()
      • setRecordBytes

        public void setRecordBytes​(byte[] recordBytes)
        Use the recordBytes[] to read BCF2 records from now on
        Parameters:
        recordBytes -
      • decodeNumberOfElements

        public final int decodeNumberOfElements​(byte typeDescriptor)
                                         throws IOException
        Throws:
        IOException
      • decodeInt

        public final int decodeInt​(byte typeDescriptor,
                                   int missingValue)
                            throws IOException
        Decode an int from the stream. If the value in the stream is missing, returns missingValue. Requires the typeDescriptor indicate an inline single element event
        Parameters:
        typeDescriptor -
        Returns:
        Throws:
        IOException
      • decodeIntArray

        public final int[] decodeIntArray​(int size,
                                          BCF2Type type,
                                          int[] maybeDest)
                                   throws IOException
        Low-level reader for int[] Requires a typeDescriptor so the function knows how many elements to read, and how they are encoded. If size == 0 => result is null If size > 0 => result depends on the actual values in the stream -- If the first element read is MISSING, result is null (all values are missing) -- Else result = int[N] where N is the first N non-missing values decoded
        Parameters:
        maybeDest - if not null we'll not allocate space for the vector, but instead use the externally allocated array of ints to store values. If the size of this vector is < the actual size of the elements, we'll be forced to use freshly allocated arrays. Also note that padded int elements are still forced to do a fresh allocation as well.
        Returns:
        see description
        Throws:
        IOException
      • decodeIntArray

        public final int[] decodeIntArray​(byte typeDescriptor,
                                          int size)
                                   throws IOException
        Throws:
        IOException
      • readBlockSize

        public final int readBlockSize​(InputStream inputStream)
                                throws IOException
        Read the size of the next block from inputStream
        Parameters:
        inputStream -
        Returns:
        Throws:
        IOException