Regular Expression Queries in JavaSpaces

  Search Here
Searching XAP 6.0 Documentation

                                               

Summary: The RegExQuery class is used to query the space using the Java Regular Expression syntax.
Using Regular Expression Queries as described below is deprecated in GigaSpaces 6.0 and onwards. It is recommended to perform Regular Expression Queries as part of SQL Queries, using the rlike keyword. For more details, refer to the SQLQuery in JavaSpaces section.

Overview

The RegExQuery class is used to query the space using the Java Regular Expression syntax.

Constructors

  • RegExQuery(Entry entry,String[] attributeName, String[]
    regExpression)entry – template Entry.
  • attributeName – attributes' names to use for matching.
  • regExpression – the regular expression. Every item in the array should match the relevant item in the attributeName array.
  • RegExQuery(String className,String[] attributeName, String[]
    regExpression)className-- template Entry class name.
  • regExpression – the regular expression. Every item in the array should match the relevant item in the attributeName array.

Methods

The RegExQuery includes the following methods:

Return Value Method
string getClassName()
Returns the template class name.
void setClassName(String className)
Sets the template class name.
void setQuery(String attributeName[],String regExpression[])
Sets the attributes and their regular expression statement.
void setTemplate(Entry entry)
Sets the template.

Supported JavaSpace Methods

Read (), take (), readIfExists (), takeIfExists (), readMultiple (), takeMultiple (), notify () with NO_WAIT timeout.

Non-Supported methods

Notify (), readIfExists (), takeIfExists (), read (), take (), readMultiple (), takeMultiple () with timeout greater than NO_WAIT.

Code example

Entry Class

We will use the following Entry class as part of the code examples:

public class MyEntry implements Entry{
public MyEntry()
{}

public String m_string = null;
public Long m_long= null;
public Time m_time= null;
public Date m_date= null;
public Integer m_integer= null;

Caching Regular Expressions

The space maintains a cache for pre-compiled regular expressions. You can control this cache size using the <regular-expressions-cache-size> space configuration file parameter:

<regular-expressions-cache-size>300</regular-expressions-cache-size>

Using RegExQuery with readMultiple ()

RegExQuery regExQuery = new RegExQuery(MyEntry.class.getName(),
new String[]{"m_string"}, new String[]{"a*b"});
Entry result[] = space.readMultiple(regExQuery, null,
Integer.MAX_VALUE);

Using RegExQuery with NotifyDelegator ()

RegExQuery m_Template =new RegExQuery(new MyEntry(),new String[]{"m_string"}, new String[]{"a*b"});
m_NotifyDelegator = new NotifyDelegator(space,
m_Template, null, this, Lease.FOREVER, null, false,
NotifyModifiers.NOTIFY_ALL);
Regular expression queries do not use indexes.


IMPORTANT: This is an old version of GigaSpaces XAP. Click here for the latest version.
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

 
(None)