Rename methods (#2312)

* 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>
This commit is contained in:
del-zhenwu 2020-05-12 18:13:05 +08:00 committed by GitHub
parent ff4c1a07fa
commit fae67ee49a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 890 additions and 886 deletions

View File

@ -60,5 +60,9 @@
<orderEntry type="library" name="Maven: org.apache.commons:commons-text:1.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20190722" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.12.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.12.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.logging.log4j:log4j-core:2.12.1" level="project" />
</component>
</module>

View File

@ -75,7 +75,7 @@ public class MainClass {
.withPort(port)
.build();
client.connect(connectParam);
// List<String> tableNames = client.showCollections().getCollectionNames();
// List<String> tableNames = client.listCollections().getCollectionNames();
// for (int j = 0; j < tableNames.size(); ++j
// ) {
// client.dropCollection(tableNames.get(j));
@ -108,7 +108,7 @@ public class MainClass {
.withPort(port)
.build();
client.connect(connectParam);
// List<String> tableNames = client.showCollections().getCollectionNames();
// List<String> tableNames = client.listCollections().getCollectionNames();
// for (int j = 0; j < tableNames.size(); ++j
// ) {
// client.dropCollection(tableNames.get(j));
@ -170,7 +170,7 @@ public class MainClass {
classes.add(new XmlClass("com.TestPartition"));
classes.add(new XmlClass("com.TestGetVectorByID"));
classes.add(new XmlClass("com.TestCollectionInfo"));
classes.add(new XmlClass("com.TestSearchByIds"));
// classes.add(new XmlClass("com.TestSearchByIds"));
test.setXmlClasses(classes) ;

View File

@ -40,7 +40,7 @@ public class TestAddVectors {
Response res_flush = client.flush(collectionName);
assert(res_flush.ok());
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
@ -56,7 +56,7 @@ public class TestAddVectors {
Response res_flush = client.flush(collectionName);
assert(res_flush.ok());
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
@ -99,7 +99,7 @@ public class TestAddVectors {
Response res_flush = client.flush(collectionName);
assert(res_flush.ok());
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb);
}
// Add vectors into collection, which tag not existed
@ -123,7 +123,7 @@ public class TestAddVectors {
Response res_flush = client.flush(collectionName);
assert(res_flush.ok());
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb);
}
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
@ -135,7 +135,7 @@ public class TestAddVectors {
Response res_flush = client.flush(collectionName);
assert(res_flush.ok());
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb);
}
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
@ -151,7 +151,7 @@ public class TestAddVectors {
Response res_flush = client.flush(collectionName);
assert(res_flush.ok());
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb);
}
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)

View File

@ -59,7 +59,7 @@ public class TestCollection {
@Test(dataProvider = "ConnectInstance", dataProviderClass = MainClass.class)
public void test_show_tables(MilvusClient client, String collectionName){
Integer tableNum = 10;
ShowCollectionsResponse res = null;
ListCollectionsResponse res = null;
for (int i = 0; i < tableNum; ++i) {
String collectionNameNew = collectionName+"_"+Integer.toString(i);
CollectionMapping tableSchema = new CollectionMapping.Builder(collectionNameNew, dimension)
@ -67,14 +67,14 @@ public class TestCollection {
.withMetricType(MetricType.L2)
.build();
client.createCollection(tableSchema);
List<String> collectionNames = client.showCollections().getCollectionNames();
List<String> collectionNames = client.listCollections().getCollectionNames();
Assert.assertTrue(collectionNames.contains(collectionNameNew));
}
}
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_show_tables_without_connect(MilvusClient client, String collectionName){
ShowCollectionsResponse res = client.showCollections();
ListCollectionsResponse res = client.listCollections();
assert(!res.getResponse().ok());
}
@ -83,7 +83,7 @@ public class TestCollection {
Response res = client.dropCollection(collectionName);
assert(res.ok());
Thread.currentThread().sleep(1000);
List<String> collectionNames = client.showCollections().getCollectionNames();
List<String> collectionNames = client.listCollections().getCollectionNames();
Assert.assertFalse(collectionNames.contains(collectionName));
}
@ -91,7 +91,7 @@ public class TestCollection {
public void test_drop_table_not_existed(MilvusClient client, String collectionName) {
Response res = client.dropCollection(collectionName+"_");
assert(!res.ok());
List<String> collectionNames = client.showCollections().getCollectionNames();
List<String> collectionNames = client.listCollections().getCollectionNames();
Assert.assertTrue(collectionNames.contains(collectionName));
}
@ -103,7 +103,7 @@ public class TestCollection {
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_describe_table(MilvusClient client, String collectionName) {
DescribeCollectionResponse res = client.describeCollection(collectionName);
GetCollectionInfoResponse res = client.getCollectionInfo(collectionName);
assert(res.getResponse().ok());
CollectionMapping tableSchema = res.getCollectionMapping().get();
Assert.assertEquals(tableSchema.getDimension(), dimension);
@ -114,7 +114,7 @@ public class TestCollection {
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_describe_table_without_connect(MilvusClient client, String collectionName) {
DescribeCollectionResponse res = client.describeCollection(collectionName);
GetCollectionInfoResponse res = client.getCollectionInfo(collectionName);
assert(!res.getResponse().ok());
}

View File

@ -16,18 +16,18 @@ public class TestCollectionCount {
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_collection_count_no_vectors(MilvusClient client, String collectionName) {
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), 0);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), 0);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_collection_count_collection_not_existed(MilvusClient client, String collectionName) {
GetCollectionRowCountResponse res = client.getCollectionRowCount(collectionName+"_");
CountEntitiesResponse res = client.countEntities(collectionName+"_");
assert(!res.getResponse().ok());
}
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_collection_count_without_connect(MilvusClient client, String collectionName) {
GetCollectionRowCountResponse res = client.getCollectionRowCount(collectionName+"_");
CountEntitiesResponse res = client.countEntities(collectionName+"_");
assert(!res.getResponse().ok());
}
@ -37,7 +37,7 @@ public class TestCollectionCount {
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
client.insert(insertParam);
client.flush(collectionName);
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb);
}
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
@ -46,13 +46,13 @@ public class TestCollectionCount {
InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
client.insert(insertParam);
client.flush(collectionName);
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_collection_count_multi_collections(MilvusClient client, String collectionName) throws InterruptedException {
Integer collectionNum = 10;
GetCollectionRowCountResponse res;
CountEntitiesResponse res;
for (int i = 0; i < collectionNum; ++i) {
String collectionNameNew = collectionName + "_" + i;
CollectionMapping collectionSchema = new CollectionMapping.Builder(collectionNameNew, dimension)
@ -67,8 +67,8 @@ public class TestCollectionCount {
}
for (int i = 0; i < collectionNum; ++i) {
String collectionNameNew = collectionName + "_" + i;
res = client.getCollectionRowCount(collectionNameNew);
Assert.assertEquals(res.getCollectionRowCount(), nb);
res = client.countEntities(collectionNameNew);
Assert.assertEquals(res.getCollectionEntityCount(), nb);
}
}

View File

@ -7,6 +7,7 @@ import io.milvus.client.*;
import org.testng.annotations.Test;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
public class TestCollectionInfo {
@ -26,9 +27,9 @@ public class TestCollectionInfo {
InsertResponse resInsert = client.insert(insertParam);
client.flush(collectionName);
List<Long> idsBefore = resInsert.getVectorIds();
client.deleteById(collectionName, idsBefore.get(0));
client.deleteEntityByID(collectionName, Collections.singletonList(idsBefore.get(0)));
client.flush(collectionName);
Response res = client.showCollectionInfo(collectionName);
Response res = client.getCollectionStats(collectionName);
System.out.println(res.getMessage());
JSONObject collectionInfo = Utils.getCollectionInfo(res.getMessage());
int row_count = collectionInfo.getIntValue("row_count");
@ -43,9 +44,9 @@ public class TestCollectionInfo {
Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
client.createIndex(index);
List<Long> idsBefore = resInsert.getVectorIds();
client.deleteById(collectionName, idsBefore.get(0));
client.deleteEntityByID(collectionName, Collections.singletonList(idsBefore.get(0)));
client.flush(collectionName);
Response res = client.showCollectionInfo(collectionName);
Response res = client.getCollectionStats(collectionName);
System.out.println(res.getMessage());
JSONObject collectionInfo = Utils.getCollectionInfo(res.getMessage());
int row_count = collectionInfo.getIntValue("row_count");
@ -58,9 +59,9 @@ public class TestCollectionInfo {
InsertResponse resInsert = client.insert(insertParam);
client.flush(collectionName);
List<Long> idsBefore = resInsert.getVectorIds();
client.deleteById(collectionName, idsBefore.get(0));
client.deleteEntityByID(collectionName, Collections.singletonList(idsBefore.get(0)));
client.flush(collectionName);
Response res = client.showCollectionInfo(collectionName);
Response res = client.getCollectionStats(collectionName);
System.out.println(res.getMessage());
JSONObject collectionInfo = Utils.getCollectionInfo(res.getMessage());
int row_count = collectionInfo.getIntValue("row_count");

View File

@ -21,12 +21,12 @@ public class TestCompact {
assert(res.getResponse().ok());
List<Long> ids = res.getVectorIds();
client.flush(collectionName);
Response res_delete = client.deleteByIds(collectionName, ids);
Response res_delete = client.deleteEntityByID(collectionName, ids);
assert(res_delete.ok());
client.flush(collectionName);
Response res_compact = client.compact(collectionName);
assert(res_compact.ok());
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), 0);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), 0);
}
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
@ -36,12 +36,12 @@ public class TestCompact {
assert(res.getResponse().ok());
List<Long> ids = res.getVectorIds();
client.flush(collectionName);
Response res_delete = client.deleteByIds(collectionName, ids);
Response res_delete = client.deleteEntityByID(collectionName, ids);
assert(res_delete.ok());
client.flush(collectionName);
Response res_compact = client.compact(collectionName);
assert(res_compact.ok());
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), 0);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), 0);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)

View File

@ -6,6 +6,7 @@ import org.testng.annotations.Test;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class TestDeleteVectors {
@ -23,11 +24,11 @@ public class TestDeleteVectors {
assert(res.getResponse().ok());
List<Long> ids = res.getVectorIds();
client.flush(collectionName);
Response res_delete = client.deleteByIds(collectionName, ids);
Response res_delete = client.deleteEntityByID(collectionName, ids);
assert(res_delete.ok());
client.flush(collectionName);
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), 0);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), 0);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
@ -41,12 +42,12 @@ public class TestDeleteVectors {
List<Long> ids = res.getVectorIds();
del_ids.add(ids.get(0));
client.flush(collectionName);
Response res_delete = client.deleteById(collectionName, ids.get(0));
Response res_delete = client.deleteEntityByID(collectionName, Collections.singletonList(ids.get(0)));
assert(res_delete.ok());
client.flush(collectionName);
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb - 1);
GetVectorsByIdsResponse res_get = client.getVectorsByIds(collectionName, del_ids);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb - 1);
GetEntityByIDResponse res_get = client.getEntityByID(collectionName, del_ids);
assert(res_get.getResponse().ok());
assert(res_get.getFloatVectors().get(0).size() == 0);
}
@ -58,7 +59,7 @@ public class TestDeleteVectors {
assert(res.getResponse().ok());
client.flush(collectionName);
List<Long> ids = res.getVectorIds();
Response res_delete = client.deleteByIds(collectionName + "_not_existed", ids);
Response res_delete = client.deleteEntityByID(collectionName + "_not_existed", ids);
assert(!res_delete.ok());
}
@ -71,11 +72,11 @@ public class TestDeleteVectors {
ids.add((long)123456);
ids.add((long)1234561);
client.flush(collectionName);
Response res_delete = client.deleteByIds(collectionName, ids);
Response res_delete = client.deleteEntityByID(collectionName, ids);
assert(res_delete.ok());
client.flush(collectionName);
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb);
}
@ -88,11 +89,11 @@ public class TestDeleteVectors {
assert(res.getResponse().ok());
List<Long> ids = res.getVectorIds();
client.flush(collectionName);
Response res_delete = client.deleteByIds(collectionName, ids);
Response res_delete = client.deleteEntityByID(collectionName, ids);
assert(res_delete.ok());
client.flush(collectionName);
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), 0);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), 0);
}
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
@ -104,11 +105,11 @@ public class TestDeleteVectors {
assert(res.getResponse().ok());
List<Long> ids = res.getVectorIds();
client.flush(collectionName);
Response res_delete = client.deleteById(collectionName, ids.get(0));
Response res_delete = client.deleteEntityByID(collectionName, Collections.singletonList(ids.get(0)));
assert(res_delete.ok());
client.flush(collectionName);
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb - 1);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb - 1);
// Cannot search for the vector
SearchParam searchParam = new SearchParam.Builder(collectionName)
.withBinaryVectors(del_vector)
@ -126,7 +127,7 @@ public class TestDeleteVectors {
assert(res.getResponse().ok());
List<Long> ids = res.getVectorIds();
client.flush(collectionName);
Response res_delete = client.deleteByIds(collectionName + "_not_existed", ids);
Response res_delete = client.deleteEntityByID(collectionName + "_not_existed", ids);
assert(!res_delete.ok());
}
@ -139,11 +140,11 @@ public class TestDeleteVectors {
ids.add((long)123456);
ids.add((long)1234561);
client.flush(collectionName);
Response res_delete = client.deleteByIds(collectionName, ids);
Response res_delete = client.deleteEntityByID(collectionName, ids);
assert(res_delete.ok());
client.flush(collectionName);
// Assert collection row count
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb);
}
}

View File

@ -52,7 +52,7 @@ public class TestFlush {
assert(res.ok());
for (int i = 0; i < 10; i++) {
// check row count
Assert.assertEquals(client.getCollectionRowCount(names.get(i)).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(names.get(i)).getCollectionEntityCount(), nb);
}
}
@ -74,7 +74,7 @@ public class TestFlush {
flushResponseFuture.get();
for (int i = 0; i < 100; i++) {
// check row count
Assert.assertEquals(client.getCollectionRowCount(names.get(i)).getCollectionRowCount(), nb);
Assert.assertEquals(client.countEntities(names.get(i)).getCollectionEntityCount(), nb);
}
}
@ -85,7 +85,7 @@ public class TestFlush {
client.insert(insertParam);
Response res = client.flush(collectionName);
assert(res.ok());
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb * (i+1));
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb * (i+1));
}
}
@ -96,7 +96,7 @@ public class TestFlush {
client.insert(insertParam);
Response res = client.flush(collectionName);
assert(res.ok());
Assert.assertEquals(client.getCollectionRowCount(collectionName).getCollectionRowCount(), nb * (i+1));
Assert.assertEquals(client.countEntities(collectionName).getCollectionEntityCount(), nb * (i+1));
}
}
}

View File

@ -5,6 +5,7 @@ import org.testng.annotations.Test;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class TestGetVectorByID {
@ -21,7 +22,7 @@ public class TestGetVectorByID {
InsertResponse resInsert = client.insert(insertParam);
List<Long> ids = resInsert.getVectorIds();
client.flush(collectionName);
GetVectorsByIdsResponse res = client.getVectorsByIds(collectionName, ids.subList(0, get_length));
GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, get_length));
assert (res.getResponse().ok());
for (int i = 0; i < get_length; i++) {
assert (res.getFloatVectors().get(i).equals(vectors.get(i)));
@ -33,10 +34,10 @@ public class TestGetVectorByID {
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
InsertResponse resInsert = client.insert(insertParam);
List<Long> ids = resInsert.getVectorIds();
Response res_delete = client.deleteById(collectionName, ids.get(0));
Response res_delete = client.deleteEntityByID(collectionName, Collections.singletonList(ids.get(0)));
assert(res_delete.ok());
client.flush(collectionName);
GetVectorsByIdsResponse res = client.getVectorsByIds(collectionName, ids.subList(0, 1));
GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, 1));
assert (res.getResponse().ok());
assert (res.getFloatVectors().get(0).size() == 0);
}
@ -44,7 +45,7 @@ public class TestGetVectorByID {
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_get_vector_by_id_collection_name_not_existed(MilvusClient client, String collectionName) {
String newCollection = "not_existed";
GetVectorsByIdsResponse res = client.getVectorsByIds(newCollection, get_ids);
GetEntityByIDResponse res = client.getEntityByID(newCollection, get_ids);
assert(!res.getResponse().ok());
}
@ -53,7 +54,7 @@ public class TestGetVectorByID {
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
client.insert(insertParam);
client.flush(collectionName);
GetVectorsByIdsResponse res = client.getVectorsByIds(collectionName, get_ids);
GetEntityByIDResponse res = client.getEntityByID(collectionName, get_ids);
assert (res.getFloatVectors().get(0).size() == 0);
}
@ -64,7 +65,7 @@ public class TestGetVectorByID {
InsertResponse resInsert = client.insert(insertParam);
List<Long> ids = resInsert.getVectorIds();
client.flush(collectionName);
GetVectorsByIdsResponse res = client.getVectorsByIds(collectionName, ids.subList(0, 1));
GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, 1));
assert res.getBinaryVectors().get(0).equals(vectorsBinary.get(0).rewind());
}
@ -73,10 +74,10 @@ public class TestGetVectorByID {
InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
InsertResponse resInsert = client.insert(insertParam);
List<Long> ids = resInsert.getVectorIds();
Response res_delete = client.deleteById(collectionName, ids.get(0));
Response res_delete = client.deleteEntityByID(collectionName, Collections.singletonList(ids.get(0)));
assert(res_delete.ok());
client.flush(collectionName);
GetVectorsByIdsResponse res = client.getVectorsByIds(collectionName, ids.subList(0, 1));
GetEntityByIDResponse res = client.getEntityByID(collectionName, ids.subList(0, 1));
assert (res.getFloatVectors().get(0).size() == 0);
}
@ -85,7 +86,7 @@ public class TestGetVectorByID {
InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
client.insert(insertParam);
client.flush(collectionName);
GetVectorsByIdsResponse res = client.getVectorsByIds(collectionName, get_ids);
GetEntityByIDResponse res = client.getEntityByID(collectionName, get_ids);
assert (res.getFloatVectors().get(0).size() == 0);
}
}

View File

@ -45,7 +45,7 @@ public class TestIndex {
Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
Response res_create = client.createIndex(index);
assert(res_create.ok());
DescribeIndexResponse res = client.describeIndex(collectionName);
GetIndexInfoResponse res = client.getIndexInfo(collectionName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(Utils.getIndexParamValue(index1.getParamsInJson(), "nlist"), n_list);
@ -63,7 +63,7 @@ public class TestIndex {
Response res_create = client.createIndex(index);
assert(res_create.ok());
Logger.getLogger("a").info("end create");
DescribeIndexResponse res = client.describeIndex(collectionName);
GetIndexInfoResponse res = client.getIndexInfo(collectionName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getIndexType(), indexType);
@ -77,7 +77,7 @@ public class TestIndex {
Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
Response res_create = client.createIndex(index);
assert(res_create.ok());
DescribeIndexResponse res = client.describeIndex(collectionName);
GetIndexInfoResponse res = client.getIndexInfo(collectionName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getIndexType(), indexType);
@ -91,7 +91,7 @@ public class TestIndex {
Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
Response res_create = client.createIndex(index);
assert(res_create.ok());
DescribeIndexResponse res = client.describeIndex(collectionName);
GetIndexInfoResponse res = client.getIndexInfo(collectionName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getIndexType(), indexType);
@ -105,7 +105,7 @@ public class TestIndex {
Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
Response res_create = client.createIndex(index);
assert(res_create.ok());
DescribeIndexResponse res = client.describeIndex(collectionName);
GetIndexInfoResponse res = client.getIndexInfo(collectionName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getIndexType(), indexType);
@ -158,7 +158,7 @@ public class TestIndex {
Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
Response res_create = client.createIndex(index);
assert(res_create.ok());
DescribeIndexResponse res = client.describeIndex(collectionName);
GetIndexInfoResponse res = client.getIndexInfo(collectionName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(Utils.getIndexParamValue(index1.getParamsInJson(), "nlist"), n_list);
@ -188,7 +188,7 @@ public class TestIndex {
Index indexNew = new Index.Builder(collectionName, indexTypeNew).withParamsInJson(indexParam).build();
Response resNew = client.createIndex(indexNew);
assert(resNew.ok());
DescribeIndexResponse res = client.describeIndex(collectionName);
GetIndexInfoResponse res = client.getIndexInfo(collectionName);
assert(res_create.ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(Utils.getIndexParamValue(index1.getParamsInJson(), "nlist"), n_list);
@ -198,13 +198,13 @@ public class TestIndex {
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_describe_index_table_not_existed(MilvusClient client, String collectionName) {
String collectionNameNew = collectionName + "_";
DescribeIndexResponse res = client.describeIndex(collectionNameNew);
GetIndexInfoResponse res = client.getIndexInfo(collectionNameNew);
assert(!res.getResponse().ok());
}
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_describe_index_without_connect(MilvusClient client, String collectionName) {
DescribeIndexResponse res = client.describeIndex(collectionName);
GetIndexInfoResponse res = client.getIndexInfo(collectionName);
assert(!res.getResponse().ok());
}
@ -217,7 +217,7 @@ public class TestIndex {
assert(res.ok());
Response res_drop = client.dropIndex(collectionName);
assert(res_drop.ok());
DescribeIndexResponse res2 = client.describeIndex(collectionName);
GetIndexInfoResponse res2 = client.getIndexInfo(collectionName);
assert(res2.getResponse().ok());
Index index1 = res2.getIndex().get();
Assert.assertEquals(Utils.getIndexParamValue(index1.getParamsInJson(), "nlist"), 0);
@ -233,7 +233,7 @@ public class TestIndex {
assert(res.ok());
Response res_drop = client.dropIndex(collectionName);
assert(res_drop.ok());
DescribeIndexResponse res2 = client.describeIndex(collectionName);
GetIndexInfoResponse res2 = client.getIndexInfo(collectionName);
assert(res2.getResponse().ok());
Index index1 = res2.getIndex().get();
Assert.assertEquals(Utils.getIndexParamValue(index1.getParamsInJson(), "nlist"), 0);
@ -249,7 +249,7 @@ public class TestIndex {
assert(res.ok());
Response res_drop = client.dropIndex(collectionName);
assert(res_drop.ok());
DescribeIndexResponse res_desc = client.describeIndex(collectionName);
GetIndexInfoResponse res_desc = client.getIndexInfo(collectionName);
assert(res_desc.getResponse().ok());
Index index1 = res_desc.getIndex().get();
Assert.assertEquals(Utils.getIndexParamValue(index1.getParamsInJson(), "nlist"), 0);
@ -275,7 +275,7 @@ public class TestIndex {
client.insert(insertParam);
Response res_drop = client.dropIndex(collectionName);
assert(res_drop.ok());
DescribeIndexResponse res = client.describeIndex(collectionName);
GetIndexInfoResponse res = client.getIndexInfo(collectionName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getIndexType(), defaultIndexType);
@ -287,7 +287,7 @@ public class TestIndex {
client.insert(insertParam);
Response res_drop = client.dropIndex(collectionName);
assert(res_drop.ok());
DescribeIndexResponse res = client.describeIndex(collectionName);
GetIndexInfoResponse res = client.getIndexInfo(collectionName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getIndexType(), defaultIndexType);

View File

@ -98,8 +98,8 @@ public class TestMix {
executor.shutdown();
Thread.sleep(2000);
GetCollectionRowCountResponse getCollectionRowCountResponse = client.getCollectionRowCount(collectionName);
Assert.assertEquals(getCollectionRowCountResponse.getCollectionRowCount(), thread_num * nb);
CountEntitiesResponse countEntitiesResponse = client.countEntities(collectionName);
Assert.assertEquals(countEntitiesResponse.getCollectionEntityCount(), thread_num * nb);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
@ -120,8 +120,8 @@ public class TestMix {
executor.shutdown();
Thread.sleep(2000);
GetCollectionRowCountResponse getCollectionRowCountResponse = client.getCollectionRowCount(collectionName);
Assert.assertEquals(getCollectionRowCountResponse.getCollectionRowCount(), thread_num * nb);
CountEntitiesResponse countEntitiesResponse = client.countEntities(collectionName);
Assert.assertEquals(countEntitiesResponse.getCollectionEntityCount(), thread_num * nb);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
@ -143,8 +143,8 @@ public class TestMix {
executor.awaitQuiescence(300, TimeUnit.SECONDS);
executor.shutdown();
Thread.sleep(2000);
GetCollectionRowCountResponse getCollectionRowCountResponse = client.getCollectionRowCount(collectionName);
Assert.assertEquals(getCollectionRowCountResponse.getCollectionRowCount(), thread_num * nb);
CountEntitiesResponse countEntitiesResponse = client.countEntities(collectionName);
Assert.assertEquals(countEntitiesResponse.getCollectionEntityCount(), thread_num * nb);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
@ -182,8 +182,8 @@ public class TestMix {
executor.awaitQuiescence(300, TimeUnit.SECONDS);
executor.shutdown();
Thread.sleep(2000);
GetCollectionRowCountResponse getCollectionRowCountResponse = client.getCollectionRowCount(collectionName);
Assert.assertEquals(getCollectionRowCountResponse.getCollectionRowCount(), thread_num * nb);
CountEntitiesResponse countEntitiesResponse = client.countEntities(collectionName);
Assert.assertEquals(countEntitiesResponse.getCollectionEntityCount(), thread_num * nb);
}
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)

View File

@ -88,7 +88,7 @@ public class TestPS {
}
executor_search.awaitQuiescence(300, TimeUnit.SECONDS);
executor_search.shutdown();
GetCollectionRowCountResponse getTableRowCountResponse = client.getCollectionRowCount(collectionName);
System.out.println(getTableRowCountResponse.getCollectionRowCount());
CountEntitiesResponse getTableRowCountResponse = client.countEntities(collectionName);
System.out.println(getTableRowCountResponse.getCollectionEntityCount());
}
}

View File

@ -1,9 +1,6 @@
package com;
import io.milvus.client.HasPartitionResponse;
import io.milvus.client.MilvusClient;
import io.milvus.client.Response;
import io.milvus.client.ShowPartitionsResponse;
import io.milvus.client.*;
import org.apache.commons.lang3.RandomStringUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
@ -21,7 +18,7 @@ public class TestPartition {
Response createpResponse = client.createPartition(collectionName, tag);
assert (createpResponse.ok());
// show partitions
List<String> partitions = client.showPartitions(collectionName).getPartitionList();
List<String> partitions = client.listPartitions(collectionName).getPartitionList();
System.out.println(partitions);
Assert.assertTrue(partitions.contains(tag));
}
@ -71,8 +68,8 @@ public class TestPartition {
Response response = client.dropPartition(collectionName, tag);
assert (response.ok());
// show partitions
System.out.println(client.showPartitions(collectionName).getPartitionList());
int length = client.showPartitions(collectionName).getPartitionList().size();
System.out.println(client.listPartitions(collectionName).getPartitionList());
int length = client.listPartitions(collectionName).getPartitionList().size();
// _default
Assert.assertEquals(length, 1);
}
@ -83,8 +80,8 @@ public class TestPartition {
Response createpResponseNew = client.createPartition(collectionName, tag);
assert (!createpResponseNew.ok());
// show partitions
// System.out.println(client.showPartitions(collectionName).getPartitionList());
// int length = client.showPartitions(collectionName).getPartitionList().size();
// System.out.println(client.listPartitions(collectionName).getPartitionList());
// int length = client.listPartitions(collectionName).getPartitionList().size();
// // _default
// Assert.assertEquals(length, 1);
}
@ -132,7 +129,7 @@ public class TestPartition {
String tag = RandomStringUtils.randomAlphabetic(10);
Response createpResponse = client.createPartition(collectionName, tag);
assert (createpResponse.ok());
ShowPartitionsResponse response = client.showPartitions(collectionName);
ListPartitionsResponse response = client.listPartitions(collectionName);
assert (response.getResponse().ok());
Assert.assertTrue(response.getPartitionList().contains(tag));
}
@ -146,7 +143,7 @@ public class TestPartition {
String tagNew = RandomStringUtils.randomAlphabetic(10);
Response newCreatepResponse = client.createPartition(collectionName, tagNew);
assert (newCreatepResponse.ok());
ShowPartitionsResponse response = client.showPartitions(collectionName);
ListPartitionsResponse response = client.listPartitions(collectionName);
assert (response.getResponse().ok());
System.out.println(response.getPartitionList());
Assert.assertTrue(response.getPartitionList().contains(tag));

View File

@ -1,273 +1,273 @@
package com;
import io.milvus.client.*;
import org.apache.commons.lang3.RandomStringUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
public class TestSearchByIds {
int dimension = 128;
int n_list = 1024;
int default_n_list = 16384;
int nb = 10000;
int small_nb = 10;
int n_probe = 20;
int top_k = 10;
int nq = 5;
double epsilon = 0.001;
IndexType indexType = IndexType.IVF_SQ8;
IndexType defaultIndexType = IndexType.FLAT;
List<Long> default_ids = Utils.toListIds(1111);
List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
List<List<Float>> small_vectors = Utils.genVectors(small_nb, dimension, true);
List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
String indexParam = Utils.setIndexParam(n_list);
public String searchParamStr = Utils.setSearchParam(n_probe);
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_collection_not_existed(MilvusClient client, String collectionName) {
String collectionNameNew = collectionName + "_";
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionNameNew)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(default_ids)
.build();
SearchResponse res_search = client.searchByIds(searchParam);
assert (!res_search.getResponse().ok());
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_collection_empty(MilvusClient client, String collectionName) {
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(default_ids)
.build();
SearchResponse res_search = client.searchByIds(searchParam);
assert (!res_search.getResponse().ok());
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_no_result(MilvusClient client, String collectionName) {
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
client.insert(insertParam);
client.flush(collectionName);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(default_ids)
.build();
List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
assert (client.searchByIds(searchParam).getResponse().ok());
Assert.assertEquals(res_search.get(0).size(), 0);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_count_lt_top_k(MilvusClient client, String collectionName) {
int top_k = 100;
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(small_vectors).build();
InsertResponse res_insert = client.insert(insertParam);
client.flush(collectionName);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(Utils.toListIds(res_insert.getVectorIds().get(0)))
.build();
List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
// reason: "Failed to query by id in collection L2_FmVKbqSZaN, result doesn\'t match id count"
assert (!client.searchByIds(searchParam).getResponse().ok());
// Assert.assertEquals(res_search.size(), default_ids.size());
// Assert.assertEquals(res_search.get(0).get(0).getVectorId(), -1);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_index_IVFLAT(MilvusClient client, String collectionName) {
IndexType indexType = IndexType.IVFLAT;
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
InsertResponse res_insert = client.insert(insertParam);
client.flush(collectionName);
Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
client.createIndex(index);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(res_insert.getVectorIds())
.build();
List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
for (int i=0; i<vectors.size(); ++i) {
Assert.assertEquals(res_search.get(i).size(), top_k);
long vectorId = res_search.get(i).get(0).getVectorId();
long insertId = res_insert.getVectorIds().get(i);
Assert.assertEquals(vectorId, insertId);
double distance = res_search.get(i).get(0).getDistance();
if (collectionName.startsWith("L2")) {
Assert.assertEquals(distance, 0.0, epsilon);
}else if (collectionName.startsWith("IP")) {
Assert.assertEquals(distance, 1.0, epsilon);
}
}
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_partition(MilvusClient client, String collectionName) {
IndexType indexType = IndexType.IVFLAT;
String tag = RandomStringUtils.randomAlphabetic(10);
client.createPartition(collectionName, tag);
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).withPartitionTag(tag).build();
InsertResponse res_insert = client.insert(insertParam);
client.flush(collectionName);
Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
client.createIndex(index);
List<String> queryTags = new ArrayList<>();
queryTags.add(tag);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(Utils.toListIds(res_insert.getVectorIds().get(0)))
.withPartitionTags(queryTags)
.build();
List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
double distance = res_search.get(0).get(0).getDistance();
if (collectionName.startsWith("L2")) {
Assert.assertEquals(distance, 0.0, epsilon);
}else if (collectionName.startsWith("IP")) {
Assert.assertEquals(distance, 1.0, epsilon);
}
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_partition_not_exited(MilvusClient client, String collectionName) {
String tag = RandomStringUtils.randomAlphabetic(10);
client.createPartition(collectionName, tag);
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).withPartitionTag(tag).build();
client.insert(insertParam);
client.flush(collectionName);
String tagNew = RandomStringUtils.randomAlphabetic(10);
List<String> queryTags = new ArrayList<>();
queryTags.add(tagNew);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(default_ids)
.withPartitionTags(queryTags)
.build();
SearchResponse res_search = client.searchByIds(searchParam);
assert (!res_search.getResponse().ok());
Assert.assertEquals(res_search.getQueryResultsList().size(), 0);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_partition_empty(MilvusClient client, String collectionName) {
String tag = RandomStringUtils.randomAlphabetic(10);
client.createPartition(collectionName, tag);
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).withPartitionTag(tag).build();
client.insert(insertParam);
client.flush(collectionName);
List<String> queryTags = new ArrayList<>();
queryTags.add(tag);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(default_ids)
.withPartitionTags(queryTags)
.build();
SearchResponse res_search = client.searchByIds(searchParam);
assert (res_search.getResponse().ok());
Assert.assertEquals(res_search.getQueryResultsList().size(), 1);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_invalid_n_probe(MilvusClient client, String collectionName) {
int n_probe_new = 0;
String searchParamStrNew = Utils.setSearchParam(n_probe_new);
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
client.insert(insertParam);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStrNew)
.withTopK(top_k)
.withIDs(default_ids)
.build();
SearchResponse res_search = client.searchByIds(searchParam);
assert (!res_search.getResponse().ok());
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_invalid_top_k(MilvusClient client, String collectionName) {
int top_k_new = 0;
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
client.insert(insertParam);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k_new)
.withIDs(default_ids)
.build();
SearchResponse res_search = client.searchByIds(searchParam);
assert (!res_search.getResponse().ok());
}
// Binary tests
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
public void test_search_collection_not_existed_binary(MilvusClient client, String collectionName) {
String collectionNameNew = collectionName + "_";
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionNameNew)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(default_ids)
.build();
SearchResponse res_search = client.searchByIds(searchParam);
assert (!res_search.getResponse().ok());
}
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
public void test_search_ids_binary(MilvusClient client, String collectionName) {
InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
InsertResponse res_insert = client.insert(insertParam);
client.flush(collectionName);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(res_insert.getVectorIds())
.build();
List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
for (int i = 0; i < top_k; i++) {
long insert_id = res_insert.getVectorIds().get(i);
long get_id = res_search.get(i).get(0).getVectorId();
System.out.println(get_id);
Assert.assertEquals(insert_id, get_id);
}
}
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
public void test_search_invalid_n_probe_binary(MilvusClient client, String collectionName) {
int n_probe_new = 0;
String searchParamStrNew = Utils.setSearchParam(n_probe_new);
InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
client.insert(insertParam);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStrNew)
.withTopK(top_k)
.withIDs(default_ids)
.build();
SearchResponse res_search = client.searchByIds(searchParam);
assert (!res_search.getResponse().ok());
}
@Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
public void test_search_invalid_top_k_binary(MilvusClient client, String collectionName) {
int top_k_new = 0;
InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
client.insert(insertParam);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k_new)
.withIDs(default_ids)
.build();
SearchResponse res_search = client.searchByIds(searchParam);
assert (!res_search.getResponse().ok());
}
}
//package com;
//
//import io.milvus.client.*;
//import org.apache.commons.lang3.RandomStringUtils;
//import org.testng.Assert;
//import org.testng.annotations.Test;
//
//import java.nio.ByteBuffer;
//import java.util.ArrayList;
//import java.util.List;
//
//public class TestSearchByIds {
// int dimension = 128;
// int n_list = 1024;
// int default_n_list = 16384;
// int nb = 10000;
// int small_nb = 10;
// int n_probe = 20;
// int top_k = 10;
// int nq = 5;
// double epsilon = 0.001;
// IndexType indexType = IndexType.IVF_SQ8;
// IndexType defaultIndexType = IndexType.FLAT;
// List<Long> default_ids = Utils.toListIds(1111);
// List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
// List<List<Float>> small_vectors = Utils.genVectors(small_nb, dimension, true);
// List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
// String indexParam = Utils.setIndexParam(n_list);
// public String searchParamStr = Utils.setSearchParam(n_probe);
//
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
// public void test_search_collection_not_existed(MilvusClient client, String collectionName) {
// String collectionNameNew = collectionName + "_";
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionNameNew)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k)
// .withIDs(default_ids)
// .build();
// SearchResponse res_search = client.searchByIds(searchParam);
// assert (!res_search.getResponse().ok());
// }
//
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
// public void test_search_collection_empty(MilvusClient client, String collectionName) {
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k)
// .withIDs(default_ids)
// .build();
// SearchResponse res_search = client.searchByIds(searchParam);
// assert (!res_search.getResponse().ok());
// }
//
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
// public void test_search_no_result(MilvusClient client, String collectionName) {
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
// client.insert(insertParam);
// client.flush(collectionName);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k)
// .withIDs(default_ids)
// .build();
// List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
// assert (client.searchByIds(searchParam).getResponse().ok());
// Assert.assertEquals(res_search.get(0).size(), 0);
// }
//
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
// public void test_search_count_lt_top_k(MilvusClient client, String collectionName) {
// int top_k = 100;
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(small_vectors).build();
// InsertResponse res_insert = client.insert(insertParam);
// client.flush(collectionName);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k)
// .withIDs(Utils.toListIds(res_insert.getVectorIds().get(0)))
// .build();
// List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
// // reason: "Failed to query by id in collection L2_FmVKbqSZaN, result doesn\'t match id count"
// assert (!client.searchByIds(searchParam).getResponse().ok());
//// Assert.assertEquals(res_search.size(), default_ids.size());
//// Assert.assertEquals(res_search.get(0).get(0).getVectorId(), -1);
// }
//
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
// public void test_search_index_IVFLAT(MilvusClient client, String collectionName) {
// IndexType indexType = IndexType.IVFLAT;
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
// InsertResponse res_insert = client.insert(insertParam);
// client.flush(collectionName);
// Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
// client.createIndex(index);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k)
// .withIDs(res_insert.getVectorIds())
// .build();
// List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
// for (int i=0; i<vectors.size(); ++i) {
// Assert.assertEquals(res_search.get(i).size(), top_k);
// long vectorId = res_search.get(i).get(0).getVectorId();
// long insertId = res_insert.getVectorIds().get(i);
// Assert.assertEquals(vectorId, insertId);
// double distance = res_search.get(i).get(0).getDistance();
// if (collectionName.startsWith("L2")) {
// Assert.assertEquals(distance, 0.0, epsilon);
// }else if (collectionName.startsWith("IP")) {
// Assert.assertEquals(distance, 1.0, epsilon);
// }
// }
// }
//
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
// public void test_search_partition(MilvusClient client, String collectionName) {
// IndexType indexType = IndexType.IVFLAT;
// String tag = RandomStringUtils.randomAlphabetic(10);
// client.createPartition(collectionName, tag);
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).withPartitionTag(tag).build();
// InsertResponse res_insert = client.insert(insertParam);
// client.flush(collectionName);
// Index index = new Index.Builder(collectionName, indexType).withParamsInJson(indexParam).build();
// client.createIndex(index);
// List<String> queryTags = new ArrayList<>();
// queryTags.add(tag);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k)
// .withIDs(Utils.toListIds(res_insert.getVectorIds().get(0)))
// .withPartitionTags(queryTags)
// .build();
// List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
// double distance = res_search.get(0).get(0).getDistance();
// if (collectionName.startsWith("L2")) {
// Assert.assertEquals(distance, 0.0, epsilon);
// }else if (collectionName.startsWith("IP")) {
// Assert.assertEquals(distance, 1.0, epsilon);
// }
// }
//
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
// public void test_search_partition_not_exited(MilvusClient client, String collectionName) {
// String tag = RandomStringUtils.randomAlphabetic(10);
// client.createPartition(collectionName, tag);
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).withPartitionTag(tag).build();
// client.insert(insertParam);
// client.flush(collectionName);
// String tagNew = RandomStringUtils.randomAlphabetic(10);
// List<String> queryTags = new ArrayList<>();
// queryTags.add(tagNew);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k)
// .withIDs(default_ids)
// .withPartitionTags(queryTags)
// .build();
// SearchResponse res_search = client.searchByIds(searchParam);
// assert (!res_search.getResponse().ok());
// Assert.assertEquals(res_search.getQueryResultsList().size(), 0);
// }
//
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
// public void test_search_partition_empty(MilvusClient client, String collectionName) {
// String tag = RandomStringUtils.randomAlphabetic(10);
// client.createPartition(collectionName, tag);
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).withPartitionTag(tag).build();
// client.insert(insertParam);
// client.flush(collectionName);
// List<String> queryTags = new ArrayList<>();
// queryTags.add(tag);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k)
// .withIDs(default_ids)
// .withPartitionTags(queryTags)
// .build();
// SearchResponse res_search = client.searchByIds(searchParam);
// assert (res_search.getResponse().ok());
// Assert.assertEquals(res_search.getQueryResultsList().size(), 1);
// }
//
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
// public void test_search_invalid_n_probe(MilvusClient client, String collectionName) {
// int n_probe_new = 0;
// String searchParamStrNew = Utils.setSearchParam(n_probe_new);
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
// client.insert(insertParam);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStrNew)
// .withTopK(top_k)
// .withIDs(default_ids)
// .build();
// SearchResponse res_search = client.searchByIds(searchParam);
// assert (!res_search.getResponse().ok());
// }
//
// @Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
// public void test_search_invalid_top_k(MilvusClient client, String collectionName) {
// int top_k_new = 0;
// InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(vectors).build();
// client.insert(insertParam);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k_new)
// .withIDs(default_ids)
// .build();
// SearchResponse res_search = client.searchByIds(searchParam);
// assert (!res_search.getResponse().ok());
// }
//
// // Binary tests
// @Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
// public void test_search_collection_not_existed_binary(MilvusClient client, String collectionName) {
// String collectionNameNew = collectionName + "_";
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionNameNew)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k)
// .withIDs(default_ids)
// .build();
// SearchResponse res_search = client.searchByIds(searchParam);
// assert (!res_search.getResponse().ok());
// }
//
// @Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
// public void test_search_ids_binary(MilvusClient client, String collectionName) {
// InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
// InsertResponse res_insert = client.insert(insertParam);
// client.flush(collectionName);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k)
// .withIDs(res_insert.getVectorIds())
// .build();
// List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
// for (int i = 0; i < top_k; i++) {
// long insert_id = res_insert.getVectorIds().get(i);
// long get_id = res_search.get(i).get(0).getVectorId();
// System.out.println(get_id);
// Assert.assertEquals(insert_id, get_id);
// }
// }
//
// @Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
// public void test_search_invalid_n_probe_binary(MilvusClient client, String collectionName) {
// int n_probe_new = 0;
// String searchParamStrNew = Utils.setSearchParam(n_probe_new);
// InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
// client.insert(insertParam);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStrNew)
// .withTopK(top_k)
// .withIDs(default_ids)
// .build();
// SearchResponse res_search = client.searchByIds(searchParam);
// assert (!res_search.getResponse().ok());
// }
//
// @Test(dataProvider = "BinaryCollection", dataProviderClass = MainClass.class)
// public void test_search_invalid_top_k_binary(MilvusClient client, String collectionName) {
// int top_k_new = 0;
// InsertParam insertParam = new InsertParam.Builder(collectionName).withBinaryVectors(vectorsBinary).build();
// client.insert(insertParam);
// SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
// .withParamsInJson(searchParamStr)
// .withTopK(top_k_new)
// .withIDs(default_ids)
// .build();
// SearchResponse res_search = client.searchByIds(searchParam);
// assert (!res_search.getResponse().ok());
// }
//
//}

View File

@ -21,7 +21,7 @@ nb = 6000
class TestAddBase:
"""
******************************************************************
The following cases are used to test `add_vectors` function
The following cases are used to test `insert` function
******************************************************************
"""
@pytest.fixture(
@ -43,7 +43,7 @@ class TestAddBase:
expected: status not ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
param = {'collection_name': collection,
'dimension': dim,
'index_file_size': index_file_size,
@ -58,7 +58,7 @@ class TestAddBase:
expected: collection exists, status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert assert_has_collection(connect, collection)
@pytest.mark.timeout(ADD_TIMEOUT)
@ -70,7 +70,7 @@ class TestAddBase:
'''
status = connect.drop_collection(collection)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert not status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -87,7 +87,7 @@ class TestAddBase:
status = connect.create_collection(param)
status = connect.drop_collection(collection)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(param['collection_name'], vector)
status, ids = connect.insert(param['collection_name'], vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -98,7 +98,7 @@ class TestAddBase:
expected: status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
status = connect.drop_collection(collection)
assert status.OK()
@ -115,7 +115,7 @@ class TestAddBase:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -126,7 +126,7 @@ class TestAddBase:
expected: status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
connect.flush([collection])
status = connect.drop_collection(collection)
@ -145,7 +145,7 @@ class TestAddBase:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
connect.flush([collection])
status = connect.drop_collection(param['collection_name'])
assert status.OK()
@ -161,7 +161,7 @@ class TestAddBase:
index_type = get_simple_index["index_type"]
status = connect.create_index(collection, index_type, index_param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -180,7 +180,7 @@ class TestAddBase:
status = connect.create_collection(param)
status = connect.create_index(collection, index_type, index_param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
connect.drop_collection(param['collection_name'])
assert status.OK()
@ -195,7 +195,7 @@ class TestAddBase:
index_type = get_simple_index["index_type"]
logging.getLogger().info(index_param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
@ -214,7 +214,7 @@ class TestAddBase:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
status = connect.create_index(param['collection_name'], index_type, index_param)
assert status.OK()
@ -228,7 +228,7 @@ class TestAddBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
connect.flush([collection])
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
@ -248,7 +248,7 @@ class TestAddBase:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
connect.flush([collection])
status = connect.create_index(param['collection_name'], index_type, index_param)
assert status.OK()
@ -261,8 +261,8 @@ class TestAddBase:
expected: status ok
'''
vector = gen_single_vector(dim)
status, result = connect.search_vectors(collection, 1, vector)
status, ids = connect.add_vectors(collection, vector)
status, result = connect.search(collection, 1, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -278,8 +278,8 @@ class TestAddBase:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, result = connect.search_vectors(collection, 1, vector)
status, ids = connect.add_vectors(param['collection_name'], vector)
status, result = connect.search(collection, 1, vector)
status, ids = connect.insert(param['collection_name'], vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -290,10 +290,10 @@ class TestAddBase:
expected: status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
connect.flush([collection])
status, result = connect.search_vectors(collection, 1, vector)
status, result = connect.search(collection, 1, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -309,8 +309,8 @@ class TestAddBase:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, result = connect.search_vectors(param['collection_name'], 1, vector)
status, ids = connect.insert(collection, vector)
status, result = connect.search(param['collection_name'], 1, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -321,9 +321,9 @@ class TestAddBase:
expected: status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
connect.flush([collection])
status, result = connect.search_vectors(collection, 1, vector)
status, result = connect.search(collection, 1, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -339,19 +339,19 @@ class TestAddBase:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
connect.flush([collection])
status, result = connect.search_vectors(param['collection_name'], 1, vector)
status, result = connect.search(param['collection_name'], 1, vector)
assert status.OK()
"""
******************************************************************
The following cases are used to test `add_vectors` function
The following cases are used to test `insert` function
******************************************************************
"""
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_ids(self, connect, collection):
def test_insert_ids(self, connect, collection):
'''
target: test add vectors in collection, use customize ids
method: create collection and add vectors in it, check the ids returned and the collection length after vectors added
@ -360,52 +360,52 @@ class TestAddBase:
nq = 5; top_k = 1;
vectors = gen_vectors(nq, dim)
ids = [i for i in range(nq)]
status, ids = connect.add_vectors(collection, vectors, ids)
status, ids = connect.insert(collection, vectors, ids)
connect.flush([collection])
assert status.OK()
assert len(ids) == nq
status, result = connect.search_vectors(collection, top_k, query_records=vectors)
status, result = connect.search(collection, top_k, query_records=vectors)
logging.getLogger().info(result)
assert len(result) == nq
for i in range(nq):
assert result[i][0].id == i
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_twice_ids_no_ids(self, connect, collection):
def test_insert_twice_ids_no_ids(self, connect, collection):
'''
target: check the result of add_vectors, with params ids and no ids
target: check the result of insert, with params ids and no ids
method: test add vectors twice, use customize ids first, and then use no ids
expected: status not OK
'''
nq = 5; top_k = 1;
vectors = gen_vectors(nq, dim)
ids = [i for i in range(nq)]
status, ids = connect.add_vectors(collection, vectors, ids)
status, ids = connect.insert(collection, vectors, ids)
assert status.OK()
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
logging.getLogger().info(status)
logging.getLogger().info(ids)
assert not status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_twice_not_ids_ids(self, connect, collection):
def test_insert_twice_not_ids_ids(self, connect, collection):
'''
target: check the result of add_vectors, with params ids and no ids
target: check the result of insert, with params ids and no ids
method: test add vectors twice, use not ids first, and then use customize ids
expected: status not OK
'''
nq = 5; top_k = 1;
vectors = gen_vectors(nq, dim)
ids = [i for i in range(nq)]
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status, ids = connect.add_vectors(collection, vectors, ids)
status, ids = connect.insert(collection, vectors, ids)
logging.getLogger().info(status)
logging.getLogger().info(ids)
assert not status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_ids_length_not_match(self, connect, collection):
def test_insert_ids_length_not_match(self, connect, collection):
'''
target: test add vectors in collection, use customize ids, len(ids) != len(vectors)
method: create collection and add vectors in it
@ -415,7 +415,7 @@ class TestAddBase:
vectors = gen_vectors(nq, dim)
ids = [i for i in range(1, nq)]
with pytest.raises(Exception) as e:
status, ids = connect.add_vectors(collection, vectors, ids)
status, ids = connect.insert(collection, vectors, ids)
@pytest.fixture(
scope="function",
@ -425,7 +425,7 @@ class TestAddBase:
yield request.param
@pytest.mark.level(2)
def test_add_vectors_ids_invalid(self, connect, collection, get_vector_id):
def test_insert_ids_invalid(self, connect, collection, get_vector_id):
'''
target: test add vectors in collection, use customize ids, which are not int64
method: create collection and add vectors in it
@ -436,10 +436,10 @@ class TestAddBase:
vector_id = get_vector_id
ids = [vector_id for _ in range(nq)]
with pytest.raises(Exception):
connect.add_vectors(collection, vectors, ids)
connect.insert(collection, vectors, ids)
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors(self, connect, collection):
def test_insert(self, connect, collection):
'''
target: test add vectors in collection created before
method: create collection and add vectors in it, check the ids returned and the collection length after vectors added
@ -447,12 +447,12 @@ class TestAddBase:
'''
nq = 5
vectors = gen_vectors(nq, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
assert len(ids) == nq
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_tag(self, connect, collection):
def test_insert_tag(self, connect, collection):
'''
target: test add vectors in collection created before
method: create collection and add vectors in it, with the partition_tag param
@ -461,12 +461,12 @@ class TestAddBase:
nq = 5
vectors = gen_vectors(nq, dim)
status = connect.create_partition(collection, tag)
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
assert status.OK()
assert len(ids) == nq
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_tag_A(self, connect, collection):
def test_insert_tag_A(self, connect, collection):
'''
target: test add vectors in collection created before
method: create partition and add vectors in it
@ -475,12 +475,12 @@ class TestAddBase:
nq = 5
vectors = gen_vectors(nq, dim)
status = connect.create_partition(collection, tag)
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
assert status.OK()
assert len(ids) == nq
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_tag_not_existed(self, connect, collection):
def test_insert_tag_not_existed(self, connect, collection):
'''
target: test add vectors in collection created before
method: create collection and add vectors in it, with the not existed partition_tag param
@ -488,11 +488,11 @@ class TestAddBase:
'''
nq = 5
vectors = gen_vectors(nq, dim)
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
assert not status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_tag_not_existed_A(self, connect, collection):
def test_insert_tag_not_existed_A(self, connect, collection):
'''
target: test add vectors in collection created before
method: create partition, add vectors with the not existed partition_tag param
@ -502,11 +502,11 @@ class TestAddBase:
vectors = gen_vectors(nq, dim)
new_tag = "new_tag"
status = connect.create_partition(collection, tag)
status, ids = connect.add_vectors(collection, vectors, partition_tag=new_tag)
status, ids = connect.insert(collection, vectors, partition_tag=new_tag)
assert not status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_tag_existed(self, connect, collection):
def test_insert_tag_existed(self, connect, collection):
'''
target: test add vectors in collection created before
method: create collection and add vectors in it repeatly, with the partition_tag param
@ -515,14 +515,14 @@ class TestAddBase:
nq = 5
vectors = gen_vectors(nq, dim)
status = connect.create_partition(collection, tag)
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
for i in range(5):
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
assert status.OK()
assert len(ids) == nq
# @pytest.mark.level(2)
# def test_add_vectors_without_connect(self, dis_connect, collection):
# def test_insert_without_connect(self, dis_connect, collection):
# '''
# target: test add vectors without connection
# method: create collection and add vectors in it, check if added successfully
@ -531,7 +531,7 @@ class TestAddBase:
# nq = 5
# vectors = gen_vectors(nq, dim)
# with pytest.raises(Exception) as e:
# status, ids = dis_connect.add_vectors(collection, vectors)
# status, ids = dis_connect.insert(collection, vectors)
def test_add_collection_not_existed(self, connect):
'''
@ -541,7 +541,7 @@ class TestAddBase:
'''
nq = 5
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(gen_unique_str("not_exist_collection"), vector)
status, ids = connect.insert(gen_unique_str("not_exist_collection"), vector)
assert not status.OK()
assert not ids
@ -552,10 +552,10 @@ class TestAddBase:
expected: status not ok
'''
vector = gen_single_vector(int(dim)//2)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert not status.OK()
def test_add_vectors_dim_not_matched(self, connect, collection):
def test_insert_dim_not_matched(self, connect, collection):
'''
target: test add vectors, the vector dimension is not equal to the collection dimension
method: the vectors dimension is half of the collection dimension, check the status
@ -563,7 +563,7 @@ class TestAddBase:
'''
nq = 5
vectors = gen_vectors(nq, int(dim)//2)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert not status.OK()
def test_add_vector_query_after_sleep(self, connect, collection):
@ -574,9 +574,9 @@ class TestAddBase:
'''
nq = 5
vectors = gen_vectors(nq, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
connect.flush([collection])
status, result = connect.search_vectors(collection, 1, [vectors[0]])
status, result = connect.search(collection, 1, [vectors[0]])
assert status.OK()
assert len(result) == 1
@ -604,7 +604,7 @@ class TestAddBase:
milvus = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
i = 0
while i < loop_num:
status, ids = milvus.add_vectors(collection, vector)
status, ids = milvus.insert(collection, vector)
i = i + 1
# milvus.disconnect()
for i in range(process_num):
@ -642,7 +642,7 @@ class TestAddBase:
def add(thread_i):
logging.getLogger().info("In thread-%d" % thread_i)
milvus = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
status, result = milvus.add_vectors(collection, records=vectors)
status, result = milvus.insert(collection, records=vectors)
assert status.OK()
status = milvus.flush([collection])
assert status.OK()
@ -674,7 +674,7 @@ class TestAddBase:
connect.create_collection(param)
for j in range(5):
for i in range(20):
status, ids = connect.add_vectors(collection_name=collection_list[i], records=vectors)
status, ids = connect.insert(collection_name=collection_list[i], records=vectors)
assert status.OK()
class TestAddAsync:
@ -710,7 +710,7 @@ class TestAddAsync:
'''
nb = insert_count
insert_vec_list = gen_vectors(nb, dim)
future = connect.add_vectors(collection, insert_vec_list, _async=True)
future = connect.insert(collection, insert_vec_list, _async=True)
status, ids = future.result()
connect.flush([collection])
assert len(ids) == nb
@ -725,7 +725,7 @@ class TestAddAsync:
'''
nb = insert_count
insert_vec_list = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, insert_vec_list, _async=False)
status, ids = connect.insert(collection, insert_vec_list, _async=False)
connect.flush([collection])
assert len(ids) == nb
assert status.OK()
@ -738,7 +738,7 @@ class TestAddAsync:
'''
nb = insert_count
insert_vec_list = gen_vectors(nb, dim)
future = connect.add_vectors(collection, insert_vec_list, _async=True, _callback=self.check_status)
future = connect.insert(collection, insert_vec_list, _async=True, _callback=self.check_status)
future.done()
@pytest.mark.level(2)
@ -750,7 +750,7 @@ class TestAddAsync:
'''
nb = 50000
insert_vec_list = gen_vectors(nb, dim)
future = connect.add_vectors(collection, insert_vec_list, _async=True, _callback=self.check_status)
future = connect.insert(collection, insert_vec_list, _async=True, _callback=self.check_status)
status, result = future.result()
assert status.OK()
assert len(result) == nb
@ -769,7 +769,7 @@ class TestAddAsync:
'''
nb = 100000
insert_vec_list = gen_vectors(nb, dim)
future = connect.add_vectors(collection, insert_vec_list, _async=True, _callback=self.check_status, timeout=1)
future = connect.insert(collection, insert_vec_list, _async=True, _callback=self.check_status, timeout=1)
future.done()
def test_insert_async_invalid_params(self, connect, collection):
@ -780,7 +780,7 @@ class TestAddAsync:
'''
insert_vec_list = gen_vectors(nb, dim)
collection_new = gen_unique_str()
future = connect.add_vectors(collection_new, insert_vec_list, _async=True)
future = connect.insert(collection_new, insert_vec_list, _async=True)
status, result = future.result()
assert not status.OK()
@ -794,13 +794,13 @@ class TestAddAsync:
insert_vec_list = []
collection_new = gen_unique_str()
with pytest.raises(Exception) as e:
future = connect.add_vectors(collection_new, insert_vec_list, _async=True)
future = connect.insert(collection_new, insert_vec_list, _async=True)
class TestAddIP:
"""
******************************************************************
The following cases are used to test `add_vectors / index / search / delete` mixed function
The following cases are used to test `insert / index / search / delete` mixed function
******************************************************************
"""
@pytest.fixture(
@ -822,7 +822,7 @@ class TestAddIP:
expected: status not ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
param = {'collection_name': ip_collection,
'dimension': dim,
'index_file_size': index_file_size,
@ -837,7 +837,7 @@ class TestAddIP:
expected: collection exists, status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert assert_has_collection(connect, ip_collection)
@pytest.mark.timeout(ADD_TIMEOUT)
@ -849,7 +849,7 @@ class TestAddIP:
'''
status = connect.drop_collection(ip_collection)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert not status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -866,7 +866,7 @@ class TestAddIP:
status = connect.create_collection(param)
status = connect.drop_collection(ip_collection)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(param['collection_name'], vector)
status, ids = connect.insert(param['collection_name'], vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -877,7 +877,7 @@ class TestAddIP:
expected: status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
status = connect.drop_collection(ip_collection)
assert status.OK()
@ -894,7 +894,7 @@ class TestAddIP:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
status = connect.drop_collection(param['collection_name'])
assert status.OK()
@ -906,7 +906,7 @@ class TestAddIP:
expected: status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
connect.flush([ip_collection])
status = connect.drop_collection(ip_collection)
assert status.OK()
@ -924,7 +924,7 @@ class TestAddIP:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
connect.flush([ip_collection])
status = connect.drop_collection(param['collection_name'])
assert status.OK()
@ -940,7 +940,7 @@ class TestAddIP:
index_type = get_simple_index["index_type"]
status = connect.create_index(ip_collection, index_type, index_param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -959,7 +959,7 @@ class TestAddIP:
status = connect.create_collection(param)
status = connect.create_index(ip_collection, index_type, index_param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -972,7 +972,7 @@ class TestAddIP:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
status, mode = connect._cmd("mode")
assert status.OK()
status = connect.create_index(ip_collection, index_type, index_param)
@ -996,7 +996,7 @@ class TestAddIP:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
status = connect.create_index(param['collection_name'], index_type, index_param)
assert status.OK()
@ -1012,7 +1012,7 @@ class TestAddIP:
if index_type == IndexType.IVF_PQ:
pytest.skip("Skip some PQ cases")
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert status.OK()
time.sleep(add_interval_time)
status = connect.create_index(ip_collection, index_type, index_param)
@ -1033,7 +1033,7 @@ class TestAddIP:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
connect.flush([ip_collection])
status = connect.create_index(param['collection_name'], index_type, index_param)
assert status.OK()
@ -1046,8 +1046,8 @@ class TestAddIP:
expected: status ok
'''
vector = gen_single_vector(dim)
status, result = connect.search_vectors(ip_collection, 1, vector)
status, ids = connect.add_vectors(ip_collection, vector)
status, result = connect.search(ip_collection, 1, vector)
status, ids = connect.insert(ip_collection, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -1063,8 +1063,8 @@ class TestAddIP:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, result = connect.search_vectors(ip_collection, 1, vector)
status, ids = connect.add_vectors(param['collection_name'], vector)
status, result = connect.search(ip_collection, 1, vector)
status, ids = connect.insert(param['collection_name'], vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -1075,10 +1075,10 @@ class TestAddIP:
expected: status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert status.OK()
connect.flush([ip_collection])
status, result = connect.search_vectors(ip_collection, 1, vector)
status, result = connect.search(ip_collection, 1, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -1094,9 +1094,9 @@ class TestAddIP:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
connect.flush([ip_collection])
status, result = connect.search_vectors(param['collection_name'], 1, vector)
status, result = connect.search(param['collection_name'], 1, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -1107,9 +1107,9 @@ class TestAddIP:
expected: status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
time.sleep(add_interval_time)
status, result = connect.search_vectors(ip_collection, 1, vector)
status, result = connect.search(ip_collection, 1, vector)
assert status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
@ -1125,20 +1125,20 @@ class TestAddIP:
'metric_type': MetricType.L2}
status = connect.create_collection(param)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert status.OK()
time.sleep(add_interval_time)
status, result = connect.search_vectors(param['collection_name'], 1, vector)
status, result = connect.search(param['collection_name'], 1, vector)
assert status.OK()
"""
******************************************************************
The following cases are used to test `add_vectors` function
The following cases are used to test `insert` function
******************************************************************
"""
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_ids(self, connect, ip_collection):
def test_insert_ids(self, connect, ip_collection):
'''
target: test add vectors in collection, use customize ids
method: create collection and add vectors in it, check the ids returned and the collection length after vectors added
@ -1147,53 +1147,53 @@ class TestAddIP:
nq = 5; top_k = 1
vectors = gen_vectors(nq, dim)
ids = [i for i in range(nq)]
status, ids = connect.add_vectors(ip_collection, vectors, ids)
status, ids = connect.insert(ip_collection, vectors, ids)
assert status.OK()
connect.flush([ip_collection])
assert len(ids) == nq
# check search result
status, result = connect.search_vectors(ip_collection, top_k, vectors)
status, result = connect.search(ip_collection, top_k, vectors)
logging.getLogger().info(result)
assert len(result) == nq
for i in range(nq):
assert result[i][0].id == i
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_twice_ids_no_ids(self, connect, ip_collection):
def test_insert_twice_ids_no_ids(self, connect, ip_collection):
'''
target: check the result of add_vectors, with params ids and no ids
target: check the result of insert, with params ids and no ids
method: test add vectors twice, use customize ids first, and then use no ids
expected: status not OK
'''
nq = 5; top_k = 1
vectors = gen_vectors(nq, dim)
ids = [i for i in range(nq)]
status, ids = connect.add_vectors(ip_collection, vectors, ids)
status, ids = connect.insert(ip_collection, vectors, ids)
assert status.OK()
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
logging.getLogger().info(status)
logging.getLogger().info(ids)
assert not status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_twice_not_ids_ids(self, connect, ip_collection):
def test_insert_twice_not_ids_ids(self, connect, ip_collection):
'''
target: check the result of add_vectors, with params ids and no ids
target: check the result of insert, with params ids and no ids
method: test add vectors twice, use not ids first, and then use customize ids
expected: status not OK
'''
nq = 5; top_k = 1
vectors = gen_vectors(nq, dim)
ids = [i for i in range(nq)]
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
status, ids = connect.add_vectors(ip_collection, vectors, ids)
status, ids = connect.insert(ip_collection, vectors, ids)
logging.getLogger().info(status)
logging.getLogger().info(ids)
assert not status.OK()
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors_ids_length_not_match(self, connect, ip_collection):
def test_insert_ids_length_not_match(self, connect, ip_collection):
'''
target: test add vectors in collection, use customize ids, len(ids) != len(vectors)
method: create collection and add vectors in it
@ -1203,7 +1203,7 @@ class TestAddIP:
vectors = gen_vectors(nq, dim)
ids = [i for i in range(1, nq)]
with pytest.raises(Exception) as e:
status, ids = connect.add_vectors(ip_collection, vectors, ids)
status, ids = connect.insert(ip_collection, vectors, ids)
@pytest.fixture(
scope="function",
@ -1213,7 +1213,7 @@ class TestAddIP:
yield request.param
@pytest.mark.level(2)
def test_add_vectors_ids_invalid(self, connect, ip_collection, get_vector_id):
def test_insert_ids_invalid(self, connect, ip_collection, get_vector_id):
'''
target: test add vectors in collection, use customize ids, which are not int64
method: create collection and add vectors in it
@ -1224,10 +1224,10 @@ class TestAddIP:
vector_id = get_vector_id
ids = [vector_id for i in range(nq)]
with pytest.raises(Exception) as e:
status, ids = connect.add_vectors(ip_collection, vectors, ids)
status, ids = connect.insert(ip_collection, vectors, ids)
@pytest.mark.timeout(ADD_TIMEOUT)
def test_add_vectors(self, connect, ip_collection):
def test_insert(self, connect, ip_collection):
'''
target: test add vectors in collection created before
method: create collection and add vectors in it, check the ids returned and the collection length after vectors added
@ -1235,12 +1235,12 @@ class TestAddIP:
'''
nq = 5
vectors = gen_vectors(nq, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
assert len(ids) == nq
# @pytest.mark.level(2)
# def test_add_vectors_without_connect(self, dis_connect, ip_collection):
# def test_insert_without_connect(self, dis_connect, ip_collection):
# '''
# target: test add vectors without connection
# method: create collection and add vectors in it, check if added successfully
@ -1249,7 +1249,7 @@ class TestAddIP:
# nq = 5
# vectors = gen_vectors(nq, dim)
# with pytest.raises(Exception) as e:
# status, ids = dis_connect.add_vectors(ip_collection, vectors)
# status, ids = dis_connect.insert(ip_collection, vectors)
def test_add_vector_dim_not_matched(self, connect, ip_collection):
'''
@ -1258,10 +1258,10 @@ class TestAddIP:
expected: status not ok
'''
vector = gen_single_vector(int(dim)//2)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert not status.OK()
def test_add_vectors_dim_not_matched(self, connect, ip_collection):
def test_insert_dim_not_matched(self, connect, ip_collection):
'''
target: test add vectors, the vector dimension is not equal to the collection dimension
method: the vectors dimension is half of the collection dimension, check the status
@ -1269,7 +1269,7 @@ class TestAddIP:
'''
nq = 5
vectors = gen_vectors(nq, int(dim)//2)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert not status.OK()
def test_add_vector_query_after_sleep(self, connect, ip_collection):
@ -1280,9 +1280,9 @@ class TestAddIP:
'''
nq = 5
vectors = gen_vectors(nq, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
time.sleep(add_interval_time)
status, result = connect.search_vectors(ip_collection, 1, [vectors[0]])
status, result = connect.search(ip_collection, 1, [vectors[0]])
assert status.OK()
assert len(result) == 1
@ -1305,7 +1305,7 @@ class TestAddIP:
connect.create_collection(param)
for j in range(10):
for i in range(20):
status, ids = connect.add_vectors(collection_name=collection_list[i], records=vectors)
status, ids = connect.insert(collection_name=collection_list[i], records=vectors)
assert status.OK()
class TestAddAdvance:
@ -1328,7 +1328,7 @@ class TestAddAdvance:
'''
nb = insert_count
insert_vec_list = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, insert_vec_list)
status, ids = connect.insert(collection, insert_vec_list)
assert len(ids) == nb
assert status.OK()
@ -1340,7 +1340,7 @@ class TestAddAdvance:
'''
nb = insert_count
insert_vec_list = gen_vectors(nb, dim)
status, ids = connect.add_vectors(ip_collection, insert_vec_list)
status, ids = connect.insert(ip_collection, insert_vec_list)
assert len(ids) == nb
assert status.OK()
@ -1352,7 +1352,7 @@ class TestAddAdvance:
'''
nb = insert_count
tmp, insert_vec_list = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, insert_vec_list)
status, ids = connect.insert(jac_collection, insert_vec_list)
assert len(ids) == nb
assert status.OK()
@ -1364,7 +1364,7 @@ class TestAddAdvance:
'''
nb = insert_count
tmp, insert_vec_list = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(ham_collection, insert_vec_list)
status, ids = connect.insert(ham_collection, insert_vec_list)
assert len(ids) == nb
assert status.OK()
@ -1376,7 +1376,7 @@ class TestAddAdvance:
'''
nb = insert_count
tmp, insert_vec_list = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(tanimoto_collection, insert_vec_list)
status, ids = connect.insert(tanimoto_collection, insert_vec_list)
assert len(ids) == nb
assert status.OK()
@ -1400,18 +1400,18 @@ class TestNameInvalid(object):
yield request.param
@pytest.mark.level(2)
def test_add_vectors_with_invalid_collection_name(self, connect, get_collection_name):
def test_insert_with_invalid_collection_name(self, connect, get_collection_name):
collection_name = get_collection_name
vectors = gen_vectors(1, dim)
status, result = connect.add_vectors(collection_name, vectors)
status, result = connect.insert(collection_name, vectors)
assert not status.OK()
@pytest.mark.level(2)
def test_add_vectors_with_invalid_tag_name(self, connect, get_collection_name, get_tag_name):
def test_insert_with_invalid_tag_name(self, connect, get_collection_name, get_tag_name):
collection_name = get_collection_name
tag_name = get_tag_name
vectors = gen_vectors(1, dim)
status, result = connect.add_vectors(collection_name, vectors, partition_tag=tag_name)
status, result = connect.insert(collection_name, vectors, partition_tag=tag_name)
assert not status.OK()
@ -1434,25 +1434,25 @@ class TestAddCollectionVectorsInvalid(object):
tmp_single_vector = copy.deepcopy(self.single_vector)
tmp_single_vector[0][1] = gen_vector
with pytest.raises(Exception) as e:
status, result = connect.add_vectors(collection, tmp_single_vector)
status, result = connect.insert(collection, tmp_single_vector)
@pytest.mark.level(2)
def test_add_vectors_with_invalid_vectors(self, connect, collection, gen_vector):
def test_insert_with_invalid_vectors(self, connect, collection, gen_vector):
tmp_vectors = copy.deepcopy(self.vectors)
tmp_vectors[1][1] = gen_vector
with pytest.raises(Exception) as e:
status, result = connect.add_vectors(collection, tmp_vectors)
status, result = connect.insert(collection, tmp_vectors)
@pytest.mark.level(2)
def test_add_vectors_with_invalid_vectors_jaccard(self, connect, jac_collection, gen_vector):
def test_insert_with_invalid_vectors_jaccard(self, connect, jac_collection, gen_vector):
tmp_vectors = copy.deepcopy(self.vectors)
tmp_vectors[1][1] = gen_vector
with pytest.raises(Exception) as e:
status, result = connect.add_vectors(jac_collection, tmp_vectors)
status, result = connect.insert(jac_collection, tmp_vectors)
@pytest.mark.level(2)
def test_add_vectors_with_invalid_vectors_hamming(self, connect, ham_collection, gen_vector):
def test_insert_with_invalid_vectors_hamming(self, connect, ham_collection, gen_vector):
tmp_vectors = copy.deepcopy(self.vectors)
tmp_vectors[1][1] = gen_vector
with pytest.raises(Exception) as e:
status, result = connect.add_vectors(ham_collection, tmp_vectors)
status, result = connect.insert(ham_collection, tmp_vectors)

View File

@ -796,7 +796,7 @@ class TestCollection:
def test_load_collection(self, connect, collection, get_simple_index):
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
status = connect.create_index(collection, index_type, index_param)
status = connect.load_collection(collection)
assert status.OK()
@ -805,7 +805,7 @@ class TestCollection:
def test_load_collection_ip(self, connect, ip_collection, get_simple_index):
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
status = connect.create_index(ip_collection, index_type, index_param)
status = connect.load_collection(ip_collection)
assert status.OK()
@ -814,7 +814,7 @@ class TestCollection:
def test_load_collection_jaccard(self, connect, jac_collection, get_simple_index):
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
status = connect.create_index(jac_collection, index_type, index_param)
status = connect.load_collection(jac_collection)
assert status.OK()
@ -823,7 +823,7 @@ class TestCollection:
def test_load_collection_hamming(self, connect, ham_collection, get_simple_index):
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
status, ids = connect.add_vectors(ham_collection, vectors)
status, ids = connect.insert(ham_collection, vectors)
status = connect.create_index(ham_collection, index_type, index_param)
status = connect.load_collection(ham_collection)
assert status.OK()
@ -833,7 +833,7 @@ class TestCollection:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
collection_name = gen_unique_str()
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
status = connect.create_index(collection, index_type, index_param)
status = connect.load_collection(collection_name)
assert not status.OK()
@ -843,7 +843,7 @@ class TestCollection:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
collection_name = gen_unique_str()
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
status = connect.create_index(ip_collection, index_type, index_param)
status = connect.load_collection(collection_name)
assert not status.OK()
@ -986,7 +986,7 @@ def create_collection(connect, **params):
return status
def search_collection(connect, **params):
status, result = connect.search_vectors(
status, result = connect.search(
params["collection_name"],
params["top_k"],
params["query_vectors"],

View File

@ -26,7 +26,7 @@ class TestCollectionCount:
20000,
],
)
def add_vectors_nb(self, request):
def insert_nb(self, request):
yield request.param
"""
@ -44,37 +44,37 @@ class TestCollectionCount:
pytest.skip("Skip PQ Temporary")
return request.param
def test_collection_rows_count(self, connect, collection, add_vectors_nb):
def test_collection_rows_count(self, connect, collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection and add vectors in it,
assert the value returned by count_entities method is equal to length of vectors
expected: the count is equal to the length of vectors
'''
nb = add_vectors_nb
nb = insert_nb
vectors = gen_vectors(nb, dim)
res = connect.add_vectors(collection_name=collection, records=vectors)
res = connect.insert(collection_name=collection, records=vectors)
connect.flush([collection])
status, res = connect.count_entities(collection)
assert res == nb
def test_collection_rows_count_partition(self, connect, collection, add_vectors_nb):
def test_collection_rows_count_partition(self, connect, collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection, create partition and add vectors in it,
assert the value returned by count_entities method is equal to length of vectors
expected: the count is equal to the length of vectors
'''
nb = add_vectors_nb
nb = insert_nb
vectors = gen_vectors(nb, dim)
status = connect.create_partition(collection, tag)
assert status.OK()
res = connect.add_vectors(collection_name=collection, records=vectors, partition_tag=tag)
res = connect.insert(collection_name=collection, records=vectors, partition_tag=tag)
connect.flush([collection])
status, res = connect.count_entities(collection)
assert res == nb
def test_collection_rows_count_multi_partitions_A(self, connect, collection, add_vectors_nb):
def test_collection_rows_count_multi_partitions_A(self, connect, collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection, create partitions and add vectors in it,
@ -82,17 +82,17 @@ class TestCollectionCount:
expected: the count is equal to the length of vectors
'''
new_tag = "new_tag"
nb = add_vectors_nb
nb = insert_nb
vectors = gen_vectors(nb, dim)
status = connect.create_partition(collection, tag)
status = connect.create_partition(collection, new_tag)
assert status.OK()
res = connect.add_vectors(collection_name=collection, records=vectors)
res = connect.insert(collection_name=collection, records=vectors)
connect.flush([collection])
status, res = connect.count_entities(collection)
assert res == nb
def test_collection_rows_count_multi_partitions_B(self, connect, collection, add_vectors_nb):
def test_collection_rows_count_multi_partitions_B(self, connect, collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection, create partitions and add vectors in one of the partitions,
@ -100,17 +100,17 @@ class TestCollectionCount:
expected: the count is equal to the length of vectors
'''
new_tag = "new_tag"
nb = add_vectors_nb
nb = insert_nb
vectors = gen_vectors(nb, dim)
status = connect.create_partition(collection, tag)
status = connect.create_partition(collection, new_tag)
assert status.OK()
res = connect.add_vectors(collection_name=collection, records=vectors, partition_tag=tag)
res = connect.insert(collection_name=collection, records=vectors, partition_tag=tag)
connect.flush([collection])
status, res = connect.count_entities(collection)
assert res == nb
def test_collection_rows_count_multi_partitions_C(self, connect, collection, add_vectors_nb):
def test_collection_rows_count_multi_partitions_C(self, connect, collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection, create partitions and add vectors in one of the partitions,
@ -118,13 +118,13 @@ class TestCollectionCount:
expected: the collection count is equal to the length of vectors
'''
new_tag = "new_tag"
nb = add_vectors_nb
nb = insert_nb
vectors = gen_vectors(nb, dim)
status = connect.create_partition(collection, tag)
status = connect.create_partition(collection, new_tag)
assert status.OK()
res = connect.add_vectors(collection_name=collection, records=vectors, partition_tag=tag)
res = connect.add_vectors(collection_name=collection, records=vectors, partition_tag=new_tag)
res = connect.insert(collection_name=collection, records=vectors, partition_tag=tag)
res = connect.insert(collection_name=collection, records=vectors, partition_tag=new_tag)
connect.flush([collection])
status, res = connect.count_entities(collection)
assert res == nb * 2
@ -139,7 +139,7 @@ class TestCollectionCount:
index_type = get_simple_index["index_type"]
nb = 100
vectors = gen_vectors(nb, dim)
res = connect.add_vectors(collection_name=collection, records=vectors)
res = connect.insert(collection_name=collection, records=vectors)
connect.flush([collection])
connect.create_index(collection, index_type, index_param)
status, res = connect.count_entities(collection)
@ -182,7 +182,7 @@ class TestCollectionCount:
'''
nq = 2
vectors = gen_vectors(nq, dim)
res = connect.add_vectors(collection_name=collection, records=vectors)
res = connect.insert(collection_name=collection, records=vectors)
time.sleep(add_time_interval)
def rows_count(milvus):
@ -219,7 +219,7 @@ class TestCollectionCount:
'index_file_size': index_file_size,
'metric_type': MetricType.L2}
connect.create_collection(param)
res = connect.add_vectors(collection_name=collection_name, records=vectors)
res = connect.insert(collection_name=collection_name, records=vectors)
connect.flush(collection_list)
for i in range(20):
status, res = connect.count_entities(collection_list[i])
@ -240,7 +240,7 @@ class TestCollectionCountIP:
20000,
],
)
def add_vectors_nb(self, request):
def insert_nb(self, request):
yield request.param
"""
@ -259,16 +259,16 @@ class TestCollectionCountIP:
pytest.skip("Skip PQ Temporary")
return request.param
def test_collection_rows_count(self, connect, ip_collection, add_vectors_nb):
def test_collection_rows_count(self, connect, ip_collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection and add vectors in it,
assert the value returned by count_entities method is equal to length of vectors
expected: the count is equal to the length of vectors
'''
nb = add_vectors_nb
nb = insert_nb
vectors = gen_vectors(nb, dim)
res = connect.add_vectors(collection_name=ip_collection, records=vectors)
res = connect.insert(collection_name=ip_collection, records=vectors)
connect.flush([ip_collection])
status, res = connect.count_entities(ip_collection)
assert res == nb
@ -283,7 +283,7 @@ class TestCollectionCountIP:
index_type = get_simple_index["index_type"]
nb = 100
vectors = gen_vectors(nb, dim)
res = connect.add_vectors(collection_name=ip_collection, records=vectors)
res = connect.insert(collection_name=ip_collection, records=vectors)
connect.flush([ip_collection])
connect.create_index(ip_collection, index_type, index_param)
status, res = connect.count_entities(ip_collection)
@ -325,7 +325,7 @@ class TestCollectionCountIP:
'''
nq = 2
vectors = gen_vectors(nq, dim)
res = connect.add_vectors(collection_name=ip_collection, records=vectors)
res = connect.insert(collection_name=ip_collection, records=vectors)
time.sleep(add_time_interval)
def rows_count(milvus):
@ -362,7 +362,7 @@ class TestCollectionCountIP:
'index_file_size': index_file_size,
'metric_type': MetricType.IP}
connect.create_collection(param)
res = connect.add_vectors(collection_name=collection_name, records=vectors)
res = connect.insert(collection_name=collection_name, records=vectors)
connect.flush(collection_list)
for i in range(20):
status, res = connect.count_entities(collection_list[i])
@ -383,7 +383,7 @@ class TestCollectionCountJAC:
20000,
],
)
def add_vectors_nb(self, request):
def insert_nb(self, request):
yield request.param
"""
@ -401,16 +401,16 @@ class TestCollectionCountJAC:
else:
pytest.skip("Skip index Temporary")
def test_collection_rows_count(self, connect, jac_collection, add_vectors_nb):
def test_collection_rows_count(self, connect, jac_collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection and add vectors in it,
assert the value returned by count_entities method is equal to length of vectors
expected: the count is equal to the length of vectors
'''
nb = add_vectors_nb
nb = insert_nb
tmp, vectors = gen_binary_vectors(nb, dim)
res = connect.add_vectors(collection_name=jac_collection, records=vectors)
res = connect.insert(collection_name=jac_collection, records=vectors)
connect.flush([jac_collection])
status, res = connect.count_entities(jac_collection)
assert res == nb
@ -425,7 +425,7 @@ class TestCollectionCountJAC:
index_param = get_jaccard_index["index_param"]
index_type = get_jaccard_index["index_type"]
tmp, vectors = gen_binary_vectors(nb, dim)
res = connect.add_vectors(collection_name=jac_collection, records=vectors)
res = connect.insert(collection_name=jac_collection, records=vectors)
connect.flush([jac_collection])
connect.create_index(jac_collection, index_type, index_param)
status, res = connect.count_entities(jac_collection)
@ -474,7 +474,7 @@ class TestCollectionCountJAC:
'index_file_size': index_file_size,
'metric_type': MetricType.JACCARD}
connect.create_collection(param)
res = connect.add_vectors(collection_name=collection_name, records=vectors)
res = connect.insert(collection_name=collection_name, records=vectors)
connect.flush(collection_list)
for i in range(20):
status, res = connect.count_entities(collection_list[i])
@ -494,7 +494,7 @@ class TestCollectionCountBinary:
20000,
],
)
def add_vectors_nb(self, request):
def insert_nb(self, request):
yield request.param
"""
@ -534,44 +534,44 @@ class TestCollectionCountBinary:
else:
pytest.skip("Skip index Temporary")
def test_collection_rows_count(self, connect, ham_collection, add_vectors_nb):
def test_collection_rows_count(self, connect, ham_collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection and add vectors in it,
assert the value returned by count_entities method is equal to length of vectors
expected: the count is equal to the length of vectors
'''
nb = add_vectors_nb
nb = insert_nb
tmp, vectors = gen_binary_vectors(nb, dim)
res = connect.add_vectors(collection_name=ham_collection, records=vectors)
res = connect.insert(collection_name=ham_collection, records=vectors)
connect.flush([ham_collection])
status, res = connect.count_entities(ham_collection)
assert res == nb
def test_collection_rows_count_substructure(self, connect, substructure_collection, add_vectors_nb):
def test_collection_rows_count_substructure(self, connect, substructure_collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection and add vectors in it,
assert the value returned by count_entities method is equal to length of vectors
expected: the count is equal to the length of vectors
'''
nb = add_vectors_nb
nb = insert_nb
tmp, vectors = gen_binary_vectors(nb, dim)
res = connect.add_vectors(collection_name=substructure_collection, records=vectors)
res = connect.insert(collection_name=substructure_collection, records=vectors)
connect.flush([substructure_collection])
status, res = connect.count_entities(substructure_collection)
assert res == nb
def test_collection_rows_count_superstructure(self, connect, superstructure_collection, add_vectors_nb):
def test_collection_rows_count_superstructure(self, connect, superstructure_collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection and add vectors in it,
assert the value returned by count_entities method is equal to length of vectors
expected: the count is equal to the length of vectors
'''
nb = add_vectors_nb
nb = insert_nb
tmp, vectors = gen_binary_vectors(nb, dim)
res = connect.add_vectors(collection_name=superstructure_collection, records=vectors)
res = connect.insert(collection_name=superstructure_collection, records=vectors)
connect.flush([superstructure_collection])
status, res = connect.count_entities(superstructure_collection)
assert res == nb
@ -586,7 +586,7 @@ class TestCollectionCountBinary:
index_type = get_hamming_index["index_type"]
index_param = get_hamming_index["index_param"]
tmp, vectors = gen_binary_vectors(nb, dim)
res = connect.add_vectors(collection_name=ham_collection, records=vectors)
res = connect.insert(collection_name=ham_collection, records=vectors)
connect.flush([ham_collection])
connect.create_index(ham_collection, index_type, index_param)
status, res = connect.count_entities(ham_collection)
@ -602,7 +602,7 @@ class TestCollectionCountBinary:
index_type = get_substructure_index["index_type"]
index_param = get_substructure_index["index_param"]
tmp, vectors = gen_binary_vectors(nb, dim)
res = connect.add_vectors(collection_name=substructure_collection, records=vectors)
res = connect.insert(collection_name=substructure_collection, records=vectors)
connect.flush([substructure_collection])
connect.create_index(substructure_collection, index_type, index_param)
status, res = connect.count_entities(substructure_collection)
@ -618,7 +618,7 @@ class TestCollectionCountBinary:
index_type = get_superstructure_index["index_type"]
index_param = get_superstructure_index["index_param"]
tmp, vectors = gen_binary_vectors(nb, dim)
res = connect.add_vectors(collection_name=superstructure_collection, records=vectors)
res = connect.insert(collection_name=superstructure_collection, records=vectors)
connect.flush([superstructure_collection])
connect.create_index(superstructure_collection, index_type, index_param)
status, res = connect.count_entities(superstructure_collection)
@ -667,7 +667,7 @@ class TestCollectionCountBinary:
'index_file_size': index_file_size,
'metric_type': MetricType.HAMMING}
connect.create_collection(param)
res = connect.add_vectors(collection_name=collection_name, records=vectors)
res = connect.insert(collection_name=collection_name, records=vectors)
connect.flush(collection_list)
for i in range(20):
status, res = connect.count_entities(collection_list[i])
@ -688,7 +688,7 @@ class TestCollectionCountTANIMOTO:
20000,
],
)
def add_vectors_nb(self, request):
def insert_nb(self, request):
yield request.param
"""
@ -706,16 +706,16 @@ class TestCollectionCountTANIMOTO:
else:
pytest.skip("Skip index Temporary")
def test_collection_rows_count(self, connect, tanimoto_collection, add_vectors_nb):
def test_collection_rows_count(self, connect, tanimoto_collection, insert_nb):
'''
target: test collection rows_count is correct or not
method: create collection and add vectors in it,
assert the value returned by count_entities method is equal to length of vectors
expected: the count is equal to the length of vectors
'''
nb = add_vectors_nb
nb = insert_nb
tmp, vectors = gen_binary_vectors(nb, dim)
res = connect.add_vectors(collection_name=tanimoto_collection, records=vectors)
res = connect.insert(collection_name=tanimoto_collection, records=vectors)
connect.flush([tanimoto_collection])
status, res = connect.count_entities(tanimoto_collection)
assert status.OK()

View File

@ -81,7 +81,7 @@ class TestCollectionInfoBase:
expected: status ok, count as expected
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -106,7 +106,7 @@ class TestCollectionInfoBase:
expected: status ok, "_default" partition is listed
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -127,7 +127,7 @@ class TestCollectionInfoBase:
'''
vectors = gen_vectors(nb, dim)
status = connect.create_partition(collection, tag)
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -151,7 +151,7 @@ class TestCollectionInfoBase:
assert status.OK()
status = connect.create_partition(collection, new_tag)
assert status.OK()
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -177,9 +177,9 @@ class TestCollectionInfoBase:
assert status.OK()
status = connect.create_partition(collection, new_tag)
assert status.OK()
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
assert status.OK()
status, ids = connect.add_vectors(collection, vectors, partition_tag=new_tag)
status, ids = connect.insert(collection, vectors, partition_tag=new_tag)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -214,7 +214,7 @@ class TestCollectionInfoBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -240,7 +240,7 @@ class TestCollectionInfoBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -264,7 +264,7 @@ class TestCollectionInfoBase:
expected: status ok, index info shown in segments
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()

View File

@ -70,7 +70,7 @@ class TestCompactBase:
expected: status ok, vector added
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -88,14 +88,14 @@ class TestCompactBase:
assert(size_before == size_after)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_and_compact(self, connect, collection):
def test_insert_and_compact(self, connect, collection):
'''
target: test add vectors and compact
method: add vectors and compact collection
expected: status ok, vectors added
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -112,14 +112,14 @@ class TestCompactBase:
assert(size_before == size_after)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_delete_part_and_compact(self, connect, collection):
def test_insert_delete_part_and_compact(self, connect, collection):
'''
target: test add vectors, delete part of them and compact
method: add vectors, delete a few and compact collection
expected: status ok, data size is smaller after compact
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -145,14 +145,14 @@ class TestCompactBase:
assert(size_before >= size_after)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_delete_all_and_compact(self, connect, collection):
def test_insert_delete_all_and_compact(self, connect, collection):
'''
target: test add vectors, delete them and compact
method: add vectors, delete all and compact collection
expected: status ok, no data size in collection info because collection is empty
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -193,7 +193,7 @@ class TestCompactBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vectors = gen_vector(count, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -228,7 +228,7 @@ class TestCompactBase:
expected: status ok, data size no change
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -254,14 +254,14 @@ class TestCompactBase:
assert(size_after == size_after_twice)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_delete_part_and_compact_twice(self, connect, collection):
def test_insert_delete_part_and_compact_twice(self, connect, collection):
'''
target: test add vectors, delete part of them and compact twice
method: add vectors, delete part and compact collection twice
expected: status ok, data size smaller after first compact, no change after second
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -310,7 +310,7 @@ class TestCompactBase:
connect.create_collection(param)
time.sleep(6)
for i in range(num_collections):
status, ids = connect.add_vectors(collection_name=collection_list[i], records=vectors)
status, ids = connect.insert(collection_name=collection_list[i], records=vectors)
assert status.OK()
status = connect.compact(collection_list[i])
assert status.OK()
@ -323,7 +323,7 @@ class TestCompactBase:
expected: status ok, vector added
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -339,7 +339,7 @@ class TestCompactBase:
size_after = info["partitions"][0]["segments"][0]["data_size"]
assert(size_before == size_after)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
@pytest.mark.timeout(COMPACT_TIMEOUT)
@ -350,7 +350,7 @@ class TestCompactBase:
expected: status ok, index description no change
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -376,7 +376,7 @@ class TestCompactBase:
expected: status ok, vectors deleted
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -397,14 +397,14 @@ class TestCompactBase:
expected: status ok
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
status = connect.compact(collection)
assert status.OK()
query_vecs = [vectors[0]]
status, res = connect.search_vectors(collection, top_k, query_records=query_vecs)
status, res = connect.search(collection, top_k, query_records=query_vecs)
logging.getLogger().info(res)
assert status.OK()
@ -416,7 +416,7 @@ class TestCompactBase:
expected: status ok, request recovered
'''
vectors = gen_vector(nb * 100, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -450,7 +450,7 @@ class TestCompactJAC:
expected: status ok, vector added
'''
tmp, vector = gen_binary_vectors(1, dim)
status, ids = connect.add_vectors(jac_collection, vector)
status, ids = connect.insert(jac_collection, vector)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -467,14 +467,14 @@ class TestCompactJAC:
assert(size_before == size_after)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_and_compact(self, connect, jac_collection):
def test_insert_and_compact(self, connect, jac_collection):
'''
target: test add vectors and compact
method: add vectors and compact collection
expected: status ok, vectors added
'''
tmp, vectors = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -491,14 +491,14 @@ class TestCompactJAC:
assert(size_before == size_after)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_delete_part_and_compact(self, connect, jac_collection):
def test_insert_delete_part_and_compact(self, connect, jac_collection):
'''
target: test add vectors, delete part of them and compact
method: add vectors, delete a few and compact collection
expected: status ok, data size is smaller after compact
'''
tmp, vectors = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -524,14 +524,14 @@ class TestCompactJAC:
assert(size_before >= size_after)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_delete_all_and_compact(self, connect, jac_collection):
def test_insert_delete_all_and_compact(self, connect, jac_collection):
'''
target: test add vectors, delete them and compact
method: add vectors, delete all and compact collection
expected: status ok, no data size in collection info because collection is empty
'''
tmp, vectors = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -558,7 +558,7 @@ class TestCompactJAC:
expected: status ok
'''
tmp, vector = gen_binary_vectors(1, dim)
status, ids = connect.add_vectors(jac_collection, vector)
status, ids = connect.insert(jac_collection, vector)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -582,14 +582,14 @@ class TestCompactJAC:
assert(size_after == size_after_twice)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_delete_part_and_compact_twice(self, connect, jac_collection):
def test_insert_delete_part_and_compact_twice(self, connect, jac_collection):
'''
target: test add vectors, delete part of them and compact twice
method: add vectors, delete part and compact collection twice
expected: status ok, data size smaller after first compact, no change after second
'''
tmp, vectors = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -638,7 +638,7 @@ class TestCompactJAC:
connect.create_collection(param)
time.sleep(6)
for i in range(num_collections):
status, ids = connect.add_vectors(collection_name=collection_list[i], records=vectors)
status, ids = connect.insert(collection_name=collection_list[i], records=vectors)
assert status.OK()
status = connect.delete_entity_by_id(collection_list[i], [ids[0], ids[-1]])
assert status.OK()
@ -655,7 +655,7 @@ class TestCompactJAC:
expected: status ok, vector added
'''
tmp, vectors = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -671,7 +671,7 @@ class TestCompactJAC:
size_after = info["partitions"][0]["segments"][0]["data_size"]
assert(size_before == size_after)
tmp, vector = gen_binary_vectors(1, dim)
status, ids = connect.add_vectors(jac_collection, vector)
status, ids = connect.insert(jac_collection, vector)
assert status.OK()
@pytest.mark.timeout(COMPACT_TIMEOUT)
@ -682,7 +682,7 @@ class TestCompactJAC:
expected: status ok, vectors deleted
'''
tmp, vectors = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -703,14 +703,14 @@ class TestCompactJAC:
expected: status ok
'''
tmp, vectors = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
status = connect.compact(jac_collection)
assert status.OK()
query_vecs = [vectors[0]]
status, res = connect.search_vectors(jac_collection, top_k, query_records=query_vecs)
status, res = connect.search(jac_collection, top_k, query_records=query_vecs)
logging.getLogger().info(res)
assert status.OK()
@ -729,7 +729,7 @@ class TestCompactIP:
expected: status ok, vector added
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -748,14 +748,14 @@ class TestCompactIP:
assert(size_before == size_after)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_and_compact(self, connect, ip_collection):
def test_insert_and_compact(self, connect, ip_collection):
'''
target: test add vectors and compact
method: add vectors and compact collection
expected: status ok, vectors added
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -772,14 +772,14 @@ class TestCompactIP:
assert(size_before == size_after)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_delete_part_and_compact(self, connect, ip_collection):
def test_insert_delete_part_and_compact(self, connect, ip_collection):
'''
target: test add vectors, delete part of them and compact
method: add vectors, delete a few and compact collection
expected: status ok, data size is smaller after compact
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -805,14 +805,14 @@ class TestCompactIP:
assert(size_before >= size_after)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_delete_all_and_compact(self, connect, ip_collection):
def test_insert_delete_all_and_compact(self, connect, ip_collection):
'''
target: test add vectors, delete them and compact
method: add vectors, delete all and compact collection
expected: status ok, no data size in collection info because collection is empty
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -839,7 +839,7 @@ class TestCompactIP:
expected: status ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -863,14 +863,14 @@ class TestCompactIP:
assert(size_after == size_after_twice)
@pytest.mark.timeout(COMPACT_TIMEOUT)
def test_add_vectors_delete_part_and_compact_twice(self, connect, ip_collection):
def test_insert_delete_part_and_compact_twice(self, connect, ip_collection):
'''
target: test add vectors, delete part of them and compact twice
method: add vectors, delete part and compact collection twice
expected: status ok, data size smaller after first compact, no change after second
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -923,7 +923,7 @@ class TestCompactIP:
connect.create_collection(param)
time.sleep(6)
for i in range(num_collections):
status, ids = connect.add_vectors(collection_name=collection_list[i], records=vectors)
status, ids = connect.insert(collection_name=collection_list[i], records=vectors)
assert status.OK()
status = connect.compact(collection_list[i])
assert status.OK()
@ -936,7 +936,7 @@ class TestCompactIP:
expected: status ok, vector added
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -952,7 +952,7 @@ class TestCompactIP:
size_after = info["partitions"][0]["segments"][0]["data_size"]
assert(size_before == size_after)
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(ip_collection, vector)
status, ids = connect.insert(ip_collection, vector)
assert status.OK()
@pytest.mark.timeout(COMPACT_TIMEOUT)
@ -963,7 +963,7 @@ class TestCompactIP:
expected: status ok, vectors deleted
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -982,13 +982,13 @@ class TestCompactIP:
expected: status ok
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
status = connect.compact(ip_collection)
assert status.OK()
query_vecs = [vectors[0]]
status, res = connect.search_vectors(ip_collection, top_k, query_records=query_vecs)
status, res = connect.search(ip_collection, top_k, query_records=query_vecs)
logging.getLogger().info(res)
assert status.OK()

View File

@ -48,7 +48,7 @@ class TestDeleteBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -58,7 +58,7 @@ class TestDeleteBase:
search_param = get_search_param(index_type)
status = connect.flush([collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(collection, top_k, vector, params=search_param)
status, res = connect.search(collection, top_k, vector, params=search_param)
logging.getLogger().info(res)
assert status.OK()
assert len(res) == 0
@ -72,7 +72,7 @@ class TestDeleteBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vectors = gen_vectors(nb, dim)
connect.add_vectors(collection, vectors, ids=[1 for i in range(nb)])
connect.insert(collection, vectors, ids=[1 for i in range(nb)])
status = connect.flush([collection])
# Bloom filter error
assert status.OK()
@ -80,7 +80,7 @@ class TestDeleteBase:
assert status.OK()
status = connect.flush([collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(collection, top_k, [vectors[0]], params=search_param)
status, res = connect.search(collection, top_k, [vectors[0]], params=search_param)
logging.getLogger().info(res)
assert status.OK()
assert len(res) == 0
@ -92,7 +92,7 @@ class TestDeleteBase:
expected: status ok, vector deleted
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -110,7 +110,7 @@ class TestDeleteBase:
expected: status ok, vector deleted
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -132,7 +132,7 @@ class TestDeleteBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -140,7 +140,7 @@ class TestDeleteBase:
assert status.OK()
status = connect.flush([collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(collection, top_k, vector, params=search_param)
status, res = connect.search(collection, top_k, vector, params=search_param)
assert status.OK()
assert res[0][0].id == ids[0]
@ -151,7 +151,7 @@ class TestDeleteBase:
expected: status not ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -159,7 +159,7 @@ class TestDeleteBase:
status = connect.delete_entity_by_id(collection_new, [0])
assert not status.OK()
def test_add_vectors_delete_vector(self, connect, collection, get_simple_index):
def test_insert_delete_vector(self, connect, collection, get_simple_index):
'''
method: add vectors and delete
expected: status ok, vectors deleted
@ -167,7 +167,7 @@ class TestDeleteBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -177,7 +177,7 @@ class TestDeleteBase:
assert status.OK()
status = connect.flush([collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(collection, top_k, query_vecs, params=search_param)
status, res = connect.search(collection, top_k, query_vecs, params=search_param)
assert status.OK()
logging.getLogger().info(res)
assert res[0][0].distance > epsilon
@ -193,7 +193,7 @@ class TestDeleteBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -205,7 +205,7 @@ class TestDeleteBase:
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
search_param = get_search_param(index_type)
status, res = connect.search_vectors(collection, top_k, query_vecs, params=search_param)
status, res = connect.search(collection, top_k, query_vecs, params=search_param)
assert status.OK()
logging.getLogger().info(res)
logging.getLogger().info(ids[0])
@ -223,7 +223,7 @@ class TestDeleteBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -234,11 +234,11 @@ class TestDeleteBase:
status = connect.delete_entity_by_id(collection, delete_ids)
assert status.OK()
status = connect.flush([collection])
status, tmp_ids = connect.add_vectors(collection, [vectors[0], vectors[-1]])
status, tmp_ids = connect.insert(collection, [vectors[0], vectors[-1]])
assert status.OK()
status = connect.flush([collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(collection, top_k, query_vecs, params=search_param)
status, res = connect.search(collection, top_k, query_vecs, params=search_param)
assert status.OK()
logging.getLogger().info(res)
assert res[0][0].id == tmp_ids[0]
@ -253,7 +253,7 @@ class TestDeleteBase:
expected: status ok, vectors deleted, and status ok for next delete operation
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -272,7 +272,7 @@ class TestDeleteBase:
expected: status ok, vectors deleted, and status ok for next delete operation
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -314,7 +314,7 @@ class TestDeleteIndexedVectors:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -324,12 +324,12 @@ class TestDeleteIndexedVectors:
assert status.OK()
status = connect.flush([collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(collection, top_k, vector, params=search_param)
status, res = connect.search(collection, top_k, vector, params=search_param)
logging.getLogger().info(res)
assert status.OK()
assert len(res) == 0
def test_add_vectors_delete_vector(self, connect, collection, get_simple_index):
def test_insert_delete_vector(self, connect, collection, get_simple_index):
'''
method: add vectors and delete
expected: status ok, vectors deleted
@ -337,7 +337,7 @@ class TestDeleteIndexedVectors:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -351,7 +351,7 @@ class TestDeleteIndexedVectors:
assert status.OK()
status = connect.flush([collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(collection, top_k, query_vecs, params=search_param)
status, res = connect.search(collection, top_k, query_vecs, params=search_param)
assert status.OK()
logging.getLogger().info(ids[0])
logging.getLogger().info(ids[1])
@ -388,7 +388,7 @@ class TestDeleteBinary:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
tmp, vector = gen_binary_vectors(1, dim)
status, ids = connect.add_vectors(jac_collection, vector)
status, ids = connect.insert(jac_collection, vector)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -396,7 +396,7 @@ class TestDeleteBinary:
assert status.OK()
status = connect.flush([jac_collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(jac_collection, top_k, vector, params=search_param)
status, res = connect.search(jac_collection, top_k, vector, params=search_param)
logging.getLogger().info(res)
assert status.OK()
assert len(res) == 0
@ -411,7 +411,7 @@ class TestDeleteBinary:
expected: status ok, vector deleted
'''
tmp, vector = gen_binary_vectors(1, dim)
status, ids = connect.add_vectors(jac_collection, vector)
status, ids = connect.insert(jac_collection, vector)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -431,7 +431,7 @@ class TestDeleteBinary:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
tmp, vector = gen_binary_vectors(1, dim)
status, ids = connect.add_vectors(jac_collection, vector)
status, ids = connect.insert(jac_collection, vector)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -440,7 +440,7 @@ class TestDeleteBinary:
status = connect.flush([jac_collection])
status = connect.flush([jac_collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(jac_collection, top_k, vector, params=search_param)
status, res = connect.search(jac_collection, top_k, vector, params=search_param)
assert status.OK()
assert res[0][0].id == ids[0]
@ -451,7 +451,7 @@ class TestDeleteBinary:
expected: status not ok
'''
tmp, vector = gen_binary_vectors(1, dim)
status, ids = connect.add_vectors(jac_collection, vector)
status, ids = connect.insert(jac_collection, vector)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -461,7 +461,7 @@ class TestDeleteBinary:
status = connect.delete_entity_by_id(collection_new, [0])
assert not status.OK()
def test_add_vectors_delete_vector(self, connect, jac_collection, get_simple_index):
def test_insert_delete_vector(self, connect, jac_collection, get_simple_index):
'''
method: add vectors and delete
expected: status ok, vectors deleted
@ -469,7 +469,7 @@ class TestDeleteBinary:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
tmp, vectors = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -479,7 +479,7 @@ class TestDeleteBinary:
assert status.OK()
status = connect.flush([jac_collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(jac_collection, top_k, query_vecs, params=search_param)
status, res = connect.search(jac_collection, top_k, query_vecs, params=search_param)
assert status.OK()
logging.getLogger().info(res)
assert res[0][0].id != ids[0]
@ -494,7 +494,7 @@ class TestDeleteBinary:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
tmp, vectors = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -503,11 +503,11 @@ class TestDeleteBinary:
status = connect.delete_entity_by_id(jac_collection, delete_ids)
assert status.OK()
status = connect.flush([jac_collection])
status, tmp_ids = connect.add_vectors(jac_collection, [vectors[0], vectors[-1]])
status, tmp_ids = connect.insert(jac_collection, [vectors[0], vectors[-1]])
assert status.OK()
status = connect.flush([jac_collection])
search_param = get_search_param(index_type)
status, res = connect.search_vectors(jac_collection, top_k, query_vecs, params=search_param)
status, res = connect.search(jac_collection, top_k, query_vecs, params=search_param)
assert status.OK()
logging.getLogger().info(res)
assert res[0][0].id == tmp_ids[0]

View File

@ -127,13 +127,13 @@ class TestFlushBase:
expected: status ok
'''
vectors = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
for i in range(10):
status = connect.flush([collection])
assert status.OK()
query_vecs = [vectors[0], vectors[1], vectors[-1]]
status, res = connect.search_vectors(collection, top_k, query_records=query_vecs)
status, res = connect.search(collection, top_k, query_records=query_vecs)
assert status.OK()
# TODO: stable case
@ -144,7 +144,7 @@ class TestFlushBase:
'''
vectors = gen_vectors(nb, dim)
ids = [i for i in range(nb)]
status, ids = connect.add_vectors(collection, vectors, ids)
status, ids = connect.insert(collection, vectors, ids)
assert status.OK()
timeout = 10
start_time = time.time()
@ -177,7 +177,7 @@ class TestFlushBase:
for i, item in enumerate(ids):
if item <= same_ids:
ids[i] = 0
status, ids = connect.add_vectors(collection, vectors, ids)
status, ids = connect.insert(collection, vectors, ids)
status = connect.flush([collection])
assert status.OK()
status, res = connect.count_entities(collection)
@ -190,7 +190,7 @@ class TestFlushBase:
expected: status ok
'''
vectors = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.delete_entity_by_id(collection, [ids[-1]])
assert status.OK()
@ -198,7 +198,7 @@ class TestFlushBase:
status = connect.flush([collection])
assert status.OK()
query_vecs = [vectors[0], vectors[1], vectors[-1]]
status, res = connect.search_vectors(collection, top_k, query_records=query_vecs)
status, res = connect.search(collection, top_k, query_records=query_vecs)
assert status.OK()
# TODO: CI fail, LOCAL pass
@ -215,7 +215,7 @@ class TestFlushBase:
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
milvus.create_collection(param)
vectors = gen_vector(nb, dim)
status, ids = milvus.add_vectors(collection, vectors, ids=[i for i in range(nb)])
status, ids = milvus.insert(collection, vectors, ids=[i for i in range(nb)])
def flush(collection_name):
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
status = milvus.delete_entity_by_id(collection_name, [i for i in range(nb)])
@ -259,7 +259,7 @@ class TestFlushAsync:
def test_flush_async(self, connect, collection):
vectors = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
future = connect.flush([collection], _async=True)
status = future.result()
assert status.OK()
@ -267,7 +267,7 @@ class TestFlushAsync:
def test_flush_async(self, connect, collection):
nb = 100000
vectors = gen_vectors(nb, dim)
connect.add_vectors(collection, vectors)
connect.insert(collection, vectors)
logging.getLogger().info("before")
future = connect.flush([collection], _async=True, _callback=self.check_status)
logging.getLogger().info("after")

View File

@ -21,7 +21,7 @@ nb = 6000
class TestGetVectorIdsBase:
def get_valid_name(self, connect, collection):
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -110,7 +110,7 @@ class TestGetVectorIdsBase:
expected: status ok
'''
vectors = gen_vector(10, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -133,7 +133,7 @@ class TestGetVectorIdsBase:
status = connect.create_partition(collection, tag)
assert status.OK()
vectors = gen_vector(10, dim)
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -170,7 +170,7 @@ class TestGetVectorIdsBase:
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
vectors = gen_vector(10, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -196,7 +196,7 @@ class TestGetVectorIdsBase:
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
vectors = gen_vector(10, dim)
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -217,7 +217,7 @@ class TestGetVectorIdsBase:
expected: status ok, vector_ids decreased after vectors deleted
'''
vectors = gen_vector(2, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
delete_ids = [ids[0]]
status = connect.delete_entity_by_id(collection, delete_ids)
@ -244,7 +244,7 @@ class TestGetVectorIdsIP:
expected: status ok
'''
vectors = gen_vector(10, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -267,7 +267,7 @@ class TestGetVectorIdsIP:
status = connect.create_partition(ip_collection, tag)
assert status.OK()
vectors = gen_vector(10, dim)
status, ids = connect.add_vectors(ip_collection, vectors, partition_tag=tag)
status, ids = connect.insert(ip_collection, vectors, partition_tag=tag)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -304,7 +304,7 @@ class TestGetVectorIdsIP:
status = connect.create_index(ip_collection, index_type, index_param)
assert status.OK()
vectors = gen_vector(10, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -330,7 +330,7 @@ class TestGetVectorIdsIP:
status = connect.create_index(ip_collection, index_type, index_param)
assert status.OK()
vectors = gen_vector(10, dim)
status, ids = connect.add_vectors(ip_collection, vectors, partition_tag=tag)
status, ids = connect.insert(ip_collection, vectors, partition_tag=tag)
assert status.OK()
status = connect.flush([ip_collection])
assert status.OK()
@ -351,7 +351,7 @@ class TestGetVectorIdsIP:
expected: status ok, vector_ids decreased after vectors deleted
'''
vectors = gen_vector(2, dim)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
delete_ids = [ids[0]]
status = connect.delete_entity_by_id(ip_collection, delete_ids)
@ -378,7 +378,7 @@ class TestGetVectorIdsJAC:
expected: status ok
'''
tmp, vectors = gen_binary_vectors(10, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -400,7 +400,7 @@ class TestGetVectorIdsJAC:
status = connect.create_partition(jac_collection, tag)
assert status.OK()
tmp, vectors = gen_binary_vectors(10, dim)
status, ids = connect.add_vectors(jac_collection, vectors, partition_tag=tag)
status, ids = connect.insert(jac_collection, vectors, partition_tag=tag)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -436,7 +436,7 @@ class TestGetVectorIdsJAC:
status = connect.create_index(jac_collection, index_type, index_param)
assert status.OK()
tmp, vectors = gen_binary_vectors(10, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -462,7 +462,7 @@ class TestGetVectorIdsJAC:
status = connect.create_index(jac_collection, index_type, index_param)
assert status.OK()
tmp, vectors = gen_binary_vectors(10, dim)
status, ids = connect.add_vectors(jac_collection, vectors, partition_tag=tag)
status, ids = connect.insert(jac_collection, vectors, partition_tag=tag)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -483,7 +483,7 @@ class TestGetVectorIdsJAC:
expected: status ok, vector_ids decreased after vectors deleted
'''
tmp, vectors = gen_binary_vectors(2, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
delete_ids = [ids[0]]
status = connect.delete_entity_by_id(jac_collection, delete_ids)

View File

@ -32,7 +32,7 @@ class TestGetBase:
expected: status ok, vector returned
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -47,7 +47,7 @@ class TestGetBase:
expected: status ok, vector returned
'''
vectors = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -64,7 +64,7 @@ class TestGetBase:
expected: status ok, vector returned
'''
vectors = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -80,7 +80,7 @@ class TestGetBase:
vectors = gen_vectors(nb, dim)
status = connect.create_partition(collection, tag)
assert status.OK()
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -99,7 +99,7 @@ class TestGetBase:
vectors = gen_vectors(nb, dim)
ids = [i for i in range(nb)]
ids[1] = 0; ids[-1] = 0
status, ids = connect.add_vectors(collection, vectors, ids=ids)
status, ids = connect.insert(collection, vectors, ids=ids)
status = connect.flush([collection])
assert status.OK()
status, res = connect.get_entity_by_id(collection, [0])
@ -126,7 +126,7 @@ class TestGetBase:
expected: status ok, get one vector
'''
vectors = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -167,7 +167,7 @@ class TestGetBase:
expected: status ok, empty result
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -182,7 +182,7 @@ class TestGetBase:
expected: status not ok
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -233,7 +233,7 @@ class TestGetIndexedVectors:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -253,7 +253,7 @@ class TestGetIndexedVectors:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
vectors = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -279,7 +279,7 @@ class TestGetIndexedVectors:
vectors = gen_vectors(nb, dim)
status = connect.create_partition(collection, tag)
ids = [i for i in range(nb)]
status, ids = connect.add_vectors(collection, vectors, ids, partition_tag=tag)
status, ids = connect.insert(collection, vectors, ids, partition_tag=tag)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -304,7 +304,7 @@ class TestGetBinary:
expected: status ok, vector returned
'''
tmp, vector = gen_binary_vectors(1, dim)
status, ids = connect.add_vectors(jac_collection, vector)
status, ids = connect.insert(jac_collection, vector)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -319,7 +319,7 @@ class TestGetBinary:
expected: status ok, vector returned
'''
tmp, vectors = gen_binary_vectors(nb, dim)
status, ids = connect.add_vectors(jac_collection, vectors)
status, ids = connect.insert(jac_collection, vectors)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -336,7 +336,7 @@ class TestGetBinary:
tmp, vectors = gen_binary_vectors(nb, dim)
ids = [i for i in range(nb)]
ids[0] = 0; ids[-1] = 0
status, ids = connect.add_vectors(jac_collection, vectors, ids=ids)
status, ids = connect.insert(jac_collection, vectors, ids=ids)
status = connect.flush([jac_collection])
assert status.OK()
status, res = connect.get_entity_by_id(jac_collection, [0])
@ -350,7 +350,7 @@ class TestGetBinary:
expected: status ok, empty result
'''
tmp, vector = gen_binary_vectors(1, dim)
status, ids = connect.add_vectors(jac_collection, vector)
status, ids = connect.insert(jac_collection, vector)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -365,7 +365,7 @@ class TestGetBinary:
expected: status not ok
'''
tmp, vector = gen_binary_vectors(1, dim)
status, ids = connect.add_vectors(jac_collection, vector)
status, ids = connect.insert(jac_collection, vector)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()
@ -381,7 +381,7 @@ class TestGetBinary:
'''
tmp, vectors = gen_binary_vectors(nb, dim)
status = connect.create_partition(jac_collection, tag)
status, ids = connect.add_vectors(jac_collection, vectors, partition_tag=tag)
status, ids = connect.insert(jac_collection, vectors, partition_tag=tag)
assert status.OK()
status = connect.flush([jac_collection])
assert status.OK()

View File

@ -68,7 +68,7 @@ class TestIndexBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
@ -96,7 +96,7 @@ class TestIndexBase:
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
status = connect.create_partition(collection, tag)
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
@ -111,7 +111,7 @@ class TestIndexBase:
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
status = connect.create_partition(collection, tag)
status, ids = connect.add_vectors(collection, vectors, partition_tag=tag)
status, ids = connect.insert(collection, vectors, partition_tag=tag)
connect.flush()
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
@ -139,13 +139,13 @@ class TestIndexBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
status = connect.create_index(collection, index_type, index_param)
logging.getLogger().info(connect.get_index_info(collection))
query_vecs = [vectors[0], vectors[1], vectors[2]]
top_k = 5
search_param = get_search_param(index_type)
status, result = connect.search_vectors(collection, top_k, query_vecs, params=search_param)
status, result = connect.search(collection, top_k, query_vecs, params=search_param)
assert status.OK()
assert len(result) == len(query_vecs)
logging.getLogger().info(result)
@ -158,7 +158,7 @@ class TestIndexBase:
method: create collection and add vectors in it, create index
expected: return code equals to 0, and search success
'''
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
def build(connect):
status = connect.create_index(collection, IndexType.IVFLAT, {"nlist": NLIST})
@ -178,7 +178,7 @@ class TestIndexBase:
query_vec = [vectors[0]]
top_k = 1
search_param = {"nprobe": nprobe}
status, result = connect.search_vectors(collection, top_k, query_vec, params=search_param)
status, result = connect.search(collection, top_k, query_vec, params=search_param)
assert len(result) == 1
assert len(result[0]) == top_k
assert result[0][0].distance == 0.0
@ -210,13 +210,13 @@ class TestIndexBase:
i = 0
while i < loop_num:
# assert connect.has_collection(collection[ids*process_num+i])
status, ids = connect.add_vectors(collection[ids*threads_num+i], vectors)
status, ids = connect.insert(collection[ids*threads_num+i], vectors)
status = connect.create_index(collection[ids*threads_num+i], IndexType.IVFLAT, {"nlist": NLIST})
assert status.OK()
query_vec = [vectors[0]]
top_k = 1
search_param = {"nprobe": nprobe}
status, result = connect.search_vectors(collection[ids*threads_num+i], top_k, query_vec, params=search_param)
status, result = connect.search(collection[ids*threads_num+i], top_k, query_vec, params=search_param)
assert len(result) == 1
assert len(result[0]) == top_k
assert result[0][0].distance == 0.0
@ -234,7 +234,7 @@ class TestIndexBase:
@pytest.mark.timeout(BUILD_TIMEOUT)
@pytest.mark.level(2)
def test_create_index_a_multithreads(self, connect, collection, args):
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
def build(connect):
status = connect.create_index(collection, IndexType.IVFLAT, {"nlist": NLIST})
assert status.OK()
@ -268,7 +268,7 @@ class TestIndexBase:
method: create collection and add vectors in it, create index
expected: return code equals to 0, and search success
'''
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
def build(connect):
status = connect.create_index(collection, IndexType.IVFLAT, {"nlist": NLIST})
@ -288,7 +288,7 @@ class TestIndexBase:
query_vec = [vectors[0]]
top_k = 1
search_param = {"nprobe": nprobe}
status, result = connect.search_vectors(collection, top_k, query_vec, params=search_param)
status, result = connect.search(collection, top_k, query_vec, params=search_param)
assert len(result) == 1
assert len(result[0]) == top_k
assert result[0][0].distance == 0.0
@ -321,14 +321,14 @@ class TestIndexBase:
i = 0
while i < loop_num:
# assert connect.has_collection(collection[ids*process_num+i])
status, ids = connect.add_vectors(collection[ids*process_num+i], vectors)
status, ids = connect.insert(collection[ids*process_num+i], vectors)
status = connect.create_index(collection[ids*process_num+i], IndexType.IVFLAT, {"nlist": NLIST})
assert status.OK()
query_vec = [vectors[0]]
top_k = 1
search_param = {"nprobe": nprobe}
status, result = connect.search_vectors(collection[ids*process_num+i], top_k, query_vec, params=search_param)
status, result = connect.search(collection[ids*process_num+i], top_k, query_vec, params=search_param)
assert len(result) == 1
assert len(result[0]) == top_k
assert result[0][0].distance == 0.0
@ -372,7 +372,7 @@ class TestIndexBase:
status = connect.create_index(collection_name, index_type, index_param)
@pytest.mark.timeout(BUILD_TIMEOUT)
def test_create_index_no_vectors_then_add_vectors(self, connect, collection, get_simple_index):
def test_create_index_no_vectors_then_insert(self, connect, collection, get_simple_index):
'''
target: test create index interface when there is no vectors in collection, and does not affect the subsequent process
method: create collection and add no vectors in it, and then create index, add vectors in it
@ -381,7 +381,7 @@ class TestIndexBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
status = connect.create_index(collection, index_type, index_param)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
@pytest.mark.level(2)
@ -407,7 +407,7 @@ class TestIndexBase:
expected: return code 0, and describe index result equals with the second index params
'''
nlist = NLIST
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
index_type_1 = IndexType.IVF_SQ8
index_type_2 = IndexType.IVFLAT
indexs = [{"index_type": index_type_1, "index_param": {"nlist": nlist}}, {"index_type": index_type_2, "index_param": {"nlist": nlist}}]
@ -435,7 +435,7 @@ class TestIndexBase:
index_param = get_index["index_param"]
index_type = get_index["index_type"]
logging.getLogger().info(get_index)
# status, ids = connect.add_vectors(collection, vectors)
# status, ids = connect.insert(collection, vectors)
status = connect.create_index(collection, index_type, index_param)
if status.OK():
status, result = connect.get_index_info(collection)
@ -464,7 +464,7 @@ class TestIndexBase:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
status, ids = connect.add_vectors(collection_name=collection_name, records=vectors)
status, ids = connect.insert(collection_name=collection_name, records=vectors)
status = connect.create_index(collection_name, index_type, index_param)
assert status.OK()
@ -521,7 +521,7 @@ class TestIndexBase:
, make sure the collection name not in index
expected: return code not equals to 0, describe index failed
'''
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
status, result = connect.get_index_info(collection)
logging.getLogger().info(result)
assert status.OK()
@ -543,7 +543,7 @@ class TestIndexBase:
'''
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
# status, ids = connect.add_vectors(collection, vectors)
# status, ids = connect.insert(collection, vectors)
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
status, result = connect.get_index_info(collection)
@ -564,7 +564,7 @@ class TestIndexBase:
'''
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
# status, ids = connect.add_vectors(collection, vectors)
# status, ids = connect.insert(collection, vectors)
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
status, result = connect.get_index_info(collection)
@ -615,7 +615,7 @@ class TestIndexBase:
method: create collection and add vectors in it, create index
expected: return code not equals to 0, drop index failed
'''
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
status, result = connect.get_index_info(collection)
logging.getLogger().info(result)
# no create index
@ -632,7 +632,7 @@ class TestIndexBase:
'''
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
# status, ids = connect.add_vectors(collection, vectors)
# status, ids = connect.insert(collection, vectors)
for i in range(2):
status = connect.create_index(collection, index_type, index_param)
assert status.OK()
@ -653,7 +653,7 @@ class TestIndexBase:
'''
nlist = NLIST
indexs = [{"index_type": IndexType.IVFLAT, "index_param": {"nlist": nlist}}, {"index_type": IndexType.IVF_SQ8, "index_param": {"nlist": nlist}}]
# status, ids = connect.add_vectors(collection, vectors)
# status, ids = connect.insert(collection, vectors)
for i in range(2):
status = connect.create_index(collection, indexs[i]["index_type"], indexs[i]["index_param"])
assert status.OK()
@ -713,7 +713,7 @@ class TestIndexIP:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
status = connect.create_index(ip_collection, index_type, index_param)
assert status.OK()
@ -728,7 +728,7 @@ class TestIndexIP:
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
status = connect.create_partition(ip_collection, tag)
status, ids = connect.add_vectors(ip_collection, vectors, partition_tag=tag)
status, ids = connect.insert(ip_collection, vectors, partition_tag=tag)
status = connect.create_index(ip_collection, index_type, index_param)
assert status.OK()
@ -755,13 +755,13 @@ class TestIndexIP:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
status = connect.create_index(ip_collection, index_type, index_param)
logging.getLogger().info(connect.get_index_info(ip_collection))
query_vecs = [vectors[0], vectors[1], vectors[2]]
top_k = 5
search_param = get_search_param(index_type)
status, result = connect.search_vectors(ip_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(ip_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result) == len(query_vecs)
@ -775,7 +775,7 @@ class TestIndexIP:
method: create collection and add vectors in it, create index
expected: return code equals to 0, and search success
'''
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
def build(connect):
status = connect.create_index(ip_collection, IndexType.IVFLAT, {"nlist": NLIST})
assert status.OK()
@ -795,7 +795,7 @@ class TestIndexIP:
query_vec = [vectors[0]]
top_k = 1
search_param = {"nprobe": nprobe}
status, result = connect.search_vectors(ip_collection, top_k, query_vec, params=search_param)
status, result = connect.search(ip_collection, top_k, query_vec, params=search_param)
assert len(result) == 1
assert len(result[0]) == top_k
assert result[0][0].distance == 0.0
@ -826,14 +826,14 @@ class TestIndexIP:
i = 0
while i < loop_num:
# assert connect.has_collection(collection[ids*process_num+i])
status, ids = connect.add_vectors(collection[ids*process_num+i], vectors)
status, ids = connect.insert(collection[ids*process_num+i], vectors)
status = connect.create_index(collection[ids*process_num+i], IndexType.IVFLAT, {"nlist": NLIST})
assert status.OK()
query_vec = [vectors[0]]
top_k = 1
search_param = {"nprobe": nprobe}
status, result = connect.search_vectors(collection[ids*process_num+i], top_k, query_vec, params=search_param)
status, result = connect.search(collection[ids*process_num+i], top_k, query_vec, params=search_param)
assert len(result) == 1
assert len(result[0]) == top_k
assert result[0][0].distance == 0.0
@ -862,7 +862,7 @@ class TestIndexIP:
assert status.OK()
@pytest.mark.timeout(BUILD_TIMEOUT)
def test_create_index_no_vectors_then_add_vectors(self, connect, ip_collection, get_simple_index):
def test_create_index_no_vectors_then_insert(self, connect, ip_collection, get_simple_index):
'''
target: test create index interface when there is no vectors in collection, and does not affect the subsequent process
method: create collection and add no vectors in it, and then create index, add vectors in it
@ -871,7 +871,7 @@ class TestIndexIP:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
status = connect.create_index(ip_collection, index_type, index_param)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
assert status.OK()
@pytest.mark.timeout(BUILD_TIMEOUT)
@ -882,7 +882,7 @@ class TestIndexIP:
expected: return code success, and search ok
'''
nlist = NLIST
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
index_type = IndexType.IVF_SQ8
index_param = {"nlist": nlist}
status = connect.create_index(ip_collection, index_type, index_param)
@ -891,7 +891,7 @@ class TestIndexIP:
query_vec = [vectors[0]]
top_k = 1
search_param = {"nprobe": nprobe}
status, result = connect.search_vectors(ip_collection, top_k, query_vec, params=search_param)
status, result = connect.search(ip_collection, top_k, query_vec, params=search_param)
assert len(result) == 1
assert len(result[0]) == top_k
@ -903,7 +903,7 @@ class TestIndexIP:
expected: return code 0, and describe index result equals with the second index params
'''
nlist = NLIST
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
index_type_1 = IndexType.IVF_SQ8
index_type_2 = IndexType.IVFLAT
indexs = [{"index_type": index_type_1, "index_param": {"nlist": nlist}}, {"index_type": index_type_2, "index_param": {"nlist": nlist}}]
@ -931,7 +931,7 @@ class TestIndexIP:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
# status, ids = connect.add_vectors(ip_collection, vectors[:5000])
# status, ids = connect.insert(ip_collection, vectors[:5000])
status = connect.create_index(ip_collection, index_type, index_param)
status, result = connect.get_index_info(ip_collection)
logging.getLogger().info(result)
@ -954,7 +954,7 @@ class TestIndexIP:
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
status = connect.create_partition(ip_collection, tag)
status, ids = connect.add_vectors(ip_collection, vectors, partition_tag=tag)
status, ids = connect.insert(ip_collection, vectors, partition_tag=tag)
status = connect.create_index(ip_collection, index_type, index_param)
status, result = connect.get_index_info(ip_collection)
logging.getLogger().info(result)
@ -974,8 +974,8 @@ class TestIndexIP:
logging.getLogger().info(get_simple_index)
status = connect.create_partition(ip_collection, tag)
status = connect.create_partition(ip_collection, new_tag)
# status, ids = connect.add_vectors(ip_collection, vectors, partition_tag=tag)
# status, ids = connect.add_vectors(ip_collection, vectors, partition_tag=new_tag)
# status, ids = connect.insert(ip_collection, vectors, partition_tag=tag)
# status, ids = connect.insert(ip_collection, vectors, partition_tag=new_tag)
status = connect.create_index(ip_collection, index_type, index_param)
status, result = connect.get_index_info(ip_collection)
logging.getLogger().info(result)
@ -1003,7 +1003,7 @@ class TestIndexIP:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
status, ids = connect.add_vectors(collection_name=collection_name, records=vectors)
status, ids = connect.insert(collection_name=collection_name, records=vectors)
status = connect.create_index(collection_name, index_type, index_param)
assert status.OK()
for i in range(10):
@ -1037,7 +1037,7 @@ class TestIndexIP:
, make sure the collection name not in index
expected: return code not equals to 0, describe index failed
'''
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
status, result = connect.get_index_info(ip_collection)
logging.getLogger().info(result)
assert status.OK()
@ -1061,7 +1061,7 @@ class TestIndexIP:
index_type = get_simple_index["index_type"]
status, mode = connect._cmd("mode")
assert status.OK()
# status, ids = connect.add_vectors(ip_collection, vectors)
# status, ids = connect.insert(ip_collection, vectors)
status = connect.create_index(ip_collection, index_type, index_param)
if str(mode) == "GPU" and (index_type == IndexType.IVF_PQ):
assert not status.OK()
@ -1085,7 +1085,7 @@ class TestIndexIP:
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
status = connect.create_partition(ip_collection, tag)
status, ids = connect.add_vectors(ip_collection, vectors, partition_tag=tag)
status, ids = connect.insert(ip_collection, vectors, partition_tag=tag)
status = connect.create_index(ip_collection, index_type, index_param)
assert status.OK()
status, result = connect.get_index_info(ip_collection)
@ -1108,7 +1108,7 @@ class TestIndexIP:
index_type = get_simple_index["index_type"]
status = connect.create_partition(ip_collection, tag)
status = connect.create_partition(ip_collection, new_tag)
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
status = connect.create_index(ip_collection, index_type, index_param)
assert status.OK()
status = connect.drop_index(ip_collection)
@ -1127,10 +1127,10 @@ class TestIndexIP:
'''
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
# status, ids = connect.add_vectors(ip_collection, vectors)
# status, ids = connect.insert(ip_collection, vectors)
status, mode = connect._cmd("mode")
assert status.OK()
# status, ids = connect.add_vectors(ip_collection, vectors)
# status, ids = connect.insert(ip_collection, vectors)
status = connect.create_index(ip_collection, index_type, index_param)
if str(mode) == "GPU" and (index_type == IndexType.IVF_PQ):
assert not status.OK()
@ -1166,7 +1166,7 @@ class TestIndexIP:
method: create collection and add vectors in it, create index
expected: return code not equals to 0, drop index failed
'''
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
status, result = connect.get_index_info(ip_collection)
logging.getLogger().info(result)
# no create index
@ -1183,7 +1183,7 @@ class TestIndexIP:
'''
index_param = get_simple_index["index_param"]
index_type = get_simple_index["index_type"]
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
for i in range(2):
status = connect.create_index(ip_collection, index_type, index_param)
assert status.OK()
@ -1204,7 +1204,7 @@ class TestIndexIP:
'''
nlist = NLIST
indexs = [{"index_type": IndexType.IVFLAT, "index_param": {"nlist": nlist}}, {"index_type": IndexType.IVF_SQ8, "index_param": {"nlist": nlist}}]
status, ids = connect.add_vectors(ip_collection, vectors)
status, ids = connect.insert(ip_collection, vectors)
for i in range(2):
status = connect.create_index(ip_collection, indexs[i]["index_type"], indexs[i]["index_param"])
assert status.OK()
@ -1277,7 +1277,7 @@ class TestIndexJAC:
index_param = get_jaccard_index["index_param"]
index_type = get_jaccard_index["index_type"]
logging.getLogger().info(get_jaccard_index)
status, ids = connect.add_vectors(jac_collection, self.vectors)
status, ids = connect.insert(jac_collection, self.vectors)
status = connect.create_index(jac_collection, index_type, index_param)
if index_type != IndexType.FLAT and index_type != IndexType.IVFLAT:
assert not status.OK()
@ -1295,7 +1295,7 @@ class TestIndexJAC:
index_type = get_jaccard_index["index_type"]
logging.getLogger().info(get_jaccard_index)
status = connect.create_partition(jac_collection, tag)
status, ids = connect.add_vectors(jac_collection, self.vectors, partition_tag=tag)
status, ids = connect.insert(jac_collection, self.vectors, partition_tag=tag)
status = connect.create_index(jac_collection, index_type, index_param)
assert status.OK()
@ -1321,13 +1321,13 @@ class TestIndexJAC:
index_param = get_jaccard_index["index_param"]
index_type = get_jaccard_index["index_type"]
logging.getLogger().info(get_jaccard_index)
status, ids = connect.add_vectors(jac_collection, self.vectors)
status, ids = connect.insert(jac_collection, self.vectors)
status = connect.create_index(jac_collection, index_type, index_param)
logging.getLogger().info(connect.get_index_info(jac_collection))
query_vecs = [self.vectors[0], self.vectors[1], self.vectors[2]]
top_k = 5
search_param = get_search_param(index_type)
status, result = connect.search_vectors(jac_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(jac_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result) == len(query_vecs)
@ -1347,7 +1347,7 @@ class TestIndexJAC:
index_param = get_jaccard_index["index_param"]
index_type = get_jaccard_index["index_type"]
logging.getLogger().info(get_jaccard_index)
# status, ids = connect.add_vectors(jac_collection, vectors[:5000])
# status, ids = connect.insert(jac_collection, vectors[:5000])
status = connect.create_index(jac_collection, index_type, index_param)
status, result = connect.get_index_info(jac_collection)
logging.getLogger().info(result)
@ -1365,7 +1365,7 @@ class TestIndexJAC:
index_type = get_jaccard_index["index_type"]
logging.getLogger().info(get_jaccard_index)
status = connect.create_partition(jac_collection, tag)
status, ids = connect.add_vectors(jac_collection, vectors, partition_tag=tag)
status, ids = connect.insert(jac_collection, vectors, partition_tag=tag)
status = connect.create_index(jac_collection, index_type, index_param)
status, result = connect.get_index_info(jac_collection)
logging.getLogger().info(result)
@ -1389,7 +1389,7 @@ class TestIndexJAC:
index_type = get_jaccard_index["index_type"]
status, mode = connect._cmd("mode")
assert status.OK()
# status, ids = connect.add_vectors(ip_collection, vectors)
# status, ids = connect.insert(ip_collection, vectors)
status = connect.create_index(jac_collection, index_type, index_param)
assert status.OK()
status, result = connect.get_index_info(jac_collection)
@ -1410,7 +1410,7 @@ class TestIndexJAC:
index_param = get_jaccard_index["index_param"]
index_type = get_jaccard_index["index_type"]
status = connect.create_partition(jac_collection, tag)
status, ids = connect.add_vectors(jac_collection, vectors, partition_tag=tag)
status, ids = connect.insert(jac_collection, vectors, partition_tag=tag)
status = connect.create_index(jac_collection, index_type, index_param)
assert status.OK()
status, result = connect.get_index_info(jac_collection)
@ -1498,7 +1498,7 @@ class TestIndexBinary:
index_param = get_hamming_index["index_param"]
index_type = get_hamming_index["index_type"]
logging.getLogger().info(get_hamming_index)
status, ids = connect.add_vectors(ham_collection, self.vectors)
status, ids = connect.insert(ham_collection, self.vectors)
status = connect.create_index(ham_collection, index_type, index_param)
if index_type != IndexType.FLAT and index_type != IndexType.IVFLAT:
assert not status.OK()
@ -1516,7 +1516,7 @@ class TestIndexBinary:
index_type = get_hamming_index["index_type"]
logging.getLogger().info(get_hamming_index)
status = connect.create_partition(ham_collection, tag)
status, ids = connect.add_vectors(ham_collection, self.vectors, partition_tag=tag)
status, ids = connect.insert(ham_collection, self.vectors, partition_tag=tag)
status = connect.create_index(ham_collection, index_type, index_param)
assert status.OK()
status, res = connect.count_entities(ham_collection)
@ -1533,7 +1533,7 @@ class TestIndexBinary:
index_type = get_substructure_index["index_type"]
logging.getLogger().info(get_substructure_index)
status = connect.create_partition(substructure_collection, tag)
status, ids = connect.add_vectors(substructure_collection, self.vectors, partition_tag=tag)
status, ids = connect.insert(substructure_collection, self.vectors, partition_tag=tag)
status = connect.create_index(substructure_collection, index_type, index_param)
assert status.OK()
status, res = connect.count_entities(substructure_collection,)
@ -1561,13 +1561,13 @@ class TestIndexBinary:
index_param = get_hamming_index["index_param"]
index_type = get_hamming_index["index_type"]
logging.getLogger().info(get_hamming_index)
status, ids = connect.add_vectors(ham_collection, self.vectors)
status, ids = connect.insert(ham_collection, self.vectors)
status = connect.create_index(ham_collection, index_type, index_param)
logging.getLogger().info(connect.get_index_info(ham_collection))
query_vecs = [self.vectors[0], self.vectors[1], self.vectors[2]]
top_k = 5
search_param = get_search_param(index_type)
status, result = connect.search_vectors(ham_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(ham_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result) == len(query_vecs)
@ -1582,13 +1582,13 @@ class TestIndexBinary:
index_param = get_superstructure_index["index_param"]
index_type = get_superstructure_index["index_type"]
logging.getLogger().info(get_superstructure_index)
status, ids = connect.add_vectors(superstructure_collection, self.vectors)
status, ids = connect.insert(superstructure_collection, self.vectors)
status = connect.create_index(superstructure_collection, index_type, index_param)
logging.getLogger().info(connect.get_index_info(superstructure_collection))
query_vecs = [self.vectors[0], self.vectors[1], self.vectors[2]]
top_k = 5
search_param = get_search_param(index_type)
status, result = connect.search_vectors(superstructure_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(superstructure_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result) == len(query_vecs)
@ -1608,7 +1608,7 @@ class TestIndexBinary:
index_param = get_hamming_index["index_param"]
index_type = get_hamming_index["index_type"]
logging.getLogger().info(get_hamming_index)
# status, ids = connect.add_vectors(jac_collection, vectors[:5000])
# status, ids = connect.insert(jac_collection, vectors[:5000])
status = connect.create_index(ham_collection, index_type, index_param)
status, result = connect.get_index_info(ham_collection)
logging.getLogger().info(result)
@ -1626,7 +1626,7 @@ class TestIndexBinary:
index_type = get_hamming_index["index_type"]
logging.getLogger().info(get_hamming_index)
status = connect.create_partition(ham_collection, tag)
status, ids = connect.add_vectors(ham_collection, vectors, partition_tag=tag)
status, ids = connect.insert(ham_collection, vectors, partition_tag=tag)
status = connect.create_index(ham_collection, index_type, index_param)
status, result = connect.get_index_info(ham_collection)
logging.getLogger().info(result)
@ -1644,7 +1644,7 @@ class TestIndexBinary:
index_type = get_superstructure_index["index_type"]
logging.getLogger().info(get_superstructure_index)
status = connect.create_partition(superstructure_collection, tag)
status, ids = connect.add_vectors(superstructure_collection, vectors, partition_tag=tag)
status, ids = connect.insert(superstructure_collection, vectors, partition_tag=tag)
status = connect.create_index(superstructure_collection, index_type, index_param)
status, result = connect.get_index_info(superstructure_collection)
logging.getLogger().info(result)
@ -1668,7 +1668,7 @@ class TestIndexBinary:
index_type = get_hamming_index["index_type"]
status, mode = connect._cmd("mode")
assert status.OK()
# status, ids = connect.add_vectors(ip_collection, vectors)
# status, ids = connect.insert(ip_collection, vectors)
status = connect.create_index(ham_collection, index_type, index_param)
assert status.OK()
status, result = connect.get_index_info(ham_collection)
@ -1710,7 +1710,7 @@ class TestIndexBinary:
index_param = get_hamming_index["index_param"]
index_type = get_hamming_index["index_type"]
status = connect.create_partition(ham_collection, tag)
status, ids = connect.add_vectors(ham_collection, vectors, partition_tag=tag)
status, ids = connect.insert(ham_collection, vectors, partition_tag=tag)
status = connect.create_index(ham_collection, index_type, index_param)
assert status.OK()
status, result = connect.get_index_info(ham_collection)
@ -1770,7 +1770,7 @@ class TestCreateIndexParamsInvalid(object):
index_param = get_index["index_param"]
index_type = get_index["index_type"]
logging.getLogger().info(get_index)
# status, ids = connect.add_vectors(collection, vectors)
# status, ids = connect.insert(collection, vectors)
if (not index_type) or (not isinstance(index_type, IndexType)):
with pytest.raises(Exception) as e:
status = connect.create_index(collection, index_type, index_param)
@ -1789,7 +1789,7 @@ class TestCreateIndexParamsInvalid(object):
yield request.param
def test_create_index_with_invalid_nlist(self, connect, collection, get_index_type):
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
status = connect.create_index(collection, get_index_type, {"nlist": INVALID_NLIST})
if get_index_type != IndexType.FLAT:
assert not status.OK()
@ -1867,7 +1867,7 @@ class TestIndexAsync:
index_type = get_simple_index["index_type"]
logging.getLogger().info(get_simple_index)
vectors = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
logging.getLogger().info("start index")
# future = connect.create_index(collection, index_type, index_param, _async=True, _callback=self.check_status)
future = connect.create_index(collection, index_type, index_param, _async=True)

View File

@ -40,7 +40,7 @@ class TestMixBase:
'index_file_size': index_file_size,
'metric_type': MetricType.L2})
for i in range(10):
status, ids = milvus_instance.add_vectors(collection, vectors)
status, ids = milvus_instance.insert(collection, vectors)
# logging.getLogger().info(ids)
if i == 0:
id_0 = ids[0]; id_1 = ids[1]
@ -50,14 +50,14 @@ class TestMixBase:
logging.getLogger().info(status)
status, result = milvus_instance.get_index_info(collection)
logging.getLogger().info(result)
def add_vectors(milvus_instance):
def insert(milvus_instance):
logging.getLogger().info("In add vectors")
status, ids = milvus_instance.add_vectors(collection, vectors)
status, ids = milvus_instance.insert(collection, vectors)
logging.getLogger().info(status)
def search(milvus_instance):
logging.getLogger().info("In search vectors")
for i in range(loops):
status, result = milvus_instance.search_vectors(collection, top_k, nprobe, query_vecs)
status, result = milvus_instance.search(collection, top_k, nprobe, query_vecs)
logging.getLogger().info(status)
assert result[0][0].id == id_0
assert result[1][0].id == id_1
@ -67,7 +67,7 @@ class TestMixBase:
p_search.start()
milvus_instance = get_milvus(args["handler"])
# milvus_instance.connect(uri=uri)
p_create = Process(target=add_vectors, args=(milvus_instance, ))
p_create = Process(target=insert, args=(milvus_instance, ))
p_create.start()
p_create.join()
@ -93,7 +93,7 @@ class TestMixBase:
'index_file_size': index_file_size,
'metric_type': MetricType.L2}
connect.create_collection(param)
status, ids = connect.add_vectors(collection_name=collection_name, records=vectors)
status, ids = connect.insert(collection_name=collection_name, records=vectors)
idx.append(ids[0])
idx.append(ids[10])
idx.append(ids[20])
@ -106,7 +106,7 @@ class TestMixBase:
'index_file_size': index_file_size,
'metric_type': MetricType.IP}
connect.create_collection(param)
status, ids = connect.add_vectors(collection_name=collection_name, records=vectors)
status, ids = connect.insert(collection_name=collection_name, records=vectors)
assert status.OK()
status = connect.flush([collection_name])
assert status.OK()
@ -147,7 +147,7 @@ class TestMixBase:
query_vecs = [vectors[0], vectors[10], vectors[20]]
for i in range(60):
collection = collection_list[i]
status, result = connect.search_vectors(collection, top_k, query_records=query_vecs, params={"nprobe": 1})
status, result = connect.search(collection, top_k, query_records=query_vecs, params={"nprobe": 1})
assert status.OK()
assert len(result) == len(query_vecs)
logging.getLogger().info(i)

View File

@ -97,7 +97,7 @@ class TestCreateBase:
assert tag_name in tag_list
assert "_default" in tag_list
def test_create_partition_add_vectors_default(self, connect, collection):
def test_create_partition_insert_default(self, connect, collection):
'''
target: test create partition, and insert vectors, check status returned
method: call function: create_partition

View File

@ -44,12 +44,12 @@
# '''
# global vectors
# if nb == 6000:
# add_vectors = vectors
# insert = vectors
# else:
# add_vectors = gen_vectors(nb, dim)
# status, ids = connect.add_vectors(collection, add_vectors)
# insert = gen_vectors(nb, dim)
# status, ids = connect.insert(collection, insert)
# connect.flush([collection])
# return add_vectors, ids
# return insert, ids
#
# def init_data_binary(self, connect, collection, nb=6000):
# '''
@ -57,32 +57,32 @@
# '''
# global binary_vectors
# if nb == 6000:
# add_vectors = binary_vectors
# insert = binary_vectors
# else:
# add_vectors = gen_binary_vectors(nb, dim)
# status, ids = connect.add_vectors(collection, add_vectors)
# insert = gen_binary_vectors(nb, dim)
# status, ids = connect.insert(collection, insert)
# connect.flush([collection])
# return add_vectors, ids
# return insert, ids
#
# def init_data_no_flush(self, connect, collection, nb=6000):
# global vectors
# if nb == 6000:
# add_vectors = vectors
# insert = vectors
# else:
# add_vectors = gen_vectors(nb, dim)
# status, ids = connect.add_vectors(collection, add_vectors)
# return add_vectors, ids
# insert = gen_vectors(nb, dim)
# status, ids = connect.insert(collection, insert)
# return insert, ids
#
# def init_data_ids(self, connect, collection, nb=6000):
# global vectors
# my_ids = [i for i in range(nb)]
# if nb == 6000:
# add_vectors = vectors
# insert = vectors
# else:
# add_vectors = gen_vectors(nb, dim)
# status, ids = connect.add_vectors(collection, add_vectors, my_ids)
# insert = gen_vectors(nb, dim)
# status, ids = connect.insert(collection, insert, my_ids)
# connect.flush([collection])
# return add_vectors, ids
# return insert, ids
#
# def init_data_partition(self, connect, collection, partition_tag, nb=6000):
# '''
@ -90,15 +90,15 @@
# '''
# global vectors
# if nb == 6000:
# add_vectors = vectors
# insert = vectors
# else:
# add_vectors = gen_vectors(nb, dim)
# add_vectors = sklearn.preprocessing.normalize(add_vectors, axis=1, norm='l2')
# add_vectors = add_vectors.tolist()
# status, ids = connect.add_vectors(collection, add_vectors, partition_tag=partition_tag)
# insert = gen_vectors(nb, dim)
# insert = sklearn.preprocessing.normalize(insert, axis=1, norm='l2')
# insert = insert.tolist()
# status, ids = connect.insert(collection, insert, partition_tag=partition_tag)
# assert status.OK()
# connect.flush([collection])
# return add_vectors, ids
# return insert, ids
#
# @pytest.fixture(
# scope="function",

View File

@ -36,13 +36,13 @@ class TestSearchBase:
add_vectors = vectors
else:
add_vectors = gen_vectors(nb, dim)
vectors = sklearn.preprocessing.normalize(vectors, axis=1, norm='l2')
vectors = vectors.tolist()
add_vectors = sklearn.preprocessing.normalize(add_vectors, axis=1, norm='l2')
add_vectors = add_vectors.tolist()
if partition_tags is None:
status, ids = connect.add_vectors(collection, add_vectors)
status, ids = connect.insert(collection, add_vectors)
assert status.OK()
else:
status, ids = connect.add_vectors(collection, add_vectors, partition_tag=partition_tags)
status, ids = connect.insert(collection, add_vectors, partition_tag=partition_tags)
assert status.OK()
sleep(add_interval_time)
return add_vectors, ids
@ -61,12 +61,12 @@ class TestSearchBase:
add_raw_vectors, add_vectors = gen_binary_vectors(nb, dim)
if insert is True:
if partition_tags is None:
status, ids = connect.add_vectors(collection, add_vectors)
status, ids = connect.insert(collection, add_vectors)
assert status.OK()
else:
status, ids = connect.add_vectors(collection, add_vectors, partition_tag=partition_tags)
status, ids = connect.insert(collection, add_vectors, partition_tag=partition_tags)
assert status.OK()
sleep(add_interval_time)
connect.flush([collection])
return add_raw_vectors, add_vectors, ids
"""
@ -151,7 +151,7 @@ class TestSearchBase:
vectors, ids = self.init_data(connect, collection)
query_vec = [vectors[0]]
top_k = get_top_k
status, result = connect.search_vectors(collection, top_k, query_vec)
status, result = connect.search(collection, top_k, query_vec)
if top_k <= 2048:
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
@ -177,7 +177,7 @@ class TestSearchBase:
status = connect.create_index(collection, index_type, index_param)
query_vec = [vectors[0]]
search_param = get_search_param(index_type)
status, result = connect.search_vectors(collection, top_k, query_vec, params=search_param)
status, result = connect.search(collection, top_k, query_vec, params=search_param)
logging.getLogger().info(result)
if top_k <= 1024:
assert status.OK()
@ -204,7 +204,7 @@ class TestSearchBase:
status = connect.create_index(collection, index_type, index_param)
query_vec = vectors[:1000]
search_param = get_search_param(index_type)
status, result = connect.search_vectors(collection, top_k, query_vec, params=search_param)
status, result = connect.search(collection, top_k, query_vec, params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
@ -228,13 +228,13 @@ class TestSearchBase:
status = connect.create_index(collection, index_type, index_param)
query_vec = [vectors[0]]
search_param = get_search_param(index_type)
status, result = connect.search_vectors(collection, top_k, query_vec, params=search_param)
status, result = connect.search(collection, top_k, query_vec, params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
assert check_result(result[0], ids[0])
assert result[0][0].distance <= epsilon
status, result = connect.search_vectors(collection, top_k, query_vec, partition_tags=[tag], params=search_param)
status, result = connect.search(collection, top_k, query_vec, partition_tags=[tag], params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result) == 0
@ -257,7 +257,7 @@ class TestSearchBase:
status = connect.create_index(collection, index_type, index_param)
query_vec = [vectors[0]]
search_param = get_search_param(index_type)
status, result = connect.search_vectors(collection, top_k, query_vec, partition_tags=[tag], params=search_param)
status, result = connect.search(collection, top_k, query_vec, partition_tags=[tag], params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result) == 0
@ -279,13 +279,13 @@ class TestSearchBase:
status = connect.create_index(collection, index_type, index_param)
query_vec = [vectors[0]]
search_param = get_search_param(index_type)
status, result = connect.search_vectors(collection, top_k, query_vec, params=search_param)
status, result = connect.search(collection, top_k, query_vec, params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
assert check_result(result[0], ids[0])
assert result[0][0].distance <= epsilon
status, result = connect.search_vectors(collection, top_k, query_vec, partition_tags=[tag], params=search_param)
status, result = connect.search(collection, top_k, query_vec, partition_tags=[tag], params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
@ -309,7 +309,7 @@ class TestSearchBase:
query_vec = [vectors[0]]
top_k = 10
search_param = get_search_param(index_type)
status, result = connect.search_vectors(collection, top_k, query_vec, partition_tags=[tag, "new_tag"], params=search_param)
status, result = connect.search(collection, top_k, query_vec, partition_tags=[tag, "new_tag"], params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
@ -331,7 +331,7 @@ class TestSearchBase:
query_vec = [vectors[0]]
top_k = 10
search_param = get_search_param(index_type)
status, result = connect.search_vectors(collection, top_k, query_vec, partition_tags=["new_tag"], params=search_param)
status, result = connect.search(collection, top_k, query_vec, partition_tags=["new_tag"], params=search_param)
logging.getLogger().info(result)
assert not status.OK()
@ -355,7 +355,7 @@ class TestSearchBase:
status = connect.create_index(collection, index_type, index_param)
query_vec = [vectors[0], new_vectors[0]]
search_param = get_search_param(index_type)
status, result = connect.search_vectors(collection, top_k, query_vec, partition_tags=[tag, new_tag], params=search_param)
status, result = connect.search(collection, top_k, query_vec, partition_tags=[tag, new_tag], params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
@ -363,7 +363,7 @@ class TestSearchBase:
assert check_result(result[1], new_ids[0])
assert result[0][0].distance <= epsilon
assert result[1][0].distance <= epsilon
status, result = connect.search_vectors(collection, top_k, query_vec, partition_tags=[new_tag], params=search_param)
status, result = connect.search(collection, top_k, query_vec, partition_tags=[new_tag], params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
@ -391,12 +391,12 @@ class TestSearchBase:
query_vec = [vectors[0], new_vectors[0]]
top_k = 10
search_param = get_search_param(index_type)
status, result = connect.search_vectors(collection, top_k, query_vec, partition_tags=["new(.*)"], params=search_param)
status, result = connect.search(collection, top_k, query_vec, partition_tags=["new(.*)"], params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert result[0][0].distance > epsilon
assert result[1][0].distance <= epsilon
status, result = connect.search_vectors(collection, top_k, query_vec, partition_tags=["(.*)tag"], params=search_param)
status, result = connect.search(collection, top_k, query_vec, partition_tags=["(.*)tag"], params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert result[0][0].distance <= epsilon
@ -419,7 +419,7 @@ class TestSearchBase:
status = connect.create_index(ip_collection, index_type, index_param)
query_vec = [vectors[0]]
search_param = get_search_param(index_type)
status, result = connect.search_vectors(ip_collection, top_k, query_vec, params=search_param)
status, result = connect.search(ip_collection, top_k, query_vec, params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
@ -444,7 +444,7 @@ class TestSearchBase:
query_vec.append(vectors[i])
top_k = 10
search_param = get_search_param(index_type)
status, result = connect.search_vectors(ip_collection, top_k, query_vec, params=search_param)
status, result = connect.search(ip_collection, top_k, query_vec, params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
@ -469,13 +469,13 @@ class TestSearchBase:
status = connect.create_index(ip_collection, index_type, index_param)
query_vec = [vectors[0]]
search_param = get_search_param(index_type)
status, result = connect.search_vectors(ip_collection, top_k, query_vec, params=search_param)
status, result = connect.search(ip_collection, top_k, query_vec, params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
assert check_result(result[0], ids[0])
assert result[0][0].distance >= 1 - gen_inaccuracy(result[0][0].distance)
status, result = connect.search_vectors(ip_collection, top_k, query_vec, partition_tags=[tag], params=search_param)
status, result = connect.search(ip_collection, top_k, query_vec, partition_tags=[tag], params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result) == 0
@ -498,7 +498,7 @@ class TestSearchBase:
status = connect.create_index(ip_collection, index_type, index_param)
query_vec = [vectors[0]]
search_param = get_search_param(index_type)
status, result = connect.search_vectors(ip_collection, top_k, query_vec, partition_tags=[tag], params=search_param)
status, result = connect.search(ip_collection, top_k, query_vec, partition_tags=[tag], params=search_param)
logging.getLogger().info(result)
assert status.OK()
assert len(result[0]) == min(len(vectors), top_k)
@ -515,7 +515,7 @@ class TestSearchBase:
# query_vectors = [vectors[0]]
# nprobe = 1
# with pytest.raises(Exception) as e:
# status, ids = dis_connect.search_vectors(collection, top_k, query_vectors)
# status, ids = dis_connect.search(collection, top_k, query_vectors)
def test_search_collection_name_not_existed(self, connect, collection):
'''
@ -526,7 +526,7 @@ class TestSearchBase:
collection_name = gen_unique_str("not_existed_collection")
nprobe = 1
query_vecs = [vectors[0]]
status, result = connect.search_vectors(collection_name, top_k, query_vecs)
status, result = connect.search(collection_name, top_k, query_vecs)
assert not status.OK()
def test_search_collection_name_None(self, connect, collection):
@ -539,7 +539,7 @@ class TestSearchBase:
nprobe = 1
query_vecs = [vectors[0]]
with pytest.raises(Exception) as e:
status, result = connect.search_vectors(collection_name, top_k, query_vecs)
status, result = connect.search(collection_name, top_k, query_vecs)
def test_search_top_k_query_records(self, connect, collection):
'''
@ -550,7 +550,7 @@ class TestSearchBase:
top_k = 10
vectors, ids = self.init_data(connect, collection)
query_vecs = [vectors[0],vectors[55],vectors[99]]
status, result = connect.search_vectors(collection, top_k, query_vecs)
status, result = connect.search(collection, top_k, query_vecs)
assert status.OK()
assert len(result) == len(query_vecs)
for i in range(len(query_vecs)):
@ -568,7 +568,7 @@ class TestSearchBase:
query_vecs = [[0.50 for i in range(dim)]]
distance_0 = numpy.linalg.norm(numpy.array(query_vecs[0]) - numpy.array(vectors[0]))
distance_1 = numpy.linalg.norm(numpy.array(query_vecs[0]) - numpy.array(vectors[1]))
status, result = connect.search_vectors(collection, top_k, query_vecs)
status, result = connect.search(collection, top_k, query_vecs)
assert abs(numpy.sqrt(result[0][0].distance) - min(distance_0, distance_1)) <= gen_inaccuracy(result[0][0].distance)
def test_search_distance_ip_flat_index(self, connect, ip_collection):
@ -590,7 +590,7 @@ class TestSearchBase:
distance_0 = numpy.inner(numpy.array(query_vecs[0]), numpy.array(vectors[0]))
distance_1 = numpy.inner(numpy.array(query_vecs[0]), numpy.array(vectors[1]))
search_param = get_search_param(index_type)
status, result = connect.search_vectors(ip_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(ip_collection, top_k, query_vecs, params=search_param)
assert abs(result[0][0].distance - max(distance_0, distance_1)) <= gen_inaccuracy(result[0][0].distance)
def test_search_distance_jaccard_flat_index(self, connect, jac_collection):
@ -613,7 +613,7 @@ class TestSearchBase:
distance_0 = jaccard(query_int_vectors[0], int_vectors[0])
distance_1 = jaccard(query_int_vectors[0], int_vectors[1])
search_param = get_search_param(index_type)
status, result = connect.search_vectors(jac_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(jac_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(status)
logging.getLogger().info(result)
assert abs(result[0][0].distance - min(distance_0, distance_1)) <= epsilon
@ -638,7 +638,7 @@ class TestSearchBase:
distance_0 = hamming(query_int_vectors[0], int_vectors[0])
distance_1 = hamming(query_int_vectors[0], int_vectors[1])
search_param = get_search_param(index_type)
status, result = connect.search_vectors(ham_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(ham_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(status)
logging.getLogger().info(result)
assert abs(result[0][0].distance - min(distance_0, distance_1).astype(float)) <= epsilon
@ -663,7 +663,7 @@ class TestSearchBase:
distance_0 = substructure(query_int_vectors[0], int_vectors[0])
distance_1 = substructure(query_int_vectors[0], int_vectors[1])
search_param = get_search_param(index_type)
status, result = connect.search_vectors(substructure_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(substructure_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(status)
logging.getLogger().info(result)
assert len(result[0]) == 0
@ -687,7 +687,7 @@ class TestSearchBase:
logging.getLogger().info(connect.get_index_info(substructure_collection))
query_int_vectors, query_vecs = gen_binary_sub_vectors(int_vectors, 2)
search_param = get_search_param(index_type)
status, result = connect.search_vectors(substructure_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(substructure_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(status)
logging.getLogger().info(result)
assert len(result[0]) == 1
@ -717,7 +717,7 @@ class TestSearchBase:
distance_0 = superstructure(query_int_vectors[0], int_vectors[0])
distance_1 = superstructure(query_int_vectors[0], int_vectors[1])
search_param = get_search_param(index_type)
status, result = connect.search_vectors(superstructure_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(superstructure_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(status)
logging.getLogger().info(result)
assert len(result[0]) == 0
@ -741,7 +741,7 @@ class TestSearchBase:
logging.getLogger().info(connect.get_index_info(superstructure_collection))
query_int_vectors, query_vecs = gen_binary_super_vectors(int_vectors, 2)
search_param = get_search_param(index_type)
status, result = connect.search_vectors(superstructure_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(superstructure_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(status)
logging.getLogger().info(result)
assert len(result[0]) == 2
@ -771,7 +771,7 @@ class TestSearchBase:
distance_0 = tanimoto(query_int_vectors[0], int_vectors[0])
distance_1 = tanimoto(query_int_vectors[0], int_vectors[1])
search_param = get_search_param(index_type)
status, result = connect.search_vectors(tanimoto_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(tanimoto_collection, top_k, query_vecs, params=search_param)
logging.getLogger().info(status)
logging.getLogger().info(result)
assert abs(result[0][0].distance - min(distance_0, distance_1)) <= epsilon
@ -793,7 +793,7 @@ class TestSearchBase:
logging.getLogger().info(connect.get_index_info(ip_collection))
query_vecs = [[0.50 for i in range(dim)]]
search_param = get_search_param(index_type)
status, result = connect.search_vectors(ip_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(ip_collection, top_k, query_vecs, params=search_param)
logging.getLogger().debug(status)
logging.getLogger().debug(result)
distance_0 = numpy.inner(numpy.array(query_vecs[0]), numpy.array(vectors[0]))
@ -811,7 +811,7 @@ class TestSearchBase:
threads = []
query_vecs = vectors[nb//2:nb]
def search():
status, result = connect.search_vectors(collection, top_k, query_vecs)
status, result = connect.search(collection, top_k, query_vecs)
assert len(result) == len(query_vecs)
for i in range(len(query_vecs)):
assert result[i][0].id in ids
@ -847,7 +847,7 @@ class TestSearchBase:
vectors, ids = self.init_data(milvus, collection, nb=nb)
query_vecs = vectors[nb//2:nb]
def search(milvus):
status, result = milvus.search_vectors(collection, top_k, query_vecs)
status, result = milvus.search(collection, top_k, query_vecs)
assert len(result) == len(query_vecs)
for i in range(len(query_vecs)):
assert result[i][0].id in ids
@ -886,7 +886,7 @@ class TestSearchBase:
vectors, ids = self.init_data(milvus, collection, nb=nb)
query_vecs = vectors[nb//2:nb]
def search(milvus):
status, result = milvus.search_vectors(collection, top_k, query_vecs)
status, result = milvus.search(collection, top_k, query_vecs)
assert len(result) == len(query_vecs)
for i in range(len(query_vecs)):
assert result[i][0].id in ids
@ -921,7 +921,7 @@ class TestSearchBase:
# create collection
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
milvus.create_collection(param)
status, ids = milvus.add_vectors(collection, vectors)
status, ids = milvus.insert(collection, vectors)
assert status.OK()
assert len(ids) == len(vectors)
collections.append(collection)
@ -933,7 +933,7 @@ class TestSearchBase:
# start query from random collection
for i in range(num):
collection = collections[i]
status, result = milvus.search_vectors(collection, top_k, query_vecs)
status, result = milvus.search(collection, top_k, query_vecs)
assert status.OK()
assert len(result) == len(query_vecs)
for j in range(len(query_vecs)):
@ -961,7 +961,7 @@ class TestSearchBase:
# create collection
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
milvus.create_collection(param)
status, ids = milvus.add_vectors(collection, vectors)
status, ids = milvus.insert(collection, vectors)
assert status.OK()
assert len(ids) == len(vectors)
collections.append(collection)
@ -973,7 +973,7 @@ class TestSearchBase:
# start query from random collection
for i in range(num):
collection = collections[i]
status, result = milvus.search_vectors(collection, top_k, query_vecs)
status, result = milvus.search(collection, top_k, query_vecs)
assert status.OK()
assert len(result) == len(query_vecs)
for j in range(len(query_vecs)):
@ -999,12 +999,12 @@ class TestSearchParamsInvalid(object):
'''
global vectors
if nb == 6000:
add_vectors = vectors
insert = vectors
else:
add_vectors = gen_vectors(nb, dim)
status, ids = connect.add_vectors(collection, add_vectors)
insert = gen_vectors(nb, dim)
status, ids = connect.insert(collection, insert)
sleep(add_interval_time)
return add_vectors, ids
return insert, ids
"""
Test search collection with invalid collection names
@ -1022,7 +1022,7 @@ class TestSearchParamsInvalid(object):
logging.getLogger().info(collection_name)
nprobe = 1
query_vecs = gen_vectors(1, dim)
status, result = connect.search_vectors(collection_name, top_k, query_vecs)
status, result = connect.search(collection_name, top_k, query_vecs)
assert not status.OK()
@pytest.mark.level(1)
@ -1030,14 +1030,14 @@ class TestSearchParamsInvalid(object):
nprobe = 1
query_vecs = gen_vectors(1, dim)
with pytest.raises(Exception) as e:
status, result = connect.search_vectors(collection, top_k, query_vecs, partition_tags="tag")
status, result = connect.search(collection, top_k, query_vecs, partition_tags="tag")
logging.getLogger().debug(result)
@pytest.mark.level(1)
def test_search_with_tag_not_existed(self, connect, collection):
nprobe = 1
query_vecs = gen_vectors(1, dim)
status, result = connect.search_vectors(collection, top_k, query_vecs, partition_tags=["tag"])
status, result = connect.search(collection, top_k, query_vecs, partition_tags=["tag"])
logging.getLogger().info(result)
assert not status.OK()
@ -1063,11 +1063,11 @@ class TestSearchParamsInvalid(object):
nprobe = 1
query_vecs = gen_vectors(1, dim)
if isinstance(top_k, int):
status, result = connect.search_vectors(collection, top_k, query_vecs)
status, result = connect.search(collection, top_k, query_vecs)
assert not status.OK()
else:
with pytest.raises(Exception) as e:
status, result = connect.search_vectors(collection, top_k, query_vecs)
status, result = connect.search(collection, top_k, query_vecs)
@pytest.mark.level(2)
def test_search_with_invalid_top_k_ip(self, connect, ip_collection, get_top_k):
@ -1081,11 +1081,11 @@ class TestSearchParamsInvalid(object):
nprobe = 1
query_vecs = gen_vectors(1, dim)
if isinstance(top_k, int):
status, result = connect.search_vectors(ip_collection, top_k, query_vecs)
status, result = connect.search(ip_collection, top_k, query_vecs)
assert not status.OK()
else:
with pytest.raises(Exception) as e:
status, result = connect.search_vectors(ip_collection, top_k, query_vecs)
status, result = connect.search(ip_collection, top_k, query_vecs)
"""
Test search collection with invalid nprobe
"""
@ -1111,11 +1111,11 @@ class TestSearchParamsInvalid(object):
logging.getLogger().info(nprobe)
query_vecs = gen_vectors(1, dim)
# if isinstance(nprobe, int):
status, result = connect.search_vectors(collection, top_k, query_vecs, params=search_param)
status, result = connect.search(collection, top_k, query_vecs, params=search_param)
assert not status.OK()
# else:
# with pytest.raises(Exception) as e:
# status, result = connect.search_vectors(collection, top_k, query_vecs, params=search_param)
# status, result = connect.search(collection, top_k, query_vecs, params=search_param)
@pytest.mark.level(2)
def test_search_with_invalid_nprobe_ip(self, connect, ip_collection, get_nprobes):
@ -1133,11 +1133,11 @@ class TestSearchParamsInvalid(object):
query_vecs = gen_vectors(1, dim)
# if isinstance(nprobe, int):
status, result = connect.search_vectors(ip_collection, top_k, query_vecs, params=search_param)
status, result = connect.search(ip_collection, top_k, query_vecs, params=search_param)
assert not status.OK()
# else:
# with pytest.raises(Exception) as e:
# status, result = connect.search_vectors(ip_collection, top_k, query_vecs, params=search_param)
# status, result = connect.search(ip_collection, top_k, query_vecs, params=search_param)
@pytest.fixture(
scope="function",
@ -1164,7 +1164,7 @@ class TestSearchParamsInvalid(object):
index_param = get_simple_index["index_param"]
connect.create_index(collection, index_type, index_param)
query_vecs = gen_vectors(1, dim)
status, result = connect.search_vectors(collection, top_k, query_vecs, params={})
status, result = connect.search(collection, top_k, query_vecs, params={})
if index_type == IndexType.FLAT:
assert status.OK()
@ -1196,7 +1196,7 @@ class TestSearchParamsInvalid(object):
if index_type == index["index_type"]:
connect.create_index(collection, index_type, index["index_param"])
query_vecs = gen_vectors(1, dim)
status, result = connect.search_vectors(collection, top_k, query_vecs, params=search_param)
status, result = connect.search(collection, top_k, query_vecs, params=search_param)
assert not status.OK()
def check_result(result, id):

View File

@ -21,14 +21,14 @@ class TestWalBase:
******************************************************************
"""
@pytest.mark.timeout(WAL_TIMEOUT)
def test_wal_add_vectors(self, connect, collection):
def test_wal_insert(self, connect, collection):
'''
target: add vectors in WAL
method: add vectors and flush when WAL is enabled
expected: status ok, vectors added
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
assert status.OK()
@ -48,7 +48,7 @@ class TestWalBase:
expected: status ok, vectors deleted
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
connect.flush([collection])
status, res = connect.count_entities(collection)
@ -69,7 +69,7 @@ class TestWalBase:
expected: status ok, search with vector have result
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
connect.flush([collection])
status = connect.delete_entity_by_id(collection, [0])
@ -87,7 +87,7 @@ class TestWalBase:
expected: status not ok
'''
vectors = gen_vector(nb, dim)
status, ids = connect.add_vectors(collection, vectors)
status, ids = connect.insert(collection, vectors)
assert status.OK()
status = connect.flush([collection])
status = connect.delete_entity_by_id(collection, [0])
@ -109,7 +109,7 @@ class TestWalBase:
expected: status ok, add request is recovered and vectors added
'''
vector = gen_single_vector(dim)
status, ids = connect.add_vectors(collection, vector)
status, ids = connect.insert(collection, vector)
assert status.OK()
status = connect.flush([collection])
status, res = connect.count_entities(collection)

View File

@ -591,7 +591,7 @@ def gen_simple_index():
{"nlist": 1024},
{"nlist": 1024},
{"nlist": 1024, "m": 16},
{"M": 16, "efConstruction": 500},
{"M": 48, "efConstruction": 500},
{"search_length": 50, "out_degree": 40, "candidate_pool_size": 100, "knng": 50},
{"n_trees": 4}
]