
public class OChainedIndexProxy<T> extends Object implements OIndex<T>
There are some cases when we need to create index for some class by traversed property. Unfortunately, such functionality is not
supported yet. But we can do that by creating index for each element of OSQLFilterItemField.FieldChain (which define
"way" to our property), and then process operations consequently using previously created indexes.
This class provides possibility to find optimal chain of indexes and then use it just like it was index for traversed property.
IMPORTANT: this class is only for internal usage!
MERGE_KEYS| Modifier and Type | Method and Description |
|---|---|
OIndex<T> |
clear()
Clears the index removing all the entries in one shot.
|
int |
compareTo(OIndex<T> o) |
boolean |
contains(Object iKey)
Tells if a key is contained in the index.
|
long |
count(Object iKey)
Counts the entries for the key.
|
OIndex<T> |
create(String name,
OIndexDefinition indexDefinition,
String clusterIndexName,
Set<String> clustersToIndex,
boolean rebuild,
OProgressListener progressListener)
Creates the index.
|
static <T> Collection<OChainedIndexProxy<T>> |
createProxies(OClass iSchemaClass,
OSQLFilterItemField.FieldChain longChain)
Create proxies that support maximum number of different operations.
|
OIndexCursor |
cursor() |
OIndex<T> |
delete()
Delete the index.
|
OIndexCursor |
descCursor() |
protected static OIndex<?> |
findBestIndex(Iterable<OIndex<?>> indexes)
Finds the index that fits better as a base index in chain.
|
void |
flush()
Flushes in-memory changes to disk.
|
T |
get(Object iKey)
Gets the set of records associated with the passed key.
|
String |
getAlgorithm()
Returns the engine of the index as string.
|
Set<String> |
getClusters()
Returns Names of clusters that will be indexed.
|
ODocument |
getConfiguration()
Returns the index configuration.
|
String |
getDatabaseName() |
OIndexDefinition |
getDefinition() |
Object |
getFirstKey() |
ORID |
getIdentity() |
int |
getIndexId() |
List<String> |
getIndexNames() |
OIndexInternal<T> |
getInternal()
Returns internal index of last chain index, because proxy applicable to all operations that last index applicable.
|
long |
getKeySize() |
OType[] |
getKeyTypes()
Types of the keys that index can accept, if index contains composite key, list of types of elements from which this index
consist will be returned, otherwise single element (key type obviously) will be returned.
|
Object |
getLastKey() |
ODocument |
getMetadata() |
String |
getName()
Returns the index name.
|
long |
getRebuildVersion()
Returns amount of times when index was rebuilt since storage was opened.
|
long |
getSize() |
String |
getType()
Returns the type of the index as string.
|
int |
getVersion()
Returns binary format version for this index.
|
static boolean |
isAppropriateAsBase(OIndex<?> index)
Checks if index can be used as base index.
|
boolean |
isAutomatic()
Tells if the index is automatic.
|
boolean |
isRebuilding() |
boolean |
isUnique() |
OIndexCursor |
iterateEntries(Collection<?> keys,
boolean ascSortOrder)
Returns cursor which presents data associated with passed in keys.
|
OIndexCursor |
iterateEntriesBetween(Object fromKey,
boolean fromInclusive,
Object toKey,
boolean toInclusive,
boolean ascOrder)
Returns cursor which presents subset of index data between passed in keys.
|
OIndexCursor |
iterateEntriesMajor(Object fromKey,
boolean fromInclusive,
boolean ascOrder)
Returns cursor which presents subset of data which associated with key which is greater than passed in key.
|
OIndexCursor |
iterateEntriesMinor(Object toKey,
boolean toInclusive,
boolean ascOrder)
Returns cursor which presents subset of data which associated with key which is less than passed in key.
|
Iterator<Map.Entry<Object,T>> |
iterator() |
OIndexKeyCursor |
keyCursor() |
Iterable<Object> |
keys() |
OIndex<T> |
put(Object iKey,
OIdentifiable iValue)
Inserts a new entry in the index.
|
long |
rebuild()
Rebuilds an automatic index.
|
long |
rebuild(OProgressListener iProgressListener)
Populate the index with all the existent records.
|
boolean |
remove(Object key)
Removes an entry by its key.
|
boolean |
remove(Object iKey,
OIdentifiable iRID)
Removes an entry by its key and value.
|
boolean |
supportsOrderedIterations() |
public static <T> Collection<OChainedIndexProxy<T>> createProxies(OClass iSchemaClass, OSQLFilterItemField.FieldChain longChain)
UNIQUE and FULLTEXT types) are possible, the creates the only one index
of each type.longChain - - property chain from the query, which should be evaluatedprotected static OIndex<?> findBestIndex(Iterable<OIndex<?>> indexes)
indexes - where searchpublic static boolean isAppropriateAsBase(OIndex<?> index)
index - to checkpublic long getRebuildVersion()
It is used to support so called "live index rebuild" feature.
Value of this version is increased every time when index is going to be rebuild. So if two sequential calls of this method return different numbers it means that index at least started to rebuild itself.
If you use indexes to increase speed of fetching data from database you should follow following workflow:
OIndex.isRebuilding(), if it is true, do not use index and fetch data directly from
database clusters.
This approach works well ONLY if you do not use methods which return OIndexCursor instance.
In case of you work with cursors index rebuild may cause data inconsistency issues in both:
To detect last data inconsistency issue please use cursor wrapper
OIndexChangesWrapper which throws OIndexIsRebuildingException
in case of index rebuild.
Both of these approaches are used in implementation of support of "live index rebuild" for SELECT SQL queries.
SELECT query is rebuilding
we skip this index.OIndexIsRebuildingException exception
and retry whole query again.getRebuildVersion in interface OIndex<T>OAbstractPaginatedStorage.command(com.orientechnologies.orient.core.command.OCommandRequestText),
OIndexChangesWrapper,
OIndexIsRebuildingException,
ORetryQueryExceptionpublic String getDatabaseName()
getDatabaseName in interface OIndex<T>public OIndexInternal<T> getInternal()
getInternal in interface OIndex<T>public OIndexDefinition getDefinition()
getDefinition in interface OIndex<T>public OIndex<T> create(String name, OIndexDefinition indexDefinition, String clusterIndexName, Set<String> clustersToIndex, boolean rebuild, OProgressListener progressListener)
OIndexpublic boolean contains(Object iKey)
OIndexpublic OType[] getKeyTypes()
OIndexgetKeyTypes in interface OIndex<T>public OIndex<T> put(Object iKey, OIdentifiable iValue)
OIndexpublic boolean remove(Object key)
OIndexpublic boolean remove(Object iKey, OIdentifiable iRID)
OIndexpublic OIndex<T> clear()
OIndexpublic long getSize()
public long count(Object iKey)
OIndexpublic long getKeySize()
getKeySize in interface OIndex<T>public void flush()
OIndexpublic String getType()
OIndexpublic String getAlgorithm()
OIndexgetAlgorithm in interface OIndex<T>public boolean isAutomatic()
OIndexisAutomatic in interface OIndex<T>public long rebuild()
OIndexrebuild in interface OIndex<T>OIndex.getRebuildVersion()public long rebuild(OProgressListener iProgressListener)
OIndexrebuild in interface OIndex<T>OIndex.getRebuildVersion()public ODocument getConfiguration()
OIndexgetConfiguration in interface OIndex<T>public ODocument getMetadata()
getMetadata in interface OIndex<T>public ORID getIdentity()
public Set<String> getClusters()
OIndexgetClusters in interface OIndex<T>public Object getFirstKey()
getFirstKey in interface OIndex<T>public Object getLastKey()
getLastKey in interface OIndex<T>public int getIndexId()
getIndexId in interface OIndex<T>public OIndexCursor cursor()
public OIndexCursor descCursor()
descCursor in interface OIndex<T>public OIndexKeyCursor keyCursor()
public int getVersion()
OIndexgetVersion in interface OIndex<T>public boolean supportsOrderedIterations()
supportsOrderedIterations in interface OIndex<T>public OIndexCursor iterateEntries(Collection<?> keys, boolean ascSortOrder)
OIndexiterateEntries in interface OIndex<T>keys - Keys data of which should be returned.ascSortOrder - Flag which determines whether data iterated by cursor should be in ascending or descending order.public OIndexCursor iterateEntriesBetween(Object fromKey, boolean fromInclusive, Object toKey, boolean toInclusive, boolean ascOrder)
OIndexiterateEntriesBetween in interface OIndex<T>fromKey - Lower border of index data.fromInclusive - Indicates whether lower border should be inclusive or exclusive.toKey - Upper border of index data.toInclusive - Indicates whether upper border should be inclusive or exclusive.ascOrder - Flag which determines whether data iterated by cursor should be in ascending or descending order.public OIndexCursor iterateEntriesMajor(Object fromKey, boolean fromInclusive, boolean ascOrder)
OIndexiterateEntriesMajor in interface OIndex<T>fromKey - Lower border of index data.fromInclusive - Indicates whether lower border should be inclusive or exclusive.ascOrder - Flag which determines whether data iterated by cursor should be in ascending or descending order.public OIndexCursor iterateEntriesMinor(Object toKey, boolean toInclusive, boolean ascOrder)
OIndexiterateEntriesMinor in interface OIndex<T>toKey - Upper border of index data.toInclusive - Indicates Indicates whether upper border should be inclusive or exclusive.ascOrder - Flag which determines whether data iterated by cursor should be in ascending or descending order.public boolean isRebuilding()
isRebuilding in interface OIndex<T>OIndex.getRebuildVersion()Copyright © 2009–2025 OrientDB. All rights reserved.