Skip to content

Commit aefdcc7

Browse files
authored
IGNITE-26973 Remove redundant maps in IndexProcessor (#12507)
1 parent 5c140fb commit aefdcc7

File tree

4 files changed

+10
-32
lines changed

4 files changed

+10
-32
lines changed

modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/IndexDdlIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,6 @@ private Collection<Index> indexes(String cacheName) {
203203

204204
/** */
205205
private LinkedHashMap<String, IndexKeyDefinition> indexKeyDefinitions(Index idx) {
206-
return grid(0).context().indexProcessor().indexDefinition(idx.id()).indexKeyDefinitions();
206+
return idx.indexDefinition().indexKeyDefinitions();
207207
}
208208
}

modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.util.HashMap;
2424
import java.util.List;
2525
import java.util.Map;
26-
import java.util.UUID;
27-
import java.util.concurrent.ConcurrentHashMap;
2826
import java.util.concurrent.locks.ReentrantReadWriteLock;
2927
import org.apache.ignite.IgniteCheckedException;
3028
import org.apache.ignite.IgniteLogger;
@@ -112,12 +110,7 @@ public static void registerIO() {
112110
/**
113111
* Registry of all indexes. High key is a cache name, lower key is an unique index name.
114112
*/
115-
private final Map<String, Map<String, Index>> cacheToIdx = new ConcurrentHashMap<>();
116-
117-
/**
118-
* Registry of all index definitions. Key is {@link Index#id()}, value is IndexDefinition used for creating index.
119-
*/
120-
private final Map<UUID, IndexDefinition> idxDefs = new ConcurrentHashMap<>();
113+
private final Map<String, Map<String, Index>> cacheToIdx = new HashMap<>();
121114

122115
/** Exclusive lock for DDL operations. */
123116
private final ReentrantReadWriteLock ddlLock = new ReentrantReadWriteLock();
@@ -242,7 +235,7 @@ public Index createIndex(GridCacheContext<?, ?> cctx, IndexFactory factory, Inde
242235
try {
243236
String cacheName = definition.idxName().cacheName();
244237

245-
cacheToIdx.putIfAbsent(cacheName, new ConcurrentHashMap<>());
238+
cacheToIdx.putIfAbsent(cacheName, new HashMap<>());
246239

247240
String uniqIdxName = definition.idxName().fullName();
248241

@@ -253,8 +246,6 @@ public Index createIndex(GridCacheContext<?, ?> cctx, IndexFactory factory, Inde
253246

254247
cacheToIdx.get(cacheName).put(uniqIdxName, idx);
255248

256-
idxDefs.put(idx.id(), definition);
257-
258249
return idx;
259250

260251
}
@@ -281,11 +272,8 @@ public void removeIndex(IndexName idxName, boolean softDelete) {
281272

282273
Index idx = idxs.remove(idxName.fullName());
283274

284-
if (idx != null) {
275+
if (idx != null)
285276
idx.destroy(softDelete);
286-
idxDefs.remove(idx.id());
287-
}
288-
289277
}
290278
finally {
291279
ddlLock.writeLock().unlock();
@@ -421,16 +409,6 @@ public Collection<Index> indexes(String cacheName) {
421409
}
422410
}
423411

424-
/**
425-
* Returns IndexDefinition used for creating index specified id.
426-
*
427-
* @param idxId UUID of index.
428-
* @return IndexDefinition used for creating index with id {@code idxId}.
429-
*/
430-
public IndexDefinition indexDefinition(UUID idxId) {
431-
return idxDefs.get(idxId);
432-
}
433-
434412
/**
435413
* Unregisters cache.
436414
*
@@ -638,7 +616,7 @@ public Map<String, Integer> secondaryIndexesInlineSize() {
638616
for (Index idx : idxs.values()) {
639617
if (idx instanceof InlineIndex && !QueryUtils.PRIMARY_KEY_INDEX.equals(idx.name())) {
640618
InlineIndex idx0 = (InlineIndex)idx;
641-
IndexDefinition idxDef = indexDefinition(idx.id());
619+
IndexDefinition idxDef = idx.indexDefinition();
642620
IndexName idxName = idxDef.idxName();
643621

644622
map.put(

modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexQueryProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public <K, V> IndexQueryResult<K, V> queryLocal(
9393

9494
GridCursor<IndexRow> cursor = queryMultipleRanges(idx, cacheFilter, qry);
9595

96-
SortedIndexDefinition def = (SortedIndexDefinition)idxProc.indexDefinition(idx.id());
96+
SortedIndexDefinition def = idx.indexDefinition();
9797

9898
IndexQueryResultMeta meta = new IndexQueryResultMeta(def, qry.critSize());
9999

@@ -274,7 +274,7 @@ private SortedSegmentedIndex assertSortedIndex(Index idx) throws IgniteCheckedEx
274274
* Criteria fields have to match to a prefix of the index. Order of fields in criteria doesn't matter.
275275
*/
276276
private boolean checkIndex(SortedSegmentedIndex idx, String tblName, Map<String, String> criteriaFlds) {
277-
IndexDefinition idxDef = idxProc.indexDefinition(idx.id());
277+
IndexDefinition idxDef = idx.indexDefinition();
278278

279279
if (!tblName.equals(idxDef.idxName().tableName()))
280280
return false;
@@ -411,7 +411,7 @@ private GridCursor<IndexRow> querySortedIndex(
411411
IndexingQueryFilter cacheFilter,
412412
IndexSingleRangeQuery qry
413413
) throws IgniteCheckedException {
414-
IndexRowComparator rowCmp = ((SortedIndexDefinition)idxProc.indexDefinition(idx.id())).rowComparator();
414+
IndexRowComparator rowCmp = idx.indexDefinition().rowComparator();
415415

416416
BPlusTree.TreeRowClosure<IndexRow, IndexRow> treeFilter = qry.filter(rowCmp);
417417

modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/defragmentation/IndexingDefragmentation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private boolean defragmentTable(
145145
for (InlineIndex oldIdx : indexes.idxs) {
146146
InlineIndexRowHandler oldRowHnd = oldIdx.segment(0).rowHandler();
147147

148-
SortedIndexDefinition idxDef = (SortedIndexDefinition)indexing.indexDefinition(oldIdx.id());
148+
SortedIndexDefinition idxDef = oldIdx.indexDefinition();
149149

150150
InlineIndexImpl newIdx = new DefragIndexFactory(newCtx.offheap(), newCachePageMemory, oldIdx)
151151
.createIndex(cctx, idxDef)
@@ -224,7 +224,7 @@ private Collection<TableIndexes> tables(CacheGroupContext gctx) {
224224
List<InlineIndex> indexes = indexing.treeIndexes(cctx.name(), false);
225225

226226
for (InlineIndex idx: indexes) {
227-
String table = indexing.indexDefinition(idx.id()).idxName().tableName();
227+
String table = idx.indexDefinition().idxName().tableName();
228228

229229
idxs.putIfAbsent(table, new TableIndexes(cctx, table));
230230

0 commit comments

Comments
 (0)