mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
* rename interfaces in cases Signed-off-by: zw <zw@zilliz.com> * rename search_by_id Signed-off-by: zw <zw@zilliz.com> * remove test search_by_id Signed-off-by: zw <zw@zilliz.com> * [skip ci] Update CHANGELOG Signed-off-by: JinHai-CN <hai.jin@zilliz.com> * rename methods Signed-off-by: zw <zw@zilliz.com> * rename methods Signed-off-by: zw <zw@milvus.io> * fix rename issue Signed-off-by: zw <zw@zilliz.com> * update hnsw default index param Signed-off-by: zw <zw@zilliz.com> * Update CHANGELOG.md Co-authored-by: JinHai-CN <hai.jin@zilliz.com> Co-authored-by: zw <zw@milvus.io>
71 lines
3.3 KiB
Java
71 lines
3.3 KiB
Java
|
|
package com;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import io.milvus.client.*;
|
|
|
|
import org.testng.annotations.Test;
|
|
|
|
import java.nio.ByteBuffer;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
public class TestCollectionInfo {
|
|
int dimension = 128;
|
|
int nb = 8000;
|
|
int n_list = 1024;
|
|
int default_n_list = 16384;
|
|
IndexType indexType = IndexType.IVF_SQ8;
|
|
IndexType defaultIndexType = IndexType.FLAT;
|
|
String indexParam = Utils.setIndexParam(n_list);
|
|
List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
|
|
List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
|
|
|
|
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
|
public void test_get_vector_ids_after_delete_vectors(MilvusClient client, String collectionName) {
|
|
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
|
|
InsertResponse resInsert = client.insert(insertParam);
|
|
client.flush(collectionName);
|
|
List<Long> idsBefore = resInsert.getVectorIds();
|
|
client.deleteEntityByID(collectionName, Collections.singletonList(idsBefore.get(0)));
|
|
client.flush(collectionName);
|
|
Response res = client.getCollectionStats(collectionName);
|
|
System.out.println(res.getMessage());
|
|
JSONObject collectionInfo = Utils.getCollectionInfo(res.getMessage());
|
|
int row_count = collectionInfo.getIntValue("row_count");
|
|
assert(row_count == nb-1);
|
|
}
|
|
|
|
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
|
|
public void test_get_vector_ids_after_delete_vectors_indexed(MilvusClient client, String collectionName) {
|
|
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
|
|
InsertResponse resInsert = client.insert(insertParam);
|
|
client.flush(collectionName);
|
|
Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
|
|
client.createIndex(index);
|
|
List<Long> idsBefore = resInsert.getVectorIds();
|
|
client.deleteEntityByID(collectionName, Collections.singletonList(idsBefore.get(0)));
|
|
client.flush(collectionName);
|
|
Response res = client.getCollectionStats(collectionName);
|
|
System.out.println(res.getMessage());
|
|
JSONObject collectionInfo = Utils.getCollectionInfo(res.getMessage());
|
|
int row_count = collectionInfo.getIntValue("row_count");
|
|
assert(row_count == nb-1);
|
|
}
|
|
|
|
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
|
|
public void test_get_vector_ids_after_delete_vectors_binary(MilvusClient client, String collectionName) {
|
|
InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
|
|
InsertResponse resInsert = client.insert(insertParam);
|
|
client.flush(collectionName);
|
|
List<Long> idsBefore = resInsert.getVectorIds();
|
|
client.deleteEntityByID(collectionName, Collections.singletonList(idsBefore.get(0)));
|
|
client.flush(collectionName);
|
|
Response res = client.getCollectionStats(collectionName);
|
|
System.out.println(res.getMessage());
|
|
JSONObject collectionInfo = Utils.getCollectionInfo(res.getMessage());
|
|
int row_count = collectionInfo.getIntValue("row_count");
|
|
assert(row_count == nb-1);
|
|
}
|
|
|
|
} |