Skip to content

Commit

Permalink
add refreshLoad api (#396)
Browse files Browse the repository at this point in the history
Signed-off-by: ryjiang <[email protected]>
  • Loading branch information
shanghaikid authored Dec 25, 2024
1 parent 1a962f9 commit 6941413
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
23 changes: 23 additions & 0 deletions milvus/grpc/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
FieldSchema,
DropCollectionPropertiesReq,
AlterCollectionFieldPropertiesReq,
RefreshLoadReq,
isVectorType,
} from '../';

Expand Down Expand Up @@ -567,6 +568,28 @@ export class Collection extends Database {
return promise;
}

/**
* Refresh the loading status of a collection.
*
* @param {RefreshLoadReq} data - The request parameters.
* @param {string} data.collection_name - The name of the collection to refresh.
* @param {string} [data.db_name] - The name of the database where the collection is located.
* @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
*
* @returns {Promise<ResStatus>} The response status of the operation.
* @returns {string} status.error_code - The error code of the operation.
* @returns {string} status.reason - The reason for the error, if any.
*
* @example
* ```
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
* const resStatus = await milvusClient.refreshLoad({ collection_name: 'my_collection' });
* ```
*/
async refreshLoad(data: RefreshLoadReq): Promise<ResStatus> {
return this.loadCollectionAsync({...data, refresh: true});
}

/**
* Same function as loadCollection, but it's a synchronous function.
* Helps to ensure this collection is loaded.
Expand Down
1 change: 1 addition & 0 deletions milvus/types/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export interface LoadCollectionReq extends collectionNameReq {
load_fields?: string[]; // optional, load fields
skip_load_dynamic_field?: boolean; // optional, skip load dynamic field, default is false
}
export interface RefreshLoadReq extends collectionNameReq {}
export interface ReleaseLoadCollectionReq extends collectionNameReq {}

export interface DropCollectionReq extends collectionNameReq {}
Expand Down
8 changes: 8 additions & 0 deletions test/grpc/Collection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,14 @@ describe(`Collection API`, () => {
expect(typeof res.progress).toEqual('string'); // int64 in node is string
});

it(`refresh load on LOAD_COLLECTION_NAME_SYNC c should success`, async () => {
const res = await milvusClient.refreshLoad({
collection_name: LOAD_COLLECTION_NAME_SYNC,
db_name: 'Collection',
});
expect(res.error_code).toEqual(ErrorCode.SUCCESS);
});

it(`Get load state throw COLLECTION_NAME_IS_REQUIRED`, async () => {
try {
await milvusClient.getLoadState({} as any);
Expand Down

0 comments on commit 6941413

Please sign in to comment.