Skip to content

[BUG] ignore trigrams with null terminator byte when constructing full text index #4422

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

Merged
merged 2 commits into from
May 2, 2025

Conversation

codetheweb
Copy link
Contributor

@codetheweb codetheweb commented May 1, 2025

Description of changes

Summarize the changes made by this PR.

The encoding/decoding method we use for packing a trigram into a u64 cannot handle null terminator bytes. E.x. decode(encode(a\0b)) == a. This resulted in index writers and the blockfile writer disagreeing on the ordering of mutations (index writers sorted with a\0b, the blockfile writer ordered with a).

To work around this, any trigrams containing null terminator bytes are now ignored. An (arguably cleaner) alternative would be to replace null terminator bytes with something like a space instead.

Test plan

How are these changes tested?

Added test currently fails on main.

Ran the full_text benchmark to confirm that no performance regression is introduced.

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

n/a

Copy link

github-actions bot commented May 1, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@codetheweb codetheweb force-pushed the bug-fts-null-terminator-byte branch from c6afeff to 5144a0b Compare May 1, 2025 23:55
@codetheweb codetheweb marked this pull request as ready for review May 2, 2025 00:10
@codetheweb codetheweb force-pushed the bug-fts-null-terminator-byte branch from 5144a0b to 2868d4d Compare May 2, 2025 00:11
@codetheweb codetheweb requested a review from Sicheng-Pan May 2, 2025 00:11
Copy link
Contributor

@Sicheng-Pan Sicheng-Pan left a comment

Choose a reason for hiding this comment

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

Although this works for now, I think we should consider about the alternative approach later. As a note we may want to use unicode codepoint in the custom use areas to encode special characters (whether it is null, document start/end, etc.)

@codetheweb codetheweb merged commit db280e9 into main May 2, 2025
70 checks passed
warpbuild-benchmark-bot bot added a commit to WarpBuilds/chroma that referenced this pull request May 2, 2025
chroma-droid pushed a commit that referenced this pull request May 5, 2025
…l text index (#4422)

## Description of changes

_Summarize the changes made by this PR._

The encoding/decoding method we use for packing a trigram into a u64
cannot handle null terminator bytes. E.x. `decode(encode(a\0b)) == a`.
This resulted in index writers and the blockfile writer disagreeing on
the ordering of mutations (index writers sorted with `a\0b`, the
blockfile writer ordered with `a`).

To work around this, any trigrams containing null terminator bytes are
now ignored. An (arguably cleaner) alternative would be to replace null
terminator bytes with something like a space instead.

## Test plan

_How are these changes tested?_

Added test currently fails on main.

Ran the `full_text` benchmark to confirm that no performance regression
is introduced.

## Documentation Changes

_Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
section](https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com)?_

n/a
eculver added a commit that referenced this pull request May 6, 2025
This PR cherry-picks the commit db280e9
onto rc/2025-05-02. If there are unresolved conflicts, please resolve
them manually.

---------

Co-authored-by: Max Isom <[email protected]>
Co-authored-by: Evan Culver <[email protected]>
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