Querying the Space

  Search Here
Searching XAP 6.0 Documentation

                                               

Summary: An extension to the JavaSpaces API which allows object matching by SQL syntax or regular expression.

Overview

The 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.

For more details, refer to the SQLQuery in JavaSpaces section.

JavaSpaces Query Interface

The 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

Return Value Method
void setClassName(String className)
Sets the template class name.
void setquery(String query)
Sets the query statement.
void setTemplate(Entry entry)
Sets the template.

SQLQuery in JavaSpaces

The 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.

For more details, refer to the SQLQuery in JavaSpaces section.

Indexing for JavaSpaces Queries

An 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>
By default, the btree index is not maintained for indexed class attributes. Leaving the btree index turned on impacts the write performance.

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
For example:

<enabled-classes>classA,classB</enabled-classes>

The Matching Algorithm

When 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.

Class fields that are not indexed are not used to construct the candidates list.

More in this Section

Query Complex Entry Attribute – The page Query Complex Entry Attribute - 6.0 does not exist.
Custom Query Pattern – The page Custom Query Pattern - 6.0 does not exist.


GigaSpaces 6.0 Documentation Contents (Current Page in Bold)

    Java

    C++

    .NET

    Middleware Capabilities

    Configuration and Management

Add GigaSpaces wiki search to your browser search engines!
(works on Firefox 2 and Internet Explorer 7)

Labels