|
@@ -895,6 +895,21 @@ class MilvusClientDockerTest {
|
|
List<Long> ids2 = insertResultWrapper.getLongIDs(); // get returned IDs(generated by server-side)
|
|
List<Long> ids2 = insertResultWrapper.getLongIDs(); // get returned IDs(generated by server-side)
|
|
Assertions.assertEquals(rowCount, ids2.size());
|
|
Assertions.assertEquals(rowCount, ids2.size());
|
|
|
|
|
|
|
|
+ // insert test vector, position() is zero with ByteBuffer.wrap()
|
|
|
|
+ byte[] byteArray = new byte[DIMENSION/8];
|
|
|
|
+ for (int i = 0; i < byteArray.length; i++) {
|
|
|
|
+ byteArray[i] = (byte) ((i%3 == 0) ? 255 : 0);
|
|
|
|
+ }
|
|
|
|
+ ByteBuffer testBuffer = ByteBuffer.wrap(byteArray);
|
|
|
|
+ List<InsertParam.Field> testData =
|
|
|
|
+ Collections.singletonList(new InsertParam.Field(DataType.BinaryVector.name(), Collections.singletonList(testBuffer)));
|
|
|
|
+ R<MutationResult> insertR3 = client.insert(InsertParam.newBuilder()
|
|
|
|
+ .withCollectionName(randomCollectionName)
|
|
|
|
+ .withFields(testData)
|
|
|
|
+ .build());
|
|
|
|
+ insertResultWrapper = new MutationResultWrapper(insertR3.getData());
|
|
|
|
+ Long testID = insertResultWrapper.getLongIDs().get(0);
|
|
|
|
+
|
|
// get collection statistics
|
|
// get collection statistics
|
|
R<GetCollectionStatisticsResponse> statR = client.getCollectionStatistics(GetCollectionStatisticsParam
|
|
R<GetCollectionStatisticsResponse> statR = client.getCollectionStatistics(GetCollectionStatisticsParam
|
|
.newBuilder()
|
|
.newBuilder()
|
|
@@ -905,7 +920,7 @@ class MilvusClientDockerTest {
|
|
|
|
|
|
GetCollStatResponseWrapper stat = new GetCollStatResponseWrapper(statR.getData());
|
|
GetCollStatResponseWrapper stat = new GetCollStatResponseWrapper(statR.getData());
|
|
System.out.println("Collection row count: " + stat.getRowCount());
|
|
System.out.println("Collection row count: " + stat.getRowCount());
|
|
- Assertions.assertEquals(2*rowCount, stat.getRowCount());
|
|
|
|
|
|
+ Assertions.assertEquals(2*rowCount+1, stat.getRowCount());
|
|
|
|
|
|
// check index
|
|
// check index
|
|
while(true) {
|
|
while(true) {
|
|
@@ -927,8 +942,8 @@ class MilvusClientDockerTest {
|
|
Assertions.assertEquals(DataType.BinaryVector.name(), indexDesc.getFieldName());
|
|
Assertions.assertEquals(DataType.BinaryVector.name(), indexDesc.getFieldName());
|
|
Assertions.assertEquals(IndexType.BIN_IVF_FLAT, indexDesc.getIndexType());
|
|
Assertions.assertEquals(IndexType.BIN_IVF_FLAT, indexDesc.getIndexType());
|
|
Assertions.assertEquals(MetricType.JACCARD, indexDesc.getMetricType());
|
|
Assertions.assertEquals(MetricType.JACCARD, indexDesc.getMetricType());
|
|
- Assertions.assertEquals(2*rowCount, indexDesc.getTotalRows());
|
|
|
|
- Assertions.assertEquals(2*rowCount, indexDesc.getIndexedRows());
|
|
|
|
|
|
+ Assertions.assertEquals(2*rowCount+1, indexDesc.getTotalRows());
|
|
|
|
+ Assertions.assertEquals(2*rowCount+1, indexDesc.getIndexedRows());
|
|
Assertions.assertEquals(0L, indexDesc.getPendingIndexRows());
|
|
Assertions.assertEquals(0L, indexDesc.getPendingIndexRows());
|
|
Assertions.assertTrue(indexDesc.getIndexFailedReason().isEmpty());
|
|
Assertions.assertTrue(indexDesc.getIndexFailedReason().isEmpty());
|
|
System.out.println("Index description: " + indexDesc);
|
|
System.out.println("Index description: " + indexDesc);
|
|
@@ -1026,6 +1041,8 @@ class MilvusClientDockerTest {
|
|
targetVectorIDs.add(ids1.get(i));
|
|
targetVectorIDs.add(ids1.get(i));
|
|
targetVectors.add((ByteBuffer) columnsData.get(0).getValues().get(i));
|
|
targetVectors.add((ByteBuffer) columnsData.get(0).getValues().get(i));
|
|
}
|
|
}
|
|
|
|
+ targetVectors.add(testBuffer);
|
|
|
|
+ targetVectorIDs.add(testID);
|
|
|
|
|
|
int topK = 5;
|
|
int topK = 5;
|
|
SearchParam searchParam = SearchParam.newBuilder()
|
|
SearchParam searchParam = SearchParam.newBuilder()
|
|
@@ -1035,6 +1052,7 @@ class MilvusClientDockerTest {
|
|
.withBinaryVectors(targetVectors)
|
|
.withBinaryVectors(targetVectors)
|
|
.withVectorFieldName(DataType.BinaryVector.name())
|
|
.withVectorFieldName(DataType.BinaryVector.name())
|
|
.withParams("{\"nprobe\":8}")
|
|
.withParams("{\"nprobe\":8}")
|
|
|
|
+ .withOutFields(Collections.singletonList(DataType.BinaryVector.name()))
|
|
.build();
|
|
.build();
|
|
|
|
|
|
R<SearchResults> searchR = client.search(searchParam);
|
|
R<SearchResults> searchR = client.search(searchParam);
|
|
@@ -1048,6 +1066,8 @@ class MilvusClientDockerTest {
|
|
System.out.println("The result of No." + i + " target vector(ID = " + targetVectorIDs.get(i) + "):");
|
|
System.out.println("The result of No." + i + " target vector(ID = " + targetVectorIDs.get(i) + "):");
|
|
System.out.println(scores);
|
|
System.out.println(scores);
|
|
Assertions.assertEquals(targetVectorIDs.get(i), scores.get(0).getLongID());
|
|
Assertions.assertEquals(targetVectorIDs.get(i), scores.get(0).getLongID());
|
|
|
|
+ ByteBuffer buf = (ByteBuffer) scores.get(0).get(DataType.BinaryVector.name());
|
|
|
|
+ Assertions.assertArrayEquals(targetVectors.get(i).array(), buf.array());
|
|
}
|
|
}
|
|
|
|
|
|
// drop collection
|
|
// drop collection
|