Interface NetricsRecSrc
-
- All Superinterfaces:
NetricsBaseRecSrc
- All Known Implementing Classes:
NetricsArrayRecSrc
,NetricsCSVRecSrc
,NetricsTableCursorRecSrc
public interface NetricsRecSrc extends NetricsBaseRecSrc
Generic interface for reading records.This interface defines how sets of single table records are passed in the API. When a constructor or method needs a set of simple records it expects an object that implements this interface. By creating a class that implements this interface the user can feed records from any source directly into the API. The API can then stream these records into the engine. For example an implementation of NetricsRecSrc that takes in a JDBC ResultSet and feeds out the records from the result set in the getNext method would allow records to be streamed from any JDBC enabled DBMS into a ibi™ Patterns - Search table. If a server side cursor was used any number of records could be streamed without incurring a large memory overhead in the Java application. E.g.:
class JDBCRecSrc implements NetricsRecSrc { ... public JDBCRecSrc(ResultSet rs) { ... } ... } ... NetricsConMgr ncm = new NetricsConMgr() ; NetricsServerInterface nsi = ncm.newConnection() ; Connection con = ConnectionFactory.getNewConnection() ; con.setAutoCommit(false) ; Statement st = con.createStatement() ; st.setFetchSize(50) ; ResultSet rs = st.executeQuery("SELECT * FROM dbmstable") ; JDBCRecSrc jdbcrecs = new JDBCRecSrc(rs) ; NetricsTableStats tblstat = nsi.recadd("patternstable",jdbcrecs,true); rs.close() ; st.close() ; ...
If the JDBC driver supports server side cursors this will add all of the records in dbmstable to the table patternstable on the ibi™ Patterns - Search Engine, holding no more than 50 records at a time on the client. Of course there may be practical reasons, such as error recovery, why streaming a large table in a single command may be undesireable, but this shows the power of taking advantage of the NetricsTableRecSrc interface.The Java interface comes with two predefined implementations of the NetricsRecSrc interface: NetricsArrayRecSrc is a simple array of records, NetricsCSVRecSrc reads records from a standard format CSV file.
- See Also:
NetricsArrayRecSrc
,NetricsCSVRecSrc
,NetricsBaseRecSrc
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description NetricsRecord
getNext()
Returns the next record.-
Methods inherited from interface com.netrics.likeit.NetricsBaseRecSrc
getCount, hasNext, reset
-
-
-
-
Method Detail
-
getNext
NetricsRecord getNext() throws NetricsRecSrcException
Returns the next record. This restricts the record returned to a single table record.- Specified by:
getNext
in interfaceNetricsBaseRecSrc
- Returns:
- the next record
- Throws:
NetricsRecSrcException
- if an error occurs, or if there are no more records.
-
-