Class InlineIndexImpl
- java.lang.Object
-
- org.apache.ignite.internal.cache.query.index.AbstractIndex
-
- org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexImpl
-
- All Implemented Interfaces:
Index,InlineIndex,SortedSegmentedIndex
public class InlineIndexImpl extends AbstractIndex implements InlineIndex
Sorted index implementation.
-
-
Field Summary
Fields Modifier and Type Field Description static StringINDEX_METRIC_PREFIX
-
Constructor Summary
Constructors Constructor Description InlineIndexImpl(GridCacheContext<?,?> cctx, SortedIndexDefinition def, InlineIndexTree[] segments, IoStatisticsHolderIndex stats)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intcalculateSegment(int segmentsCnt, int part)booleancanHandle(CacheDataRow row)Checks whether index handles specified cache row.longcount(int segment)Counts index rows in specified tree segment.longcount(int segment, IndexQueryContext qryCtx)Counts index rows in specified tree segment with cache filter.booleancreated()trueif index is created andfalseif it is restored from disk.voiddestroy(boolean softDel)Destroy index.GridCursor<IndexRow>find(IndexRow lower, IndexRow upper, boolean lowIncl, boolean upIncl, int segment, IndexQueryContext qryCtx)Finds index rows by specified range in specifed tree segment with cache filtering.GridCursor<IndexRow>find(IndexRow lower, IndexRow upper, boolean lowIncl, boolean upIncl, IndexQueryContext qryCtx)Finds index rows by specified range in all tree segments with cache filtering.GridCursor<IndexRow>findFirst(int segment, IndexQueryContext qryCtx)Finds first index row for specified tree segment and cache filter.GridCursor<IndexRow>findFirstOrLast(IndexQueryContext qryCtx, boolean first)Takes only one first or last index record.GridCursor<IndexRow>findLast(int segment, IndexQueryContext qryCtx)Finds last index row for specified tree segment and cache filter.UUIDid()Unique ID.SortedIndexDefinitionindexDefinition()intinlineSize()IndexKeyTypeSettingskeyTypeSettings()Stringname()Index name.voidonUpdate(@Nullable CacheDataRow oldRow, @Nullable CacheDataRow newRow, boolean prevRowAvailable)Callback that runs when the underlying cache is updated.voidputIndexRow(IndexRowImpl row)Put index row to index.InlineIndexTreesegment(int segment)intsegmentForRow(CacheDataRow row)intsegmentsCount()Returns amount of index tree segments.longtotalCount()Returns number of elements in the tree by scanning pages of the bottom (leaf) level.-
Methods inherited from class org.apache.ignite.internal.cache.query.index.AbstractIndex
markIndexRebuild, rebuildInProgress, unwrap
-
-
-
-
Field Detail
-
INDEX_METRIC_PREFIX
public static final String INDEX_METRIC_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InlineIndexImpl
public InlineIndexImpl(GridCacheContext<?,?> cctx, SortedIndexDefinition def, InlineIndexTree[] segments, IoStatisticsHolderIndex stats)
Constructor.
-
-
Method Detail
-
find
public GridCursor<IndexRow> find(IndexRow lower, IndexRow upper, boolean lowIncl, boolean upIncl, int segment, IndexQueryContext qryCtx) throws IgniteCheckedException
Finds index rows by specified range in specifed tree segment with cache filtering. Range can be bound or unbound.- Specified by:
findin interfaceSortedSegmentedIndex- Parameters:
lower- Nullable lower bound.upper- Nullable upper bound.lowIncl-truefor inclusive lower bound, otherwisefalse.upIncl-truefor inclusive upper bound, otherwisefalse.segment- Number of tree segment to find.qryCtx- External index query context.- Returns:
- Cursor of found index rows.
- Throws:
IgniteCheckedException
-
findFirstOrLast
public GridCursor<IndexRow> findFirstOrLast(IndexQueryContext qryCtx, boolean first) throws IgniteCheckedException
Takes only one first or last index record.- Specified by:
findFirstOrLastin interfaceSortedSegmentedIndex- Parameters:
qryCtx- External index qyery context.first-Trueto take first index value.Falseto take last index value.- Throws:
IgniteCheckedException
-
find
public GridCursor<IndexRow> find(IndexRow lower, IndexRow upper, boolean lowIncl, boolean upIncl, IndexQueryContext qryCtx) throws IgniteCheckedException
Finds index rows by specified range in all tree segments with cache filtering. Range can be bound or unbound.- Specified by:
findin interfaceSortedSegmentedIndex- Parameters:
lower- Nullable lower bound.upper- Nullable upper bound.lowIncl-truefor inclusive lower bound, otherwisefalse.upIncl-truefor inclusive upper bound, otherwisefalse.qryCtx- External index query context.- Returns:
- Cursor of found index rows.
- Throws:
IgniteCheckedException
-
count
public long count(int segment) throws IgniteCheckedExceptionCounts index rows in specified tree segment.- Specified by:
countin interfaceSortedSegmentedIndex- Parameters:
segment- Number of tree segment to find.- Returns:
- count of index rows for specified segment.
- Throws:
IgniteCheckedException
-
count
public long count(int segment, IndexQueryContext qryCtx) throws IgniteCheckedExceptionCounts index rows in specified tree segment with cache filter.- Specified by:
countin interfaceSortedSegmentedIndex- Parameters:
segment- Number of tree segment to find.qryCtx- Index query context.- Returns:
- count of index rows for specified segment.
- Throws:
IgniteCheckedException
-
totalCount
public long totalCount() throws IgniteCheckedExceptionReturns number of elements in the tree by scanning pages of the bottom (leaf) level.- Specified by:
totalCountin interfaceSortedSegmentedIndex- Returns:
- Number of elements in the tree.
- Throws:
IgniteCheckedException- If failed.
-
findFirst
public GridCursor<IndexRow> findFirst(int segment, IndexQueryContext qryCtx) throws IgniteCheckedException
Finds first index row for specified tree segment and cache filter.- Specified by:
findFirstin interfaceSortedSegmentedIndex- Parameters:
segment- Number of tree segment to find.qryCtx- External index qyery context.- Returns:
- Cursor of found index rows.
- Throws:
IgniteCheckedException
-
findLast
public GridCursor<IndexRow> findLast(int segment, IndexQueryContext qryCtx) throws IgniteCheckedException
Finds last index row for specified tree segment and cache filter.- Specified by:
findLastin interfaceSortedSegmentedIndex- Parameters:
segment- Number of tree segment to find.qryCtx- External index qyery context.- Returns:
- Cursor of found index rows.
- Throws:
IgniteCheckedException
-
onUpdate
public void onUpdate(@Nullable @Nullable CacheDataRow oldRow, @Nullable @Nullable CacheDataRow newRow, boolean prevRowAvailable) throws IgniteCheckedExceptionCallback that runs when the underlying cache is updated.- Specified by:
onUpdatein interfaceIndex- Parameters:
oldRow- Cache row that was replaced with newRow.newRow- Cache row that was stored.prevRowAvailable- Whether oldRow available.- Throws:
IgniteCheckedException
-
putIndexRow
public void putIndexRow(IndexRowImpl row) throws IgniteCheckedException
Put index row to index. This method is for internal use only.- Parameters:
row- Index row.- Throws:
IgniteCheckedException
-
inlineSize
public int inlineSize()
- Specified by:
inlineSizein interfaceInlineIndex- Returns:
- amount of bytes to store inlined index keys.
-
keyTypeSettings
public IndexKeyTypeSettings keyTypeSettings()
-
segmentsCount
public int segmentsCount()
Returns amount of index tree segments.- Specified by:
segmentsCountin interfaceSortedSegmentedIndex- Returns:
- amount of index tree segments.
-
segmentForRow
public int segmentForRow(CacheDataRow row)
- Parameters:
row- Сache row.- Returns:
- Segment ID for given key.
-
calculateSegment
public static int calculateSegment(int segmentsCnt, int part)- Parameters:
segmentsCnt- Сount of segments in cache.part- Partition.- Returns:
- Segment ID for given segment count and partition.
-
created
public boolean created()
trueif index is created andfalseif it is restored from disk.- Specified by:
createdin interfaceInlineIndex
-
segment
public InlineIndexTree segment(int segment)
- Specified by:
segmentin interfaceInlineIndex- Parameters:
segment- Number of tree segment.- Returns:
- Tree segment for specified number.
-
destroy
public void destroy(boolean softDel)
Destroy index.
-
canHandle
public boolean canHandle(CacheDataRow row) throws IgniteCheckedException
Checks whether index handles specified cache row.- Specified by:
canHandlein interfaceIndex- Parameters:
row- Cache row.- Returns:
- Whether index handles specified cache row
- Throws:
IgniteCheckedException
-
indexDefinition
public SortedIndexDefinition indexDefinition()
- Specified by:
indexDefinitionin interfaceIndex- Specified by:
indexDefinitionin interfaceSortedSegmentedIndex- Returns:
- Index definition.
-
-