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.MilvusServiceBlockingStubblockingStub()voidclose(long maxWaitSeconds)Close this MilvusClient.Responsecommand(java.lang.String command)Sends a command to serverResponsecompact(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).CountEntitiesResponsecountEntities(java.lang.String collectionName)Gets current entity count of a collectionResponsecreateCollection(CollectionMapping collectionMapping)Creates collection specified bycollectionMappingResponsecreateIndex(Index index)Creates index specified byindexcom.google.common.util.concurrent.ListenableFuture<Response>createIndexAsync(Index index)Creates index specified byindexasynchronouslyResponsecreatePartition(java.lang.String collectionName, java.lang.String tag)Creates a partition specified bycollectionNameandtagResponsedeleteEntityByID(java.lang.String collectionName, java.lang.String partitionTag, java.util.List<java.lang.Long> ids)Deletes data in a collection by a list of idsResponsedropCollection(java.lang.String collectionName)Drops collectionResponsedropIndex(java.lang.String collectionName)Drops collection indexResponsedropPartition(java.lang.String collectionName, java.lang.String tag)Drops partition specified bycollectionNameandtagResponseflush(java.lang.String collectionName)Flushes data in a collection.Responseflush(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.MilvusServiceFutureStubfutureStub()GetCollectionInfoResponsegetCollectionInfo(java.lang.String collectionName)Gets collection infoResponsegetCollectionStats(java.lang.String collectionName)Shows collection information.GetEntityByIDResponsegetEntityByID(java.lang.String collectionName, java.lang.String partitionTag, java.util.List<java.lang.Long> ids)Gets vectors data by id arrayGetIndexInfoResponsegetIndexInfo(java.lang.String collectionName)Gets collection index informationResponsegetServerStatus()Get server statusResponsegetServerVersion()Get server versionHasCollectionResponsehasCollection(java.lang.String collectionName)Checks whether the collection existsHasPartitionResponsehasPartition(java.lang.String collectionName, java.lang.String tag)Checks whether the partition existsInsertResponseinsert(InsertParam insertParam)Inserts data specified byinsertParamcom.google.common.util.concurrent.ListenableFuture<InsertResponse>insertAsync(InsertParam insertParam)Inserts data specified byinsertParamasynchronouslyListCollectionsResponselistCollections()Lists current collectionsListIDInSegmentResponselistIDInSegment(java.lang.String collectionName, java.lang.String segmentName)Gets all vector ids in a segmentListPartitionsResponselistPartitions(java.lang.String collectionName)Lists current partitions of a collectionResponseloadCollection(java.lang.String collectionName)Pre-loads collection to memoryResponseloadCollection(java.lang.String collectionName, java.util.List<java.lang.String> partitionTags)Pre-loads collection/partitions to memoryprotected booleanmaybeAvailable()ResponsereleaseCollection(java.lang.String collectionName)Release collection from memoryResponsereleaseCollection(java.lang.String collectionName, java.util.List<java.lang.String> partitionTags)Release collection/partitions from memorySearchResponsesearch(SearchParam searchParam)Searches vectors specified bysearchParamcom.google.common.util.concurrent.ListenableFuture<SearchResponse>searchAsync(SearchParam searchParam)Searches vectors specified bysearchParamasynchronouslyMilvusClientwithTimeout(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:MilvusClientClose 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:MilvusClientCreates collection specified bycollectionMapping- Specified by:
createCollectionin interfaceMilvusClient- Parameters:
collectionMapping- theCollectionMappingobjectexample 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:MilvusClientChecks whether the collection exists- Specified by:
hasCollectionin 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:MilvusClientDrops collection- Specified by:
dropCollectionin interfaceMilvusClient- Parameters:
collectionName- collection to drop- Returns:
Response- See Also:
Response
-
createIndex
public Response createIndex(@Nonnull Index index)
Description copied from interface:MilvusClientCreates index specified byindex- Specified by:
createIndexin interfaceMilvusClient- Parameters:
index- theIndexobjectexample 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:MilvusClientCreates index specified byindexasynchronously- Specified by:
createIndexAsyncin interfaceMilvusClient- Parameters:
index- theIndexobjectexample usage:
Index index = new Index.Builder(collectionName, IndexType.IVF_SQ8) .withParamsInJson("{\"nlist\": 16384}") .build();- Returns:
- a
ListenableFutureobject 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:MilvusClientCreates a partition specified bycollectionNameandtag- Specified by:
createPartitionin 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:MilvusClientChecks whether the partition exists- Specified by:
hasPartitionin interfaceMilvusClient- Parameters:
collectionName- collection nametag- partition tag- Returns:
HasPartitionResponse- See Also:
Response
-
listPartitions
public ListPartitionsResponse listPartitions(java.lang.String collectionName)
Description copied from interface:MilvusClientLists current partitions of a collection- Specified by:
listPartitionsin 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:MilvusClientDrops partition specified bycollectionNameandtag- Specified by:
dropPartitionin interfaceMilvusClient- Parameters:
collectionName- collection nametag- partition tag- See Also:
Response
-
insert
public InsertResponse insert(@Nonnull InsertParam insertParam)
Description copied from interface:MilvusClientInserts data specified byinsertParam- Specified by:
insertin interfaceMilvusClient- Parameters:
insertParam- theInsertParamobjectexample 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:MilvusClientInserts data specified byinsertParamasynchronously- Specified by:
insertAsyncin interfaceMilvusClient- Parameters:
insertParam- theInsertParamobjectexample usage:
InsertParam insertParam = new InsertParam.Builder(collectionName) .withFloatVectors(floatVectors) .withVectorIds(vectorIds) .withPartitionTag(tag) .build();- Returns:
- a
ListenableFutureobject which holds theInsertResponse - See Also:
InsertParam,InsertResponse,Response,ListenableFuture
-
search
public SearchResponse search(@Nonnull SearchParam searchParam)
Description copied from interface:MilvusClientSearches vectors specified bysearchParam- Specified by:
searchin interfaceMilvusClient- Parameters:
searchParam- theSearchParamobjectexample 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:MilvusClientSearches vectors specified bysearchParamasynchronously- Specified by:
searchAsyncin interfaceMilvusClient- Parameters:
searchParam- theSearchParamobjectexample usage:
SearchParam searchParam = new SearchParam.Builder(collectionName) .withFloatVectors(floatVectors) .withTopK(topK) .withPartitionTags(partitionTagsList) .withParamsInJson("{\"nprobe\": 20}") .build();- Returns:
- a
ListenableFutureobject which holds theSearchResponse - See Also:
SearchParam,SearchResponse,SearchResponse.QueryResult,Response,ListenableFuture
-
getCollectionInfo
public GetCollectionInfoResponse getCollectionInfo(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClientGets collection info- Specified by:
getCollectionInfoin interfaceMilvusClient- Parameters:
collectionName- collection to describe- See Also:
GetCollectionInfoResponse,CollectionMapping,Response
-
listCollections
public ListCollectionsResponse listCollections()
Description copied from interface:MilvusClientLists current collections- Specified by:
listCollectionsin interfaceMilvusClient- Returns:
ListCollectionsResponse- See Also:
ListCollectionsResponse,Response
-
countEntities
public CountEntitiesResponse countEntities(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClientGets current entity count of a collection- Specified by:
countEntitiesin interfaceMilvusClient- Parameters:
collectionName- collection to count entities- Returns:
CountEntitiesResponse- See Also:
CountEntitiesResponse,Response
-
getServerStatus
public Response getServerStatus()
Description copied from interface:MilvusClientGet server status- Specified by:
getServerStatusin interfaceMilvusClient- Returns:
Response- See Also:
Response
-
getServerVersion
public Response getServerVersion()
Description copied from interface:MilvusClientGet server version- Specified by:
getServerVersionin interfaceMilvusClient- Returns:
Response- See Also:
Response
-
command
public Response command(@Nonnull java.lang.String command)
Description copied from interface:MilvusClientSends a command to server- Specified by:
commandin interfaceMilvusClient- Returns:
Responsecommand's response will be return inmessage- See Also:
Response
-
loadCollection
public Response loadCollection(@Nonnull java.lang.String collectionName)
Description copied from interface:MilvusClientPre-loads collection to memory- Specified by:
loadCollectionin 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:MilvusClientPre-loads collection/partitions to memory- Specified by:
loadCollectionin 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:MilvusClientRelease collection from memory- Specified by:
releaseCollectionin 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:MilvusClientRelease collection/partitions from memory- Specified by:
releaseCollectionin 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:MilvusClientGets collection index information- Specified by:
getIndexInfoin 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:MilvusClientDrops collection index- Specified by:
dropIndexin 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:MilvusClientShows 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:
getCollectionStatsin 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:MilvusClientGets vectors data by id array- Specified by:
getEntityByIDin interfaceMilvusClient- Parameters:
collectionName- collection to get vectors frompartitionTag- partition to get vectors fromids- aListof vector ids- Returns:
GetEntityByIDResponse- See Also:
GetEntityByIDResponse,Response
-
listIDInSegment
public ListIDInSegmentResponse listIDInSegment(java.lang.String collectionName, java.lang.String segmentName)
Description copied from interface:MilvusClientGets all vector ids in a segment- Specified by:
listIDInSegmentin 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:MilvusClientDeletes data in a collection by a list of ids- Specified by:
deleteEntityByIDin interfaceMilvusClient- Parameters:
collectionName- collection to delete ids frompartitionTag- partition to delete ids fromids- aListof vector ids to delete- Returns:
Response- See Also:
Response
-
flush
public Response flush(java.util.List<java.lang.String> collectionNames)
Description copied from interface:MilvusClientFlushes data in a list collections. Newly inserted or modifications on data will be visible afterflushreturned- Specified by:
flushin interfaceMilvusClient- Parameters:
collectionNames- aListof 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:MilvusClientFlushes data in a list collections asynchronously. Newly inserted or modifications on data will be visible afterflushreturned- Specified by:
flushAsyncin interfaceMilvusClient- Parameters:
collectionNames- aListof collections to flush- Returns:
- a
ListenableFutureobject which holds theResponse - See Also:
Response,ListenableFuture
-
flush
public Response flush(java.lang.String collectionName)
Description copied from interface:MilvusClientFlushes data in a collection. Newly inserted or modifications on data will be visible afterflushreturned- Specified by:
flushin 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:MilvusClientFlushes data in a collection asynchronously. Newly inserted or modifications on data will be visible afterflushreturned- Specified by:
flushAsyncin interfaceMilvusClient- Parameters:
collectionName- name of collection to flush- Returns:
- a
ListenableFutureobject which holds theResponse - See Also:
Response,ListenableFuture
-
compact
public Response compact(java.lang.String collectionName)
Description copied from interface:MilvusClientCompacts 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:
compactin 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:MilvusClientCompacts 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:
compactAsyncin interfaceMilvusClient- Parameters:
collectionName- name of collection to compact- Returns:
- a
ListenableFutureobject which holds theResponse - See Also:
Response,ListenableFuture
-
-