Package com.arcadedb.index.lsm
Class LSMTreeIndex
- java.lang.Object
-
- com.arcadedb.index.lsm.LSMTreeIndex
-
- All Implemented Interfaces:
Index
,IndexInternal
,RangeIndex
public class LSMTreeIndex extends Object implements RangeIndex, IndexInternal
LSM-Tree index implementation. It relies on a mutable index and its underlying immutable, compacted index.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LSMTreeIndex.IndexFactoryHandler
static class
LSMTreeIndex.PaginatedComponentFactoryHandlerNotUnique
static class
LSMTreeIndex.PaginatedComponentFactoryHandlerUnique
-
Nested classes/interfaces inherited from interface com.arcadedb.index.Index
Index.BuildIndexCallback
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicReference<LSMTreeIndexAbstract.COMPACTING_STATUS>
compactingStatus
protected LSMTreeIndexMutable
mutable
protected List<String>
propertyNames
-
Constructor Summary
Constructors Constructor Description LSMTreeIndex(DatabaseInternal database, String name, boolean unique, String filePath, int id, PaginatedFile.MODE mode, int pageSize, int version)
Called at load time (1st page only).LSMTreeIndex(DatabaseInternal database, String name, boolean unique, String filePath, PaginatedFile.MODE mode, Type[] keyTypes, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy)
Called at creation time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
build(Index.BuildIndexCallback callback)
void
close()
boolean
compact()
long
countEntries()
void
drop()
boolean
equals(Object obj)
IndexCursor
get(Object[] keys)
Retrieves the set of RIDs associated to a key.IndexCursor
get(Object[] keys, int limit)
Retrieves the set of RIDs associated to a key with a limit for the result.int
getAssociatedBucketId()
byte[]
getBinaryKeyTypes()
int
getFileId()
List<Integer>
getFileIds()
Type[]
getKeyTypes()
LSMTreeIndexMutable
getMutableIndex()
String
getName()
LSMTreeIndexAbstract.NULL_STRATEGY
getNullStrategy()
int
getPageSize()
PaginatedComponent
getPaginatedComponent()
List<String>
getPropertyNames()
Map<String,Long>
getStats()
Schema.INDEX_TYPE
getType()
TypeIndex
getTypeIndex()
String
getTypeName()
int
hashCode()
boolean
isAutomatic()
boolean
isCompacting()
boolean
isUnique()
IndexCursor
iterator(boolean ascendingOrder)
The returning iterator does not skip deleted entries and it might contains duplicated entries.IndexCursor
iterator(boolean ascendingOrder, Object[] fromKeys, boolean inclusive)
The returning iterator does not skip deleted entries and it might contains duplicated entries.void
put(Object[] keys, RID[] rids)
Add multiple values for one key in the index.IndexCursor
range(boolean ascendingOrder, Object[] beginKeys, boolean beginKeysInclusive, Object[] endKeys, boolean endKeysInclusive)
The returning iterator does not skip deleted entries and it might contains duplicated entries.void
remove(Object[] keys)
Removes the keys from the index.void
remove(Object[] keys, Identifiable rid)
Removes an entry keys/record entry from the index.boolean
scheduleCompaction()
void
setMetadata(String typeName, String[] propertyNames, int associatedBucketId)
void
setNullStrategy(LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy)
void
setTypeIndex(TypeIndex typeIndex)
protected LSMTreeIndexMutable
splitIndex(int startingFromPage, LSMTreeIndexCompacted compactedIndex)
boolean
supportsOrderedIterations()
String
toString()
-
-
-
Field Detail
-
mutable
protected LSMTreeIndexMutable mutable
-
compactingStatus
protected AtomicReference<LSMTreeIndexAbstract.COMPACTING_STATUS> compactingStatus
-
-
Constructor Detail
-
LSMTreeIndex
public LSMTreeIndex(DatabaseInternal database, String name, boolean unique, String filePath, PaginatedFile.MODE mode, Type[] keyTypes, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy)
Called at creation time.
-
LSMTreeIndex
public LSMTreeIndex(DatabaseInternal database, String name, boolean unique, String filePath, int id, PaginatedFile.MODE mode, int pageSize, int version) throws IOException
Called at load time (1st page only).- Throws:
IOException
-
-
Method Detail
-
scheduleCompaction
public boolean scheduleCompaction()
- Specified by:
scheduleCompaction
in interfaceIndex
-
setMetadata
public void setMetadata(String typeName, String[] propertyNames, int associatedBucketId)
- Specified by:
setMetadata
in interfaceIndexInternal
-
getBinaryKeyTypes
public byte[] getBinaryKeyTypes()
- Specified by:
getBinaryKeyTypes
in interfaceIndexInternal
-
getFileIds
public List<Integer> getFileIds()
- Specified by:
getFileIds
in interfaceIndexInternal
-
getTypeIndex
public TypeIndex getTypeIndex()
- Specified by:
getTypeIndex
in interfaceIndexInternal
-
setTypeIndex
public void setTypeIndex(TypeIndex typeIndex)
- Specified by:
setTypeIndex
in interfaceIndexInternal
-
getKeyTypes
public Type[] getKeyTypes()
- Specified by:
getKeyTypes
in interfaceIndexInternal
-
getType
public Schema.INDEX_TYPE getType()
-
getTypeName
public String getTypeName()
- Specified by:
getTypeName
in interfaceIndex
-
getPropertyNames
public List<String> getPropertyNames()
- Specified by:
getPropertyNames
in interfaceIndex
-
compact
public boolean compact() throws IOException, InterruptedException
- Specified by:
compact
in interfaceIndexInternal
- Throws:
IOException
InterruptedException
-
isCompacting
public boolean isCompacting()
- Specified by:
isCompacting
in interfaceIndex
-
close
public void close()
- Specified by:
close
in interfaceIndexInternal
-
drop
public void drop()
- Specified by:
drop
in interfaceIndexInternal
-
countEntries
public long countEntries()
- Specified by:
countEntries
in interfaceIndex
-
iterator
public IndexCursor iterator(boolean ascendingOrder)
Description copied from interface:RangeIndex
The returning iterator does not skip deleted entries and it might contains duplicated entries. WARNING: this method does not read pending changes in transaction.- Specified by:
iterator
in interfaceRangeIndex
-
iterator
public IndexCursor iterator(boolean ascendingOrder, Object[] fromKeys, boolean inclusive)
Description copied from interface:RangeIndex
The returning iterator does not skip deleted entries and it might contains duplicated entries. WARNING: this method does not read pending changes in transaction.- Specified by:
iterator
in interfaceRangeIndex
-
range
public IndexCursor range(boolean ascendingOrder, Object[] beginKeys, boolean beginKeysInclusive, Object[] endKeys, boolean endKeysInclusive)
Description copied from interface:RangeIndex
The returning iterator does not skip deleted entries and it might contains duplicated entries. WARNING: this method does not read pending changes in transaction.- Specified by:
range
in interfaceRangeIndex
-
supportsOrderedIterations
public boolean supportsOrderedIterations()
- Specified by:
supportsOrderedIterations
in interfaceIndex
-
isAutomatic
public boolean isAutomatic()
- Specified by:
isAutomatic
in interfaceIndex
-
getPageSize
public int getPageSize()
- Specified by:
getPageSize
in interfaceIndex
-
get
public IndexCursor get(Object[] keys)
Description copied from interface:Index
Retrieves the set of RIDs associated to a key.
-
get
public IndexCursor get(Object[] keys, int limit)
Description copied from interface:Index
Retrieves the set of RIDs associated to a key with a limit for the result.
-
put
public void put(Object[] keys, RID[] rids)
Description copied from interface:Index
Add multiple values for one key in the index.
-
remove
public void remove(Object[] keys)
Description copied from interface:Index
Removes the keys from the index.
-
remove
public void remove(Object[] keys, Identifiable rid)
Description copied from interface:Index
Removes an entry keys/record entry from the index.
-
getStats
public Map<String,Long> getStats()
- Specified by:
getStats
in interfaceIndexInternal
-
getNullStrategy
public LSMTreeIndexAbstract.NULL_STRATEGY getNullStrategy()
- Specified by:
getNullStrategy
in interfaceIndex
-
setNullStrategy
public void setNullStrategy(LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy)
- Specified by:
setNullStrategy
in interfaceIndex
-
getFileId
public int getFileId()
- Specified by:
getFileId
in interfaceIndexInternal
-
getMutableIndex
public LSMTreeIndexMutable getMutableIndex()
-
getPaginatedComponent
public PaginatedComponent getPaginatedComponent()
- Specified by:
getPaginatedComponent
in interfaceIndexInternal
-
getAssociatedBucketId
public int getAssociatedBucketId()
- Specified by:
getAssociatedBucketId
in interfaceIndex
-
splitIndex
protected LSMTreeIndexMutable splitIndex(int startingFromPage, LSMTreeIndexCompacted compactedIndex)
-
build
public long build(Index.BuildIndexCallback callback)
- Specified by:
build
in interfaceIndexInternal
-
-