Package io.milvus.client
Class MilvusGrpcClient
- java.lang.Object
-
- io.milvus.client.MilvusGrpcClient
-
- All Implemented Interfaces:
MilvusClient
public class MilvusGrpcClient extends java.lang.Object
-
-
Field Summary
-
Fields inherited from interface io.milvus.client.MilvusClient
clientVersion
-
-
Constructor Summary
Constructors Constructor Description MilvusGrpcClient(ConnectParam connectParam)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected io.milvus.grpc.MilvusServiceGrpc.MilvusServiceBlockingStub
blockingStub()
void
close(long maxWaitSeconds)
Close this MilvusClient.Response
command(java.lang.String command)
Sends a command to serverResponse
compact(java.lang.String collectionName)
Compacts the collection, erasing deleted data from disk and rebuild index in background (if the data size after compaction is still larger than indexFileSize).com.google.common.util.concurrent.ListenableFuture<Response>
compactAsync(java.lang.String collectionName)
Compacts the collection asynchronously, erasing deleted data from disk and rebuild index in background (if the data size after compaction is still larger than indexFileSize).CountEntitiesResponse
countEntities(java.lang.String collectionName)
Gets current entity count of a collectionResponse
createCollection(CollectionMapping collectionMapping)
Creates collection specified bycollectionMapping
Response
createIndex(Index index)
Creates index specified byindex
com.google.common.util.concurrent.ListenableFuture<Response>
createIndexAsync(Index index)
Creates index specified byindex
asynchronouslyResponse
createPartition(java.lang.String collectionName, java.lang.String tag)
Creates a partition specified bycollectionName
andtag
Response
deleteEntityByID(java.lang.String collectionName, java.lang.String partitionTag, java.util.List<java.lang.Long> ids)
Deletes data in a collection by a list of idsResponse
dropCollection(java.lang.String collectionName)
Drops collectionResponse
dropIndex(java.lang.String collectionName)
Drops collection indexResponse
dropPartition(java.lang.String collectionName, java.lang.String tag)
Drops partition specified bycollectionName
andtag
Response
flush(java.lang.String collectionName)
Flushes data in a collection.Response
flush(java.util.List<java.lang.String> collectionNames)
Flushes data in a list collections.com.google.common.util.concurrent.ListenableFuture<Response>
flushAsync(java.lang.String collectionName)
Flushes data in a collection asynchronously.com.google.common.util.concurrent.ListenableFuture<Response>
flushAsync(java.util.List<java.lang.String> collectionNames)
Flushes data in a list collections asynchronously.protected io.milvus.grpc.MilvusServiceGrpc.MilvusServiceFutureStub
futureStub()
GetCollectionInfoResponse
getCollectionInfo(java.lang.String collectionName)
Gets collection infoResponse
getCollectionStats(java.lang.String collectionName)
Shows collection information.GetEntityByIDResponse
getEntityByID(java.lang.String collectionName, java.lang.String partitionTag, java.util.List<java.lang.Long> ids)
Gets vectors data by id arrayGetIndexInfoResponse
getIndexInfo(java.lang.String collectionName)
Gets collection index informationResponse
getServerStatus()
Get server statusResponse
getServerVersion()
Get server versionHasCollectionResponse
hasCollection(java.lang.String collectionName)
Checks whether the collection existsHasPartitionResponse
hasPartition(java.lang.String collectionName, java.lang.String tag)
Checks whether the partition existsInsertResponse
insert(InsertParam insertParam)
Inserts data specified byinsertParam
com.google.common.util.concurrent.ListenableFuture<InsertResponse>
insertAsync(InsertParam insertParam)
Inserts data specified byinsertParam
asynchronouslyListCollectionsResponse
listCollections()
Lists current collectionsListIDInSegmentResponse
listIDInSegment(java.lang.String collectionName, java.lang.String segmentName)
Gets all vector ids in a segmentListPartitionsResponse
listPartitions(java.lang.String collectionName)
Lists current partitions of a collectionResponse
loadCollection(java.lang.String collectionName)
Pre-loads collection to memoryResponse
loadCollection(java.lang.String collectionName, java.util.List<java.lang.String> partitionTags)
Pre-loads collection/partitions to memoryprotected boolean
maybeAvailable()
Response
releaseCollection(java.lang.String collectionName)
Release collection from memoryResponse
releaseCollection(java.lang.String collectionName, java.util.List<java.lang.String> partitionTags)
Release collection/partitions from memorySearchResponse
search(SearchParam searchParam)
Searches vectors specified bysearchParam
com.google.common.util.concurrent.ListenableFuture<SearchResponse>
searchAsync(SearchParam searchParam)
Searches vectors specified bysearchParam
asynchronouslyMilvusClient
withTimeout(long timeout, java.util.concurrent.TimeUnit timeoutUnit)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.milvus.client.MilvusClient
close, getClientVersion
-
-
-
-
Constructor Detail
-
MilvusGrpcClient
public MilvusGrpcClient(ConnectParam connectParam)
-
-
Method Detail
-
blockingStub
protected io.milvus.grpc.MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub()
-
futureStub
protected io.milvus.grpc.MilvusServiceGrpc.MilvusServiceFutureStub futureStub()
-
maybeAvailable
protected boolean maybeAvailable()
-
close
public void close(long maxWaitSeconds)
Description copied from interface:MilvusClient
Close this MilvusClient. Wait at most `maxWaitSeconds` for graceful shutdown.
-
withTimeout
public MilvusClient withTimeout(long timeout, java.util.concurrent.TimeUnit timeoutUnit)
-
createCollection
public Response createCollection(@Nonnull CollectionMapping collectionMapping)
Description copied from interface:MilvusClient
Creates collection specified bycollectionMapping
- Specified by:
createCollection
in interfaceMilvusClient
- Parameters:
collectionMapping
- theCollectionMapping
objectexample usage:
CollectionMapping collectionMapping = new CollectionMapping.Builder(collectionName, dimension) .withIndexFileSize(1024) .withMetricType(MetricType.IP) .build();
- Returns:
Response
- See Also:
CollectionMapping
,MetricType
,Response
-
hasCollection
public HasCollectionResponse hasCollection(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClient
Checks whether the collection exists- Specified by:
hasCollection
in interfaceMilvusClient
- Parameters:
collectionName
- collection to check- Returns:
HasCollectionResponse
- See Also:
HasCollectionResponse
,Response
-
dropCollection
public Response dropCollection(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClient
Drops collection- Specified by:
dropCollection
in interfaceMilvusClient
- Parameters:
collectionName
- collection to drop- Returns:
Response
- See Also:
Response
-
createIndex
public Response createIndex(@Nonnull Index index)
Description copied from interface:MilvusClient
Creates index specified byindex
- Specified by:
createIndex
in interfaceMilvusClient
- Parameters:
index
- theIndex
objectexample usage:
Index index = new Index.Builder(collectionName, IndexType.IVF_SQ8) .withParamsInJson("{\"nlist\": 16384}") .build();
- Returns:
Response
- See Also:
Index
,IndexType
,Response
-
createIndexAsync
public com.google.common.util.concurrent.ListenableFuture<Response> createIndexAsync(@Nonnull Index index)
Description copied from interface:MilvusClient
Creates index specified byindex
asynchronously- Specified by:
createIndexAsync
in interfaceMilvusClient
- Parameters:
index
- theIndex
objectexample usage:
Index index = new Index.Builder(collectionName, IndexType.IVF_SQ8) .withParamsInJson("{\"nlist\": 16384}") .build();
- Returns:
- a
ListenableFuture
object which holds theResponse
- See Also:
Index
,IndexType
,Response
,ListenableFuture
-
createPartition
public Response createPartition(java.lang.String collectionName, java.lang.String tag)
Description copied from interface:MilvusClient
Creates a partition specified bycollectionName
andtag
- Specified by:
createPartition
in interfaceMilvusClient
- Parameters:
collectionName
- collection nametag
- partition tag- Returns:
Response
- See Also:
Response
-
hasPartition
public HasPartitionResponse hasPartition(java.lang.String collectionName, java.lang.String tag)
Description copied from interface:MilvusClient
Checks whether the partition exists- Specified by:
hasPartition
in interfaceMilvusClient
- Parameters:
collectionName
- collection nametag
- partition tag- Returns:
HasPartitionResponse
- See Also:
Response
-
listPartitions
public ListPartitionsResponse listPartitions(java.lang.String collectionName)
Description copied from interface:MilvusClient
Lists current partitions of a collection- Specified by:
listPartitions
in interfaceMilvusClient
- Parameters:
collectionName
- collection name- Returns:
ListPartitionsResponse
- See Also:
ListPartitionsResponse
,Response
-
dropPartition
public Response dropPartition(java.lang.String collectionName, java.lang.String tag)
Description copied from interface:MilvusClient
Drops partition specified bycollectionName
andtag
- Specified by:
dropPartition
in interfaceMilvusClient
- Parameters:
collectionName
- collection nametag
- partition tag- See Also:
Response
-
insert
public InsertResponse insert(@Nonnull InsertParam insertParam)
Description copied from interface:MilvusClient
Inserts data specified byinsertParam
- Specified by:
insert
in interfaceMilvusClient
- Parameters:
insertParam
- theInsertParam
objectexample usage:
InsertParam insertParam = new InsertParam.Builder(collectionName) .withFloatVectors(floatVectors) .withVectorIds(vectorIds) .withPartitionTag(tag) .build();
- Returns:
InsertResponse
- See Also:
InsertParam
,InsertResponse
,Response
-
insertAsync
public com.google.common.util.concurrent.ListenableFuture<InsertResponse> insertAsync(@Nonnull InsertParam insertParam)
Description copied from interface:MilvusClient
Inserts data specified byinsertParam
asynchronously- Specified by:
insertAsync
in interfaceMilvusClient
- Parameters:
insertParam
- theInsertParam
objectexample usage:
InsertParam insertParam = new InsertParam.Builder(collectionName) .withFloatVectors(floatVectors) .withVectorIds(vectorIds) .withPartitionTag(tag) .build();
- Returns:
- a
ListenableFuture
object which holds theInsertResponse
- See Also:
InsertParam
,InsertResponse
,Response
,ListenableFuture
-
search
public SearchResponse search(@Nonnull SearchParam searchParam)
Description copied from interface:MilvusClient
Searches vectors specified bysearchParam
- Specified by:
search
in interfaceMilvusClient
- Parameters:
searchParam
- theSearchParam
objectexample usage:
SearchParam searchParam = new SearchParam.Builder(collectionName) .withFloatVectors(floatVectors) .withTopK(topK) .withPartitionTags(partitionTagsList) .withParamsInJson("{\"nprobe\": 20}") .build();
- Returns:
SearchResponse
- See Also:
SearchParam
,SearchResponse
,SearchResponse.QueryResult
,Response
-
searchAsync
public com.google.common.util.concurrent.ListenableFuture<SearchResponse> searchAsync(@Nonnull SearchParam searchParam)
Description copied from interface:MilvusClient
Searches vectors specified bysearchParam
asynchronously- Specified by:
searchAsync
in interfaceMilvusClient
- Parameters:
searchParam
- theSearchParam
objectexample usage:
SearchParam searchParam = new SearchParam.Builder(collectionName) .withFloatVectors(floatVectors) .withTopK(topK) .withPartitionTags(partitionTagsList) .withParamsInJson("{\"nprobe\": 20}") .build();
- Returns:
- a
ListenableFuture
object which holds theSearchResponse
- See Also:
SearchParam
,SearchResponse
,SearchResponse.QueryResult
,Response
,ListenableFuture
-
getCollectionInfo
public GetCollectionInfoResponse getCollectionInfo(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClient
Gets collection info- Specified by:
getCollectionInfo
in interfaceMilvusClient
- Parameters:
collectionName
- collection to describe- See Also:
GetCollectionInfoResponse
,CollectionMapping
,Response
-
listCollections
public ListCollectionsResponse listCollections()
Description copied from interface:MilvusClient
Lists current collections- Specified by:
listCollections
in interfaceMilvusClient
- Returns:
ListCollectionsResponse
- See Also:
ListCollectionsResponse
,Response
-
countEntities
public CountEntitiesResponse countEntities(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClient
Gets current entity count of a collection- Specified by:
countEntities
in interfaceMilvusClient
- Parameters:
collectionName
- collection to count entities- Returns:
CountEntitiesResponse
- See Also:
CountEntitiesResponse
,Response
-
getServerStatus
public Response getServerStatus()
Description copied from interface:MilvusClient
Get server status- Specified by:
getServerStatus
in interfaceMilvusClient
- Returns:
Response
- See Also:
Response
-
getServerVersion
public Response getServerVersion()
Description copied from interface:MilvusClient
Get server version- Specified by:
getServerVersion
in interfaceMilvusClient
- Returns:
Response
- See Also:
Response
-
command
public Response command(@Nonnull java.lang.String command)
Description copied from interface:MilvusClient
Sends a command to server- Specified by:
command
in interfaceMilvusClient
- Returns:
Response
command's response will be return inmessage
- See Also:
Response
-
loadCollection
public Response loadCollection(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClient
Pre-loads collection to memory- Specified by:
loadCollection
in interfaceMilvusClient
- Parameters:
collectionName
- collection to load- Returns:
Response
- See Also:
Response
-
loadCollection
public Response loadCollection(@Nonnull java.lang.String collectionName, java.util.List<java.lang.String> partitionTags)
Description copied from interface:MilvusClient
Pre-loads collection/partitions to memory- Specified by:
loadCollection
in interfaceMilvusClient
- Parameters:
collectionName
- collection to loadpartitionTags
- partitions to load- Returns:
Response
- See Also:
Response
-
releaseCollection
public Response releaseCollection(java.lang.String collectionName)
Description copied from interface:MilvusClient
Release collection from memory- Specified by:
releaseCollection
in interfaceMilvusClient
- Parameters:
collectionName
- collection to release- Returns:
Response
- See Also:
Response
-
releaseCollection
public Response releaseCollection(java.lang.String collectionName, java.util.List<java.lang.String> partitionTags)
Description copied from interface:MilvusClient
Release collection/partitions from memory- Specified by:
releaseCollection
in interfaceMilvusClient
- Parameters:
collectionName
- collection to releasepartitionTags
- partitions to release- Returns:
Response
- See Also:
Response
-
getIndexInfo
public GetIndexInfoResponse getIndexInfo(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClient
Gets collection index information- Specified by:
getIndexInfo
in interfaceMilvusClient
- Parameters:
collectionName
- collection to get info from- See Also:
GetIndexInfoResponse
,Index
,Response
-
dropIndex
public Response dropIndex(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClient
Drops collection index- Specified by:
dropIndex
in interfaceMilvusClient
- Parameters:
collectionName
- collection to drop index of- Returns:
Response
- See Also:
Response
-
getCollectionStats
public Response getCollectionStats(java.lang.String collectionName)
Description copied from interface:MilvusClient
Shows collection information. A collection consists of one or multiple partitions (including the default partition), and a partitions consists of one or more segments. Each partition or segment can be uniquely identified by its partition tag or segment name respectively. The result will be returned as JSON string.- Specified by:
getCollectionStats
in interfaceMilvusClient
- Parameters:
collectionName
- collection to show info from- Returns:
Response
- See Also:
Response
-
getEntityByID
public GetEntityByIDResponse getEntityByID(java.lang.String collectionName, java.lang.String partitionTag, java.util.List<java.lang.Long> ids)
Description copied from interface:MilvusClient
Gets vectors data by id array- Specified by:
getEntityByID
in interfaceMilvusClient
- Parameters:
collectionName
- collection to get vectors frompartitionTag
- partition to get vectors fromids
- aList
of vector ids- Returns:
GetEntityByIDResponse
- See Also:
GetEntityByIDResponse
,Response
-
listIDInSegment
public ListIDInSegmentResponse listIDInSegment(java.lang.String collectionName, java.lang.String segmentName)
Description copied from interface:MilvusClient
Gets all vector ids in a segment- Specified by:
listIDInSegment
in interfaceMilvusClient
- Parameters:
collectionName
- collection to get vector ids fromsegmentName
- segment name in the collection- Returns:
ListIDInSegmentResponse
- See Also:
ListIDInSegmentResponse
,Response
-
deleteEntityByID
public Response deleteEntityByID(java.lang.String collectionName, java.lang.String partitionTag, java.util.List<java.lang.Long> ids)
Description copied from interface:MilvusClient
Deletes data in a collection by a list of ids- Specified by:
deleteEntityByID
in interfaceMilvusClient
- Parameters:
collectionName
- collection to delete ids frompartitionTag
- partition to delete ids fromids
- aList
of vector ids to delete- Returns:
Response
- See Also:
Response
-
flush
public Response flush(java.util.List<java.lang.String> collectionNames)
Description copied from interface:MilvusClient
Flushes data in a list collections. Newly inserted or modifications on data will be visible afterflush
returned- Specified by:
flush
in interfaceMilvusClient
- Parameters:
collectionNames
- aList
of collections to flush- Returns:
Response
- See Also:
Response
-
flushAsync
public com.google.common.util.concurrent.ListenableFuture<Response> flushAsync(@Nonnull java.util.List<java.lang.String> collectionNames)
Description copied from interface:MilvusClient
Flushes data in a list collections asynchronously. Newly inserted or modifications on data will be visible afterflush
returned- Specified by:
flushAsync
in interfaceMilvusClient
- Parameters:
collectionNames
- aList
of collections to flush- Returns:
- a
ListenableFuture
object which holds theResponse
- See Also:
Response
,ListenableFuture
-
flush
public Response flush(java.lang.String collectionName)
Description copied from interface:MilvusClient
Flushes data in a collection. Newly inserted or modifications on data will be visible afterflush
returned- Specified by:
flush
in interfaceMilvusClient
- Parameters:
collectionName
- name of collection to flush- Returns:
Response
- See Also:
Response
-
flushAsync
public com.google.common.util.concurrent.ListenableFuture<Response> flushAsync(java.lang.String collectionName)
Description copied from interface:MilvusClient
Flushes data in a collection asynchronously. Newly inserted or modifications on data will be visible afterflush
returned- Specified by:
flushAsync
in interfaceMilvusClient
- Parameters:
collectionName
- name of collection to flush- Returns:
- a
ListenableFuture
object which holds theResponse
- See Also:
Response
,ListenableFuture
-
compact
public Response compact(java.lang.String collectionName)
Description copied from interface:MilvusClient
Compacts the collection, erasing deleted data from disk and rebuild index in background (if the data size after compaction is still larger than indexFileSize). Data was only soft-deleted until you call compact.- Specified by:
compact
in interfaceMilvusClient
- Parameters:
collectionName
- name of collection to compact- Returns:
Response
- See Also:
Response
-
compactAsync
public com.google.common.util.concurrent.ListenableFuture<Response> compactAsync(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClient
Compacts the collection asynchronously, erasing deleted data from disk and rebuild index in background (if the data size after compaction is still larger than indexFileSize). Data was only soft-deleted until you call compact.- Specified by:
compactAsync
in interfaceMilvusClient
- Parameters:
collectionName
- name of collection to compact- Returns:
- a
ListenableFuture
object which holds theResponse
- See Also:
Response
,ListenableFuture
-
-