public interface GridIndexingSpi extends GridSpi
GridCacheConfiguration.getIndexingSpiName()). Logically storage is organized into separate spaces.
Usually cache name will be used as space name, so multiple caches can write to single indexing SPI instance.
Functionality of this SPI is exposed to GridCacheQueries interface:
GridCacheQueries.createSqlQuery(Class, String)GridCacheQueries.createSqlFieldsQuery(String)GridCacheQueries.createFullTextQuery(Class, String)
The default indexing SPI implementation is GridH2IndexingSpi which uses H2 database engine
for data indexing and querying. User can implement his own indexing SPI and use his own data structures
and query language instead of SQL. SPI can be configured for grid using GridConfiguration.getIndexingSpi().
GridGain comes with following built-in indexing SPI implementations:
GridH2IndexingSpi
NOTE: this SPI (i.e. methods in this interface) should never be used directly. SPIs provide
internal view on the subsystem and is used internally by GridGain kernal. In rare use cases when
access to a specific implementation of this SPI is required - an instance of this SPI can be obtained
via Grid.configuration() method to check its configuration properties or call other non-SPI
methods. Note again that calling methods from this interface on the obtained instance can lead
to undefined behavior and explicitly not supported.
| Modifier and Type | Method and Description |
|---|---|
<K> void |
onSwap(String spaceName,
String swapSpaceName,
K key)
Will be called when entry with given key is swapped.
|
<K,V> void |
onUnswap(String spaceName,
K key,
V val,
byte[] valBytes)
Will be called when entry with given key is unswapped.
|
<K,V> GridSpiCloseableIterator<GridIndexingKeyValueRow<K,V>> |
query(String spaceName,
String qry,
Collection<Object> params,
GridIndexingTypeDescriptor type,
GridIndexingQueryFilter<K,V>... filters)
Executes regular query.
|
<K,V> GridIndexingFieldsResult |
queryFields(String spaceName,
String qry,
Collection<Object> params,
GridIndexingQueryFilter<K,V>... filters)
Queries individual fields (generally used by JDBC drivers).
|
<K,V> GridSpiCloseableIterator<GridIndexingKeyValueRow<K,V>> |
queryText(String spaceName,
String qry,
GridIndexingTypeDescriptor type,
GridIndexingQueryFilter<K,V>... filters)
Executes text query.
|
void |
rebuildIndexes(String spaceName,
GridIndexingTypeDescriptor type)
Rebuilds all indexes of given type.
|
void |
registerMarshaller(GridIndexingMarshaller marshaller)
Marshaller to be used by SPI.
|
void |
registerSpace(String spaceName)
Registers space in this SPI.
|
boolean |
registerType(String spaceName,
GridIndexingTypeDescriptor desc)
Registers type if it was not known before or updates it otherwise.
|
<K> boolean |
remove(String spaceName,
GridIndexingEntity<K> key)
Removes index entry by key.
|
long |
size(String spaceName,
GridIndexingTypeDescriptor desc)
Gets size of index for given type or -1 if it is a unknown type.
|
<K,V> void |
store(String spaceName,
GridIndexingTypeDescriptor type,
GridIndexingEntity<K> key,
GridIndexingEntity<V> val,
byte[] ver,
long expirationTime)
Updates index.
|
void |
unregisterType(String spaceName,
GridIndexingTypeDescriptor type)
Unregisters type and removes all corresponding data.
|
getName, getNodeAttributes, onContextDestroyed, onContextInitialized, spiStart, spiStop<K,V> GridIndexingFieldsResult queryFields(@Nullable String spaceName, String qry, Collection<Object> params, GridIndexingQueryFilter<K,V>... filters) throws GridSpiException
spaceName - Space name.qry - Query.params - Query parameters.filters - Space name and key filters.GridSpiException - If failed.<K,V> GridSpiCloseableIterator<GridIndexingKeyValueRow<K,V>> query(@Nullable String spaceName, String qry, Collection<Object> params, GridIndexingTypeDescriptor type, GridIndexingQueryFilter<K,V>... filters) throws GridSpiException
spaceName - Space name.qry - Query.params - Query parameters.type - Query return type.filters - Space name and key filters.GridSpiException - If failed.<K,V> GridSpiCloseableIterator<GridIndexingKeyValueRow<K,V>> queryText(@Nullable String spaceName, String qry, GridIndexingTypeDescriptor type, GridIndexingQueryFilter<K,V>... filters) throws GridSpiException
spaceName - Space name.qry - Text query.type - Query return type.filters - Space name and key filter.GridSpiException - If failed.long size(@Nullable String spaceName, GridIndexingTypeDescriptor desc) throws GridSpiException
spaceName - Space name.desc - Type descriptor.GridSpiException - If failed.boolean registerType(@Nullable String spaceName, GridIndexingTypeDescriptor desc) throws GridSpiException
spaceName - Space name.desc - Type descriptor.True if type was registered, false if for some reason it was rejected.GridSpiException - If failed.void unregisterType(@Nullable String spaceName, GridIndexingTypeDescriptor type) throws GridSpiException
spaceName - Space name.type - Type descriptor.GridSpiException - If failed.<K,V> void store(@Nullable String spaceName, GridIndexingTypeDescriptor type, GridIndexingEntity<K> key, GridIndexingEntity<V> val, byte[] ver, long expirationTime) throws GridSpiException
spaceName - Space name.type - Value type.key - Key.val - Value.ver - Version.expirationTime - Expiration time or 0 if never expires.GridSpiException - If failed.<K> boolean remove(@Nullable String spaceName, GridIndexingEntity<K> key) throws GridSpiException
spaceName - Space name.key - Key.True if removed by this operation, false otherwise.GridSpiException - If failed.<K> void onSwap(@Nullable String spaceName, String swapSpaceName, K key) throws GridSpiException
spaceName - Space name.swapSpaceName - Swap space name.key - Key.GridSpiException - If failed.<K,V> void onUnswap(@Nullable String spaceName, K key, V val, byte[] valBytes) throws GridSpiException
spaceName - Space name.key - Key.val - Value.valBytes - Value bytes.GridSpiException - If failed.void registerMarshaller(GridIndexingMarshaller marshaller)
marshaller - Marshaller.void registerSpace(String spaceName) throws GridSpiException
spaceName - Space name.GridSpiException - If failed.void rebuildIndexes(@Nullable String spaceName, GridIndexingTypeDescriptor type)
spaceName - Space name.type - Type descriptor.Copyright © 2014. All rights reserved.