Interface ByteArrayDecoder<T>

  • Type Parameters:
    T - The decoded item data type
    All Known Subinterfaces:
    ByteArrayCodec<T>
    All Known Implementing Classes:
    DelegatingByteArrayCodec

    public interface ByteArrayDecoder<T>
    A functional interface for decoders working on byte arrays representing single items. In contract to ItemDecoder, this decoder should always be stateless, and is suitable for cases where the data to decode is already in an array, whose bytes encode a single item to decode.
    Author:
    Eyal Schneider
    • Method Detail

      • decode

        T decode​(byte[] bytes)
          throws ValidationPipeException
        Parameters:
        bytes - The byte representation of an item to decode
        Returns:
        The decoded item
        Throws:
        ValidationPipeException - In case that the data for decoding is illegal
      • newFixedRecSizeDecoder

        default ItemDecoder<T> newFixedRecSizeDecoder​(InputStream is,
                                                      FileReadOptions readOptions,
                                                      int recSize)
                                               throws IOException
        Returns an efficient ItemDecoder based on this byte array decoder, assuming a fixed record size.
        Parameters:
        is - The input stream to build the decoder for
        readOptions - The read options defining how the input stream should be manipulated
        recSize - The fixed record size
        Returns:
        A new item decoder based on the given input stream, and using this byte array decoder under the hood
        Throws:
        IOException - In case of IO error while preparing to read from the input stream