Skip to content

Conversation

@ishaksebsib
Copy link
Contributor

@ishaksebsib ishaksebsib commented Oct 26, 2025

Description

This PR adds support for IS_IN operations on string properties by implementing IntoPrimitive for the Value enum. Previously, IS_IN only worked with numeric types due to trait constraints.

Problem

Queries using IS_IN with string arrays failed to compile with trait bound IntoPrimitive<String> not satisfied. For example:

• Schema:

N::MyNode { 
  INDEX field: String,
   ...
 }

• Query:

QUERY GetNodes (fields: [String]) =>
	node <- N<MyNode>::WHERE(_::{field}::IS_IN(fields))
 }

• Error: Compilation failed because Value::is_in couldn't handle strings.

Related Issues

None

Checklist when merging to main

  • No compiler warnings (if applicable)
  • Code is formatted with rustfmt
  • No useless or dead code (if applicable)
  • Code is easy to understand
  • Doc comments are used for all functions, enums, structs, and fields (where appropriate)
  • All tests pass
  • Performance has not regressed (assuming change was not to fix a bug)
  • Version number has been updated in helix-cli/Cargo.toml and helixdb/Cargo.toml

Additional Notes

None

Greptile Overview

Updated On: 2025-10-26 07:44:19 UTC

Greptile Summary

Enables IS_IN operations on string properties by implementing IntoPrimitive<String> trait for the Value enum.

Changes:

  • Added IntoPrimitive<String> implementation at value.rs:1623-1630 that extracts the string reference from Value::String variant
  • Mirrors existing implementations for numeric types (i8, i16, i32, i64, u8, u16, u32, u64, u128, f32, f64), booleans, dates, and IDs
  • Satisfies trait bounds required by the is_in<T>() method at line 115-121

Implementation:
The implementation correctly follows the pattern of other IntoPrimitive implementations. The is_in method requires both IntoPrimitive<T> and Into<T> trait bounds, and Into<T> is already satisfied by the existing From<Value> for String implementation at lines 992-999.

Impact:
This unblocks HQL queries that use IS_IN with string arrays, such as filtering nodes by string field membership in a provided list.

Important Files Changed

File Analysis

Filename Score Overview
helix-db/src/protocol/value.rs 5/5 Added IntoPrimitive<String> implementation to enable IS_IN operations on string properties

Sequence Diagram

sequenceDiagram
    participant Query as HQL Query
    participant Compiler as HelixQL Compiler
    participant Generator as Code Generator
    participant Runtime as Runtime (is_in method)
    participant Value as Value Type

    Query->>Compiler: QUERY with IS_IN(field_array)
    Compiler->>Compiler: Validate field type (String)
    Compiler->>Generator: Generate is_in() call
    Generator->>Generator: Create IsIn BoolOp
    Generator->>Runtime: Generate: v.is_in(field_array)
    Runtime->>Value: Call is_in<String>()
    Value->>Value: Check IntoPrimitive<String> trait bound
    Value->>Value: into_primitive() extracts &String
    Value->>Runtime: values.contains(&String)
    Runtime->>Query: Return boolean result
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@xav-db xav-db changed the base branch from dev to arena-implementation October 29, 2025 10:54
@xav-db
Copy link
Member

xav-db commented Oct 29, 2025

this has already been implemented so closing

@xav-db xav-db closed this Oct 29, 2025
@xav-db xav-db mentioned this pull request Oct 29, 2025
8 tasks
xav-db added a commit that referenced this pull request Nov 7, 2025
## Description
<!-- Provide a brief description of the changes in this PR -->

## Related Issues
<!-- Link to any related issues using #issue_number -->

Closes #670 #666 #667 #672  #668 #661 #655 #654 #652 #436 

## Checklist when merging to main
<!-- Mark items with "x" when completed -->

- [ ] No compiler warnings (if applicable)
- [ ] Code is formatted with `rustfmt`
- [ ] No useless or dead code (if applicable)
- [ ] Code is easy to understand
- [ ] Doc comments are used for all functions, enums, structs, and
fields (where appropriate)
- [ ] All tests pass
- [ ] Performance has not regressed (assuming change was not to fix a
bug)
- [ ] Version number has been updated in `helix-cli/Cargo.toml` and
`helixdb/Cargo.toml`

## Additional Notes
<!-- Add any additional information that would be helpful for reviewers
-->

<!-- greptile_comment -->

<h2>Greptile Overview</h2>

Updated On: 2025-11-07 00:19:04 UTC

<h3>Greptile Summary</h3>


This PR implements arena-based memory allocation for graph traversals
and refactors the worker pool's channel selection mechanism.

**Key Changes:**
- **Arena Implementation**: Introduced `'arena` lifetime parameter
throughout traversal operations (`in_e.rs`), replacing owned data with
arena-allocated references for improved memory efficiency
- **Worker Pool Refactor**: Replaced `flume::Selector` with a
parity-based `try_recv()`/`recv()` pattern to handle two channels
(`cont_rx` and `rx`) across multiple worker threads
- **Badge Addition**: Added Manta Graph badge to README

**Issues Found:**
- **Worker Pool Channel Handling**: The new parity-based approach
requires an even number of workers (≥2) and uses non-blocking
`try_recv()` followed by blocking `recv()` on alternating channels.
While this avoids a true busy-wait (since one `recv()` always blocks),
the asymmetry means channels are polled at different frequencies,
potentially causing channel starvation or unfair scheduling compared to
the previous `Selector::wait()` approach.

The arena implementation appears solid and follows Rust lifetime best
practices. The worker pool change seems to be addressing a specific
issue with core affinity (per commit `7437cf0f`), but the trade-off in
channel fairness should be monitored.

<details><summary><h3>Important Files Changed</h3></summary>



File Analysis



| Filename | Score | Overview |
|----------|-------|----------|
| README.md | 5/5 | Added Manta Graph badge to README - cosmetic
documentation change with no functional impact |
| helix-db/src/helix_engine/traversal_core/ops/in_/in_e.rs | 5/5 |
Refactored to use arena-based lifetimes ('arena) instead of owned data,
replacing separate InEdgesIterator struct with inline closures for
better memory management |
| helix-db/src/helix_gateway/worker_pool/mod.rs | 3/5 | Replaced flume
Selector with parity-based try_recv/recv pattern requiring even worker
count, but implementation has potential busy-wait issues that could
cause high CPU usage |

</details>


</details>


<details><summary><h3>Sequence Diagram</h3></summary>

```mermaid
sequenceDiagram
    participant Client
    participant WorkerPool
    participant Worker1 as Worker (parity=true)
    participant Worker2 as Worker (parity=false)
    participant Router
    participant Storage

    Client->>WorkerPool: process(request)
    WorkerPool->>WorkerPool: Send request to req_rx channel
    
    par Worker1 Loop (parity=true)
        loop Every iteration
            Worker1->>Worker1: try_recv(cont_rx) - non-blocking
            alt Continuation available
                Worker1->>Worker1: Execute continuation function
            else Empty
                Worker1->>Worker1: Skip (no busy wait here)
            end
            Worker1->>Worker1: recv(rx) - BLOCKS until request
            alt Request received
                Worker1->>Router: Route request to handler
                Router->>Storage: Execute graph operation
                Storage-->>Router: Return result
                Router-->>Worker1: Response
                Worker1->>WorkerPool: Send response via ret_chan
            end
        end
    end
    
    par Worker2 Loop (parity=false)
        loop Every iteration
            Worker2->>Worker2: try_recv(rx) - non-blocking
            alt Request available
                Worker2->>Router: Route request to handler
                Router->>Storage: Execute graph operation
                Storage-->>Router: Return result
                Router-->>Worker2: Response
                Worker2->>WorkerPool: Send response via ret_chan
            else Empty
                Worker2->>Worker2: Skip (no busy wait here)
            end
            Worker2->>Worker2: recv(cont_rx) - BLOCKS until continuation
            alt Continuation received
                Worker2->>Worker2: Execute continuation function
            end
        end
    end

    WorkerPool-->>Client: Response
```
</details>


<!-- greptile_other_comments_section -->

<!-- /greptile_comment -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants