-
Notifications
You must be signed in to change notification settings - Fork 97
H-4880, H-4881: Introduce Value
type
#7499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new, immutable, and structurally shared Value type for HashQL and expands support for composite types (tuple, struct, list, dict, opaque) along with updated literal APIs.
- Implements the Value enum with variant-specific behaviors and corresponding error types.
- Adds new modules for tuple, struct, opaque, list, and dict while updating literal types and build configurations.
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
libs/@local/hashql/core/src/value/*.rs | New modules implementing the Value type variants and field/index access APIs. |
libs/@local/hashql/core/src/literal/* | Enhancements to literal types (string, integer, float) with additional conversion methods. |
Cargo.toml & package.json | Updates to dependencies and enabled features required by the new implementations. |
Comments suppressed due to low confidence (1)
libs/@local/hashql/core/src/literal/float.rs:99
- Consider adding an explicit 'use memchr::memchr3;' import at the top of the file to clearly indicate the dependency and improve code clarity for future maintainers.
let is_integer = memchr::memchr3(b'.', b'e', b'E', self.value.as_bytes()).is_none();
@CodiumAI-Agent /review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR introduces a well-designed Value
type system for HashQL that properly handles all the different types of values in the language. The implementation is very thorough, with each value type having appropriate operations and error handling.
The code is of high quality, with particularly strong points including:
-
Immutability and Structural Sharing: All types are properly immutable, using structural sharing (via
Rc
and persistent data structures from therpds
crate) to maintain performance while providing immutable semantics. -
Comprehensive Error Handling: The error types and messages are clear and provide good context for debugging.
-
Documentation: Every type and method has detailed documentation with examples, which is excellent for maintainability.
-
Test Coverage: You've included property-based tests for complex algorithms like
co_sort
, which provides strong confidence in the correctness of the implementation. -
Performance Considerations: The implementation shows attention to performance details, like using
memchr
for parsing and efficient data structures.
I've left some minor comments in the diff, mostly noting good practices or suggesting minor improvements, but none of these are blockers. The code is well-structured, follows Rust best practices, and implements all the required functionality according to the Linear ticket.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7499 +/- ##
==========================================
+ Coverage 53.08% 53.22% +0.13%
==========================================
Files 1079 1085 +6
Lines 95645 96167 +522
Branches 4431 4447 +16
==========================================
+ Hits 50774 51181 +407
- Misses 43919 44020 +101
- Partials 952 966 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
@CodiumAI-Agent /improve |
PR Code Suggestions ✨
|
@CodiumAI-Agent /describe |
Title(Describe updated until commit e06508c)H-4880, H-4881: Introduce User description🌟 What is the purpose of this PR?The Pre-Merge Checklist 🚀🚢 Has this modified a publishable library?This PR:
📜 Does this require a change to the docs?The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?The changes in this PR:
PR TypeEnhancement, Tests Description
Changes diagramflowchart LR
IL["`IntegerLiteral` conversions"]
FL["`FloatLiteral` conversions"]
R["`Real` numeric conversions"]
V["`Value` enum & collections"]
IL -- "typed conversions" --> V
FL -- "integer/real conversions" --> R
R -- "exact/lossy float" --> V
Changes walkthrough 📝
|
Value
typeValue
type
6db3ab9
to
3fa4c37
Compare
5786759
to
7efbb3e
Compare
638fe3f
to
1c5e38e
Compare
7efbb3e
to
ae9f9af
Compare
10d0a65
to
c519933
Compare
c519933
to
223f535
Compare
223f535
to
f570ad7
Compare
Benchmark results
|
Function | Value | Mean | Flame graphs |
---|---|---|---|
entity_by_id | 1 entities | Flame Graph | |
entity_by_id | 10 entities | Flame Graph | |
entity_by_id | 10000 entities | Flame Graph | |
entity_by_id | 100 entities | Flame Graph | |
entity_by_id | 1000 entities | Flame Graph |
representative_read_entity_type
Function | Value | Mean | Flame graphs |
---|---|---|---|
get_entity_type_by_id | Account ID: bf5a9ef5-dc3b-43cf-a291-6210c0321eba
|
Flame Graph |
representative_read_multiple_entities
Function | Value | Mean | Flame graphs |
---|---|---|---|
entity_by_property | depths: DT=0, PT=2, ET=2, E=2 | Flame Graph | |
entity_by_property | depths: DT=0, PT=0, ET=2, E=2 | Flame Graph | |
entity_by_property | depths: DT=0, PT=0, ET=0, E=2 | Flame Graph | |
entity_by_property | depths: DT=0, PT=0, ET=0, E=0 | Flame Graph | |
entity_by_property | depths: DT=255, PT=255, ET=255, E=255 | Flame Graph | |
entity_by_property | depths: DT=2, PT=2, ET=2, E=2 | Flame Graph | |
link_by_source_by_property | depths: DT=0, PT=2, ET=2, E=2 | Flame Graph | |
link_by_source_by_property | depths: DT=0, PT=0, ET=2, E=2 | Flame Graph | |
link_by_source_by_property | depths: DT=0, PT=0, ET=0, E=2 | Flame Graph | |
link_by_source_by_property | depths: DT=0, PT=0, ET=0, E=0 | Flame Graph | |
link_by_source_by_property | depths: DT=255, PT=255, ET=255, E=255 | Flame Graph | |
link_by_source_by_property | depths: DT=2, PT=2, ET=2, E=2 | Flame Graph |
scaling_read_entity_complete_one_depth
Function | Value | Mean | Flame graphs |
---|---|---|---|
entity_by_id | 50 entities | Flame Graph | |
entity_by_id | 1 entities | Flame Graph | |
entity_by_id | 10 entities | Flame Graph | |
entity_by_id | 5 entities | Flame Graph | |
entity_by_id | 25 entities | Flame Graph |
scaling_read_entity_complete_zero_depth
Function | Value | Mean | Flame graphs |
---|---|---|---|
entity_by_id | 50 entities | Flame Graph | |
entity_by_id | 1 entities | Flame Graph | |
entity_by_id | 10 entities | Flame Graph | |
entity_by_id | 5 entities | Flame Graph | |
entity_by_id | 25 entities | Flame Graph |
representative_read_entity
Function | Value | Mean | Flame graphs |
---|---|---|---|
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1
|
Flame Graph | |
entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1
|
Flame Graph |
let inside_f32 = Real::from_natural(123_456, 0); // 123456 - needs ~17 bits | ||
let inside_f64 = Real::from_natural(16_777_217, 0); // 2^24 + 1 - needs 25 bits | ||
let outside_f64 = Real::from_natural(123_456_789, 20); // 123456789 * 10^20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just pass the exponent? e.g. from_natural(1, 17)
? That's more intuitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in theory yes, but the issue described only happens if the significand is larger than eg 53 bits, which wouldn't happen if we use an exponent because the exponent is saved separately
🌟 What is the purpose of this PR?
The
Value
type is used during evaluation for any value inHashQL
, due to the constraints of the language it's immutable and uses structural sharing where possible.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR: