Parcourir la source

add BITMAP index type to IndexType and updated BITMAP related cases (#1072)

Signed-off-by: wangting0128 <ting.wang@zilliz.com>
wt il y a 7 mois
Parent
commit
eff740181d

+ 1 - 0
src/main/java/io/milvus/param/IndexType.java

@@ -52,6 +52,7 @@ public enum IndexType {
     // Only for scalar type field
     STL_SORT(200), // only for numeric type field
     INVERTED(201), // works for all scalar fields except JSON type field
+    BITMAP(202), // works for all scalar fields except JSON, FLOAT and DOUBLE type fields
 
     // Only for sparse vectors
     SPARSE_INVERTED_INDEX(300),

+ 18 - 12
tests/milvustestv2/src/test/java/com/zilliz/milvustestv2/index/CreateIndexTest.java

@@ -35,41 +35,48 @@ public class CreateIndexTest extends BaseTest {
     public Object[][] providerScalarIndex() {
         return new Object[][]{
                 {new ArrayList<FieldParam>() {{
-//                    add(FieldParam.builder().fieldName(CommonData.fieldInt8).indextype(IndexParam.IndexType.BITMAP).build());
+                    add(FieldParam.builder().fieldName(CommonData.fieldInt8).indextype(IndexParam.IndexType.BITMAP).build());
                     add(FieldParam.builder().fieldName(CommonData.fieldInt16).indextype(IndexParam.IndexType.STL_SORT).build());
                     add(FieldParam.builder().fieldName(CommonData.fieldInt64).indextype(IndexParam.IndexType.INVERTED).build());
                     add(FieldParam.builder().fieldName(CommonData.fieldVarchar).indextype(IndexParam.IndexType.TRIE).build());
                 }}
                 },
                 {new ArrayList<FieldParam>() {{
-//                    add(FieldParam.builder().fieldName(CommonData.fieldInt16).indextype(IndexParam.IndexType.BITMAP).build());
+                    add(FieldParam.builder().fieldName(CommonData.fieldInt16).indextype(IndexParam.IndexType.BITMAP).build());
+                }}
+                },
+                {new ArrayList<FieldParam>() {{
+                    add(FieldParam.builder().fieldName(CommonData.fieldInt32).indextype(IndexParam.IndexType.BITMAP).build());
                 }}
                 },
                 {new ArrayList<FieldParam>() {{
-//                    add(FieldParam.builder().fieldName(CommonData.fieldInt32).indextype(IndexParam.IndexType.BITMAP).build());
+                    add(FieldParam.builder().fieldName(CommonData.fieldVarchar).indextype(IndexParam.IndexType.BITMAP).build());
                 }}
                 },
                 {new ArrayList<FieldParam>() {{
-//                    add(FieldParam.builder().fieldName(CommonData.fieldInt64).indextype(IndexParam.IndexType.BITMAP).build());
+                    add(FieldParam.builder().fieldName(CommonData.fieldBool).indextype(IndexParam.IndexType.BITMAP).build());
                 }}
                 },
-/*                {new ArrayList<FieldParam>() {{
+                {new ArrayList<FieldParam>() {{
+                    add(FieldParam.builder().fieldName(CommonData.fieldArray).indextype(IndexParam.IndexType.BITMAP).build());
+                }}
+                },
+                {new ArrayList<FieldParam>() {{
                     add(FieldParam.builder().fieldName(CommonData.fieldVarchar).indextype(IndexParam.IndexType.BITMAP).build());
                     add(FieldParam.builder().fieldName(CommonData.fieldInt8).indextype(IndexParam.IndexType.BITMAP).build());
                     add(FieldParam.builder().fieldName(CommonData.fieldInt16).indextype(IndexParam.IndexType.BITMAP).build());
                     add(FieldParam.builder().fieldName(CommonData.fieldInt32).indextype(IndexParam.IndexType.BITMAP).build());
-                    add(FieldParam.builder().fieldName(CommonData.fieldInt64).indextype(IndexParam.IndexType.BITMAP).build());
                     add(FieldParam.builder().fieldName(CommonData.fieldBool).indextype(IndexParam.IndexType.BITMAP).build());
                     add(FieldParam.builder().fieldName(CommonData.fieldArray).indextype(IndexParam.IndexType.BITMAP).build());
                 }}
-                },*/
+                },
         };
     }
 
     @BeforeClass(alwaysRun = true)
     public void providerCollection() {
         newCollectionName = CommonFunction.createNewCollection(CommonData.dim, null, DataType.FloatVector);
-        List<JsonObject> jsonObjects = CommonFunction.generateDefaultData(0,CommonData.numberEntities * 10, CommonData.dim, DataType.FloatVector);
+        List<JsonObject> jsonObjects = CommonFunction.generateDefaultData(0, CommonData.numberEntities * 10, CommonData.dim, DataType.FloatVector);
         milvusClientV2.insert(InsertReq.builder().collectionName(newCollectionName).data(jsonObjects).build());
     }
 
@@ -110,7 +117,7 @@ public class CreateIndexTest extends BaseTest {
                 .build());
     }
 
-    @Test(description = "Create scalar index", groups = {"Smoke"}, dependsOnMethods = {"createVectorIndex"}, enabled = false)
+    @Test(description = "Create scalar index", groups = {"Smoke"}, dependsOnMethods = {"createVectorIndex"})
     public void createMultiScalarIndex() {
         milvusClientV2.releaseCollection(ReleaseCollectionReq.builder().collectionName(newCollectionName).build());
         IndexParam indexParam1 = IndexParam.builder()
@@ -127,7 +134,7 @@ public class CreateIndexTest extends BaseTest {
                 .build();
         IndexParam indexParam4 = IndexParam.builder()
                 .fieldName(CommonData.fieldInt16)
-//                .indexType(IndexParam.IndexType.BITMAP)
+                .indexType(IndexParam.IndexType.BITMAP)
                 .build();
         milvusClientV2.createIndex(CreateIndexReq.builder()
                 .collectionName(newCollectionName)
@@ -141,8 +148,7 @@ public class CreateIndexTest extends BaseTest {
     @Test(description = "Create scalar index",
             groups = {"Smoke"},
             dependsOnMethods = {"createVectorIndex"},
-            dataProvider = "multiScalar",
-            enabled = false)
+            dataProvider = "multiScalar")
     public void createAllBitmapIndex(List<FieldParam> FieldParamList) {
         milvusClientV2.releaseCollection(ReleaseCollectionReq.builder().collectionName(newCollectionName).build());
         CommonFunction.dropScalarCommonIndex(newCollectionName, FieldParamList);

+ 7 - 7
tests/milvustestv2/src/test/java/com/zilliz/milvustestv2/vectorOperation/SearchTest.java

@@ -165,13 +165,13 @@ public class SearchTest extends BaseTest {
 
         // Build Scalar Index
         List<FieldParam> FieldParamList = new ArrayList<FieldParam>() {{
-//            add(FieldParam.builder().fieldName(CommonData.fieldVarchar).indextype(IndexParam.IndexType.BITMAP).build());
-//            add(FieldParam.builder().fieldName(CommonData.fieldInt8).indextype(IndexParam.IndexType.BITMAP).build());
-//            add(FieldParam.builder().fieldName(CommonData.fieldInt16).indextype(IndexParam.IndexType.BITMAP).build());
-//            add(FieldParam.builder().fieldName(CommonData.fieldInt32).indextype(IndexParam.IndexType.BITMAP).build());
-//            add(FieldParam.builder().fieldName(CommonData.fieldInt64).indextype(IndexParam.IndexType.BITMAP).build());
-//            add(FieldParam.builder().fieldName(CommonData.fieldBool).indextype(IndexParam.IndexType.BITMAP).build());
-//            add(FieldParam.builder().fieldName(CommonData.fieldArray).indextype(IndexParam.IndexType.BITMAP).build());
+            add(FieldParam.builder().fieldName(CommonData.fieldVarchar).indextype(IndexParam.IndexType.BITMAP).build());
+            add(FieldParam.builder().fieldName(CommonData.fieldInt8).indextype(IndexParam.IndexType.BITMAP).build());
+            add(FieldParam.builder().fieldName(CommonData.fieldInt16).indextype(IndexParam.IndexType.BITMAP).build());
+            add(FieldParam.builder().fieldName(CommonData.fieldInt32).indextype(IndexParam.IndexType.BITMAP).build());
+            add(FieldParam.builder().fieldName(CommonData.fieldInt64).indextype(IndexParam.IndexType.STL_SORT).build());
+            add(FieldParam.builder().fieldName(CommonData.fieldBool).indextype(IndexParam.IndexType.BITMAP).build());
+            add(FieldParam.builder().fieldName(CommonData.fieldArray).indextype(IndexParam.IndexType.BITMAP).build());
         }};
         CommonFunction.createScalarCommonIndex(newCollectionName, FieldParamList);
         log.info("Create Scalar index done{}, scalar index:{}", newCollectionName, FieldParamList);