From 0060a33d692d87c5dc4391e085fa59ba7762f599 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 08:45:05 +0000 Subject: [PATCH] =?UTF-8?q?style(grid-db):=20address=20code=20review=20?= =?UTF-8?q?=E2=80=94=20rename=20constant,=20improve=20BTree=20comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- grid-db/src/core/namespace.js | 4 ++-- grid-db/src/index/btree.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grid-db/src/core/namespace.js b/grid-db/src/core/namespace.js index c86fd116..82bbc8ab 100644 --- a/grid-db/src/core/namespace.js +++ b/grid-db/src/core/namespace.js @@ -16,7 +16,7 @@ * 命名空间名称规则:非空字符串,仅允许字母、数字、连字符、下划线。 */ -const NAME_PATTERN = /^[a-zA-Z0-9_-]+$/; +const NAMESPACE_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/; class NamespaceManager { /** @@ -128,7 +128,7 @@ class NamespaceManager { if (!name || typeof name !== 'string') { throw new Error('NamespaceManager: 命名空间名称必须是非空字符串'); } - if (!NAME_PATTERN.test(name)) { + if (!NAMESPACE_NAME_PATTERN.test(name)) { throw new Error(`NamespaceManager: 命名空间名称只能包含字母、数字、连字符和下划线,收到: '${name}'`); } } diff --git a/grid-db/src/index/btree.js b/grid-db/src/index/btree.js index 3d8ad26a..31ff63cb 100644 --- a/grid-db/src/index/btree.js +++ b/grid-db/src/index/btree.js @@ -258,7 +258,7 @@ class BTree { const newNode = new BTreeNode(child.isLeaf); if (child.isLeaf) { - // 叶子节点分裂:右半部分复制到新节点,提升中间键的副本 + // 叶子节点分裂:splice 从 mid 处截断 child,返回值作为 newNode 内容 newNode.keys = child.keys.splice(mid); newNode.children = child.children.splice(mid);