|
@@ -25,6 +25,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
import java.util.Properties;
|
|
import java.util.Properties;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.function.Supplier;
|
|
import java.util.function.Supplier;
|
|
@@ -32,6 +33,8 @@ import java.util.function.Supplier;
|
|
/** The Milvus Client Interface */
|
|
/** The Milvus Client Interface */
|
|
public interface MilvusClient {
|
|
public interface MilvusClient {
|
|
|
|
|
|
|
|
+ String extraParamKey = "params";
|
|
|
|
+
|
|
String clientVersion = new Supplier<String>() {
|
|
String clientVersion = new Supplier<String>() {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -49,6 +52,8 @@ public interface MilvusClient {
|
|
}
|
|
}
|
|
}.get();
|
|
}.get();
|
|
|
|
|
|
|
|
+ String target();
|
|
|
|
+
|
|
/** @return current Milvus client version: 0.9.0 */
|
|
/** @return current Milvus client version: 0.9.0 */
|
|
default String getClientVersion() {
|
|
default String getClientVersion() {
|
|
return clientVersion;
|
|
return clientVersion;
|
|
@@ -83,30 +88,24 @@ public interface MilvusClient {
|
|
* Refer to <code>withFields</code> method for example <code>fields</code> usage.
|
|
* Refer to <code>withFields</code> method for example <code>fields</code> usage.
|
|
* </pre>
|
|
* </pre>
|
|
*
|
|
*
|
|
- * @return <code>Response</code>
|
|
|
|
* @see CollectionMapping
|
|
* @see CollectionMapping
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response createCollection(CollectionMapping collectionMapping);
|
|
|
|
|
|
+ void createCollection(CollectionMapping collectionMapping);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Checks whether the collection exists
|
|
* Checks whether the collection exists
|
|
*
|
|
*
|
|
* @param collectionName collection to check
|
|
* @param collectionName collection to check
|
|
- * @return <code>HasCollectionResponse</code>
|
|
|
|
- * @see HasCollectionResponse
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return true if the collection exists, false otherwise.
|
|
*/
|
|
*/
|
|
- HasCollectionResponse hasCollection(String collectionName);
|
|
|
|
|
|
+ boolean hasCollection(String collectionName);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Drops collection
|
|
* Drops collection
|
|
*
|
|
*
|
|
* @param collectionName collection to drop
|
|
* @param collectionName collection to drop
|
|
- * @return <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response dropCollection(String collectionName);
|
|
|
|
|
|
+ void dropCollection(String collectionName);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates index specified by <code>index</code>
|
|
* Creates index specified by <code>index</code>
|
|
@@ -123,11 +122,9 @@ public interface MilvusClient {
|
|
* </code>
|
|
* </code>
|
|
* </pre>
|
|
* </pre>
|
|
*
|
|
*
|
|
- * @return <code>Response</code>
|
|
|
|
* @see Index
|
|
* @see Index
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response createIndex(Index index);
|
|
|
|
|
|
+ void createIndex(Index index);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates index specified by <code>index</code> asynchronously
|
|
* Creates index specified by <code>index</code> asynchronously
|
|
@@ -146,49 +143,42 @@ public interface MilvusClient {
|
|
*
|
|
*
|
|
* @return a <code>ListenableFuture</code> object which holds the <code>Response</code>
|
|
* @return a <code>ListenableFuture</code> object which holds the <code>Response</code>
|
|
* @see Index
|
|
* @see Index
|
|
- * @see Response
|
|
|
|
* @see ListenableFuture
|
|
* @see ListenableFuture
|
|
*/
|
|
*/
|
|
- ListenableFuture<Response> createIndexAsync(Index index);
|
|
|
|
|
|
+ ListenableFuture<Void> createIndexAsync(Index index);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates a partition specified by <code>collectionName</code> and <code>tag</code>
|
|
* Creates a partition specified by <code>collectionName</code> and <code>tag</code>
|
|
*
|
|
*
|
|
* @param collectionName collection name
|
|
* @param collectionName collection name
|
|
* @param tag partition tag
|
|
* @param tag partition tag
|
|
- * @return <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response createPartition(String collectionName, String tag);
|
|
|
|
|
|
+ void createPartition(String collectionName, String tag);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Checks whether the partition exists
|
|
* Checks whether the partition exists
|
|
*
|
|
*
|
|
* @param collectionName collection name
|
|
* @param collectionName collection name
|
|
* @param tag partition tag
|
|
* @param tag partition tag
|
|
- * @return <code>HasPartitionResponse</code>
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return true if the partition exists, false otherwise.
|
|
*/
|
|
*/
|
|
- HasPartitionResponse hasPartition(String collectionName, String tag);
|
|
|
|
|
|
+ boolean hasPartition(String collectionName, String tag);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Lists current partitions of a collection
|
|
* Lists current partitions of a collection
|
|
*
|
|
*
|
|
* @param collectionName collection name
|
|
* @param collectionName collection name
|
|
- * @return <code>ListPartitionsResponse</code>
|
|
|
|
- * @see ListPartitionsResponse
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return a list of partition names
|
|
*/
|
|
*/
|
|
- ListPartitionsResponse listPartitions(String collectionName);
|
|
|
|
|
|
+ List<String> listPartitions(String collectionName);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Drops partition specified by <code>collectionName</code> and <code>tag</code>
|
|
* Drops partition specified by <code>collectionName</code> and <code>tag</code>
|
|
*
|
|
*
|
|
* @param collectionName collection name
|
|
* @param collectionName collection name
|
|
* @param tag partition tag
|
|
* @param tag partition tag
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response dropPartition(String collectionName, String tag);
|
|
|
|
|
|
+ void dropPartition(String collectionName, String tag);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Inserts data specified by <code>insertParam</code>
|
|
* Inserts data specified by <code>insertParam</code>
|
|
@@ -205,12 +195,10 @@ public interface MilvusClient {
|
|
* </code>
|
|
* </code>
|
|
* </pre>
|
|
* </pre>
|
|
*
|
|
*
|
|
- * @return <code>InsertResponse</code>
|
|
|
|
|
|
+ * @return a list of ids for the inserted entities
|
|
* @see InsertParam
|
|
* @see InsertParam
|
|
- * @see InsertResponse
|
|
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- InsertResponse insert(InsertParam insertParam);
|
|
|
|
|
|
+ List<Long> insert(InsertParam insertParam);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Inserts data specified by <code>insertParam</code> asynchronously
|
|
* Inserts data specified by <code>insertParam</code> asynchronously
|
|
@@ -227,13 +215,11 @@ public interface MilvusClient {
|
|
* </code>
|
|
* </code>
|
|
* </pre>
|
|
* </pre>
|
|
*
|
|
*
|
|
- * @return a <code>ListenableFuture</code> object which holds the <code>InsertResponse</code>
|
|
|
|
|
|
+ * @return a <code>ListenableFuture</code> object which holds the list of ids for the inserted entities.
|
|
* @see InsertParam
|
|
* @see InsertParam
|
|
- * @see InsertResponse
|
|
|
|
- * @see Response
|
|
|
|
* @see ListenableFuture
|
|
* @see ListenableFuture
|
|
*/
|
|
*/
|
|
- ListenableFuture<InsertResponse> insertAsync(InsertParam insertParam);
|
|
|
|
|
|
+ ListenableFuture<List<Long>> insertAsync(InsertParam insertParam);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Searches entities specified by <code>searchParam</code>
|
|
* Searches entities specified by <code>searchParam</code>
|
|
@@ -250,13 +236,11 @@ public interface MilvusClient {
|
|
* </code>
|
|
* </code>
|
|
* </pre>
|
|
* </pre>
|
|
*
|
|
*
|
|
- * @return <code>SearchResponse</code>
|
|
|
|
|
|
+ * @return <code>SearchResult</code>
|
|
* @see SearchParam
|
|
* @see SearchParam
|
|
- * @see SearchResponse
|
|
|
|
- * @see SearchResponse.QueryResult
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @see SearchResult
|
|
*/
|
|
*/
|
|
- SearchResponse search(SearchParam searchParam);
|
|
|
|
|
|
+ SearchResult search(SearchParam searchParam);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Searches entities specified by <code>searchParam</code> asynchronously
|
|
* Searches entities specified by <code>searchParam</code> asynchronously
|
|
@@ -273,77 +257,64 @@ public interface MilvusClient {
|
|
* </code>
|
|
* </code>
|
|
* </pre>
|
|
* </pre>
|
|
*
|
|
*
|
|
- * @return a <code>ListenableFuture</code> object which holds the <code>SearchResponse</code>
|
|
|
|
|
|
+ * @return a <code>ListenableFuture</code> object which holds the <code>SearchResult</code>
|
|
* @see SearchParam
|
|
* @see SearchParam
|
|
- * @see SearchResponse
|
|
|
|
- * @see SearchResponse.QueryResult
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @see SearchResult
|
|
* @see ListenableFuture
|
|
* @see ListenableFuture
|
|
*/
|
|
*/
|
|
- ListenableFuture<SearchResponse> searchAsync(SearchParam searchParam);
|
|
|
|
|
|
+ ListenableFuture<SearchResult> searchAsync(SearchParam searchParam);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets collection info
|
|
* Gets collection info
|
|
*
|
|
*
|
|
* @param collectionName collection to describe
|
|
* @param collectionName collection to describe
|
|
- * @return <code>GetCollectionInfoResponse</code>
|
|
|
|
- * @see GetCollectionInfoResponse
|
|
|
|
|
|
+ * @return <code>CollectionMapping</code>
|
|
* @see CollectionMapping
|
|
* @see CollectionMapping
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- GetCollectionInfoResponse getCollectionInfo(String collectionName);
|
|
|
|
|
|
+ CollectionMapping getCollectionInfo(String collectionName);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Lists current collections
|
|
* Lists current collections
|
|
*
|
|
*
|
|
- * @return <code>ListCollectionsResponse</code>
|
|
|
|
- * @see ListCollectionsResponse
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return a list of collection names
|
|
*/
|
|
*/
|
|
- ListCollectionsResponse listCollections();
|
|
|
|
|
|
+ List<String> listCollections();
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets current entity count of a collection
|
|
* Gets current entity count of a collection
|
|
*
|
|
*
|
|
* @param collectionName collection name
|
|
* @param collectionName collection name
|
|
- * @return <code>CountEntitiesResponse</code>
|
|
|
|
- * @see CountEntitiesResponse
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return a count of entities in the collection
|
|
*/
|
|
*/
|
|
- CountEntitiesResponse countEntities(String collectionName);
|
|
|
|
|
|
+ long countEntities(String collectionName);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets server status
|
|
* Gets server status
|
|
*
|
|
*
|
|
- * @return <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return a server status string
|
|
*/
|
|
*/
|
|
- Response getServerStatus();
|
|
|
|
|
|
+ String getServerStatus();
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets server version
|
|
* Gets server version
|
|
*
|
|
*
|
|
- * @return <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return a server version string.
|
|
*/
|
|
*/
|
|
- Response getServerVersion();
|
|
|
|
|
|
+ String getServerVersion();
|
|
|
|
|
|
/**
|
|
/**
|
|
* Sends a command to server
|
|
* Sends a command to server
|
|
*
|
|
*
|
|
- * @return <code>Response</code> command's response will be return in <code>message</code>
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return a message string
|
|
*/
|
|
*/
|
|
- Response command(String command);
|
|
|
|
|
|
+ String command(String command);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Pre-loads collection to memory
|
|
* Pre-loads collection to memory
|
|
*
|
|
*
|
|
* @param collectionName collection to load
|
|
* @param collectionName collection to load
|
|
- * @return <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response loadCollection(String collectionName);
|
|
|
|
|
|
+ void loadCollection(String collectionName);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Drops collection index
|
|
* Drops collection index
|
|
@@ -351,10 +322,8 @@ public interface MilvusClient {
|
|
* @param collectionName The collection to drop index.
|
|
* @param collectionName The collection to drop index.
|
|
* @param fieldName Name of the field to drop index for. If this is set to empty string,
|
|
* @param fieldName Name of the field to drop index for. If this is set to empty string,
|
|
* index of all fields in the collection will be dropped.
|
|
* index of all fields in the collection will be dropped.
|
|
- * @return <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response dropIndex(String collectionName, String fieldName);
|
|
|
|
|
|
+ void dropIndex(String collectionName, String fieldName);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Shows collection information. A collection consists of one or multiple partitions (including
|
|
* Shows collection information. A collection consists of one or multiple partitions (including
|
|
@@ -363,10 +332,8 @@ public interface MilvusClient {
|
|
* result will be returned as JSON string.
|
|
* result will be returned as JSON string.
|
|
*
|
|
*
|
|
* @param collectionName collection to show info from
|
|
* @param collectionName collection to show info from
|
|
- * @return <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response getCollectionStats(String collectionName);
|
|
|
|
|
|
+ String getCollectionStats(String collectionName);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets entities data by id array
|
|
* Gets entities data by id array
|
|
@@ -375,85 +342,71 @@ public interface MilvusClient {
|
|
* @param ids a <code>List</code> of entity ids
|
|
* @param ids a <code>List</code> of entity ids
|
|
* @param fieldNames a <code>List</code> of field names. Server will only return entity
|
|
* @param fieldNames a <code>List</code> of field names. Server will only return entity
|
|
* information for these fields.
|
|
* information for these fields.
|
|
- * @return <code>GetEntityByIDResponse</code>
|
|
|
|
- * @see GetEntityByIDResponse
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return a map of entity id to entity properties
|
|
*/
|
|
*/
|
|
- GetEntityByIDResponse getEntityByID(String collectionName, List<Long> ids, List<String> fieldNames);
|
|
|
|
|
|
+ Map<Long, Map<String, Object>> getEntityByID(String collectionName, List<Long> ids, List<String> fieldNames);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets entities data by id array
|
|
* Gets entities data by id array
|
|
*
|
|
*
|
|
* @param collectionName collection to get entities from
|
|
* @param collectionName collection to get entities from
|
|
* @param ids a <code>List</code> of entity ids
|
|
* @param ids a <code>List</code> of entity ids
|
|
- * @return <code>GetEntityByIDResponse</code>
|
|
|
|
- * @see GetEntityByIDResponse
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return a map of entity id to entity properties
|
|
*/
|
|
*/
|
|
- GetEntityByIDResponse getEntityByID(String collectionName, List<Long> ids);
|
|
|
|
|
|
+ Map<Long, Map<String, Object>> getEntityByID(String collectionName, List<Long> ids);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets all entity ids in a segment
|
|
* Gets all entity ids in a segment
|
|
*
|
|
*
|
|
* @param collectionName collection to get entity ids from
|
|
* @param collectionName collection to get entity ids from
|
|
* @param segmentId segment id in the collection
|
|
* @param segmentId segment id in the collection
|
|
- * @return <code>ListIDInSegmentResponse</code>
|
|
|
|
- * @see ListIDInSegmentResponse
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return a list of entity ids in the segment
|
|
*/
|
|
*/
|
|
- ListIDInSegmentResponse listIDInSegment(String collectionName, Long segmentId);
|
|
|
|
|
|
+ List<Long> listIDInSegment(String collectionName, Long segmentId);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Deletes data in a collection by a list of ids
|
|
* Deletes data in a collection by a list of ids
|
|
*
|
|
*
|
|
* @param collectionName collection to delete ids from
|
|
* @param collectionName collection to delete ids from
|
|
* @param ids a <code>List</code> of entity ids to delete
|
|
* @param ids a <code>List</code> of entity ids to delete
|
|
- * @return <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response deleteEntityByID(String collectionName, List<Long> ids);
|
|
|
|
|
|
+ void deleteEntityByID(String collectionName, List<Long> ids);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Flushes data in a list collections. Newly inserted or modifications on data will be visible
|
|
* Flushes data in a list collections. Newly inserted or modifications on data will be visible
|
|
* after <code>flush</code> returned
|
|
* after <code>flush</code> returned
|
|
*
|
|
*
|
|
* @param collectionNames a <code>List</code> of collections to flush
|
|
* @param collectionNames a <code>List</code> of collections to flush
|
|
- * @return <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response flush(List<String> collectionNames);
|
|
|
|
|
|
+ void flush(List<String> collectionNames);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Flushes data in a list collections asynchronously. Newly inserted or modifications on data will
|
|
* Flushes data in a list collections asynchronously. Newly inserted or modifications on data will
|
|
* be visible after <code>flush</code> returned
|
|
* be visible after <code>flush</code> returned
|
|
*
|
|
*
|
|
* @param collectionNames a <code>List</code> of collections to flush
|
|
* @param collectionNames a <code>List</code> of collections to flush
|
|
- * @return a <code>ListenableFuture</code> object which holds the <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return <code>ListenableFuture</code>
|
|
* @see ListenableFuture
|
|
* @see ListenableFuture
|
|
*/
|
|
*/
|
|
- ListenableFuture<Response> flushAsync(List<String> collectionNames);
|
|
|
|
|
|
+ ListenableFuture<Void> flushAsync(List<String> collectionNames);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Flushes data in a collection. Newly inserted or modifications on data will be visible after
|
|
* Flushes data in a collection. Newly inserted or modifications on data will be visible after
|
|
* <code>flush</code> returned
|
|
* <code>flush</code> returned
|
|
*
|
|
*
|
|
* @param collectionName name of collection to flush
|
|
* @param collectionName name of collection to flush
|
|
- * @return <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response flush(String collectionName);
|
|
|
|
|
|
+ void flush(String collectionName);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Flushes data in a collection asynchronously. Newly inserted or modifications on data will be
|
|
* Flushes data in a collection asynchronously. Newly inserted or modifications on data will be
|
|
* visible after <code>flush</code> returned
|
|
* visible after <code>flush</code> returned
|
|
*
|
|
*
|
|
* @param collectionName name of collection to flush
|
|
* @param collectionName name of collection to flush
|
|
- * @return a <code>ListenableFuture</code> object which holds the <code>Response</code>
|
|
|
|
- * @see Response
|
|
|
|
|
|
+ * @return <code>ListenableFuture</code>
|
|
* @see ListenableFuture
|
|
* @see ListenableFuture
|
|
*/
|
|
*/
|
|
- ListenableFuture<Response> flushAsync(String collectionName);
|
|
|
|
|
|
+ ListenableFuture<Void> flushAsync(String collectionName);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Compacts the collection, erasing deleted data from disk and rebuild index in background (if the
|
|
* Compacts the collection, erasing deleted data from disk and rebuild index in background (if the
|
|
@@ -470,11 +423,9 @@ public interface MilvusClient {
|
|
* </code>
|
|
* </code>
|
|
* </pre>
|
|
* </pre>
|
|
*
|
|
*
|
|
- * @return <code>Response</code>
|
|
|
|
* @see CompactParam
|
|
* @see CompactParam
|
|
- * @see Response
|
|
|
|
*/
|
|
*/
|
|
- Response compact(CompactParam compactParam);
|
|
|
|
|
|
+ void compact(CompactParam compactParam);
|
|
|
|
|
|
/**
|
|
/**
|
|
* Compacts the collection, erasing deleted data from disk and rebuild index in background (if the
|
|
* Compacts the collection, erasing deleted data from disk and rebuild index in background (if the
|
|
@@ -493,8 +444,7 @@ public interface MilvusClient {
|
|
*
|
|
*
|
|
* @return a <code>ListenableFuture</code> object which holds the <code>Response</code>
|
|
* @return a <code>ListenableFuture</code> object which holds the <code>Response</code>
|
|
* @see CompactParam
|
|
* @see CompactParam
|
|
- * @see Response
|
|
|
|
* @see ListenableFuture
|
|
* @see ListenableFuture
|
|
*/
|
|
*/
|
|
- ListenableFuture<Response> compactAsync(CompactParam compactParam);
|
|
|
|
|
|
+ ListenableFuture<Void> compactAsync(CompactParam compactParam);
|
|
}
|
|
}
|