
public class OIndexRecorder extends Object implements OIndex<OIdentifiable>, OIndexInternal<OIdentifiable>
ALGORITHM, CONFIG_AUTOMATIC, CONFIG_KEYTYPE, CONFIG_NAME, CONFIG_TYPE, INDEX_DEFINITION, INDEX_DEFINITION_CLASS, INDEX_VERSION, METADATA, VALUE_CONTAINER_ALGORITHMMERGE_KEYS| Constructor and Description |
|---|
OIndexRecorder(OIndexInternal<OIdentifiable> delegate) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquireAtomicExclusiveLock(Object key)
Acquires exclusive lock in the active atomic operation running on the current thread for this index.
|
OIndex<OIdentifiable> |
addCluster(String iClusterName)
Add given cluster to the list of clusters that should be automatically indexed.
|
void |
addTxOperation(OTransactionIndexChanges changes) |
boolean |
canBeUsedInEqualityOperators()
Indicates whether given index can be used to calculate result of
OQueryOperatorEquality operators. |
ODocument |
checkEntry(OIdentifiable iRecord,
Object iKey)
For unique indexes it will throw exception if passed in key is contained in index.
|
OIndex<OIdentifiable> |
clear()
Clears the index removing all the entries in one shot.
|
void |
close() |
void |
commit() |
int |
compareTo(OIndex<OIdentifiable> 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<OIdentifiable> |
create(String name,
OIndexDefinition indexDefinition,
String clusterIndexName,
Set<String> clustersToIndex,
boolean rebuild,
OProgressListener progressListener)
Creates the index.
|
OIndexCursor |
cursor() |
OIndex<OIdentifiable> |
delete()
Delete the index.
|
OIndexCursor |
descCursor() |
void |
flush()
Flushes in-memory changes to disk.
|
OIdentifiable |
get(Object iKey)
Gets the set of records associated with the passed key.
|
List<Object> |
getAffectedKeys() |
String |
getAlgorithm()
Returns the engine of the index as string.
|
Set<String> |
getClusters()
Returns Names of clusters that will be indexed.
|
Object |
getCollatingValue(Object key) |
ODocument |
getConfiguration()
Returns the index configuration.
|
String |
getDatabaseName() |
OIndexDefinition |
getDefinition() |
Object |
getFirstKey() |
int |
getIndexId() |
String |
getIndexNameByKey(Object key)
Returns the index name for a key.
|
OIndexInternal<OIdentifiable> |
getInternal()
Returns the internal index used.
|
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.
|
boolean |
hasRangeQuerySupport() |
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.
|
OIndexKeyCursor |
keyCursor() |
boolean |
loadFromConfiguration(ODocument iConfig)
Loads the index giving the configuration.
|
OIndexMetadata |
loadMetadata(ODocument iConfig) |
Lock[] |
lockKeysForUpdate(Collection<Object> keys)
Applies exclusive lock on keys which prevents read/modification of this keys in following methods:
OIndex.put(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)
OIndex.checkEntry(com.orientechnologies.orient.core.db.record.OIdentifiable, Object)
OIndex.remove(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)
OIndex.remove(Object)
|
void |
lockKeysForUpdate(Object... key)
Applies exclusive lock on keys which prevents read/modification of this keys in following methods:
OIndex.put(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)
OIndex.checkEntry(com.orientechnologies.orient.core.db.record.OIdentifiable, Object)
OIndex.remove(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)
OIndex.remove(Object)
|
void |
postCommit() |
void |
preCommit() |
OIndex<OIdentifiable> |
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.
|
void |
releaseKeysForUpdate(Object... key)
Release exclusive lock on keys which prevents read/modification of this keys in following methods:
OIndex.put(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)
OIndex.checkEntry(com.orientechnologies.orient.core.db.record.OIdentifiable, Object)
OIndex.remove(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)
OIndex.remove(Object)
This is internal method and cannot be used by end users. |
boolean |
remove(Object key)
Removes an entry by its key.
|
boolean |
remove(Object iKey,
OIdentifiable iRID)
Removes an entry by its key and value.
|
OIndex<OIdentifiable> |
removeCluster(String iClusterName)
Remove given cluster from the list of clusters that should be automatically indexed.
|
void |
setRebuildingFlag() |
void |
setType(OType type) |
boolean |
supportsOrderedIterations() |
String |
toString() |
ODocument |
updateConfiguration()
Saves the index configuration to disk.
|
public OIndexRecorder(OIndexInternal<OIdentifiable> delegate)
public OIndex<OIdentifiable> create(String name, OIndexDefinition indexDefinition, String clusterIndexName, Set<String> clustersToIndex, boolean rebuild, OProgressListener progressListener)
OIndexcreate in interface OIndex<OIdentifiable>clusterIndexName - Cluster name where to place the TreeMappublic String getDatabaseName()
getDatabaseName in interface OIndex<OIdentifiable>public OType[] getKeyTypes()
OIndexgetKeyTypes in interface OIndex<OIdentifiable>public OIdentifiable get(Object iKey)
OIndexget in interface OIndex<OIdentifiable>iKey - The key to searchpublic boolean contains(Object iKey)
OIndexcontains in interface OIndex<OIdentifiable>iKey - The key to searchpublic OIndex<OIdentifiable> put(Object iKey, OIdentifiable iValue)
OIndexput in interface OIndex<OIdentifiable>iKey - Entry's keyiValue - Entry's value as OIdentifiable instancepublic boolean remove(Object key)
OIndexremove in interface OIndex<OIdentifiable>key - The entry's key to removepublic boolean remove(Object iKey, OIdentifiable iRID)
OIndexremove in interface OIndex<OIdentifiable>iKey - The entry's key to removepublic OIndex<OIdentifiable> clear()
OIndexclear in interface OIndex<OIdentifiable>public long getSize()
getSize in interface OIndex<OIdentifiable>public long count(Object iKey)
OIndexcount in interface OIndex<OIdentifiable>public long getKeySize()
getKeySize in interface OIndex<OIdentifiable>public ODocument checkEntry(OIdentifiable iRecord, Object iKey)
OIndexcheckEntry in interface OIndex<OIdentifiable>public int getVersion()
OIndexgetVersion in interface OIndex<OIdentifiable>public long getRebuildVersion()
OIndexIt 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<OIdentifiable>OCommandExecutorSQLSelect.searchForIndexes(com.orientechnologies.orient.core.metadata.schema.OClass),
OCommandExecutorSQLSelect.getIndexCursors(com.orientechnologies.orient.core.metadata.schema.OClass),
OCommandExecutorSQLSelect.getOptimizedSortCursor(com.orientechnologies.orient.core.metadata.schema.OClass),
OAbstractPaginatedStorage.command(com.orientechnologies.orient.core.command.OCommandRequestText),
OIndexChangesWrapper,
OIndexIsRebuildingException,
ORetryQueryExceptionpublic void flush()
OIndexflush in interface OIndex<OIdentifiable>public OIndex<OIdentifiable> delete()
OIndexdelete in interface OIndex<OIdentifiable>public String getName()
OIndexgetName in interface OIndex<OIdentifiable>public String getType()
OIndexgetType in interface OIndex<OIdentifiable>public boolean isAutomatic()
OIndexisAutomatic in interface OIndex<OIdentifiable>public long rebuild()
OIndexrebuild in interface OIndex<OIdentifiable>OIndex.getRebuildVersion()public long rebuild(OProgressListener iProgressListener)
OIndexrebuild in interface OIndex<OIdentifiable>OIndex.getRebuildVersion()public ODocument getConfiguration()
OIndexgetConfiguration in interface OIndex<OIdentifiable>public OIndexInternal<OIdentifiable> getInternal()
OIndexgetInternal in interface OIndex<OIdentifiable>public OIndexCursor iterateEntries(Collection<?> keys, boolean ascSortOrder)
OIndexiterateEntries in interface OIndex<OIdentifiable>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 OIndexDefinition getDefinition()
getDefinition in interface OIndex<OIdentifiable>public Set<String> getClusters()
OIndexgetClusters in interface OIndex<OIdentifiable>public OIndexCursor iterateEntriesBetween(Object fromKey, boolean fromInclusive, Object toKey, boolean toInclusive, boolean ascOrder)
OIndexiterateEntriesBetween in interface OIndex<OIdentifiable>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<OIdentifiable>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<OIdentifiable>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 OIndexCursor cursor()
cursor in interface OIndex<OIdentifiable>public OIndexCursor descCursor()
descCursor in interface OIndex<OIdentifiable>public OIndexKeyCursor keyCursor()
keyCursor in interface OIndex<OIdentifiable>public ODocument getMetadata()
getMetadata in interface OIndex<OIdentifiable>public boolean supportsOrderedIterations()
supportsOrderedIterations in interface OIndex<OIdentifiable>public boolean isRebuilding()
isRebuilding in interface OIndex<OIdentifiable>OIndex.getRebuildVersion()public Object getFirstKey()
getFirstKey in interface OIndex<OIdentifiable>public Object getLastKey()
getLastKey in interface OIndex<OIdentifiable>public int getIndexId()
getIndexId in interface OIndex<OIdentifiable>public boolean isUnique()
isUnique in interface OIndex<OIdentifiable>public int compareTo(OIndex<OIdentifiable> o)
compareTo in interface Comparable<OIndex<OIdentifiable>>public Object getCollatingValue(Object key)
getCollatingValue in interface OIndexInternal<OIdentifiable>public boolean loadFromConfiguration(ODocument iConfig)
OIndexInternalloadFromConfiguration in interface OIndexInternal<OIdentifiable>iConfig - ODocument instance containing the configurationpublic ODocument updateConfiguration()
OIndexInternalupdateConfiguration in interface OIndexInternal<OIdentifiable>OIndex.getConfiguration()public OIndex<OIdentifiable> addCluster(String iClusterName)
OIndexInternaladdCluster in interface OIndexInternal<OIdentifiable>iClusterName - Cluster to add.public OIndex<OIdentifiable> removeCluster(String iClusterName)
OIndexInternalremoveCluster in interface OIndexInternal<OIdentifiable>iClusterName - Cluster to remove.public boolean canBeUsedInEqualityOperators()
OIndexInternalOQueryOperatorEquality operators.canBeUsedInEqualityOperators in interface OIndexInternal<OIdentifiable>true if given index can be used to calculate result of
OQueryOperatorEquality operators.public boolean hasRangeQuerySupport()
hasRangeQuerySupport in interface OIndexInternal<OIdentifiable>public void lockKeysForUpdate(Object... key)
OIndexInternalOIndex.put(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)OIndex.checkEntry(com.orientechnologies.orient.core.db.record.OIdentifiable, Object)OIndex.remove(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)OIndex.remove(Object)If you want to lock several keys in single thread, you should pass all those keys in single method call. Several calls of this method in single thread are not allowed because it may lead to deadlocks.
This is internal method and cannot be used by end users.lockKeysForUpdate in interface OIndexInternal<OIdentifiable>key - Keys to lock.public Lock[] lockKeysForUpdate(Collection<Object> keys)
OIndexInternalOIndex.put(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)OIndex.checkEntry(com.orientechnologies.orient.core.db.record.OIdentifiable, Object)OIndex.remove(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)OIndex.remove(Object)If you want to lock several keys in single thread, you should pass all those keys in single method call. Several calls of this method in single thread are not allowed because it may lead to deadlocks.
This is internal method and cannot be used by end users.lockKeysForUpdate in interface OIndexInternal<OIdentifiable>keys - Keys to lock.public void releaseKeysForUpdate(Object... key)
OIndexInternalreleaseKeysForUpdate in interface OIndexInternal<OIdentifiable>key - Keys to unlock.public void setType(OType type)
setType in interface OIndexInternal<OIdentifiable>public OIndexMetadata loadMetadata(ODocument iConfig)
loadMetadata in interface OIndexInternal<OIdentifiable>public void setRebuildingFlag()
setRebuildingFlag in interface OIndexInternal<OIdentifiable>public void close()
close in interface OIndexInternal<OIdentifiable>public String getAlgorithm()
OIndexgetAlgorithm in interface OIndex<OIdentifiable>public void preCommit()
preCommit in interface OIndexInternal<OIdentifiable>public void addTxOperation(OTransactionIndexChanges changes)
addTxOperation in interface OIndexInternal<OIdentifiable>public void commit()
commit in interface OIndexInternal<OIdentifiable>public void postCommit()
postCommit in interface OIndexInternal<OIdentifiable>public boolean acquireAtomicExclusiveLock(Object key)
OIndexInternalAcquires exclusive lock in the active atomic operation running on the current thread for this index.
If this index supports a more narrow locking, for example key-based sharding, it may use the provided key to infer a
more narrow lock scope, but that is not a requirement.
acquireAtomicExclusiveLock in interface OIndexInternal<OIdentifiable>key - the index key to lock.true if this index was locked entirely, false if this index locking is sensitive to the provided key and only some subset of this index was locked.public String getIndexNameByKey(Object key)
OIndexInternalReturns the index name for a key. The name is always the current index name, but in cases where the index supports key-based sharding.
getIndexNameByKey in interface OIndexInternal<OIdentifiable>key - the index key.Copyright © 2009–2025 OrientDB. All rights reserved.