|
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:
Implicit IndexingIf the Implicit Indexing is enabled, GigaSpaces will automatically index all the class attributes that are not indexed programmatically. Implicit Indexing is managed through the <number-implicit-indexes> tag in the space schema configuration file. GigaSpaces recommends disabling the Implicit Indexing since it might index Entries without real need. When the Implicit Indexing is turned on, the first String, Integer or Long class attributes field values are indexed. For example, the following class: public class myClass implements Entry { public String a; public Long b; public Integer c; public String d; }
Setting the <number-implicit-indexes>-1</number-implicit-indexes> will not implicitly indexed any of the entry classes field values for all space Entries unless explicit indexing has been used. Explicit Indexing
You can specify programmatically which fields of an Entry class are indexed. You must explicitly request indexing on each Entry class even if it extends another indexed class. If you want the space to create an index for specific fields of an Entry class, implement the public static String[] __getSpaceIndexedFields() method that specifies the names of the fields that are to be indexed. For example, lets take the following Person class: public class Person implements Entry { public String m_Id; public String m_Name; public Integer m_YearOfBirth; public String m_Email; public static String[] __getSpaceIndexedFields() { String[] indexedFields = { "m_Id", "m_Name", "m_Email" }; return indexedFields; } } It has four fields, of which only three are indexed, as determined by the __getSpaceIndexedFields() method. Note that __getSpaceIndexedFields() must be a public static method. Having the __getSpaceIndexedFields() defined as part of the class overrides the number-implicit-indexes value for the relevant class done at the space level.
Extended IndexingTo turn on the btree index, modify the space schema 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> Indexing Options Summary<space-config> <number-implicit-indexes>-1</number-implicit-indexes> <engine> <extended-match> <enabled-classes></enabled-classes> <regular-expressions-cache-size>300</regular-expressions-cache-size> </extended-match> </engine> </space-config>
|
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