See: Description
Package | Description |
---|---|
com.netrics.likeit |
Package Contents
The Java interface is delivered as a ZIP archive. The root directory
within the archive is named:
"Netrics-Server-M.N-Java-Interface-M.N.I"
Where M, N and I are the Major, Minor and Incremental
release levels respectively. Under this directory are the following:
Installation
There are two choices for installation:
Copy the com directory and all its contents to a directory
on your Java class path.
Copy the jar file to a location of your choice and add an entry
to your Java class path for the jar file.
See the sample program documentation: "NSCGuide-<M.N.I>.pdf" in the sample directory for instructions on running the sample program.
The interface is compiled to be compatible with Java release 1.5 or higher. Your Java engine and compiler must support release 1.5 or higher in order to use this interface.
The sample program uses the apache common routines for command line parsing, which is packaged in the executable jar file and is distributed under the apache license.
Interface Overview
Before describing the interface a brief description of what the matching
engine does may be helpful in understanding it.
The TIBCO Patterns Engine is an in-memory database which uses
patented advanced matching technology to search data with a tolerance
for errors. Data is stored as records which have field structure.
A field can be a number of types, including integer,
float, date, date/time, text and
searchable text. Error tolerant matching can only be performed
on searchable text fields (exact matching can be performed on
any field type). All fields will be returned from the matching
engine whenever a record is accessed. Records also must include a
record key which is a unique, user-specified id for the record.
Records are grouped into tables much the same way as within a DBMS
system with all records within a table having the same field structure.
It's important to point out that there are four basic versions of the
matching engine. Not all features described here are applicable to
every version. The three basic versions are:
The NetricsServerInterface object and its auxiliary objects:
The NetricsServerInterface object is the core object of the TIBCO Patterns Engine Java interface. It is the only object one can use to communicate with a TIBCO Patterns Engine. All operations (e.g. creating a table, adding a record, and searching a table) happen through the NetricsServerInterface object. The auxiliary objects - NetricsRecord, NetricsSearchOpts, and the other objects - are only used as parameters passed to or returned from a NetricsServerInterface object.
Other than maintaining the connection information, the NetricsServerInterface object is entirely stateless. That is, no information is stored in the object, and the object requires no memory overhead other than that required for the object itself. All data is stored in the TIBCO Patterns Engine. The NetricsServerInterface object serves only to transport the information supplied to it in the auxiliary objects (NetricsRecord, NetricsTable, etc.) to the TIBCO Patterns Engine, where they are stored.
Each call to the API is translated into the TIBCO Patterns Engine Protocol (the text-based raw socket communication) which is sent to the matching engine. The matching engine then completes the request and returns a response (also in the protocol) which is parsed by the interface. In this way all raw socket communication is hidden from the user of the NetricsServerInterface, and the matching engine can be run on any computer under any supported operating system.
The NetricsServerInterface object has methods for most of the familiar database operations. It can load tables and search them, add, get, delete, replace records, and much more. The complete documentation is available under the NetricsServerInterface class description.
Tips to get started:
1. The matching engine host and port are given in the constructor of the
NetricsServerInterface object.
2. Make sure the IP address of the client is on the authentication list of the matching engine (see the TIBCO Patterns Engines User's Guide).
Other Classes
The other classes included in the interface are used by the NetricsServerInterface.
The NetricsRecord and NetricsTable objects are the interface's representation of the TIBCO Patterns Engine fielded record and table of records. NetricsRecSrc is an interface that is used for retrieving records from some source. NetricsArrayRecSrc and NetricsCSVRecSrc are two implementations of that interface. A NetricsRecFile object is used to define the format of a file containing records that is to be read by the TIBCO Patterns Engine. The NetricsFieldedReader interface can be considered a lower level version of NetricsRecSrc, it defines a basic reader of a generic fielded record. This interface is used by the Thesaurus objects to read equivalence class records. NetricsCSVReader is an implementation of the NetricsFieldedReader for CSV format files. A NetricsLock represents a user set lock on a table. It is both returned by and sent to the server.
The NetricsException, NetricsFileFormatException, NetricsRecSrcException, NetricsMappedRecord, NetricsSearchResponse, NetricsSearchResult, NetricsIdxStats, NetricsModelStats, NetricsTableStats, NetricsThesStats and NetricsVersionInfo objects are used to return information to the user.
The NetricsQuery, NetricsSearchOpts, NetricsPredicate and NetricsSearchCfg objects are used to configure searches of the data in the matching engine. As searching is the very reason the TIBCO Patterns Engine exists, the search is very flexible in its operation and can be easily configured by use of these objects.
The NetricsCombinedThesaurs, NetricsThesaurus and NetricsWeightedDictionary objects represent the three types of thesauri that can be used when searching and are used to create them. A NetricsCharmap object is used to define and create custom character maps associated with the fields of a table and thesauri. Other classes in the interface represent deprecated versions of the interface or internal objects that should not be used directly.
Here is a simple example for how to use the search method of the NetricsServerInterface class.
String query = "thecityoflakesalt"; String tblName = "city_names"; String []fieldNames = new String [] { "full name", "common name" } ; LikeItServerInterface si = new LikeItServerInterface("localhost", 5051); // accept the default options NetricsSearchOpts opts = new NetricsSearchOpts(); NetricsSearchCfg searchCfg = new NetricsSearchCfg(tblName); // add the query itself searchCfg.setNetricsQuery(NetricsQuery.Simple(query,fieldNames,null)); NetricsSearchResponse response = si.dbsearch(searchCfg, opts); // get the matching record array NetricsSearchResult []results = response.getSearchResults(); for( int i = 0 ; i < results.length ; i++ ) { System.out.println(result[i].getMatchScore() + ". " + result[i].getKey() + "\n"); }