From 5c53ab5c79f2776fc5654da285adb802808bee29 Mon Sep 17 00:00:00 2001 From: shoulinwei Date: Mon, 29 Apr 2024 23:05:44 +0800 Subject: [PATCH] add find refs --- csst_dfs_api_cluster/common/catalog.py | 9 ++++++++- csst_dfs_api_cluster/common/utils.py | 9 ++++++++- csst_dfs_api_cluster/facility/level1.py | 8 +++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/csst_dfs_api_cluster/common/catalog.py b/csst_dfs_api_cluster/common/catalog.py index 687c2da..a219878 100644 --- a/csst_dfs_api_cluster/common/catalog.py +++ b/csst_dfs_api_cluster/common/catalog.py @@ -31,7 +31,14 @@ class CatalogApi(object): return Result.error(message = str(resp.error.detail)) datas.flush() records = pickle.loads(datas.getvalue()) + records, cols = records[0], records[1] + columns = [] + for col in cols: + if col in columns: + columns.append("%s_1" % (col, )) + else: + columns.append(col) - return Result.ok_data(data = records).append("totalCount", totalCount).append("columns", kwargs['columns']) + return Result.ok_data(data = records).append("totalCount", totalCount).append("columns", columns) except grpc.RpcError as e: return Result.error(message="%s:%s" % (e.code().value, e.details())) diff --git a/csst_dfs_api_cluster/common/utils.py b/csst_dfs_api_cluster/common/utils.py index 691cf6a..1c1047f 100644 --- a/csst_dfs_api_cluster/common/utils.py +++ b/csst_dfs_api_cluster/common/utils.py @@ -114,8 +114,15 @@ def find_req(function, kwargs): else: records = pickle.loads(datas.getvalue()) records, cols = records[0], records[1] + columns = [] + for col in cols: + if col in columns: + columns.append("%s_1" % (col, )) + else: + columns.append(col) + return Result.ok_data(data = records).append("totalCount", totalCount)\ - .append("columns", cols) + .append("columns", columns) except grpc.RpcError as e: return Result.error(message="%s:%s" % (e.code().value, e.details())) diff --git a/csst_dfs_api_cluster/facility/level1.py b/csst_dfs_api_cluster/facility/level1.py index 238f658..02d07bf 100644 --- a/csst_dfs_api_cluster/facility/level1.py +++ b/csst_dfs_api_cluster/facility/level1.py @@ -16,7 +16,13 @@ class Level1DataApi(object): if not isinstance(get_parameter(kwargs, "brick_ids"), list): return Result.error(message="brick_ids is not a list") return find_req("Level1Servicer.FindByBrickIds", kwargs) - + + @grpc_channel + def find_refs_by_ids(self, **kwargs): + if not isinstance(get_parameter(kwargs, "ids"), list): + return Result.error(message="ids is not a list") + return find_req("Level1Servicer.FindRefsByIds", kwargs) + @grpc_channel def find_by_ids(self, **kwargs): if not isinstance(get_parameter(kwargs, "ids"), list): -- GitLab