aboutsummaryrefslogtreecommitdiff
path: root/icing/store/document-store.cc
diff options
context:
space:
mode:
authorCassie Wang <cassiewang@google.com>2020-06-26 13:14:18 -0700
committerCassie Wang <cassiewang@google.com>2020-06-26 14:29:07 -0700
commit1db05b5d41d80b78de1acafa6f061af6dac689f2 (patch)
treed6251802e82a3a78d9669332e22e0fadd4e80a03 /icing/store/document-store.cc
parent40fad6a05f152d5207dcc1644f9b411d5ec78e39 (diff)
parent09d66401215254a2bdfc134009039636054d28d2 (diff)
downloadicing-1db05b5d41d80b78de1acafa6f061af6dac689f2.tar.gz
Merge remote-tracking branch 'aosp/upstream-master' into androidx-master-dev
* aosp/upstream-master: Pull upstream changes. Change-Id: Ia97bfcc86c1facdfedf6984a47db254129fa11ce
Diffstat (limited to 'icing/store/document-store.cc')
-rw-r--r--icing/store/document-store.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/icing/store/document-store.cc b/icing/store/document-store.cc
index ae8360b..93cebaa 100644
--- a/icing/store/document-store.cc
+++ b/icing/store/document-store.cc
@@ -778,6 +778,36 @@ libtextclassifier3::StatusOr<DocumentId> DocumentStore::GetDocumentId(
return document_id_or.ValueOrDie();
}
+std::vector<std::string> DocumentStore::GetAllNamespaces() const {
+ std::unordered_map<NamespaceId, std::string> namespace_id_to_namespace =
+ namespace_mapper_->GetValuesToKeys();
+
+ std::unordered_set<NamespaceId> existing_namespace_ids;
+ for (DocumentId document_id = 0; document_id < filter_cache_->num_elements();
+ ++document_id) {
+ // filter_cache_->Get can only fail if document_id is < 0
+ // or >= filter_cache_->num_elements. So, this error SHOULD NEVER HAPPEN.
+ auto status_or_data = filter_cache_->Get(document_id);
+ if (!status_or_data.ok()) {
+ ICING_LOG(ERROR)
+ << "Error while iterating over filter cache in GetAllNamespaces";
+ return std::vector<std::string>();
+ }
+ const DocumentFilterData* data = status_or_data.ValueOrDie();
+
+ if (DoesDocumentExist(document_id)) {
+ existing_namespace_ids.insert(data->namespace_id());
+ }
+ }
+
+ std::vector<std::string> existing_namespaces;
+ for (auto itr = existing_namespace_ids.begin();
+ itr != existing_namespace_ids.end(); ++itr) {
+ existing_namespaces.push_back(namespace_id_to_namespace.at(*itr));
+ }
+ return existing_namespaces;
+}
+
libtextclassifier3::StatusOr<int64_t>
DocumentStore::DoesDocumentExistAndGetFileOffset(DocumentId document_id) const {
if (!IsDocumentIdValid(document_id)) {