ibessonov commented on code in PR #2200:
URL: https://github.com/apache/ignite-3/pull/2200#discussion_r1232132258


##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/ColumnFamilyUtils.java:
##########
@@ -67,24 +93,135 @@ static ColumnFamilyType fromCfName(String cfName) {
     }
 
     /**
-     * Creates a column family name by index ID.
-     *
-     * @param indexId Index ID.
+     * Generates a sorted index column family name by its columns descriptions.
+     * The resulting array has a {@link #SORTED_INDEX_CF_PREFIX} prefix as a 
UTF8 array, followed by a number of pairs
+     * {@code {type, flags}}, where type represents ordinal of the 
corresponding {@link NativeTypeSpec}, and
+     * flags store information about column's nullability and comparison order.
      *
-     * @see #sortedIndexId
+     * @see #comparatorFromCfName(byte[])
      */
-    static String sortedIndexCfName(int indexId) {
-        return SORTED_INDEX_CF_PREFIX + indexId;
+    static byte[] sortedIndexCfName(List<StorageSortedIndexColumnDescriptor> 
columns) {
+        ByteBuffer buf = ByteBuffer.allocate(SORTED_INDEX_CF_PREFIX.length() + 
columns.size() * 2);
+
+        buf.put(SORTED_INDEX_CF_PREFIX.getBytes(UTF_8));
+
+        for (StorageSortedIndexColumnDescriptor column : columns) {
+            NativeType nativeType = column.type();
+            NativeTypeSpec nativeTypeSpec = nativeType.spec();
+
+            buf.put((byte) nativeTypeSpec.ordinal());
+
+            int flags = 0;
+
+            if (column.nullable()) {
+                flags |= NULLABILITY_FLAG;
+            }
+
+            if (column.asc()) {
+                flags |= ASC_ORDER_FLAG;
+            }
+
+            buf.put((byte) flags);
+        }
+
+        return buf.array();
     }
 
     /**
-     * Extracts a Sorted Index ID from the given Column Family name.
-     *
-     * @param cfName Column Family name.
-     *
-     * @see #sortedIndexCfName
+     * Creates an {@link org.rocksdb.AbstractComparator} instance to compare 
keys in column family with name {@code cfName}.
+     * Please refer to {@link #sortedIndexCfName(List)} for the details of the 
CF name encoding.
      */
-    static int sortedIndexId(String cfName) {
-        return 
Integer.parseInt(cfName.substring(SORTED_INDEX_CF_PREFIX.length()));
+    public static RocksDbBinaryTupleComparator comparatorFromCfName(byte[] 
cfName) {

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