sashapolo commented on code in PR #1076:
URL: https://github.com/apache/ignite-3/pull/1076#discussion_r974311747


##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/BinaryTupleComparator.java:
##########
@@ -15,80 +15,82 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal.storage.index.impl;
+package org.apache.ignite.internal.storage.index;
 
+import static 
org.apache.ignite.internal.binarytuple.BinaryTupleCommon.isPrefix;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 import java.util.Arrays;
 import java.util.Comparator;
 import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.schema.BinaryTuplePrefix;
+import org.apache.ignite.internal.schema.BinaryTupleSchema;
 import org.apache.ignite.internal.schema.NativeTypeSpec;
-import org.apache.ignite.internal.storage.index.SortedIndexDescriptor;
+import org.apache.ignite.internal.schema.row.InternalTuple;
 import 
org.apache.ignite.internal.storage.index.SortedIndexDescriptor.ColumnDescriptor;
 
 /**
- * Comparator implementation for comparting {@link BinaryTuple}s on a 
per-column basis.
+ * Comparator implementation for comparing {@link BinaryTuple}s on a 
per-column basis.
  */
-class BinaryTupleComparator implements Comparator<BinaryTuple> {
+public class BinaryTupleComparator implements Comparator<ByteBuffer> {
     private final SortedIndexDescriptor descriptor;
 
-    private final int prefixLength;
-
-    private BinaryTupleComparator(SortedIndexDescriptor descriptor, int 
prefixLength) {
-        if (prefixLength > descriptor.indexColumns().size()) {
-            throw new IllegalArgumentException("Invalid prefix length: " + 
prefixLength);
-        }
-
-        this.descriptor = descriptor;
-        this.prefixLength = prefixLength;
-    }
-
     /**
      * Creates a comparator for a Sorted Index identified by the given 
descriptor.
      */
-    static BinaryTupleComparator newComparator(SortedIndexDescriptor 
descriptor) {
-        return new BinaryTupleComparator(descriptor, 
descriptor.indexColumns().size());
-    }
-
-    /**
-     * Similar to {@link #newComparator} but creates a comparator that only 
compares first {@code prefixLength} index columns.
-     */
-    static BinaryTupleComparator newPrefixComparator(SortedIndexDescriptor 
descriptor, int prefixLength) {
-        return new BinaryTupleComparator(descriptor, prefixLength);
+    public BinaryTupleComparator(SortedIndexDescriptor descriptor) {
+        this.descriptor = descriptor;
     }
 
     @Override
-    public int compare(BinaryTuple tuple1, BinaryTuple tuple2) {
-        return compare(tuple1, tuple2, 1, 0);
-    }
+    public int compare(ByteBuffer buffer1, ByteBuffer buffer2) {
+        assert buffer1.order() == ByteOrder.LITTLE_ENDIAN;
+        assert buffer2.order() == ByteOrder.LITTLE_ENDIAN;
+
+        BinaryTupleSchema schema = descriptor.binaryTupleSchema();
+
+        InternalTuple tuple1;
+        InternalTuple tuple2;
+        int columnsToCompare;
+
+        if (isPrefix(buffer1)) {

Review Comment:
   sure



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