|
Summary: An extension to the JavaSpaces API which allows object matching by SQL syntax or regular expression.
OverviewThe JavaSpaces technology provides the ability to search for Entries using exact matching. In some cases there is a need to query for Entries with attribute values larger or smaller than a specific value. There are also cases where there is a need to locate Entries with string attributes that match a regular expression. GigaSpaces Space API provides the ability to query space Entries using the SELECT SQL syntax, as well as Java regular expressions. To do this, construct a SQLQuery Entry com.j_spaces.core.client.SQLQuery for all SQL based queries. You can also construct a SQLQuery using the rlike keyword – this allows you to performs Regular Expression Queries as part of the SQLQuery. SQLQuery with rlike uses the read, take, notify, readMultiple, takeMultiple operations as usual.
JavaSpaces Query InterfaceThe query interface extends the net.jini.core.entry.Entry interface and is the base interface for the SQLquery and the RegExquery classes. Future query syntaxes will implement this interface. Methods
SQLQuery in JavaSpacesThe SQLQuery class is used to query the space using the SQL like syntax. The query statement should only include the WHERE clause. You can also query the space using the Java Regular Expression Query syntax. This is done using the rlike option, as part of the SQLQuery itself.
Indexing for JavaSpaces QueriesAn Entry's attributes can be indexed using explicit or implicit indexing (see Indexing). By default, when class attributes are indexed, a hash-based index is maintained. The hash-based index is used for the regular JavaSpaces matching (i.e., "equals") and accelerates the read () and take () operations. In order to accelerate the read () and take () operations that use SQLQuery with greater than/less than operations, turn on the btree index. To turn on the btree index, modify the space configuration file as follows (note the asterisk): <extended-match> <enabled-classes>*</enabled-classes> <regular-expressions-cache-size>300</regular-expressions-cache-size> </extended-match>
The <enabled-classes>*</enabled-classes> can be replaced with a list of class names separated with commas that you want to index using the btree index <enabled-classes>classA,classB</enabled-classes> The Matching AlgorithmWhen a read, take, readMultiple, or takeMultiple call is performed, a template is used to locate matching Entries inside the space. The template might have multiple field values – some might include values and some might not (null field values). The fields that do not include values are ignored during the matching process. In addition, some class fields might be indexed and some might not be indexed. When multiple class fields are indexed, the space looks for the field value index that includes the smallest amount of matching Entries with the corresponding template field value as the index key. The smallest set of Entries is the list of Entries to perform the matching against (candidates). Once the candidates Entries list has been constructed, it is scanned to locate Entries that fully match the given template – i.e. all non-null template fields match the corresponding Entry fields.
More in this Section
|
(works on Firefox 2 and Internet Explorer 7)