timoninmaxim commented on code in PR #10080:
URL: https://github.com/apache/ignite/pull/10080#discussion_r915540208


##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/keys/DateTimeIndexKey.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+/**
+ * Class that represnts a numeric index key.

Review Comment:
   Not numeric, but date/time.



##########
modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryAllTypesTest.java:
##########
@@ -286,20 +290,79 @@ public void testBoolField() {
         check(cache.query(qry), 0, CNT / 2 + 1, valGen, persGen);
     }
 
+    /** */
+    @Test
+    public void testRangeCrossTypeConvertion() {
+        int cnt = 100;

Review Comment:
   Let's add also a test for cases that is out of default range. As we 
discussed (byteKey vs (int)1000) and similar. 



##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/QueryIndexDefinition.java:
##########
@@ -0,0 +1,155 @@
+/*
+ * 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.LinkedHashMap;
+import org.apache.ignite.internal.cache.query.index.IndexName;
+import org.apache.ignite.internal.processors.query.GridQueryRowDescriptor;
+
+/**
+ * Define query index.
+ */
+public class QueryIndexDefinition implements SortedIndexDefinition {
+    /** Wrapped key definitions. */
+    private final LinkedHashMap<String, IndexKeyDefinition> keyDefs;
+
+    /** Table row descriptor. */
+    private final GridQueryRowDescriptor rowDescriptor;
+
+    /** Index name. */
+    private final IndexName idxName;
+
+    /** Index tree name. */
+    private final String treeName;
+
+    /** Configured inline size. */
+    private final int inlineSize;
+
+    /** Segments. */
+    private final int segments;
+
+    /** Whether this index is primary key (unique) or not. */
+    private final boolean isPrimary;
+
+    /** Whether this index is affinity key index or not. */
+    private final boolean isAffinity;
+
+    /** Index row comparator. */
+    private final IndexRowComparator rowComparator;

Review Comment:
   Do we actually need interface `IndexRowComparator`? Now there is a single 
implementation of it within the same module.



##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/inline/InlineIndexKeyType.java:
##########
@@ -90,6 +91,13 @@ public interface InlineIndexKeyType {
      */
     public int compare(long pageAddr, int off, int maxSize, IndexKey v);
 
+    /**
+     * @return {@code True} if inlined value can be compared to index key .

Review Comment:
   whitespace before the dot.



##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/QueryIndexRowHandler.java:
##########
@@ -98,68 +108,45 @@ public List<IndexColumn> getH2IdxColumns() {
 
     /** */
     private Object getKey(int idx, CacheDataRow row) {
-        int cacheIdx = h2IdxColumns.get(idx).column.getColumnId();

Review Comment:
   Can we replace it with `rowDesc.getFieldValue(row, idx)`? Looks like this 
method just invokes different methods of descriptor multiple times.



##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/QueryIndexRowHandler.java:
##########
@@ -15,70 +15,80 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal.processors.query.h2.index;
+package org.apache.ignite.internal.cache.query.index.sorted;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
 import org.apache.ignite.internal.binary.BinaryObjectImpl;
-import org.apache.ignite.internal.cache.query.index.sorted.IndexKeyDefinition;
-import 
org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypeSettings;
-import 
org.apache.ignite.internal.cache.query.index.sorted.InlineIndexRowHandler;
 import 
org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexKeyType;
 import org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKey;
 import 
org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKeyFactory;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
-import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
+import org.apache.ignite.internal.processors.query.GridQueryRowDescriptor;
 import org.apache.ignite.internal.processors.query.QueryUtils;
-import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor;
-import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
-import org.h2.table.IndexColumn;
 
-/** Maps CacheDataRow to IndexRow using H2 columns references. */
+/** Maps CacheDataRow to IndexRow using columns references. */
 public class QueryIndexRowHandler implements InlineIndexRowHandler {
     /** Cache descriptor. */
-    private final GridH2RowDescriptor cacheDesc;
+    private final GridQueryRowDescriptor rowDescriptor;
 
-    /** H2 index columns. */
-    private final List<IndexColumn> h2IdxColumns;
+    /** Index to columns references. */
+    private volatile List<Integer> keyColumns;

Review Comment:
   Do we have already another level of sync here? I suppose in case of altering 
columns all query threads should be locked before updating Index and unlocked 
after invoking `onMetadataUpdated()`? Otherwise it may not be thread-safe and 
then throw `ArraysOutOfBoundException` in 
`GridQueryRowDescriptorImpl#getFieldValue`. Then we don't need additional sync 
here. Am I missing something?
   
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to