Class OIndexAbstract
java.lang.Object
com.orientechnologies.orient.core.index.OIndexAbstract
- All Implemented Interfaces:
OIndex,OIndexInternal,Comparable<OIndex>
- Direct Known Subclasses:
OIndexMultiValues,OIndexOneValue,OLuceneIndexNotUnique
Handles indexing when records change. The underlying lock manager for keys can be the
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.- Author:
- Luca Garulli (l.garulli--(at)--orientdb.com)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumIndicates search behavior in case ofOCompositeKeykeys that have less amount of internal keys are used, whether lowest or highest partially matched key should be used. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected static final Stringprotected OIndexMetadataprotected intprotected final OStorageFields inherited from interface com.orientechnologies.orient.core.index.OIndexInternal
ALGORITHM, CONFIG_AUTOMATIC, CONFIG_KEYTYPE, CONFIG_NAME, CONFIG_TYPE, INDEX_DEFINITION, INDEX_DEFINITION_CLASS, INDEX_VERSION, MERGE_KEYS, METADATA, VALUE_CONTAINER_ALGORITHM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAcquires exclusive lock in the active atomic operation running on the current thread for this index.protected voidprotected voidaddCluster(String clusterName) Add given cluster to the list of clusters that should be automatically indexed.clear()Deprecated.Manual indexes are deprecated and will be removedvoidclose()intlongDeprecated.create(OIndexMetadata indexMetadata, boolean rebuild, OProgressListener progressListener) Creates the index.cursor()Deprecated.delete()Delete the index.Deprecated.protected voiddoDelete()protected voidenhanceFromCompositeKeyBetweenAsc(Object keyFrom, boolean fromInclusive) enhanceFromCompositeKeyBetweenDesc(Object keyFrom, boolean fromInclusive) enhanceToCompositeKeyBetweenAsc(Object keyTo, boolean toInclusive) enhanceToCompositeKeyBetweenDesc(Object keyTo, boolean toInclusive) booleanvoidflush()Deprecated.Returns the engine of the index as string.Returns Names of clusters that will be indexed.getCollatingValue(Object key) Returns the index configuration.protected static ODatabaseDocumentInternalDeprecated.intgetIndexNameByKey(Object key) Returns the index name for a key.Returns the internal index used.longDeprecated.OType[]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.Deprecated.getName()Returns the index name.longDeprecated.longgetSize()Deprecated.getType()Returns the type of the index as string.intReturns binary format version for this index.inthashCode()booleanInterprets transaction index changes for a certain key.booleanTells if the index is automatic.booleanDeprecated.booleanisUnique()iterateEntries(Collection<?> keys, boolean ascSortOrder) Deprecated.iterateEntriesBetween(Object fromKey, boolean fromInclusive, Object toKey, boolean toInclusive, boolean ascOrder) Deprecated.iterateEntriesMajor(Object fromKey, boolean fromInclusive, boolean ascOrder) Deprecated.iterateEntriesMinor(Object toKey, boolean toInclusive, boolean ascOrder) Deprecated.Deprecated.booleanloadFromConfiguration(ODocument config) Loads the index giving the configuration.loadMetadata(ODocument config) static OIndexMetadataloadMetadataFromDoc(ODocument config) static OIndexMetadataloadMetadataInternal(ODocument config, String type, String algorithm, String valueContainerAlgorithm) static voidlongrebuild()Rebuilds an automatic index.longrebuild(OProgressListener iProgressListener) Populate the index with all the existent records.protected voidprotected voidbooleanRemoves an entry by its key.booleanremove(Object key, OIdentifiable rid) Removes an entry by its key and value.removeCluster(String iClusterName) Remove given cluster from the list of clusters that should be automatically indexed.toString()Saves the index configuration to disk.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.orientechnologies.orient.core.index.OIndex
get, put, supportsOrderedIterationsMethods inherited from interface com.orientechnologies.orient.core.index.OIndexInternal
canBeUsedInEqualityOperators, descStream, getRids, getRidsIgnoreTx, isNativeTxSupported, size, stream, streamEntries, streamEntriesBetween, streamEntriesMajor, streamEntriesMinor
-
Field Details
-
CONFIG_MAP_RID
- See Also:
-
storage
-
indexId
protected volatile int indexId -
apiVersion
protected volatile int apiVersion -
im
-
-
Constructor Details
-
OIndexAbstract
-
-
Method Details
-
loadMetadataFromDoc
-
loadMetadataInternal
public static OIndexMetadata loadMetadataInternal(ODocument config, String type, String algorithm, String valueContainerAlgorithm) -
hasRangeQuerySupport
public boolean hasRangeQuerySupport()- Specified by:
hasRangeQuerySupportin interfaceOIndexInternal
-
create
public OIndexInternal create(OIndexMetadata indexMetadata, boolean rebuild, OProgressListener progressListener) Creates the index.- Specified by:
createin interfaceOIndexInternal
-
doReloadIndexEngine
protected void doReloadIndexEngine() -
loadFromConfiguration
Description copied from interface:OIndexInternalLoads the index giving the configuration.- Specified by:
loadFromConfigurationin interfaceOIndexInternal- Parameters:
config- ODocument instance containing the configuration
-
loadMetadata
- Specified by:
loadMetadatain interfaceOIndexInternal
-
rebuild
public long rebuild()Rebuilds an automatic index. -
close
public void close()- Specified by:
closein interfaceOIndexInternal
-
getSize
Deprecated. -
count
Deprecated.Counts the entries for the key. -
getKeySize
Deprecated.- Specified by:
getKeySizein interfaceOIndex- Returns:
- Number of keys in index
-
flush
Deprecated.Flushes in-memory changes to disk. -
getRebuildVersion
Deprecated.- Specified by:
getRebuildVersionin interfaceOIndex
-
isRebuilding
Deprecated.- Specified by:
isRebuildingin interfaceOIndex- Returns:
- Indicates whether index is rebuilding at the moment.
- See Also:
-
getFirstKey
Deprecated.- Specified by:
getFirstKeyin interfaceOIndex
-
getLastKey
Deprecated.- Specified by:
getLastKeyin interfaceOIndex
-
cursor
Deprecated. -
descCursor
Deprecated.- Specified by:
descCursorin interfaceOIndex
-
keyCursor
Deprecated. -
iterateEntries
Deprecated.Description copied from interface:OIndexReturns cursor which presents data associated with passed in keys.- Specified by:
iterateEntriesin interfaceOIndex- Parameters:
keys- Keys data of which should be returned.ascSortOrder- Flag which determines whether data iterated by cursor should be in ascending or descending order.- Returns:
- cursor which presents data associated with passed in keys.
-
iterateEntriesBetween
@Deprecated public OIndexCursor iterateEntriesBetween(Object fromKey, boolean fromInclusive, Object toKey, boolean toInclusive, boolean ascOrder) Deprecated.Description copied from interface:OIndexReturns cursor which presents subset of index data between passed in keys.- Specified by:
iterateEntriesBetweenin interfaceOIndex- Parameters:
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.- Returns:
- Cursor which presents subset of index data between passed in keys.
-
iterateEntriesMajor
@Deprecated public OIndexCursor iterateEntriesMajor(Object fromKey, boolean fromInclusive, boolean ascOrder) Deprecated.Description copied from interface:OIndexReturns cursor which presents subset of data which associated with key which is greater than passed in key.- Specified by:
iterateEntriesMajorin interfaceOIndex- Parameters:
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.- Returns:
- cursor which presents subset of data which associated with key which is greater than passed in key.
-
iterateEntriesMinor
@Deprecated public OIndexCursor iterateEntriesMinor(Object toKey, boolean toInclusive, boolean ascOrder) Deprecated.Description copied from interface:OIndexReturns cursor which presents subset of data which associated with key which is less than passed in key.- Specified by:
iterateEntriesMinorin interfaceOIndex- Parameters:
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.- Returns:
- cursor which presents subset of data which associated with key which is less than passed in key.
-
rebuild
Populate the index with all the existent records. -
remove
Description copied from interface:OIndexRemoves an entry by its key and value. -
remove
Description copied from interface:OIndexRemoves an entry by its key. -
clear
Deprecated.Manual indexes are deprecated and will be removedClears the index removing all the entries in one shot. -
delete
Description copied from interface:OIndexDelete the index. -
doDelete
protected void doDelete() -
getName
Description copied from interface:OIndexReturns the index name. -
getType
Description copied from interface:OIndexReturns the type of the index as string. -
getAlgorithm
Description copied from interface:OIndexReturns the engine of the index as string.- Specified by:
getAlgorithmin interfaceOIndex
-
toString
-
getInternal
Description copied from interface:OIndexReturns the internal index used.- Specified by:
getInternalin interfaceOIndex
-
getClusters
Description copied from interface:OIndexReturns Names of clusters that will be indexed.- Specified by:
getClustersin interfaceOIndex- Returns:
- Names of clusters that will be indexed.
-
addCluster
Description copied from interface:OIndexInternalAdd given cluster to the list of clusters that should be automatically indexed.- Specified by:
addClusterin interfaceOIndexInternal- Parameters:
clusterName- Cluster to add.- Returns:
- Current index instance.
-
removeCluster
Description copied from interface:OIndexInternalRemove given cluster from the list of clusters that should be automatically indexed.- Specified by:
removeClusterin interfaceOIndexInternal- Parameters:
iClusterName- Cluster to remove.- Returns:
- Current index instance.
-
getVersion
public int getVersion()Description copied from interface:OIndexReturns binary format version for this index. Index format changes during system development but old formats are supported for binary compatibility. This method may be used to detect version of binary format which is used by current index and upgrade index to new one.- Specified by:
getVersionin interfaceOIndex- Returns:
- Returns binary format version for this index if possible, otherwise -1.
-
updateConfiguration
Description copied from interface:OIndexInternalSaves the index configuration to disk.- Specified by:
updateConfigurationin interfaceOIndexInternal- Returns:
- The configuration as ODocument instance
- See Also:
-
interpretTxKeyChanges
public Iterable<OStorageTransactionIndexChange> interpretTxKeyChanges(OTransactionIndexChangesPerKey changes) Interprets transaction index changes for a certain key. Override it to customize index behaviour on interpreting index changes. This may be viewed as an optimization, but in some cases this is a requirement. For example, if you put multiple values under the same key during the transaction for single-valued/unique index, but remove all of them except one before commit, there is no point in throwingORecordDuplicatedExceptionwhile applying index changes.- Specified by:
interpretTxKeyChangesin interfaceOIndexInternal- Parameters:
changes- the changes to interpret.- Returns:
- the interpreted index key changes.
-
getConfiguration
Description copied from interface:OIndexReturns the index configuration.- Specified by:
getConfigurationin interfaceOIndex- Returns:
- An ODocument object containing all the index properties
-
getMetadata
- Specified by:
getMetadatain interfaceOIndex
-
isUnique
public boolean isUnique() -
isAutomatic
public boolean isAutomatic()Description copied from interface:OIndexTells if the index is automatic. Automatic means it's maintained automatically by OrientDB. This is the case of indexes created against schema properties. Automatic indexes can always been rebuilt.- Specified by:
isAutomaticin interfaceOIndex- Returns:
- True if the index is automatic, otherwise false
-
getKeyTypes
Description copied from interface:OIndexTypes 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.- Specified by:
getKeyTypesin interfaceOIndex
-
keyStream
- Specified by:
keyStreamin interfaceOIndexInternal
-
getDefinition
- Specified by:
getDefinitionin interfaceOIndex
-
equals
-
hashCode
public int hashCode() -
getIndexId
public int getIndexId()- Specified by:
getIndexIdin interfaceOIndexInternal
-
getDatabaseName
- Specified by:
getDatabaseNamein interfaceOIndex
-
getCollatingValue
- Specified by:
getCollatingValuein interfaceOIndexInternal
-
compareTo
- Specified by:
compareToin interfaceComparable<OIndex>
-
getIndexNameByKey
Description copied from interface: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.- Specified by:
getIndexNameByKeyin interfaceOIndexInternal- Parameters:
key- the index key.- Returns:
- The index name involved
-
acquireAtomicExclusiveLock
Description copied from interface: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
keyto infer a more narrow lock scope, but that is not a requirement.- Specified by:
acquireAtomicExclusiveLockin interfaceOIndexInternal- Parameters:
key- the index key to lock.- Returns:
trueif this index was locked entirely,falseif this index locking is sensitive to the providedkeyand only some subset of this index was locked.
-
getDatabase
-
releaseExclusiveLock
protected void releaseExclusiveLock() -
acquireExclusiveLock
protected void acquireExclusiveLock() -
manualIndexesWarning
public static void manualIndexesWarning() -
enhanceToCompositeKeyBetweenAsc
-
enhanceFromCompositeKeyBetweenAsc
-
enhanceToCompositeKeyBetweenDesc
-
enhanceFromCompositeKeyBetweenDesc
-