diff options
author | Jiayu Hu <hujiayu@google.com> | 2023-04-19 12:31:23 -0700 |
---|---|---|
committer | Jiayu Hu <hujiayu@google.com> | 2023-04-19 12:33:32 -0700 |
commit | a7d57e98ea7168d66cf01ace85598e33d5e9e5db (patch) | |
tree | 6685971fd4a027f52d674ee646a79ab41d4ce24f /icing/index | |
parent | b59049b030cc330b6c8ae1d03ea4c1a34235ac9b (diff) | |
download | icing-a7d57e98ea7168d66cf01ace85598e33d5e9e5db.tar.gz |
Update Icing from upstream.
Descriptions:
========================================================================
Adds join info to QueryStatsProto
========================================================================
[Join][cleanup][1/x] Add Icing benchmark for qualified id join
========================================================================
[NumericSearch][benchmark][2/x] Modify run-benchmarks.py to onboard numeric search benchmark
========================================================================
[NumericSearch][benchmark][1/x] Add numeric search icing search engine benchmark
========================================================================
Switch Iterator access type used in SnippetRetriever back to kForwardIterator.
========================================================================
Fix `DocumentStore::OptimizeInto` by passing `options_.document_store_namespace_id_fingerprint()`
========================================================================
Add file size check when initializing mmap for existing metadata file.
========================================================================
Add compression level option to Icing and propagate down to PortableFileBackedProtoLog
========================================================================
Add portable_equals_proto namespace for EqualsProto in tokenized-document_test.
========================================================================
Refactor schema to check consistency of polymorphism by dependency map
========================================================================
Support the `this.propertyWeights()` function in advanced scoring
========================================================================
Randomly set optimize_rebuild_index_threshold in monkey test
========================================================================
Change benchmark batch query latency to average
========================================================================
Performance improvements to SnippetRetriever.
========================================================================
Bug: 270102295
Bug: 260625837
Bug: 269295094
Bug: 193244409
Bug: 269513147
Bug: 276345448
Bug: 259744228
Bug: 272145329
Bug: 276349029
Change-Id: Ief1cb2c21f67aac420d6b79d9b946bbecdc39a5c
Diffstat (limited to 'icing/index')
-rw-r--r-- | icing/index/index-processor_test.cc | 7 | ||||
-rw-r--r-- | icing/index/integer-section-indexing-handler_test.cc | 7 | ||||
-rw-r--r-- | icing/index/iterator/doc-hit-info-iterator-filter_test.cc | 51 | ||||
-rw-r--r-- | icing/index/iterator/doc-hit-info-iterator-section-restrict_test.cc | 7 | ||||
-rw-r--r-- | icing/index/numeric/integer-index-storage.cc | 3 | ||||
-rw-r--r-- | icing/index/numeric/integer-index.cc | 7 | ||||
-rw-r--r-- | icing/index/numeric/integer-index_test.cc | 17 |
7 files changed, 73 insertions, 26 deletions
diff --git a/icing/index/index-processor_test.cc b/icing/index/index-processor_test.cc index 47baabe..9453e58 100644 --- a/icing/index/index-processor_test.cc +++ b/icing/index/index-processor_test.cc @@ -273,7 +273,12 @@ class IndexProcessorTest : public Test { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, DocumentStore::Create(&filesystem_, doc_store_dir_, &fake_clock_, - schema_store_.get())); + schema_store_.get(), + /*force_recovery_and_revalidate_documents=*/false, + /*namespace_id_fingerprint=*/false, + PortableFileBackedProtoLog< + DocumentWrapper>::kDeflateCompressionLevel, + /*initialize_stats=*/nullptr)); doc_store_ = std::move(create_result.document_store); ICING_ASSERT_OK_AND_ASSIGN( diff --git a/icing/index/integer-section-indexing-handler_test.cc b/icing/index/integer-section-indexing-handler_test.cc index 71c6bd5..895fe57 100644 --- a/icing/index/integer-section-indexing-handler_test.cc +++ b/icing/index/integer-section-indexing-handler_test.cc @@ -163,7 +163,12 @@ class IntegerSectionIndexingHandlerTest : public ::testing::Test { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult doc_store_create_result, DocumentStore::Create(&filesystem_, document_store_dir_, &fake_clock_, - schema_store_.get())); + schema_store_.get(), + /*force_recovery_and_revalidate_documents=*/false, + /*namespace_id_fingerprint=*/false, + PortableFileBackedProtoLog< + DocumentWrapper>::kDeflateCompressionLevel, + /*initialize_stats=*/nullptr)); document_store_ = std::move(doc_store_create_result.document_store); } diff --git a/icing/index/iterator/doc-hit-info-iterator-filter_test.cc b/icing/index/iterator/doc-hit-info-iterator-filter_test.cc index ddb216a..0900e1f 100644 --- a/icing/index/iterator/doc-hit-info-iterator-filter_test.cc +++ b/icing/index/iterator/doc-hit-info-iterator-filter_test.cc @@ -48,6 +48,17 @@ using ::testing::ElementsAre; using ::testing::Eq; using ::testing::IsEmpty; +libtextclassifier3::StatusOr<DocumentStore::CreateResult> CreateDocumentStore( + const Filesystem* filesystem, const std::string& base_dir, + const Clock* clock, const SchemaStore* schema_store) { + return DocumentStore::Create( + filesystem, base_dir, clock, schema_store, + /*force_recovery_and_revalidate_documents=*/false, + /*namespace_id_fingerprint=*/false, + PortableFileBackedProtoLog<DocumentWrapper>::kDeflateCompressionLevel, + /*initialize_stats=*/nullptr); +} + class DocHitInfoIteratorDeletedFilterTest : public ::testing::Test { protected: DocHitInfoIteratorDeletedFilterTest() @@ -73,8 +84,8 @@ class DocHitInfoIteratorDeletedFilterTest : public ::testing::Test { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, - DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + CreateDocumentStore(&filesystem_, test_dir_, &fake_clock_, + schema_store_.get())); document_store_ = std::move(create_result.document_store); } @@ -240,8 +251,8 @@ class DocHitInfoIteratorNamespaceFilterTest : public ::testing::Test { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, - DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + CreateDocumentStore(&filesystem_, test_dir_, &fake_clock_, + schema_store_.get())); document_store_ = std::move(create_result.document_store); } @@ -395,8 +406,8 @@ class DocHitInfoIteratorSchemaTypeFilterTest : public ::testing::Test { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, - DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + CreateDocumentStore(&filesystem_, test_dir_, &fake_clock_, + schema_store_.get())); document_store_ = std::move(create_result.document_store); } @@ -535,8 +546,8 @@ class DocHitInfoIteratorExpirationFilterTest : public ::testing::Test { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, - DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + CreateDocumentStore(&filesystem_, test_dir_, &fake_clock_, + schema_store_.get())); document_store_ = std::move(create_result.document_store); } @@ -563,8 +574,8 @@ TEST_F(DocHitInfoIteratorExpirationFilterTest, TtlZeroIsntFilteredOut) { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, - DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + CreateDocumentStore(&filesystem_, test_dir_, &fake_clock_, + schema_store_.get())); std::unique_ptr<DocumentStore> document_store = std::move(create_result.document_store); @@ -595,8 +606,8 @@ TEST_F(DocHitInfoIteratorExpirationFilterTest, BeforeTtlNotFilteredOut) { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, - DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + CreateDocumentStore(&filesystem_, test_dir_, &fake_clock_, + schema_store_.get())); std::unique_ptr<DocumentStore> document_store = std::move(create_result.document_store); @@ -627,8 +638,8 @@ TEST_F(DocHitInfoIteratorExpirationFilterTest, EqualTtlFilteredOut) { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, - DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + CreateDocumentStore(&filesystem_, test_dir_, &fake_clock_, + schema_store_.get())); std::unique_ptr<DocumentStore> document_store = std::move(create_result.document_store); @@ -660,8 +671,8 @@ TEST_F(DocHitInfoIteratorExpirationFilterTest, PastTtlFilteredOut) { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, - DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + CreateDocumentStore(&filesystem_, test_dir_, &fake_clock_, + schema_store_.get())); std::unique_ptr<DocumentStore> document_store = std::move(create_result.document_store); @@ -735,8 +746,8 @@ class DocHitInfoIteratorFilterTest : public ::testing::Test { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, - DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + CreateDocumentStore(&filesystem_, test_dir_, &fake_clock_, + schema_store_.get())); document_store_ = std::move(create_result.document_store); } @@ -770,8 +781,8 @@ TEST_F(DocHitInfoIteratorFilterTest, CombineAllFiltersOk) { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, - DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + CreateDocumentStore(&filesystem_, test_dir_, &fake_clock_, + schema_store_.get())); std::unique_ptr<DocumentStore> document_store = std::move(create_result.document_store); diff --git a/icing/index/iterator/doc-hit-info-iterator-section-restrict_test.cc b/icing/index/iterator/doc-hit-info-iterator-section-restrict_test.cc index 5dd69c1..60b9a12 100644 --- a/icing/index/iterator/doc-hit-info-iterator-section-restrict_test.cc +++ b/icing/index/iterator/doc-hit-info-iterator-section-restrict_test.cc @@ -100,7 +100,12 @@ class DocHitInfoIteratorSectionRestrictTest : public ::testing::Test { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult create_result, DocumentStore::Create(&filesystem_, test_dir_, &fake_clock_, - schema_store_.get())); + schema_store_.get(), + /*force_recovery_and_revalidate_documents=*/false, + /*namespace_id_fingerprint=*/false, + PortableFileBackedProtoLog< + DocumentWrapper>::kDeflateCompressionLevel, + /*initialize_stats=*/nullptr)); document_store_ = std::move(create_result.document_store); } diff --git a/icing/index/numeric/integer-index-storage.cc b/icing/index/numeric/integer-index-storage.cc index db1983c..f3901e1 100644 --- a/icing/index/numeric/integer-index-storage.cc +++ b/icing/index/numeric/integer-index-storage.cc @@ -818,6 +818,9 @@ IntegerIndexStorage::InitializeExistingFiles( /*max_file_size=*/kMetadataFileSize, /*pre_mapping_file_offset=*/0, /*pre_mapping_mmap_size=*/kMetadataFileSize)); + if (metadata_mmapped_file.available_size() != kMetadataFileSize) { + return absl_ports::FailedPreconditionError("Incorrect metadata file size"); + } // Initialize sorted_buckets int32_t pre_mapping_mmap_size = sizeof(Bucket) * (1 << 10); diff --git a/icing/index/numeric/integer-index.cc b/icing/index/numeric/integer-index.cc index 2f876e4..e7978bf 100644 --- a/icing/index/numeric/integer-index.cc +++ b/icing/index/numeric/integer-index.cc @@ -293,6 +293,10 @@ libtextclassifier3::Status IntegerIndex::Optimize( /*max_file_size=*/kMetadataFileSize, /*pre_mapping_file_offset=*/0, /*pre_mapping_mmap_size=*/kMetadataFileSize)); + if (metadata_mmapped_file.available_size() != kMetadataFileSize) { + return absl_ports::InternalError( + "Invalid metadata file size after Optimize"); + } metadata_mmapped_file_ = std::make_unique<MemoryMappedFile>(std::move(metadata_mmapped_file)); @@ -410,6 +414,9 @@ IntegerIndex::InitializeExistingFiles(const Filesystem& filesystem, /*max_file_size=*/kMetadataFileSize, /*pre_mapping_file_offset=*/0, /*pre_mapping_mmap_size=*/kMetadataFileSize)); + if (metadata_mmapped_file.available_size() != kMetadataFileSize) { + return absl_ports::FailedPreconditionError("Incorrect metadata file size"); + } auto posting_list_serializer = std::make_unique<PostingListIntegerIndexSerializer>(); diff --git a/icing/index/numeric/integer-index_test.cc b/icing/index/numeric/integer-index_test.cc index c4dacb8..ec7f55b 100644 --- a/icing/index/numeric/integer-index_test.cc +++ b/icing/index/numeric/integer-index_test.cc @@ -84,7 +84,12 @@ class NumericIndexIntegerTest : public ::testing::Test { ICING_ASSERT_OK_AND_ASSIGN( DocumentStore::CreateResult doc_store_create_result, DocumentStore::Create(&filesystem_, document_store_dir, &clock_, - schema_store_.get())); + schema_store_.get(), + /*force_recovery_and_revalidate_documents=*/false, + /*namespace_id_fingerprint=*/false, + PortableFileBackedProtoLog< + DocumentWrapper>::kDeflateCompressionLevel, + /*initialize_stats=*/nullptr)); doc_store_ = std::move(doc_store_create_result.document_store); } @@ -132,7 +137,8 @@ class NumericIndexIntegerTest : public ::testing::Test { } ICING_ASSIGN_OR_RETURN( std::vector<DocumentId> docid_map, - doc_store_->OptimizeInto(document_store_compact_dir, nullptr)); + doc_store_->OptimizeInto(document_store_compact_dir, nullptr, + /*namespace_id_fingerprint=*/false)); doc_store_.reset(); if (!filesystem_.SwapFiles(document_store_dir.c_str(), @@ -147,7 +153,12 @@ class NumericIndexIntegerTest : public ::testing::Test { ICING_ASSIGN_OR_RETURN( DocumentStore::CreateResult doc_store_create_result, DocumentStore::Create(&filesystem_, document_store_dir, &clock_, - schema_store_.get())); + schema_store_.get(), + /*force_recovery_and_revalidate_documents=*/false, + /*namespace_id_fingerprint=*/false, + PortableFileBackedProtoLog< + DocumentWrapper>::kDeflateCompressionLevel, + /*initialize_stats=*/nullptr)); doc_store_ = std::move(doc_store_create_result.document_store); return docid_map; } |