Interface DecoderFactory<T>

  • Type Parameters:
    T - The decoded items' data type
    All Known Subinterfaces:
    CodecFactory<T>
    All Known Implementing Classes:
    AvroCodecFactory, DelegatingCodecFactory, SimpleDecoderFactory, TxtCodecFactory, TxtDecoderFactory

    public interface DecoderFactory<T>
    Allows creating ItemDecoder instances of some specific type. This is the preferred type to be given to pipes. This allows the pipe to create dynamically as many instances as needed, thus solving threading issues and state issues easily. This interface includes a getByteArrayDecoder(..) method with default implementation. This decoder serves for decoding individual items which are given as byte arrays rather than being part of an input stream. The default implementation is not very efficient, and sub-classes are encouraged to override it.
    Author:
    Eyal Schneider
    • Method Detail

      • newDecoder

        ItemDecoder<T> newDecoder​(InputStream is,
                                  FileReadOptions readOptions)
                           throws IOException
        Parameters:
        is - The input stream the decoder should be bound to. Not expected to be buffered. Buffering is added by the decoder.
        readOptions - defines how the input stream should be handled
        Returns:
        The new decoder
        Throws:
        IOException - In case of an IO error while preparing to read from the input stream
      • newDecoder

        default ItemDecoder<T> newDecoder​(InputStream is)
                                   throws IOException
        Parameters:
        is - The input stream the decoder should be bound to
        Returns:
        The new decoder
        Throws:
        IOException - In case of an IO error while preparing to read from the input stream
      • newByteArrayDecoder

        default ByteArrayDecoder<T> newByteArrayDecoder()
        Returns:
        A new ByteArrayDecoder, able to efficiently decode individual items from byte arrays. The default implementation goes through a ByteArrayInputStream and is not very efficient, so sub-classes are encouraged to override it when a faster alternative is available.