Skip to content

Commit

Permalink
update: add formatted data for listPartitions like listCollections (
Browse files Browse the repository at this point in the history
#357)

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
  • Loading branch information
shanghaikid authored Sep 5, 2024
1 parent 69f2b13 commit 62c4fd4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions milvus/grpc/Partition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
formatKeyValueData,
ErrorCode,
sleep,
PartitionData,
} from '../';

export class Partition extends Index {
Expand Down Expand Up @@ -114,6 +115,16 @@ export class Partition extends Index {
data,
data.timeout || this.timeout
);
const result: PartitionData[] = [];
promise.partition_names.forEach((name: string, index: number) => {
result.push({
name,
id: promise.partitionIDs[index],
timestamp: promise.created_utc_timestamps[index],
loadedPercentage: promise.inMemory_percentages[index],
});
});
promise.data = result;
return promise;
}
showPartitions = this.listPartitions;
Expand Down
3 changes: 3 additions & 0 deletions milvus/types/Partition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ResStatus, TimeStampArray, collectionNameReq } from './Common';
import { CollectionData } from './';

interface PartitionParent extends collectionNameReq {
partition_name: string;
Expand All @@ -18,9 +19,11 @@ export interface LoadPartitionsReq extends collectionNameReq {
export interface ReleasePartitionsReq extends collectionNameReq {
partition_names: string[]; // required, partition names
}
export interface PartitionData extends CollectionData {}

export interface ShowPartitionsResponse extends TimeStampArray {
status: ResStatus;
partition_names: string[];
partitionIDs: number[];
data: PartitionData[];
}
6 changes: 6 additions & 0 deletions test/grpc/Partition.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ describe(`Partition API`, () => {
expect(list.status.error_code).toEqual(ErrorCode.SUCCESS);
expect(list.partition_names).toEqual(res.partition_names);
expect(list.partitionIDs.length).toEqual(res.partitionIDs.length);
expect(list.data.length).toEqual(res.data.length);
const resultKeys = Object.keys(list.data[0]);
expect(resultKeys).toContain('name');
expect(resultKeys).toContain('id');
expect(resultKeys).toContain('timestamp');
expect(resultKeys).toContain('loadedPercentage');
});

it(
Expand Down

0 comments on commit 62c4fd4

Please sign in to comment.