adelapena commented on code in PR #2916:
URL: https://github.com/apache/cassandra/pull/2916#discussion_r1400907256


##########
test/unit/org/apache/cassandra/index/sai/cql/StorageAttachedIndexDDLTest.java:
##########
@@ -778,6 +800,7 @@ public void truncateWithBuiltIndexes()
     }
 
     @Test
+    @Ignore("Ignored until CASSANDRA-19032")

Review Comment:
   We shouldn't ignore flaky tests.



##########
test/unit/org/apache/cassandra/index/sai/utils/IndexTermTypeTest.java:
##########
@@ -142,25 +172,25 @@ private static void 
testCollectionType(BiFunction<AbstractType<?>, Boolean, Abst
             AbstractType<?> frozenCollection = 
init.apply(elementType.getType(), false);
             AbstractType<?> reversedFrozenCollection = 
ReversedType.getInstance(frozenCollection);
 
-            AbstractType<?> type = 
TypeUtil.cellValueType(column(frozenCollection), IndexTarget.Type.FULL);
-            assertTrue(TypeUtil.isFrozenCollection(type));
-            assertTrue(TypeUtil.isLiteral(type));
-            assertFalse(type.isReversed());
+            IndexTermType indexTermType = indexTermType(frozenCollection, 
IndexTarget.Type.FULL);
+            assertTrue(indexTermType.isFrozenCollection());
+            assertTrue(indexTermType.isLiteral());
+            assertFalse(indexTermType.isReversed());
 
-            type = TypeUtil.cellValueType(column(reversedFrozenCollection), 
IndexTarget.Type.FULL);
-            assertTrue(TypeUtil.isFrozenCollection(type));
-            assertTrue(TypeUtil.isLiteral(type));
-            assertTrue(type.isReversed());
+            IndexTermType reversedIndexTermType = 
indexTermType(reversedFrozenCollection, IndexTarget.Type.FULL);
+            assertTrue(reversedIndexTermType.isFrozenCollection());
+            assertTrue(reversedIndexTermType.isLiteral());
+            assertTrue(reversedIndexTermType.isReversed());
 
             AbstractType<?> nonFrozenCollection = 
init.apply(elementType.getType(), true);
-            assertEquals(elementType.getType(), 
cellValueType(nonFrozenCollection, IndexTarget.Type.VALUES));
+            assertEquals(elementType.getType(), 
indexTermType(nonFrozenCollection, IndexTarget.Type.VALUES).indexType());
             nonFrozenCollectionTester.accept(elementType.getType(), 
nonFrozenCollection);
         }
     }
 
-    private static AbstractType<?> cellValueType(AbstractType<?> type, 
IndexTarget.Type indexType)
+    private static IndexTermType indexTermType(AbstractType<?> type, 
IndexTarget.Type indexType)
     {
-        return TypeUtil.cellValueType(column(type), indexType);
+        return IndexTermType.create(column(type), Collections.EMPTY_LIST, 
indexType);

Review Comment:
   ```suggestion
           return IndexTermType.create(column(type), Collections.emptyList(), 
indexType);
   ```



##########
test/unit/org/apache/cassandra/index/sai/SAITester.java:
##########
@@ -250,16 +257,59 @@ public void corrupt(File file) throws IOException
         public abstract void corrupt(File file) throws IOException;
     }
 
-    public static IndexContext createIndexContext(String name, AbstractType<?> 
validator)
+    public static StorageAttachedIndex createMockIndex(ColumnMetadata column)
     {
-        return new IndexContext("test_ks",
-                                "test_cf",
-                                UTF8Type.instance,
-                                Murmur3Partitioner.instance,
-                                new ClusteringComparator(),
-                                ColumnMetadata.regularColumn("sai", 
"internal", name, validator),
-                                IndexTarget.Type.SIMPLE,
-                                IndexMetadata.fromSchemaMetadata(name, 
IndexMetadata.Kind.CUSTOM, null));
+        TableMetadata table = TableMetadata.builder(column.ksName, 
column.cfName)
+                                           .addPartitionKeyColumn("pk", 
Int32Type.instance)
+                                           .addRegularColumn(column.name, 
column.type)
+                                           
.partitioner(Murmur3Partitioner.instance)
+                                           
.caching(CachingParams.CACHE_NOTHING)
+                                           .build();
+
+        Map<String, String> options = new HashMap<>();
+        options.put(IndexTarget.CUSTOM_INDEX_OPTION_NAME, 
StorageAttachedIndex.class.getCanonicalName());
+        options.put("target", column.name.toString());
+
+        IndexMetadata indexMetadata = 
IndexMetadata.fromSchemaMetadata(column.name.toString(), 
IndexMetadata.Kind.CUSTOM, options);
+
+        ColumnFamilyStore cfs = MockSchema.newCFS(table);
+
+        return new StorageAttachedIndex(cfs, indexMetadata);
+    }
+
+    public static StorageAttachedIndex createMockIndex(String columnName, 
AbstractType<?> cellType)
+    {
+        TableMetadata table = TableMetadata.builder("test", "test")
+                                           .addPartitionKeyColumn("pk", 
Int32Type.instance)
+                                           .addRegularColumn(columnName, 
cellType)
+                                           
.partitioner(Murmur3Partitioner.instance)
+                                           
.caching(CachingParams.CACHE_NOTHING)
+                                           .build();
+
+        Map<String, String> options = new HashMap<>();
+        options.put(IndexTarget.CUSTOM_INDEX_OPTION_NAME, 
StorageAttachedIndex.class.getCanonicalName());
+        options.put("target", columnName);
+
+        IndexMetadata indexMetadata = 
IndexMetadata.fromSchemaMetadata(columnName, IndexMetadata.Kind.CUSTOM, 
options);
+
+        ColumnFamilyStore cfs = MockSchema.newCFS(table);
+
+        return new StorageAttachedIndex(cfs, indexMetadata);
+    }
+
+    public static IndexTermType createIndexTermType(AbstractType<?> cellType)
+    {
+        return IndexTermType.create(ColumnMetadata.regularColumn("sai", 
"internal", "val", cellType), Collections.EMPTY_LIST, IndexTarget.Type.SIMPLE);

Review Comment:
   ```suggestion
           return IndexTermType.create(ColumnMetadata.regularColumn("sai", 
"internal", "val", cellType), Collections.emptyList(), IndexTarget.Type.SIMPLE);
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to