From 62c4fd401e44440c708ec8d81804ce0ed9515aae Mon Sep 17 00:00:00 2001 From: ryjiang Date: Thu, 5 Sep 2024 14:19:42 +0800 Subject: [PATCH] update: add formatted data for `listPartitions` like `listCollections` (#357) Signed-off-by: ryjiang --- milvus/grpc/Partition.ts | 11 +++++++++++ milvus/types/Partition.ts | 3 +++ test/grpc/Partition.spec.ts | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/milvus/grpc/Partition.ts b/milvus/grpc/Partition.ts index 023debe6..5c6cdffd 100644 --- a/milvus/grpc/Partition.ts +++ b/milvus/grpc/Partition.ts @@ -18,6 +18,7 @@ import { formatKeyValueData, ErrorCode, sleep, + PartitionData, } from '../'; export class Partition extends Index { @@ -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; diff --git a/milvus/types/Partition.ts b/milvus/types/Partition.ts index 833a2a4c..bd8435fe 100644 --- a/milvus/types/Partition.ts +++ b/milvus/types/Partition.ts @@ -1,4 +1,5 @@ import { ResStatus, TimeStampArray, collectionNameReq } from './Common'; +import { CollectionData } from './'; interface PartitionParent extends collectionNameReq { partition_name: string; @@ -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[]; } diff --git a/test/grpc/Partition.spec.ts b/test/grpc/Partition.spec.ts index 78907822..259c25bb 100644 --- a/test/grpc/Partition.spec.ts +++ b/test/grpc/Partition.spec.ts @@ -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(