Skip to content

Conversation

xav-db
Copy link
Member

@xav-db xav-db commented Aug 6, 2025

Description

fixing filtering by index for n by index

Related Issues

Closes #

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
  • Lines are kept under 100 characters where possible
  • Code is good

Additional Notes

@xav-db xav-db requested review from Copilot and Gahnxd August 6, 2025 19:15
@xav-db xav-db enabled auto-merge August 6, 2025 19:15
Copy link
Contributor

@Copilot Copilot AI left a 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 fixes the filtering functionality for the n_from_index operation by adding label-based filtering to ensure only nodes with the correct label are returned from index queries.

  • Added a label parameter to the NFromIndex struct and related operations
  • Modified the iterator implementation to filter nodes by label before returning them
  • Updated the Display format and test cases to use the new three-parameter signature

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
helix-db/src/helixc/generator/source_steps.rs Added label field to NFromIndex struct and updated Display format
helix-db/src/helixc/analyzer/methods/traversal_validation.rs Added label parameter when constructing NFromIndex instances
helix-db/src/helix_engine/graph_core/traversal_tests.rs Updated test calls to use new three-parameter n_from_index signature
helix-db/src/helix_engine/graph_core/ops/source/n_from_index.rs Implemented label filtering logic and updated API signature

}

impl<'a> Iterator for NFromIndex<'a> {
type Item = Result<TraversalVal, GraphError>;

#[debug_trace("N_FROM_INDEX")]
fn next(&mut self) -> Option<Self::Item> {
if let Some(value) = self.iter.by_ref().next() {
for value in self.iter.by_ref() {
Copy link
Preview

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The change from if let Some(value) to for value in alters the iterator behavior. The original code processed one item per next() call, while this new code will potentially consume multiple items in a single next() call, which could impact performance and memory usage when dealing with large result sets.

Suggested change
for value in self.iter.by_ref() {
while let Some(value) = self.iter.next() {

Copilot uses AI. Check for mistakes.

Comment on lines +34 to +35
} else {
continue;
Copy link
Preview

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The continue statement is unnecessary since it's at the end of the loop iteration. The else branch can be removed entirely as the loop will naturally continue to the next iteration.

Suggested change
} else {
continue;

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@Gahnxd Gahnxd left a comment

Choose a reason for hiding this comment

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

Works as expected

@xav-db xav-db merged commit f053836 into dev Aug 6, 2025
13 checks passed
@xav-db xav-db deleted the fix-for-n-from-by-index-label-filtering branch August 20, 2025 16:58
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