Class FeedSimTupleInputStream

All Implemented Interfaces:
Closeable, AutoCloseable

public abstract class FeedSimTupleInputStream extends FeedSimCSVInputStream
FeedSim can be configured to use classes that extend this abstract class. This allows users to read proprietary formatted files and deliver their contents so that FeedSim can play their data like any other product supported format.

This interface may be helpful for proprietary data formats where converting to CSV is relatively expensive when compared with using native data types and converting directly to a StreamBase tuple.

This class provides an implementation of the read() method declared in the superclass. However in 7.5.4 and beyond, the read() method is no longer used. The implementation here calls "readTuple()" and converts each Tuple to a sequence of "char"s in CSV format, with those chars yielded by "read()" one at a time. Though not used by FeedSim or the FeedSim editor in Studio, the "read()" method is provided as a convenience, if the equivalent CSV data is desired. In 7.5.4 and beyond, configuration of a FeedSim file that uses this kind of plugin is similar to a FeedSim file configuration via a CSV file that includes a header, however the "getSchema()" field names are used instead of the CSV header names. Also the column strings in a CSV file are replaced by the field values in the "readTuple()" results. Also, in 7.5.4, mapping to destination fields is required, and done by-name. Before 7.5.4, the read() method was still used in the FeedSim editor to display preview contents, etc. If the Timestamp builder was used, then the readTuple() method was not be called, and data was only delivered via the read() method. Also, before 7.5.4, by-name field to simulation field mapping was not supported: only by-index, when the index mappings were incrementing by 1, starting at 1 (1, 2, 3...) was supported.

Since:
6.5.8
  • Constructor Details

    • FeedSimTupleInputStream

      public FeedSimTupleInputStream(String path) throws IOException
      Constructor
      Parameters:
      path - - path of the file to open
      Throws:
      IOException - I/O error
  • Method Details

    • getSchema

      public abstract Schema getSchema() throws StreamBaseException
      This method must return the Schema of the data to be returned by readTuple()
      Returns:
      The Schema of the data to be returned by readTuple()
      Throws:
      StreamBaseException - Error accessing schema
    • readTuple

      public abstract Tuple readTuple() throws StreamBaseException
      This method is called by a FeedSim thread to get the next tuple to send. A null returned means end of data.
      Returns:
      Next Tuple to be sent to the FeedSim Stream
      Throws:
      StreamBaseException - Error reading tuple
    • read

      public int read() throws IOException
      Provide a default implementation for the required read() method that uses the readTuple implementation.
      Specified by:
      read in class InputStream
      Returns:
      the next character in the CSV representation of the input
      Throws:
      IOException
      Since:
      7.4
    • close

      public void close() throws IOException
      Close that cleans up the default read() state
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException
      Since:
      7.4