Skip to content

Implement a SearchView::for_each helper#881

Merged
jviotti merged 3 commits intomainfrom
search-view-for-each
May 6, 2026
Merged

Implement a SearchView::for_each helper#881
jviotti merged 3 commits intomainfrom
search-view-for-each

Conversation

@jviotti
Copy link
Copy Markdown
Member

@jviotti jviotti commented May 5, 2026

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai 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 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/search/search.cc">

<violation number="1" location="src/search/search.cc:312">
P2: Add bounds checks for the offset table and each record before reading, similar to the validations in search(...). As written, a malformed payload can make for_each read past payload_size_.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/search/search.cc
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 5, 2026

🤖 Augment PR Summary

Summary: This PR introduces a SearchView::for_each helper to iterate over a slice of the on-disk search index without repeatedly calling at().

Changes:

  • Added a new public `SearchView::for_each(offset, count, callback)` API to visit entries in a specified range.
  • Implemented the iteration logic in src/search/search.cc, building SearchListEntry views directly from the mapped payload.
  • Included <functional> in the public header and implementation to support the callback type.
  • Added unit tests covering full-range iteration, subset iteration with offsets, count clamping, and no-op behavior for out-of-range/zero-count cases.

Technical Notes: The helper preserves the same ordering as the underlying search index (and matches at() order), and returns string views backed by the mapped file payload.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/search/search.cc Outdated
Comment thread src/search/search.cc
jviotti added 2 commits May 5, 2026 16:35
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Benchmark Index (enterprise)

Details
Benchmark suite Current: b81201b Previous: 14223a3 Ratio
Add one schema (0 existing) 197 ms 205 ms 0.96
Add one schema (100 existing) 23 ms 23 ms 1
Add one schema (1000 existing) 72 ms 72 ms 1
Add one schema (10000 existing) 608 ms 585 ms 1.04
Update one schema (1 existing) 17 ms 17 ms 1
Update one schema (101 existing) 23 ms 23 ms 1
Update one schema (1001 existing) 72 ms 71 ms 1.01
Update one schema (10001 existing) 604 ms 909 ms 0.66
Cached rebuild (1 existing) 5 ms 5 ms 1
Cached rebuild (101 existing) 7 ms 7 ms 1
Cached rebuild (1001 existing) 27 ms 27 ms 1
Cached rebuild (10001 existing) 240 ms 237 ms 1.01
Index 100 schemas 120 ms 111 ms 1.08
Index 1000 schemas 965 ms 1009 ms 0.96
Index 10000 schemas 12885 ms 12620 ms 1.02

This comment was automatically generated by workflow using github-action-benchmark.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Benchmark Index (community)

Details
Benchmark suite Current: b81201b Previous: 14223a3 Ratio
Add one schema (0 existing) 180 ms 220 ms 0.82
Add one schema (100 existing) 18 ms 22 ms 0.82
Add one schema (1000 existing) 63 ms 76 ms 0.83
Add one schema (10000 existing) 553 ms 841 ms 0.66
Update one schema (1 existing) 12 ms 16 ms 0.75
Update one schema (101 existing) 18 ms 23 ms 0.78
Update one schema (1001 existing) 65 ms 80 ms 0.81
Update one schema (10001 existing) 597 ms 662 ms 0.90
Cached rebuild (1 existing) 3 ms 5 ms 0.60
Cached rebuild (101 existing) 4 ms 7 ms 0.57
Cached rebuild (1001 existing) 18 ms 27 ms 0.67
Cached rebuild (10001 existing) 170 ms 248 ms 0.69
Index 100 schemas 88 ms 138 ms 0.64
Index 1000 schemas 812 ms 1128 ms 0.72
Index 10000 schemas 11564 ms 14292 ms 0.81

This comment was automatically generated by workflow using github-action-benchmark.

@jviotti jviotti merged commit 1c0b546 into main May 6, 2026
5 checks passed
@jviotti jviotti deleted the search-view-for-each branch May 6, 2026 12:46
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.

1 participant