refactor(store): integrate store grpc module#27
refactor(store): integrate store grpc module#27imbajin merged 6 commits intohugegraph:3.7.1-pd-storefrom
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Walkthrough在多个 gRPC Proto 文件中新增与调整接口:为 ScanPartitionRequest.Request 增加 batchSize 字段;新增独立的查询协议与 QueryService(含流式与非流式查询);新增 TTLCleanRequest;移除 HgStoreSession 的 Count RPC 与 Agg 消息;为 HgStoreState 增加 getPeers RPC 及相关请求/响应消息。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant QueryService
participant Store
rect rgb(235, 245, 255)
note over Client,QueryService: 双向流式查询(新)
Client->>QueryService: stream QueryRequest
QueryService->>Store: 执行扫描/索引/聚合
Store-->>QueryService: 扫描结果分批
QueryService-->>Client: stream QueryResponse(is_ok, data, is_finished)
Client-->>QueryService: 流结束
end
rect rgb(240, 255, 240)
note over Client,QueryService: 非流式查询(query0 / count)
Client->>QueryService: QueryRequest
QueryService->>Store: 执行查询/计数
Store-->>QueryService: 结果/计数
QueryService-->>Client: QueryResponse
end
sequenceDiagram
autonumber
actor Admin
participant HgStoreState
participant Partition
rect rgb(255, 248, 235)
note over Admin,HgStoreState: 获取分区 Peers(新)
Admin->>HgStoreState: getPeers(PartitionRequest{id})
HgStoreState->>Partition: 查询副本信息
Partition-->>HgStoreState: Peers 列表
HgStoreState-->>Admin: PeersResponse{peers}
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@codecov-ai-reviewer review |
This comment has been minimized.
This comment has been minimized.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (8)
hugegraph-store/hg-store-grpc/src/main/proto/graphpb.proto (1)
47-49: 新增字段命名与类型建议:batchSize → batch_size,且与全局分区类型保持一致
- 当前新增字段为 int32 batchSize = 12; 建议统一采用 protobuf 样式:snake_case,即 batch_size。
- 语义上“批大小”应非负,且在本工程其他 proto 中分区/计数多用无符号整型(例如同文件的 partition_id 为 uint32)。建议评估是否使用 uint32 并在实现侧约束范围(>0 才生效,=0 表示使用默认)。
- 另外,请明确与 Reply/seq_no 的背压与窗口语义关系:batch_size 是否仅限制每次返回的元素数,还是作为流控窗口?建议加注释避免误用。
可选修正示例(仅示意字段命名与注释,不影响已分配的 tag 12):
- int32 batchSize = 12; + // Max items per response chunk; 0 uses server default. + uint32 batch_size = 12;hugegraph-store/hg-store-grpc/src/main/proto/store_state.proto (2)
35-36: getPeers 返回类型过于宽泛,建议结构化返回当前 PeersResponse 仅有 string peers,缺乏结构化信息(如地址、角色、是否 leader、term 等)。建议返回 repeated 字段或定义 Peer 消息,便于客户端解析与演进。
示例:
-rpc getPeers(PartitionRequest) returns (PeersResponse){} +rpc getPeers(PartitionRequest) returns (PeersResponse) {}并将响应改为:
-message PeersResponse{ - string peers = 1; -} +message Peer { + string id = 1; + string address = 2; + bool is_leader = 3; +} +message PeersResponse { + repeated Peer peers = 1; +}
75-80: 分区 ID 命名与类型对齐建议
- PartitionRequest.id 为 int32,而其他文件(graphpb.proto)使用 uint32 partition_id。为避免混淆,建议统一命名为 partition_id,类型用 uint32。
应用示例(不改变 tag):
-message PartitionRequest{ - int32 id = 1; -} +message PartitionRequest { + uint32 partition_id = 1; +}hugegraph-store/hg-store-grpc/src/main/proto/query.proto (5)
26-32: RPC 命名一致性与语义清晰度
- query0 命名不直观;建议采用 query_unary 或 simple_query。
- count 与 store_session.proto 移除的 Count 流式聚合存在命名重叠语义,请确认迁移文档并避免歧义。
48-54: 枚举命名与注释不一致:NO_SCANNO_SCAN 的注释为 “only scan index”,与名称相矛盾。建议更名为 INDEX_ONLY 或修正文档,避免误导。
- NO_SCAN = 3; // only scan index + INDEX_ONLY = 3; // only scan index
55-63: ScanTypeParam 字段语义需要更明确的编码约定
- key_start/key_end/id_prefix 为 bytes,但未说明编码(大端/小端、是否包含 label/方向、是否带 code 前缀)。建议补充注释以确保多语言一致解析。
- scan_boundary/code 的取值范围与含义(闭区间/开区间)需明确。
76-114: QueryRequest 字段一致性与边界约束
- 字段编号无须递增,但 21、23、24、25 的顺序混乱,建议在注释中标注迁移历史并使用 reserved 声明空洞编号,防止未来误用。
- property 与 null_property 组合语义可能冲突(既指定属性又声明只返回 key),建议定义优先级或互斥校验。
- sample_factor 应明确取值范围 (0,1] 并在服务端校验;limit/offset 建议定义上限。
- load_property_from_index/check_ttl 的开关需说明对性能与一致性的影响。
116-123: 跨文件类型引用与包名QueryResponse.data 使用 Kv,依赖 store_common.proto。建议为 store_common.proto 增加 package 声明(例如 package common_pb;),并在引用处使用未限定名或限定名以避免冲突。同时需要确保 Java 包(option java_package)与 proto 包的区别被正确处理。
如需,我可以提交一份最小可编译的 buf.yaml/proto 包名与 import 路径修正补丁。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
hugegraph-store/hg-store-grpc/src/main/proto/graphpb.proto(1 hunks)hugegraph-store/hg-store-grpc/src/main/proto/query.proto(1 hunks)hugegraph-store/hg-store-grpc/src/main/proto/store_common.proto(1 hunks)hugegraph-store/hg-store-grpc/src/main/proto/store_session.proto(0 hunks)hugegraph-store/hg-store-grpc/src/main/proto/store_state.proto(2 hunks)
💤 Files with no reviewable changes (1)
- hugegraph-store/hg-store-grpc/src/main/proto/store_session.proto
🧰 Additional context used
🪛 Buf (1.55.1)
hugegraph-store/hg-store-grpc/src/main/proto/query.proto
20-20: import "store_common.proto": file does not exist
(COMPILE)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: pd
- GitHub Check: Analyze (java)
- GitHub Check: build-server (hbase, 11)
|
@codecov review |
|
@codecov-ai-reviewer review |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull Request Overview
This PR integrates the store gRPC module by adding a new QueryService for streaming queries and updating existing message structures. The changes support bidirectional streaming queries, TTL cleanup operations, and peer discovery functionality.
- Adds QueryService with bidirectional streaming support for queries, counts, and aggregations
- Introduces TTL cleanup functionality with new message types
- Updates existing services to support peer discovery and batch size configuration
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| store_state.proto | Adds getPeers RPC and supporting message types for partition peer discovery |
| store_session.proto | Removes Count RPC and Agg message, cleans up imports |
| store_common.proto | Adds TTLCleanRequest message for TTL cleanup operations |
| query.proto | New file defining QueryService with streaming query capabilities and comprehensive query options |
| graphpb.proto | Adds batchSize parameter to ScanPartitionRequest for batch size control |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| message PeersResponse{ | ||
| string peers = 1; |
There was a problem hiding this comment.
The 'peers' field returns a string, but peer information would be better represented as a structured format (e.g., repeated string or a structured message with host/port fields) to avoid requiring string parsing on the client side.
| message PeersResponse{ | |
| string peers = 1; | |
| message PeerInfo { | |
| string host = 1; | |
| uint32 port = 2; | |
| } | |
| message PeersResponse{ | |
| repeated PeerInfo peers = 1; |
@codecov-ai-reviewer review |
This comment has been minimized.
This comment has been minimized.
| uint32 offset = 25; // offset | ||
|
|
There was a problem hiding this comment.
The sample_factor field (line 102) should have validation constraints. Sampling factors should be between 0 and 1, and the comment should clarify this requirement. Consider using a more descriptive name like 'sampling_rate'.
| uint32 offset = 25; // offset | |
| double sampling_rate = 31; // Sampling rate between 0.0 and 1.0 (exclusive of 0, inclusive of 1) |
Did we get this right? 👍 / 👎 to inform future reviews.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
* refactor: integrate store-grpc module * ref: change comments to en * reformat&add comments --------- Co-authored-by: Copilot <[email protected]>
* refactor: integrate store-grpc module * ref: change comments to en * reformat&add comments --------- Co-authored-by: Copilot <[email protected]>
* refactor: integrate store-grpc module * ref: change comments to en * reformat&add comments --------- Co-authored-by: Copilot <[email protected]>
* refactor: integrate store-grpc module * ref: change comments to en * reformat&add comments --------- Co-authored-by: Copilot <[email protected]>
Purpose of the PR
Main Changes
Verifying these changes
Does this PR potentially affect the following parts?
Documentation Status
Doc - TODODoc - DoneDoc - No NeedSummary by CodeRabbit