Skip to content

Commit

Permalink
RavenDB-21498 Make sure that we properly handle reconstruction of fre…
Browse files Browse the repository at this point in the history
…quencies for terms that has > 16
  • Loading branch information
ayende committed Sep 29, 2023
1 parent d04b4fe commit d53c4cc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Corax/Utils/EntryTermsReader.cs
Expand Up @@ -223,7 +223,7 @@ private void HandleRegularTerm(long termContainerId)
}
else
{
Frequency = (byte)(termContainerId >> 3);
Frequency = EntryIdEncodings.FrequencyReconstructionFromQuantization((byte)(termContainerId >> 3));
TermId = (termContainerId >> 8) & ~0b111;
}

Expand Down
42 changes: 42 additions & 0 deletions test/SlowTests/Issues/RavenDB_21498.cs
Expand Up @@ -66,6 +66,48 @@ public void ProperlyUpdateSmallPostingListWithDifferentFrequencies()

string TextGen(int count) => string.Join(" ", Enumerable.Range(0, count).Select(_ => "Maciej"));
}


[RavenFact(RavenTestCategory.Indexes)]
public void ProperlyUpdateSmallPostingListWithDifferentFrequencies2()
{
using var store = GetDocumentStore(Options.ForSearchEngine(RavenSearchEngineMode.Corax));

using (var session = store.OpenSession())
{
session.Store(new User(TextGen(32)), "doc/1");
session.Store(new User(TextGen(32)), "doc/2");
session.SaveChanges();

var results = session.Query<User>()
.Search(x => x.Text, "maciej")
.ToList();

Indexes.WaitForIndexing(store);

session.SaveChanges();
}

using (var session = store.OpenSession())
{
var userToUpdate = session.Load<User>("doc/1");
userToUpdate.Text = TextGen(64);
session.Store(userToUpdate);
session.SaveChanges();

Indexes.WaitForIndexing(store);

var results = session.Query<User>()
.Search(x => x.Text, "maciej")
.Count(); // will do not check by Raven's ids but results from Corax :

Assert.Equal(2, results);
}


string TextGen(int count) => string.Join(" ", Enumerable.Range(0, count).Select(_ => "Maciej"));
}


private sealed class User
{
Expand Down

0 comments on commit d53c4cc

Please sign in to comment.