
public abstract class OIndexAbstract<T> extends Object implements OIndexInternal<T>
OPartitionedLockManager, the
default one, or the OOneEntryPerKeyLockManager in case of distributed. This is to avoid deadlock situation between nodes
where keys have the same hash code.| Modifier and Type | Class and Description |
|---|---|
protected static class |
OIndexAbstract.IndexConfiguration |
static class |
OIndexAbstract.IndexTxSnapshot |
| Modifier and Type | Field and Description |
|---|---|
protected int |
apiVersion |
protected int |
binaryFormatVersion |
protected Set<String> |
clustersToIndex |
protected static String |
CONFIG_MAP_RID |
protected int |
indexId |
protected ODocument |
metadata |
protected OAbstractPaginatedStorage |
storage |
protected String |
valueContainerAlgorithm |
ALGORITHM, CONFIG_AUTOMATIC, CONFIG_KEYTYPE, CONFIG_NAME, CONFIG_TYPE, INDEX_DEFINITION, INDEX_DEFINITION_CLASS, INDEX_VERSION, METADATA, VALUE_CONTAINER_ALGORITHMMERGE_KEYS| Constructor and Description |
|---|
OIndexAbstract(String name,
String type,
String algorithm,
String valueContainerAlgorithm,
ODocument metadata,
int version,
OStorage storage,
int binaryFormatVersion) |
| 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.
|
void |
acquireExclusiveLock() |
protected void |
acquireSharedLock() |
OIndexAbstract<T> |
addCluster(String clusterName)
Add given cluster to the list of clusters that should be automatically indexed.
|
void |
addTxOperation(OIndexAbstract.IndexTxSnapshot snapshots,
OTransactionIndexChanges changes) |
OIndex<T> |
clear()
Clears the index removing all the entries in one shot.
|
protected void |
clearSnapshot(OIndexAbstract.IndexTxSnapshot indexTxSnapshot) |
void |
close() |
void |
commit(OIndexAbstract.IndexTxSnapshot snapshots) |
protected void |
commitSnapshot(Map<Object,Object> snapshot) |
int |
compareTo(OIndex<T> index) |
boolean |
contains(Object key)
Tells if a key is contained in the index.
|
long |
count(Object iKey)
Counts the entries for the key.
|
OIndexInternal<?> |
create(OIndexDefinition indexDefinition,
String clusterIndexName,
Set<String> clustersToIndex,
boolean rebuild,
OProgressListener progressListener,
OBinarySerializer valueSerializer)
Creates the index.
|
OIndexInternal<T> |
delete()
Delete the index.
|
protected abstract OBinarySerializer |
determineValueSerializer() |
protected void |
doReloadIndexEngine() |
boolean |
doRemove(OAbstractPaginatedStorage storage,
Object key) |
boolean |
doRemove(OAbstractPaginatedStorage storage,
Object key,
ORID rid) |
boolean |
equals(Object o) |
void |
flush()
Flushes in-memory changes to disk.
|
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.
|
protected static ODatabaseDocumentInternal |
getDatabase() |
String |
getDatabaseName() |
OIndexDefinition |
getDefinition() |
Object |
getFirstKey() |
int |
getIndexId() |
String |
getIndexNameByKey(Object key)
Returns the index name for a key.
|
OIndexInternal<T> |
getInternal()
Returns the internal index used.
|
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.
|
String |
getType()
Returns the type of the index as string.
|
int |
getVersion()
Returns binary format version for this index.
|
int |
hashCode() |
boolean |
hasRangeQuerySupport() |
Iterable<OTransactionIndexChangesPerKey.OTransactionIndexEntry> |
interpretTxKeyChanges(OTransactionIndexChangesPerKey changes)
Interprets transaction index changes for a certain key.
|
boolean |
isAutomatic()
Tells if the index is automatic.
|
boolean |
isRebuilding() |
boolean |
isUnique() |
OIndexKeyCursor |
keyCursor() |
boolean |
loadFromConfiguration(ODocument config)
Loads the index giving the configuration.
|
OIndexMetadata |
loadMetadata(ODocument config) |
static OIndexMetadata |
loadMetadataInternal(ODocument config,
String type,
String algorithm,
String valueContainerAlgorithm) |
protected void |
onIndexEngineChange(int indexId) |
void |
postCommit(OIndexAbstract.IndexTxSnapshot snapshots) |
protected void |
putInSnapshot(Object key,
OIdentifiable value,
Map<Object,Object> snapshot) |
long |
rebuild()
Rebuilds an automatic index.
|
long |
rebuild(OProgressListener iProgressListener)
Populate the index with all the existent records.
|
void |
releaseExclusiveLock() |
protected void |
releaseSharedLock() |
boolean |
remove(Object key)
Removes an entry by its key.
|
boolean |
remove(Object key,
OIdentifiable value)
Removes an entry by its key and value.
|
OIndexAbstract<T> |
removeCluster(String iClusterName)
Remove given cluster from the list of clusters that should be automatically indexed.
|
protected void |
removeFromSnapshot(Object key,
OIdentifiable value,
Map<Object,Object> snapshot) |
void |
setRebuildingFlag() |
void |
setType(OType type) |
String |
toString() |
ODocument |
updateConfiguration()
Saves the index configuration to disk.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcanBeUsedInEqualityOperators, doPut, isNativeTxSupportedcreate, cursor, descCursor, get, getKeySize, getSize, iterateEntries, iterateEntriesBetween, iterateEntriesMajor, iterateEntriesMinor, put, supportsOrderedIterationsprotected static final String CONFIG_MAP_RID
protected final ODocument metadata
protected final OAbstractPaginatedStorage storage
protected volatile String valueContainerAlgorithm
protected volatile int indexId
protected volatile int apiVersion
protected final int binaryFormatVersion
public static OIndexMetadata loadMetadataInternal(ODocument config, String type, String algorithm, String valueContainerAlgorithm)
public void flush()
OIndexpublic boolean hasRangeQuerySupport()
hasRangeQuerySupport in interface OIndexInternal<T>public OIndexInternal<?> create(OIndexDefinition indexDefinition, String clusterIndexName, Set<String> clustersToIndex, boolean rebuild, OProgressListener progressListener, OBinarySerializer valueSerializer)
clusterIndexName - Cluster name where to place the TreeMapprotected void doReloadIndexEngine()
public long count(Object iKey)
OIndexpublic boolean loadFromConfiguration(ODocument config)
OIndexInternalloadFromConfiguration in interface OIndexInternal<T>config - ODocument instance containing the configurationpublic OIndexMetadata loadMetadata(ODocument config)
loadMetadata in interface OIndexInternal<T>public boolean contains(Object key)
OIndexpublic long rebuild()
rebuild in interface OIndex<T>OIndex.getRebuildVersion()public void setRebuildingFlag()
setRebuildingFlag in interface OIndexInternal<T>public void close()
close in interface OIndexInternal<T>public Object getFirstKey()
getFirstKey in interface OIndex<T>public Object getLastKey()
getLastKey in interface OIndex<T>public 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 long rebuild(OProgressListener iProgressListener)
rebuild in interface OIndex<T>OIndex.getRebuildVersion()public boolean remove(Object key, OIdentifiable value)
OIndexpublic boolean doRemove(OAbstractPaginatedStorage storage, Object key, ORID rid) throws OInvalidIndexEngineIdException
doRemove in interface OIndexInternal<T>OInvalidIndexEngineIdExceptionpublic boolean remove(Object key)
OIndexpublic boolean doRemove(OAbstractPaginatedStorage storage, Object key) throws OInvalidIndexEngineIdException
doRemove in interface OIndexInternal<T>OInvalidIndexEngineIdExceptionpublic OIndex<T> clear()
OIndexpublic OIndexInternal<T> delete()
OIndexpublic String getType()
OIndexpublic void setType(OType type)
setType in interface OIndexInternal<T>public String getAlgorithm()
OIndexgetAlgorithm in interface OIndex<T>public OIndexInternal<T> getInternal()
OIndexgetInternal in interface OIndex<T>public Set<String> getClusters()
OIndexgetClusters in interface OIndex<T>public OIndexAbstract<T> addCluster(String clusterName)
OIndexInternaladdCluster in interface OIndexInternal<T>clusterName - Cluster to add.public OIndexAbstract<T> removeCluster(String iClusterName)
OIndexInternalremoveCluster in interface OIndexInternal<T>iClusterName - Cluster to remove.public int getVersion()
OIndexgetVersion in interface OIndex<T>public ODocument updateConfiguration()
OIndexInternalupdateConfiguration in interface OIndexInternal<T>OIndex.getConfiguration()public void addTxOperation(OIndexAbstract.IndexTxSnapshot snapshots, OTransactionIndexChanges changes)
addTxOperation in interface OIndexInternal<T>public Iterable<OTransactionIndexChangesPerKey.OTransactionIndexEntry> interpretTxKeyChanges(OTransactionIndexChangesPerKey changes)
ORecordDuplicatedException while applying index
changes.interpretTxKeyChanges in interface OIndexInternal<T>changes - the changes to interpret.public void commit(OIndexAbstract.IndexTxSnapshot snapshots)
commit in interface OIndexInternal<T>public void postCommit(OIndexAbstract.IndexTxSnapshot snapshots)
postCommit in interface OIndexInternal<T>public ODocument getConfiguration()
OIndexgetConfiguration in interface OIndex<T>public ODocument getMetadata()
getMetadata in interface OIndex<T>public boolean isAutomatic()
OIndexisAutomatic in interface OIndex<T>public OType[] getKeyTypes()
OIndexgetKeyTypes in interface OIndex<T>public OIndexKeyCursor keyCursor()
public OIndexDefinition getDefinition()
getDefinition in interface OIndex<T>public int getIndexId()
getIndexId in interface OIndex<T>public String getDatabaseName()
getDatabaseName in interface OIndex<T>public boolean isRebuilding()
isRebuilding in interface OIndex<T>OIndex.getRebuildVersion()protected abstract OBinarySerializer determineValueSerializer()
public Object getCollatingValue(Object key)
getCollatingValue in interface OIndexInternal<T>protected void putInSnapshot(Object key, OIdentifiable value, Map<Object,Object> snapshot)
protected void removeFromSnapshot(Object key, OIdentifiable value, Map<Object,Object> snapshot)
protected void clearSnapshot(OIndexAbstract.IndexTxSnapshot indexTxSnapshot)
public int compareTo(OIndex<T> index)
compareTo in interface Comparable<OIndex<T>>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<T>key - the index key.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<T>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.protected static ODatabaseDocumentInternal getDatabase()
public void releaseExclusiveLock()
public void acquireExclusiveLock()
protected void releaseSharedLock()
protected void acquireSharedLock()
protected void onIndexEngineChange(int indexId)
Copyright © 2009–2025 OrientDB. All rights reserved.