|
OverviewJavaSpaces – the underlying technology of GigaSpaces XAP – provides the ability to search for Entries using exact matching. In some cases there is a need to query 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. The 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. Alternatively, you can construct a com.j_spaces.core.client.RegExQuery Entry for every regular expression that matches the relevant values and 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.
Regular Expression Queries in JavaSpacesThe RegExQuery class is used to query the space using the Java Regular Expression syntax.
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
|
Wiki Content Tree
Your Feedback Needed!
We need your help to improve this wiki site. If you have any suggestions or corrections, write to us at techw@gigaspaces.com. Please provide a link to the wiki page you are referring to.
Add Comment