aboutsummaryrefslogtreecommitdiff
path: root/icing/index/lite/lite-index_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'icing/index/lite/lite-index_test.cc')
-rw-r--r--icing/index/lite/lite-index_test.cc191
1 files changed, 103 insertions, 88 deletions
diff --git a/icing/index/lite/lite-index_test.cc b/icing/index/lite/lite-index_test.cc
index 7ff006e..f8ea94a 100644
--- a/icing/index/lite/lite-index_test.cc
+++ b/icing/index/lite/lite-index_test.cc
@@ -27,7 +27,6 @@
#include "icing/index/hit/hit.h"
#include "icing/index/iterator/doc-hit-info-iterator.h"
#include "icing/index/lite/doc-hit-info-iterator-term-lite.h"
-#include "icing/index/lite/lite-index-header.h"
#include "icing/index/lite/term-id-hit-pair.h"
#include "icing/index/term-id-codec.h"
#include "icing/legacy/index/icing-dynamic-trie.h"
@@ -73,15 +72,25 @@ class LiteIndexTest : public testing::Test {
constexpr NamespaceId kNamespace0 = 0;
+TEST_F(LiteIndexTest, TermIdHitPairInvalidValue) {
+ TermIdHitPair invalidTermHitPair(TermIdHitPair::kInvalidValue);
+
+ EXPECT_THAT(invalidTermHitPair.term_id(), Eq(0));
+ EXPECT_THAT(invalidTermHitPair.hit().value(), Eq(Hit::kInvalidValue));
+ EXPECT_THAT(invalidTermHitPair.hit().term_frequency(),
+ Eq(Hit::kDefaultTermFrequency));
+}
+
TEST_F(LiteIndexTest,
LiteIndexFetchHits_sortAtQuerying_unsortedHitsBelowSortThreshold) {
// Set up LiteIndex and TermIdCodec
std::string lite_index_file_name = index_dir_ + "/test_file.lite-idx.index";
- // At 64 bytes the unsorted tail can contain a max of 8 TermHitPairs.
- LiteIndex::Options options(lite_index_file_name,
- /*hit_buffer_want_merge_bytes=*/1024 * 1024,
- /*hit_buffer_sort_at_indexing=*/false,
- /*hit_buffer_sort_threshold_bytes=*/64);
+ // Unsorted tail can contain a max of 8 TermIdHitPairs.
+ LiteIndex::Options options(
+ lite_index_file_name,
+ /*hit_buffer_want_merge_bytes=*/1024 * 1024,
+ /*hit_buffer_sort_at_indexing=*/false,
+ /*hit_buffer_sort_threshold_bytes=*/sizeof(TermIdHitPair) * 8);
ICING_ASSERT_OK_AND_ASSIGN(std::unique_ptr<LiteIndex> lite_index,
LiteIndex::Create(options, &icing_filesystem_));
ICING_ASSERT_OK_AND_ASSIGN(
@@ -97,9 +106,9 @@ TEST_F(LiteIndexTest,
ICING_ASSERT_OK_AND_ASSIGN(uint32_t foo_term_id,
term_id_codec_->EncodeTvi(foo_tvi, TviType::LITE));
Hit foo_hit0(/*section_id=*/0, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit foo_hit1(/*section_id=*/1, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
ICING_ASSERT_OK(lite_index->AddHit(foo_term_id, foo_hit0));
ICING_ASSERT_OK(lite_index->AddHit(foo_term_id, foo_hit1));
@@ -109,9 +118,9 @@ TEST_F(LiteIndexTest,
ICING_ASSERT_OK_AND_ASSIGN(uint32_t bar_term_id,
term_id_codec_->EncodeTvi(bar_tvi, TviType::LITE));
Hit bar_hit0(/*section_id=*/0, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit bar_hit1(/*section_id=*/1, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
ICING_ASSERT_OK(lite_index->AddHit(bar_term_id, bar_hit0));
ICING_ASSERT_OK(lite_index->AddHit(bar_term_id, bar_hit1));
@@ -154,15 +163,16 @@ TEST_F(LiteIndexTest,
LiteIndexFetchHits_sortAtIndexing_unsortedHitsBelowSortThreshold) {
// Set up LiteIndex and TermIdCodec
std::string lite_index_file_name = index_dir_ + "/test_file.lite-idx.index";
- // At 64 bytes the unsorted tail can contain a max of 8 TermHitPairs.
+ // The unsorted tail can contain a max of 8 TermIdHitPairs.
// However note that in these tests we're unable to sort hits after
// indexing, as sorting performed by the string-section-indexing-handler
// after indexing all hits in an entire document, rather than after each
// AddHits() operation.
- LiteIndex::Options options(lite_index_file_name,
- /*hit_buffer_want_merge_bytes=*/1024 * 1024,
- /*hit_buffer_sort_at_indexing=*/true,
- /*hit_buffer_sort_threshold_bytes=*/64);
+ LiteIndex::Options options(
+ lite_index_file_name,
+ /*hit_buffer_want_merge_bytes=*/1024 * 1024,
+ /*hit_buffer_sort_at_indexing=*/true,
+ /*hit_buffer_sort_threshold_bytes=*/sizeof(TermIdHitPair) * 8);
ICING_ASSERT_OK_AND_ASSIGN(std::unique_ptr<LiteIndex> lite_index,
LiteIndex::Create(options, &icing_filesystem_));
ICING_ASSERT_OK_AND_ASSIGN(
@@ -178,9 +188,9 @@ TEST_F(LiteIndexTest,
ICING_ASSERT_OK_AND_ASSIGN(uint32_t foo_term_id,
term_id_codec_->EncodeTvi(foo_tvi, TviType::LITE));
Hit foo_hit0(/*section_id=*/0, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit foo_hit1(/*section_id=*/1, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
ICING_ASSERT_OK(lite_index->AddHit(foo_term_id, foo_hit0));
ICING_ASSERT_OK(lite_index->AddHit(foo_term_id, foo_hit1));
@@ -190,9 +200,9 @@ TEST_F(LiteIndexTest,
ICING_ASSERT_OK_AND_ASSIGN(uint32_t bar_term_id,
term_id_codec_->EncodeTvi(bar_tvi, TviType::LITE));
Hit bar_hit0(/*section_id=*/0, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit bar_hit1(/*section_id=*/1, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
ICING_ASSERT_OK(lite_index->AddHit(bar_term_id, bar_hit0));
ICING_ASSERT_OK(lite_index->AddHit(bar_term_id, bar_hit1));
@@ -237,15 +247,16 @@ TEST_F(
LiteIndexFetchHits_sortAtQuerying_unsortedHitsExceedingSortAtIndexThreshold) {
// Set up LiteIndex and TermIdCodec
std::string lite_index_file_name = index_dir_ + "/test_file.lite-idx.index";
- // At 64 bytes the unsorted tail can contain a max of 8 TermHitPairs.
+ // The unsorted tail can contain a max of 8 TermIdHitPairs.
// However note that in these tests we're unable to sort hits after
// indexing, as sorting performed by the string-section-indexing-handler
// after indexing all hits in an entire document, rather than after each
// AddHits() operation.
- LiteIndex::Options options(lite_index_file_name,
- /*hit_buffer_want_merge_bytes=*/1024 * 1024,
- /*hit_buffer_sort_at_indexing=*/false,
- /*hit_buffer_sort_threshold_bytes=*/64);
+ LiteIndex::Options options(
+ lite_index_file_name,
+ /*hit_buffer_want_merge_bytes=*/1024 * 1024,
+ /*hit_buffer_sort_at_indexing=*/false,
+ /*hit_buffer_sort_threshold_bytes=*/sizeof(TermIdHitPair) * 8);
ICING_ASSERT_OK_AND_ASSIGN(std::unique_ptr<LiteIndex> lite_index,
LiteIndex::Create(options, &icing_filesystem_));
ICING_ASSERT_OK_AND_ASSIGN(
@@ -257,36 +268,36 @@ TEST_F(
// Create 4 hits for docs 0-2, and 2 hits for doc 3 -- 14 in total
// Doc 0
Hit doc0_hit0(/*section_id=*/0, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc0_hit1(/*section_id=*/0, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc0_hit2(/*section_id=*/1, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc0_hit3(/*section_id=*/2, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
// Doc 1
Hit doc1_hit0(/*section_id=*/0, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc1_hit1(/*section_id=*/0, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc1_hit2(/*section_id=*/1, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc1_hit3(/*section_id=*/2, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
// Doc 2
Hit doc2_hit0(/*section_id=*/0, /*document_id=*/2, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc2_hit1(/*section_id=*/0, /*document_id=*/2, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc2_hit2(/*section_id=*/1, /*document_id=*/2, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc2_hit3(/*section_id=*/2, /*document_id=*/2, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
// Doc 3
Hit doc3_hit0(/*section_id=*/0, /*document_id=*/3, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc3_hit1(/*section_id=*/0, /*document_id=*/3, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
// Create terms
// Foo
@@ -398,11 +409,12 @@ TEST_F(
LiteIndexFetchHits_sortAtIndexing_unsortedHitsExceedingSortAtIndexThreshold) {
// Set up LiteIndex and TermIdCodec
std::string lite_index_file_name = index_dir_ + "/test_file.lite-idx.index";
- // At 64 bytes the unsorted tail can contain a max of 8 TermHitPairs.
- LiteIndex::Options options(lite_index_file_name,
- /*hit_buffer_want_merge_bytes=*/1024 * 1024,
- /*hit_buffer_sort_at_indexing=*/true,
- /*hit_buffer_sort_threshold_bytes=*/64);
+ // The unsorted tail can contain a max of 8 TermIdHitPairs.
+ LiteIndex::Options options(
+ lite_index_file_name,
+ /*hit_buffer_want_merge_bytes=*/1024 * 1024,
+ /*hit_buffer_sort_at_indexing=*/true,
+ /*hit_buffer_sort_threshold_bytes=*/sizeof(TermIdHitPair) * 8);
ICING_ASSERT_OK_AND_ASSIGN(std::unique_ptr<LiteIndex> lite_index,
LiteIndex::Create(options, &icing_filesystem_));
ICING_ASSERT_OK_AND_ASSIGN(
@@ -414,49 +426,49 @@ TEST_F(
// Create 4 hits for docs 0-2, and 2 hits for doc 3 -- 14 in total
// Doc 0
Hit doc0_hit0(/*section_id=*/0, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc0_hit1(/*section_id=*/0, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc0_hit2(/*section_id=*/1, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc0_hit3(/*section_id=*/2, /*document_id=*/0, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
// Doc 1
Hit doc1_hit0(/*section_id=*/0, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc1_hit1(/*section_id=*/0, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc1_hit2(/*section_id=*/1, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc1_hit3(/*section_id=*/2, /*document_id=*/1, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
// Doc 2
Hit doc2_hit0(/*section_id=*/0, /*document_id=*/2, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc2_hit1(/*section_id=*/0, /*document_id=*/2, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc2_hit2(/*section_id=*/1, /*document_id=*/2, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc2_hit3(/*section_id=*/2, /*document_id=*/2, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
// Doc 3
Hit doc3_hit0(/*section_id=*/0, /*document_id=*/3, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc3_hit1(/*section_id=*/0, /*document_id=*/3, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc3_hit2(/*section_id=*/1, /*document_id=*/3, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc3_hit3(/*section_id=*/2, /*document_id=*/3, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
// Doc 4
Hit doc4_hit0(/*section_id=*/0, /*document_id=*/4, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc4_hit1(/*section_id=*/0, /*document_id=*/4, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc4_hit2(/*section_id=*/1, /*document_id=*/4, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc4_hit3(/*section_id=*/2, /*document_id=*/4, Hit::kDefaultTermFrequency,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
// Create terms
// Foo
@@ -590,11 +602,12 @@ TEST_F(
TEST_F(LiteIndexTest, LiteIndexIterator) {
// Set up LiteIndex and TermIdCodec
std::string lite_index_file_name = index_dir_ + "/test_file.lite-idx.index";
- // At 64 bytes the unsorted tail can contain a max of 8 TermHitPairs.
- LiteIndex::Options options(lite_index_file_name,
- /*hit_buffer_want_merge_bytes=*/1024 * 1024,
- /*hit_buffer_sort_at_indexing=*/true,
- /*hit_buffer_sort_threshold_bytes=*/64);
+ // The unsorted tail can contain a max of 8 TermIdHitPairs.
+ LiteIndex::Options options(
+ lite_index_file_name,
+ /*hit_buffer_want_merge_bytes=*/1024 * 1024,
+ /*hit_buffer_sort_at_indexing=*/true,
+ /*hit_buffer_sort_threshold_bytes=*/sizeof(TermIdHitPair) * 8);
ICING_ASSERT_OK_AND_ASSIGN(std::unique_ptr<LiteIndex> lite_index,
LiteIndex::Create(options, &icing_filesystem_));
ICING_ASSERT_OK_AND_ASSIGN(
@@ -610,9 +623,9 @@ TEST_F(LiteIndexTest, LiteIndexIterator) {
ICING_ASSERT_OK_AND_ASSIGN(uint32_t foo_term_id,
term_id_codec_->EncodeTvi(tvi, TviType::LITE));
Hit doc0_hit0(/*section_id=*/0, /*document_id=*/0, /*term_frequency=*/3,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc0_hit1(/*section_id=*/1, /*document_id=*/0, /*term_frequency=*/5,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
SectionIdMask doc0_section_id_mask = 0b11;
std::unordered_map<SectionId, Hit::TermFrequency>
expected_section_ids_tf_map0 = {{0, 3}, {1, 5}};
@@ -620,9 +633,9 @@ TEST_F(LiteIndexTest, LiteIndexIterator) {
ICING_ASSERT_OK(lite_index->AddHit(foo_term_id, doc0_hit1));
Hit doc1_hit1(/*section_id=*/1, /*document_id=*/1, /*term_frequency=*/7,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc1_hit2(/*section_id=*/2, /*document_id=*/1, /*term_frequency=*/11,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
SectionIdMask doc1_section_id_mask = 0b110;
std::unordered_map<SectionId, Hit::TermFrequency>
expected_section_ids_tf_map1 = {{1, 7}, {2, 11}};
@@ -658,11 +671,12 @@ TEST_F(LiteIndexTest, LiteIndexIterator) {
TEST_F(LiteIndexTest, LiteIndexIterator_sortAtIndexingDisabled) {
// Set up LiteIndex and TermIdCodec
std::string lite_index_file_name = index_dir_ + "/test_file.lite-idx.index";
- // At 64 bytes the unsorted tail can contain a max of 8 TermHitPairs.
- LiteIndex::Options options(lite_index_file_name,
- /*hit_buffer_want_merge_bytes=*/1024 * 1024,
- /*hit_buffer_sort_at_indexing=*/false,
- /*hit_buffer_sort_threshold_bytes=*/64);
+ // The unsorted tail can contain a max of 8 TermIdHitPairs.
+ LiteIndex::Options options(
+ lite_index_file_name,
+ /*hit_buffer_want_merge_bytes=*/1024 * 1024,
+ /*hit_buffer_sort_at_indexing=*/false,
+ /*hit_buffer_sort_threshold_bytes=*/sizeof(TermIdHitPair) * 8);
ICING_ASSERT_OK_AND_ASSIGN(std::unique_ptr<LiteIndex> lite_index,
LiteIndex::Create(options, &icing_filesystem_));
ICING_ASSERT_OK_AND_ASSIGN(
@@ -678,9 +692,9 @@ TEST_F(LiteIndexTest, LiteIndexIterator_sortAtIndexingDisabled) {
ICING_ASSERT_OK_AND_ASSIGN(uint32_t foo_term_id,
term_id_codec_->EncodeTvi(tvi, TviType::LITE));
Hit doc0_hit0(/*section_id=*/0, /*document_id=*/0, /*term_frequency=*/3,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc0_hit1(/*section_id=*/1, /*document_id=*/0, /*term_frequency=*/5,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
SectionIdMask doc0_section_id_mask = 0b11;
std::unordered_map<SectionId, Hit::TermFrequency>
expected_section_ids_tf_map0 = {{0, 3}, {1, 5}};
@@ -688,9 +702,9 @@ TEST_F(LiteIndexTest, LiteIndexIterator_sortAtIndexingDisabled) {
ICING_ASSERT_OK(lite_index->AddHit(foo_term_id, doc0_hit1));
Hit doc1_hit1(/*section_id=*/1, /*document_id=*/1, /*term_frequency=*/7,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit doc1_hit2(/*section_id=*/2, /*document_id=*/1, /*term_frequency=*/11,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
SectionIdMask doc1_section_id_mask = 0b110;
std::unordered_map<SectionId, Hit::TermFrequency>
expected_section_ids_tf_map1 = {{1, 7}, {2, 11}};
@@ -726,11 +740,12 @@ TEST_F(LiteIndexTest, LiteIndexIterator_sortAtIndexingDisabled) {
TEST_F(LiteIndexTest, LiteIndexHitBufferSize) {
// Set up LiteIndex and TermIdCodec
std::string lite_index_file_name = index_dir_ + "/test_file.lite-idx.index";
- // At 64 bytes the unsorted tail can contain a max of 8 TermHitPairs.
- LiteIndex::Options options(lite_index_file_name,
- /*hit_buffer_want_merge_bytes=*/1024 * 1024,
- /*hit_buffer_sort_at_indexing=*/true,
- /*hit_buffer_sort_threshold_bytes=*/64);
+ // The unsorted tail can contain a max of 8 TermIdHitPairs.
+ LiteIndex::Options options(
+ lite_index_file_name,
+ /*hit_buffer_want_merge_bytes=*/1024 * 1024,
+ /*hit_buffer_sort_at_indexing=*/true,
+ /*hit_buffer_sort_threshold_bytes=*/sizeof(TermIdHitPair) * 8);
ICING_ASSERT_OK_AND_ASSIGN(std::unique_ptr<LiteIndex> lite_index,
LiteIndex::Create(options, &icing_filesystem_));
ICING_ASSERT_OK_AND_ASSIGN(
@@ -746,9 +761,9 @@ TEST_F(LiteIndexTest, LiteIndexHitBufferSize) {
ICING_ASSERT_OK_AND_ASSIGN(uint32_t foo_term_id,
term_id_codec_->EncodeTvi(tvi, TviType::LITE));
Hit hit0(/*section_id=*/0, /*document_id=*/0, /*term_frequency=*/3,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
Hit hit1(/*section_id=*/1, /*document_id=*/0, /*term_frequency=*/5,
- /*is_in_prefix_section=*/false);
+ /*is_in_prefix_section=*/false, /*is_prefix_hit=*/false);
ICING_ASSERT_OK(lite_index->AddHit(foo_term_id, hit0));
ICING_ASSERT_OK(lite_index->AddHit(foo_term_id, hit1));