korlov42 commented on a change in pull request #8490:
URL: https://github.com/apache/ignite/pull/8490#discussion_r590063542
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/DurableBackgroundCleanupIndexTreeTask.java
##########
@@ -102,7 +96,7 @@ public DurableBackgroundCleanupIndexTreeTask(
IoStatisticsHolderIndex stats = new IoStatisticsHolderIndex(
Review comment:
`stats` is not being used
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/Order.java
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cache.query.index;
+
+/**
+ * Represents ordering of rows within sorted index.
+ */
+public class Order {
+ /** */
+ private final NullsOrder nullsOrder;
+
+ /** */
+ private final SortOrder sortOrder;
+
+ /** */
+ public Order(SortOrder sortOrder, NullsOrder nullsOrder) {
+ this.sortOrder = sortOrder;
+ this.nullsOrder = nullsOrder;
+ }
+
+ /** */
+ public SortOrder getSortOrder() {
Review comment:
According to [our
guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines#CodingGuidelines-Gettersandsetters)
a prefix `get` should be omitted for internal packages. Please fix this
everywhere in this PR.
##########
File path:
modules/core/src/main/java/org/apache/ignite/spi/indexing/IndexingSpi.java
##########
@@ -84,7 +91,56 @@
* @param expirationTime Expiration time or 0 if never expires.
* @throws IgniteSpiException If failed.
*/
- public void store(@Nullable String cacheName, Object key, Object val, long
expirationTime) throws IgniteSpiException;
+ public default void store(@Nullable String cacheName, Object key, Object
val, long expirationTime) throws IgniteSpiException {
+ // No-op.
+ }
+
+ /**
+ * Updates index with new row. Note that key is unique for cache, so if
cache contains multiple indexes
+ * the key should be removed from indexes other than one being updated.
+ *
+ * @param cctx Cache context.
+ * @param newRow cache row to store in index.
+ * @param prevRow optional cache row that will be replaced with new row.
+ */
+ public void store(GridCacheContext<?, ?> cctx, CacheDataRow newRow,
@Nullable CacheDataRow prevRow,
Review comment:
I don't sure it's a good idea to request an internal classes from
public API
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/IndexValueCursor.java
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cache.query.index.sorted;
+
+import java.util.function.Function;
+import org.apache.ignite.IgniteCheckedException;
+import
org.apache.ignite.internal.cache.query.index.sorted.inline.io.IndexSearchRow;
+import org.apache.ignite.internal.util.lang.GridCursor;
+
+/**
+ * Cursor over index values.
+ *
+ * @param <V> class represents of value stored in an index.
+ */
+public class IndexValueCursor<V> implements GridCursor<V> {
+ /**
+ * Empty cursor implementation.
+ */
+ public static final GridCursor EMPTY = new GridCursor() {
+ /** {@inheritDoc} */
+ @Override public boolean next() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object get() {
+ return null;
Review comment:
looks like this is the best we can do now. Let's add a comment
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/MetaPageInfo.java
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cache.query.index.sorted;
+
+import
org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusMetaIO;
+import org.apache.ignite.lang.IgniteProductVersion;
+
+/**
+ * Meta page stores meta data about InlineIndexTree.
+ */
+public class MetaPageInfo {
+ /** Inline size used for a tree. */
+ int inlineSize;
Review comment:
let's add `private` to all fields
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/keys/BooleanIndexKey.java
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cache.query.index.sorted.keys;
+
+import
org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypeSettings;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypes;
+
+/** */
+public class BooleanIndexKey implements IndexKey {
+ /** */
+ private final boolean key;
+
+ /** */
+ public BooleanIndexKey(boolean key) {
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object getKey() {
+ return key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getType() {
+ return IndexKeyTypes.BOOLEAN;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int compare(IndexKey o, IndexKeyTypeSettings keySettings)
{
Review comment:
it looks like `keySettings` is used only for `BytesIndexKey`. So may be
it worth to provide `SignedBytesIndexKey` similar to
`SignedBytesInlineIndexKeyType`
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/inline/JavaObjectKeySerializer.java
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cache.query.index.sorted.inline;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.Marshaller;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Serializer for representing JO as byte array in inline.
+ */
+public class JavaObjectKeySerializer {
+ /** Class loader. */
+ private final ClassLoader clsLdr;
+
+ /** Marshaller. */
+ private final Marshaller marshaller;
+
+ /**
+ * Constructor.
+ *
+ * @param cfg Ignite configuration.
+ */
+ public JavaObjectKeySerializer(@NotNull IgniteConfiguration cfg) {
Review comment:
we don't use `@NotNull` annotation
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/DurableBackgroundCleanupIndexTreeTask.java
##########
@@ -46,53 +49,44 @@
private List<Long> rootPages;
/** */
- private transient List<H2Tree> trees;
+ private transient List<InlineIndexTree> trees;
/** */
private transient volatile boolean completed;
/** */
- private String cacheGrpName;
+ private final String cacheName;
/** */
- private String cacheName;
+ private final IndexName idxName;
Review comment:
I would prefer to leave idxName as a simple string. This will allow us
to remove Serialized from IndexName. I think this is a good idea because the
current approach to naming system indexes with a constant (like `PK_IDX_NAME`)
violates some sql restrictions (it is currently possible to have multiple
indexes with the same name in the same sql schema). This should be reworked,
and using `IndexName` as being serializable could potentially lead to a
compatibility issue.
So WDYT?
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/Index.java
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cache.query.index;
+
+import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Basic interface for Ignite indexes.
+ */
+public interface Index {
+ /**
+ * Unique ID.
+ */
+ public UUID id();
+
+ /**
+ * Index name.
+ */
+ public String name();
+
+ /**
+ * Checks whether index handles specified cache row.
+ *
+ * @param row Cache row.
+ * @return Whether index handles specified cache row
+ */
+ public boolean canHandle(CacheDataRow row) throws IgniteCheckedException;
+
+ /**
+ * Callback that runs when the underlying cache is updated.
+ *
+ * @param oldRow Cache row that was replaced with newRow.
+ * @param newRow Cache row that was stored.
+ * @param prevRowAvailable Whether oldRow available.
+ */
+ public void onUpdate(@Nullable CacheDataRow oldRow, @Nullable CacheDataRow
newRow, boolean prevRowAvailable)
+ throws IgniteCheckedException;
+
+ /**
+ * Put cache row to index.
+ *
+ * @return {@code True} if replaced existing row.
+ */
+ public boolean putx(CacheDataRow row) throws IgniteCheckedException;
+
+ /**
+ * Remove cache row from index.
+ *
+ * @return {@code True} if removed row.
+ */
+ public boolean removex(CacheDataRow row) throws IgniteCheckedException;
Review comment:
let's remove `putx` and `removex` from interface and from
implementations too.
It looks like `removex` actually is not called anywhere, and `putx` is
called in exactly one place and could be safely replaced with `onUpdate(null,
row, false)`
##########
File path:
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowCache.java
##########
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.query.h2;
-
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.pagemem.PageIdUtils;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.processors.cache.CacheGroupContext;
-import org.apache.ignite.internal.processors.cache.GridCacheContextInfo;
-import org.apache.ignite.internal.processors.query.GridQueryRowCacheCleaner;
-import org.apache.ignite.internal.processors.query.h2.opt.H2CacheRow;
-import org.apache.ignite.internal.util.typedef.F;
-import org.jsr166.ConcurrentLinkedHashMap;
-
-import static org.jsr166.ConcurrentLinkedHashMap.DFLT_INIT_CAP;
-import static org.jsr166.ConcurrentLinkedHashMap.DFLT_LOAD_FACTOR;
-
-/**
- * H2 row cache.
- */
-public class H2RowCache implements GridQueryRowCacheCleaner {
Review comment:
Why did you decide to get rid of this? This row cache is not the same
thing as H2's internal object cache
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/keys/BytesCompareUtils.java
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cache.query.index.sorted.keys;
+
+/** */
+public final class BytesCompareUtils {
+ /** */
+ public static int compareNotNullSigned(byte[] arr0, byte[] arr1) {
+ if (arr0 == arr1)
+ return 0;
+ else {
+ int commonLen = Math.min(arr0.length, arr1.length);
+
+ for (int i = 0; i < commonLen; ++i) {
+ byte b0 = arr0[i];
+ byte b1 = arr1[i];
+
+ if (b0 != b1)
+ return b0 > b1 ? 1 : -1;
+ }
+
+ return Integer.signum(arr0.length - arr1.length);
+ }
+ }
+
+ /** */
+ public static int compareNotNullUnsigned(byte[] arr0, byte[] arr1) {
+ if (arr0 == arr1)
+ return 0;
+ else {
+ int commonLen = Math.min(arr0.length, arr1.length);
+
+ for (int i = 0; i < commonLen; ++i) {
+ int var4 = arr0[i] & 255;
Review comment:
do var[1-3] exist?
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/IndexSearchRow.java
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cache.query.index.sorted;
+
+import org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKey;
+
+/**
+ * Represents a complex index key.
+ */
+public interface IndexSearchRow {
Review comment:
the value of this interface is unclear to me. Seem like it could be
simply merged with `IndexRow`. And it's better to replace `public IndexKey[]
getKeys()` with `public int size()`
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IgniteIndexing.java
##########
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cache.query.index;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.cache.Cache;
+import org.apache.ignite.IgniteCheckedException;
+import
org.apache.ignite.internal.cache.query.index.sorted.inline.io.AbstractInlineInnerIO;
+import
org.apache.ignite.internal.cache.query.index.sorted.inline.io.AbstractInlineLeafIO;
+import org.apache.ignite.internal.cache.query.index.sorted.inline.io.InnerIO;
+import org.apache.ignite.internal.cache.query.index.sorted.inline.io.LeafIO;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
+import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
+import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
+import org.apache.ignite.internal.processors.query.IgniteSQLException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.spi.IgniteSpiContext;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.indexing.IndexingQueryFilter;
+import org.apache.ignite.spi.indexing.IndexingSpi;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of IndexingSpi that tracks all cache indexes.
+ */
+public class IgniteIndexing implements IndexingSpi {
+ /**
+ * Register inline IOs for sorted indexes.
+ */
+ static {
+ PageIO.registerH2(InnerIO.VERSIONS, LeafIO.VERSIONS, null, null);
+
+ AbstractInlineInnerIO.register();
+ AbstractInlineLeafIO.register();
+ }
+
+ /**
+ * Registry of all indexes. High key is a cache name, lower key is an
unique index name.
+ */
+ private final Map<String, Map<String, Index>> cacheToIdx = new
ConcurrentHashMap<>();
+
+ /**
+ * Registry of all index definitions. Key is {@link Index#id()}, value is
IndexDefinition used for creating index.
+ */
+ private final Map<UUID, IndexDefinition> idxDefs = new
ConcurrentHashMap<>();
+
+ /** Exclusive lock for DDL operations. */
+ private final ReentrantReadWriteLock ddlLock = new
ReentrantReadWriteLock();
+
+ /** {@inheritDoc} */
+ @Override public Iterator<Cache.Entry<?, ?>> query(@Nullable String
cacheName, Collection<Object> params,
+ @Nullable IndexingQueryFilter filters) throws IgniteSpiException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void store(@Nullable String cacheName, Object key, Object
val,
+ long expirationTime) throws IgniteSpiException {
+ throw new IgniteSpiException("Not implemented.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void store(GridCacheContext<?, ?> cctx, CacheDataRow
newRow, @Nullable CacheDataRow prevRow,
+ boolean prevRowAvailable)
+ throws IgniteSpiException {
+ try {
+ updateIndexes(cctx.name(), newRow, prevRow, prevRowAvailable);
+
+ } catch (IgniteCheckedException e) {
+ throw new IgniteSpiException("Failed to store row in cache", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void store(Collection<? extends Index> idxs, CacheDataRow
newRow, @Nullable CacheDataRow prevRow,
+ boolean prevRowAvailable) throws IgniteSpiException {
+ IgniteCheckedException err = null;
+
+ ddlLock.readLock().lock();
+
+ try {
+ for (Index idx : idxs)
+ err = updateIndex(idx, newRow, prevRow, prevRowAvailable, err);
+
+ if (err != null)
+ throw err;
+
+ } catch (IgniteCheckedException e) {
+ throw new IgniteSpiException("Failed to store row in index", e);
+
+ } finally {
+ ddlLock.readLock().unlock();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(@Nullable String cacheName, Object key)
throws IgniteSpiException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(String cacheName, @Nullable CacheDataRow
prevRow) throws IgniteSpiException {
+ try {
+ updateIndexes(cacheName, null, prevRow, true);
+
+ } catch (IgniteCheckedException e) {
+ throw new IgniteSpiException("Failed to remove row in cache", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public Index createIndex(GridCacheContext<?, ?> cctx,
IndexFactory factory, IndexDefinition definition) {
+ ddlLock.writeLock().lock();
+
+ try {
+ String cacheName = definition.getIdxName().cacheName();
+
+ cacheToIdx.putIfAbsent(cacheName, new ConcurrentHashMap<>());
+
+ String uniqIdxName = definition.getIdxName().fullName();
+
+ // GridQueryProcessor already checked schema operation for index
duplication.
+ assert cacheToIdx.get(cacheName).get(uniqIdxName) == null :
"Duplicated index name " + uniqIdxName;
+
+ Index idx = factory.createIndex(cctx, definition);
+
+ cacheToIdx.get(cacheName).put(uniqIdxName, idx);
+
+ idxDefs.put(idx.id(), definition);
+
+ return idx;
+
+ } finally {
+ ddlLock.writeLock().unlock();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeIndex(GridCacheContext<?, ?> cctx,
IndexDefinition def, boolean softDelete) {
Review comment:
`IndexName` should uniquely describe index, so let's use it instead of
`IndexDefinition`
##########
File path:
modules/core/src/test/java/org/apache/ignite/internal/cache/query/index/sorted/inline/InlineIndexKeyTypeRegistryTest.java
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cache.query.index.sorted.inline;
+
+import org.apache.ignite.internal.binary.BinaryObjectImpl;
+import
org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypeSettings;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypes;
+import
org.apache.ignite.internal.cache.query.index.sorted.keys.IntegerIndexKey;
+import org.apache.ignite.internal.cache.query.index.sorted.keys.NullIndexKey;
+import
org.apache.ignite.internal.cache.query.index.sorted.keys.PlainJavaObjectIndexKey;
+import org.apache.ignite.internal.cache.query.index.sorted.keys.StringIndexKey;
+import org.junit.Test;
+
+/** */
+public class InlineIndexKeyTypeRegistryTest {
+ /** */
+ private static final IndexKeyTypeSettings pojoHashKeyTypeSettings =
+ new IndexKeyTypeSettings();
+
+ /** */
+ private static final IndexKeyTypeSettings pojoArrayKeyTypeSettings =
+ new IndexKeyTypeSettings().inlineObjHash(false);
+
+ /** */
+ private static final IndexKeyTypeSettings strNoCompareKeyTypeSettings =
+ new
IndexKeyTypeSettings().inlineObjHash(false).stringOptimizedCompare(false);
+
+ /** */
+ @Test
+ public void testNulls() {
+ int t = InlineIndexKeyTypeRegistry.get(NullIndexKey.INSTANCE,
IndexKeyTypes.INT, pojoArrayKeyTypeSettings).type();
+ assert t == IndexKeyTypes.INT;
Review comment:
let's replace `assert` with JUnit assertions
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]