[Improve]: clarify ConditionQuery.condition() semantics for missing, conflicting, and multi-value conditions
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với ConditionQuery.condition(Object key), sau đó kiểm tra các caller được liệt kê: GraphTransaction.constructEdgesQuery(), GraphTransaction.matchPartialEdgeSortKeys(), GraphIndexTransaction.queryByLabel(), BinarySerializer.writeQueryEdgePrefix() và HugeTraverser. So sánh caller nào cần các điều kiện thô và caller nào cần một label được resolve duy nhất, sử dụng #2933 và PR #2990 làm ngữ cảnh. Được xem là hoàn thành khi API contract phân biệt được các kết quả absent, unique, empty và multiple, đồng thời các caller không còn dựa vào ngữ nghĩa null mơ hồ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Background
While fixing #2933, we found that ConditionQuery.condition() currently mixes multiple different semantics into a single API.
The immediate bug in #2933 has been fixed separately, but this method still has unclear behavior boundaries and several callers implicitly rely on assumptions that are not obvious from the method contract.
Current behavior
ConditionQuery.condition(Object key) may currently produce different kinds of results depending on how conditions are stored:
-
Return
null- when there is no condition for the given key
-
Return
null- when conditions exist for the key, but the intersection becomes empty
-
Return a single value
- for example, a single
EQ
- for example, a single
-
Return the whole
INlist- when there is one
INcondition and noEQ
- when there is one
-
Throw
IllegalStateException- when the intersection still contains multiple candidates
That means the same method is currently used for:
- raw condition lookup
- unique-value extraction
- empty-intersection signaling
- multi-value conflict signaling
Why this is a problem
These states are semantically different, but the API does not distinguish them clearly.
For example:
ConditionQuery q1 = new ConditionQuery(HugeType.EDGE);
// no LABEL condition
ConditionQuery q2 = new ConditionQuery(HugeType.EDGE);
q2.eq(HugeKeys.LABEL, label1);
q2.eq(HugeKeys.LABEL, label2);
// conflicting LABEL conditions, intersection is empty
Both of these may currently lead to:
q1.condition(HugeKeys.LABEL) == null
q2.condition(HugeKeys.LABEL) == null
But they do not mean the same thing:
q1: no such condition existsq2: the condition exists, but it is contradictory
Also, for LABEL, the method can return a raw IN list in some cases, even though many callers use it as if it were always either a unique Id or null.
Evidence in current code
LABEL can be stored as IN
Multi-label edge queries are constructed like this:
query.query(Condition.in(HugeKeys.LABEL, edgeLabels));
See:
GraphTransaction.constructEdgesQuery(...)
many callers assume unique label or null
Examples:
GraphTransaction.matchPartialEdgeSortKeys(...)GraphIndexTransaction.queryByLabel(...)BinarySerializer.writeQueryEdgePrefix(...)HugeTraverser
These call sites typically do:
Id label = query.condition(HugeKeys.LABEL);
which means they implicitly expect condition(HugeKeys.LABEL) to behave like a "resolved unique label" API, not a raw condition accessor.
Suggested direction
This issue is not about changing behavior immediately in a bugfix PR. It is about clarifying and improving the API contract.
Possible follow-up directions:
-
Split responsibilities into different APIs
- one API for raw condition retrieval
- one API for unique-value resolution / intersection result
-
Introduce an explicit result type
- absent
- unique value
- empty intersection
- multiple values
-
Audit call sites of
condition(HugeKeys.LABEL)- identify which ones want raw values
- identify which ones want a unique resolved label
- remove reliance on ambiguous
nullsemantics
Scope
This issue is a follow-up design / refactor task exposed by the fix for #2933.
Related:
- #2933
- PR #2990
I’d be happy to follow up on this as a separate improvement issue and work on a later refinement PR.
- Ngôn ngữ chính
- Java
- Star
- 3.2k
- Fork
- 641
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 74
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/hugegraph
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
apache/hugegraph#3231 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
help wanted improvement rust
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] CI accepts obsolete PR targets after retargeting or force-pushCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/hugegraph
Issue tương tự
-
StepExamBenchmarkTest runs a loop and prints a timing but asserts nothingCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởjules
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
open-learning-exchange/myplanet#18199 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Authorization 'Artifacts' is shown under category Run instead of Job in Authorization matrixĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Scheme-less stream URLs throw NullPointerException instead of URISyntaxExceptionCó thể đã có người làm @blihio đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
pedroSG94/RootEncoder#2218 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/rocketmq-dashboard#6872 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ADORSYS-GIS/token-status-link#168 ·
Maintainer thường phản hồi trong vòng 2 ngày