XAP

Space Index

Index Types

The index type is determined by the SpaceIndexType enumeration. The index types are:

NONE - No indexing is used.

EQUAL - performs equality matching (equal to/not equal to).

ORDERED - performs ordered matching (bigger than/less than).

EQUAL_AND_ORDERED - performs both equality and ordered matching, and uses a larger memory footprint than the other indexing types.

The BASIC and EXTENDED index types have been deprecated as of version 12.3.

Indexing at Design Time

Specifying which properties of a class are indexed is done using annotations or gs.xml.

@SpaceClass
public class Person
{
    private String lastName;
    private String firstName;
    private Integer age;

    ...
    @SpaceIndex(type=SpaceIndexType.EQUAL)
    public String getFirstName() {return firstName;}
    public void setFirstName(String firstName) {this.firstName = firstName;}

    @SpaceIndex(type=SpaceIndexType.EQUAL)
    public String getLastName() {return lastName;}
    public void setLastName(String name) {this.lastName = name;}

    @SpaceIndex(type=SpaceIndexType.ORDERED)
    public Integer getAge() {return age;}
    public void setAge(Integer age) {this.age = age;}
}
<gigaspaces-mapping>
    <class name="com.gigaspaces.examples.Person" persist="false" replicate="false" fifo="false" >
        <property name="lastName">
            <index type="EQUAL"/>
        </property>
        <property name="firstName">
            <index type="EQUAL"/>
        </property>
        <property name="age">
             <index type="ORDERED"/>
        </property>
    </class>
</gigaspaces-mapping>

Inheritance

By default, a property's index is inherited in sub-classes (i.e. if a property is indexed in a superclass, it is also indexed in a sub-class). If you need to change the index type of a property in a sub-class, you can override the property and annotate it with @SpaceIndex using the requested index type (to disable indexing, use NONE).

Query Protective Mode

Query protection mode provides protection against executing queries that perform a full scan if the table size is above a limit.

Parameters:

  • com.gs.protectiveMode.queryWithoutIndex

  • com.gs.protectiveMode.queryWithoutIndex.queryWithoutIndexLimitValue - default value is 10000.

By default, this protective mode is disabled. If enabled, an exception will be thrown when a query as ” select * from the table” is performed and the table size is larger than the specified limit. The same will happen if the query includes a condition, but no index can be used.

Doing readMultiple and limiting the results with max entries less than the limit will pass successfully.

Also, “select count(*) from table” or using an aggregation that uses the index will pass the protective mode, as no full scan is performed.

If the protective mode is disabled, a warning message will be logged if the query meets the protective mode conditions. It is recommended to enable this property in QA and stage environments.

To disable the warning log related to a query with no index, you can set the following log level com.gigaspaces.cache.index.level=OFF