Class NetricsCompoundReader

  • All Implemented Interfaces:
    NetricsBaseRecSrc, NetricsCompoundRecSrc

    public class NetricsCompoundReader
    extends java.lang.Object
    implements NetricsCompoundRecSrc
    Read compound records from a set of record sources.

    Objects of this class provide a means of reading in compound records. A compound record is a parent record along with a set of zero or more child records. It may also be an orphan child record. This class builds compound records from a set of record sources. One source represents the parent table, zero or more additional sources represent the child tables. Each source is associated with a table name, all table names must be unique.

    To build compound records it is assumed that all sources are sorted by the parent record key. The child record sources are not sorted by their own key, they must be sorted by the parent record key. In this way the sources can be read in parallel and merged.

    • Constructor Detail

      • NetricsCompoundReader

        public NetricsCompoundReader​(java.lang.String parent_tbl_name,
                                     NetricsRecSrc parent_recs,
                                     boolean return_orphans)
                              throws java.lang.IllegalArgumentException,
                                     NetricsRecSrcException
        Create a compound record reader. This creates a compound record reader. It is created with a single parent table. Child tables must be added using the addChildTable method.
        Parameters:
        parent_tbl_name - the name of the parent table.
        parent_recs - a record source that provides parent records. The records MUST be provided in sort order of the record keys.
        return_orphans - if this is true orphan child records are returned as a NetricsCompoundRecord with no children. If this is false orphan child records are quietly skipped.
        Throws:
        java.lang.IllegalArgumentException - if any argument is null or the parent table name is empty (zero length).
        NetricsRecSrcException - if there is an error reading the first parent record.
    • Method Detail

      • addChildTable

        public void addChildTable​(java.lang.String child_tbl_name,
                                  NetricsRecSrc child_recs)
                           throws java.lang.IllegalArgumentException,
                                  NetricsRecSrcException
        add a new child table to this compound record reader. This is used to add a child table to this compound record reader. This call should be made before any records are read, but this is not enforced.
        Parameters:
        child_tbl_name - the name of the child table. This must not be the same as the name of the parent table or any existing child table.
        child_recs - this is the source of child records. The records returned by this source should be child records. The records must be returned in sort order of the parent key.
        Throws:
        java.lang.IllegalArgumentException - if either argument is null, the table name is zero length, the table name is the same as the parent table or an existing child table.
        NetricsRecSrcException - if there is an error reading the first record.
      • getPosition

        @Deprecated
        public int getPosition()
        Deprecated.
        Returns:
        an indicator of the current position in the scan.
      • getCount

        public java.lang.Integer getCount()
        Description copied from interface: NetricsBaseRecSrc
        Get the count of records that have been retrieved from the record source.
        Sources that don't support a count will return null.
        Specified by:
        getCount in interface NetricsBaseRecSrc
        Returns:
        The number of records that have been retrieved from the record source.
      • getParentTable

        public java.lang.String getParentTable()
        Specified by:
        getParentTable in interface NetricsCompoundRecSrc
        Returns:
        the parent/primary table name for the compound record.
      • getChildTables

        public java.util.List<java.lang.String> getChildTables()
        Description copied from interface: NetricsCompoundRecSrc
        return a list of child table names used. This list represents all possible child tables. Any particular compound record returned may not contain child records for all of these tables.
        Specified by:
        getChildTables in interface NetricsCompoundRecSrc
        Returns:
        the list of child table names.