public class NetricsCompoundReader extends java.lang.Object implements NetricsCompoundRecSrc
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 and Description |
|---|
NetricsCompoundReader(java.lang.String parent_tbl_name,
NetricsRecSrc parent_recs,
boolean return_orphans)
Create a compound record reader.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChildTable(java.lang.String child_tbl_name,
NetricsRecSrc child_recs)
add a new child table to this compound record reader.
|
java.util.List<java.lang.String> |
getChildTables()
return a list of child table names used.
|
NetricsCompoundRecord |
getNext()
return the next record.
|
java.lang.String |
getParentTable() |
int |
getPosition() |
boolean |
hasNext()
Implement the hasNext method.
|
void |
reset()
Implement the reset method.
|
public NetricsCompoundReader(java.lang.String parent_tbl_name,
NetricsRecSrc parent_recs,
boolean return_orphans)
throws java.lang.IllegalArgumentException,
NetricsRecSrcException
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.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.public void addChildTable(java.lang.String child_tbl_name,
NetricsRecSrc child_recs)
throws java.lang.IllegalArgumentException,
NetricsRecSrcException
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.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.public NetricsCompoundRecord getNext() throws NetricsRecSrcException
getNext in interface NetricsBaseRecSrcgetNext in interface NetricsCompoundRecSrcNetricsRecSrcException - if there is an error on any of the
underlying readers when reading the next record.public boolean hasNext()
throws NetricsRecSrcException
hasNext in interface NetricsBaseRecSrcNetricsRecSrcException - if an error occurs.public void reset()
throws NetricsRecSrcException
reset in interface NetricsBaseRecSrcNetricsRecSrcException - if an error occurs, or if the record
source does not support resetting.public int getPosition()
public java.lang.String getParentTable()
getParentTable in interface NetricsCompoundRecSrcpublic java.util.List<java.lang.String> getChildTables()
NetricsCompoundRecSrcgetChildTables in interface NetricsCompoundRecSrc