aboutsummaryrefslogtreecommitdiff
path: root/icing/monkey_test/in-memory-icing-search-engine.h
diff options
context:
space:
mode:
authorArmaan Danewalia <adanewalia@google.com>2022-11-11 18:53:19 +0000
committerArmaan Danewalia <adanewalia@google.com>2022-11-11 20:38:15 +0000
commit2658f90984737e5bf6c76d82024103dccd4d51c6 (patch)
tree829722f920f1bca12a8e15bf3b81d87c24673e24 /icing/monkey_test/in-memory-icing-search-engine.h
parent0cdc7152cbee44a55b800ef1ac4cb4ee609c0389 (diff)
downloadicing-2658f90984737e5bf6c76d82024103dccd4d51c6.tar.gz
Sync from upstream.
Descriptions: ====================================================================== Include equals-proto and convert CodeToString methods to inline. ====================================================================== Add schema and document generators used by monkey test ====================================================================== Create in-memory icing for monkey testing ====================================================================== [NumericSearch][Storage][refactor_posting_list][1/x] Create PostingListUsedHitSerializer ====================================================================== [NumericSearch][Storage][refactor_posting_list][2/x] Create PostingListUsedHitSerializerTest ====================================================================== [NumericSearch][Storage][refactor_posting_list][3/x] Refactor all posting list related classes to use PostingListUsedSerializer ====================================================================== Adds a JoinSpecProto, and a new ranking strategy ====================================================================== Create Monkey Test Runner that randomly performs Icing API calls and check the results with the in-memory Icing ====================================================================== Support monkey testing the DeleteByQuery and Search APIs of Icing search engine ====================================================================== Directly include proto.h files from portable_proto_library() instead of wrapper pb.h files. ====================================================================== Directly include proto.h files from portable_proto_library() instead of wrapper pb.h files. ====================================================================== Directly include proto.h files from portable_proto_library() instead of wrapper pb.h files. ====================================================================== Removes nested_query from JoinSpec, as nested_search_spec includes it. ====================================================================== Directly include proto.h files from portable_proto_library() instead of wrapper pb.h files. ====================================================================== Swap the order when we build the doc-hit-info-iterator-and. ====================================================================== Support monkey testing section restrictions in the DeleteByQuery and Search APIs ====================================================================== Allow the in-memory icing to return the number of deleted documents, and check it with the delete stats of DeleteByNamespace, DeleteBySchemaType, and DeleteByQuery in the monkey test ====================================================================== [NumericSearch][Storage][refactor_posting_list][4/x] Move posting list common files into another directory ====================================================================== Add file-skipping for exports to Jetpack using @exportToAOSP:skipFile() tag ====================================================================== Change invalid type int32 to int32_t in icing-search-enging-jni.cc. ====================================================================== Minor fix, move generate term_iterator inside of the ranking_strategy checking ====================================================================== Address index out of bounds issue in third_party/icing/result/snippet-retriever.cc. This issue is causing test failures (see example failure: http://sponge2/cfcda71a-1312-455a-9a70-821c74c708e6). ====================================================================== Fix 1 DependencyCleaner findings: ====================================================================== Implement URL tokenization for Icing-lib [2/2]: ====================================================================== [NumericSearch][General][1/x] Create numeric.proto and add IntegerIndexingConfig ====================================================================== [NumericSearch][General][2/x] Refactor GetStringSectionContent and GetStringPropertyContent ====================================================================== [NumericSearch][General][3/x] Add DataType into SectionMetadata and change AssignSections ====================================================================== Move unit test constant definition into schema builder ====================================================================== [NumericSearch][General][4/x] Create templated Section and SectionGroup ====================================================================== [NumericSearch][General][5/x] Create BasicHit ====================================================================== Change URL tokenizer's url_parse dependency to use third_party/url_parse:url_parse_stripped_down ====================================================================== Exclude memory-mapped-file-leak_test.cc from export to AOSP. ====================================================================== Rollback of changelist 487633403. Reason: This cl breaks YouTube Music builds due to duplicate symbols. ====================================================================== [ez] Fix ScoredDocumentHit related comparators ====================================================================== Bug: 193244409 Bug: 246984163 Bug: 249829533 Bug: 256022027 Bug: 256679292 Bug: 246964044 Change-Id: I55c2ed417a31321c22de377e97ffe0096478d28c
Diffstat (limited to 'icing/monkey_test/in-memory-icing-search-engine.h')
-rw-r--r--icing/monkey_test/in-memory-icing-search-engine.h39
1 files changed, 33 insertions, 6 deletions
diff --git a/icing/monkey_test/in-memory-icing-search-engine.h b/icing/monkey_test/in-memory-icing-search-engine.h
index 0c6c03b..a5d8872 100644
--- a/icing/monkey_test/in-memory-icing-search-engine.h
+++ b/icing/monkey_test/in-memory-icing-search-engine.h
@@ -27,6 +27,7 @@
#include "icing/monkey_test/monkey-tokenized-document.h"
#include "icing/proto/document.pb.h"
#include "icing/proto/schema.pb.h"
+#include "icing/proto/search.pb.h"
#include "icing/store/document-id.h"
namespace icing {
@@ -47,6 +48,8 @@ class InMemoryIcingSearchEngine {
: random_(random),
schema_(std::make_unique<SchemaProto>(std::move(schema))) {}
+ uint32_t GetNumAliveDocuments() const { return existing_doc_ids_.size(); }
+
const SchemaProto *GetSchema() const { return schema_.get(); }
// Randomly pick a document from the in-memory Icing for monkey testing.
@@ -81,16 +84,35 @@ class InMemoryIcingSearchEngine {
// Deletes all Documents belonging to the specified namespace.
//
// Returns:
- // OK on success
- // NOT_FOUND if namespace doesn't exist
- libtextclassifier3::Status DeleteByNamespace(const std::string &name_space);
+ // The number of deleted documents on success
+ // INTERNAL_ERROR if there are inconsistencies in the in-memory Icing
+ libtextclassifier3::StatusOr<uint32_t> DeleteByNamespace(
+ const std::string &name_space);
// Deletes all Documents belonging to the specified type
//
// Returns:
- // OK on success
- // NOT_FOUND if schema type doesn't exist
- libtextclassifier3::Status DeleteBySchemaType(const std::string &schema_type);
+ // The number of deleted documents on success
+ // INTERNAL_ERROR if there are inconsistencies in the in-memory Icing
+ libtextclassifier3::StatusOr<uint32_t> DeleteBySchemaType(
+ const std::string &schema_type);
+
+ // Deletes all Documents that match the query specified in search_spec.
+ // Currently, only the "query" and "term_match_type" fields are recognized by
+ // the in-memory Icing, and only single term queries with possible section
+ // restrictions are supported.
+ //
+ // Returns:
+ // The number of deleted documents on success
+ // INTERNAL_ERROR if there are inconsistencies in the in-memory Icing
+ libtextclassifier3::StatusOr<uint32_t> DeleteByQuery(
+ const SearchSpecProto &search_spec);
+
+ // Retrieves documents according to search_spec.
+ // Currently, only the "query" and "term_match_type" fields are recognized by
+ // the in-memory Icing, and only single term queries with possible section
+ // restrictions are supported.
+ std::vector<DocumentProto> Search(const SearchSpecProto &search_spec) const;
private:
// Does not own.
@@ -113,6 +135,11 @@ class InMemoryIcingSearchEngine {
// NOT_FOUND if the key doesn't exist or doc has been deleted
libtextclassifier3::StatusOr<DocumentId> InternalGet(
const std::string &name_space, const std::string &uri) const;
+
+ // A helper method for DeleteByQuery and Search to get matched internal doc
+ // ids.
+ std::vector<DocumentId> InternalSearch(
+ const SearchSpecProto &search_spec) const;
};
} // namespace lib