Summary: Setting implicit indexing, extended indexing, and related options.
OverviewTo improve performance, the space can maintain an index for entry field values. This speeds read and take operations, but consumes resources, so only fields used for matching should be indexed. GigaSpaces support hash based index used for equality matching (used by default) and B-tree index used for bigger/less than matching (need the Extended Indexing to be turned on). You can automatically index the first n fields of each class (implicit indexing) or index certain fields of a specific class (explicit indexing). There are three types of indexing:
Explicit Indexing
Using XMLWhen using POJO as your Space Domain Class you can use the gs.xml to specify the indxed fields. See below example: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE gigaspaces-mapping PUBLIC "-//GIGASPACES//DTD GS//EN" "http://www.gigaspaces.com/dtd/6_0/gigaspaces-metadata.dtd"> <gigaspaces-mapping> <class name="com.j_spaces.examples.hellospacepojo.Employee" persist="false" replicate="false" fifo="false" > <version name="versionID" /> <id name="employeeID" auto-generate="false" /> <routing name="employeeID" /> <property name="lastName" index="BASIC" /> <property name="firstName" index="BASIC" /> </class> </gigaspaces-mapping> Using CodeYou can specify programmatically which fields of an Entry or POJO class are indexed. The @SpaceProperty(index=IndexType.BASIC) should be used to index specefic field. @SpaceClass(replicate=true,persist=false,fifo=false) public class Person { private String lastName;private String firstName; public Person(){} public Person(String lastName, String firstName){this.lastName = lastName;this.firstName = firstName;} @SpaceProperty(index=IndexType.BASIC) public String getFirstName(){return firstName;} public void setFirstName(String firstName){this.firstName = firstName;} @SpaceProperty(index=IndexType.BASIC) public String getLastName(){return lastName;} public void setLastName(String name) {this.lastName = name;} } Extended IndexingExtended Indexing should be used when you have bigger/less than SQL queries used. space-config.engine.extended-match.enabled-classes.enabled-classes=*
The space-config.engine.extended-match.enabled-classes.enabled-classes can have a list of class names separated with commas that you want to index using the btree index. space-config.engine.extended-match.enabled-classes.enabled-classes=pack1.classA,pack2.classB More Indexing Options
How Indexes are used?When a read, take, readMultiple, or takeMultiple call is performed, a template is used to locate matching space objects. The template might have multiple field values – some might include values and some might not (i.e. null field values acting as wildcard). 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 space objects with the corresponding template field value as the index key. The smallest set of space objects is the list of objects to perform the matching against (matching candidates). Once the candidates space object list has been constructed, it is scanned to locate space objects that fully match the given template – i.e. all non-null template fields match the corresponding space object fields.
|
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |