Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore: Optimize local cache sync when resuming a query that had docs deleted #11457

Merged
merged 30 commits into from
Jun 20, 2023
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ca6f7d2
add bloomFilter to proto (#10823)
milaGGL Feb 16, 2023
abd5af2
Create bloom filter class header filer (#10841)
milaGGL Feb 21, 2023
2e78e41
Merge branch 'master' into mila/BloomFilter
milaGGL Feb 23, 2023
024df8c
Implement BloomFilter class (#10846)
milaGGL Feb 28, 2023
698c946
Firestore: Add CalculateMd5Digest() function (#10854)
dconeybe Feb 28, 2023
93815e6
Add golden tests for BloomFilter (#10874)
milaGGL Mar 3, 2023
3b5b49b
Add expected count to Target (#10872)
milaGGL Mar 8, 2023
d08ee84
Merge branch 'master' into mila/BloomFilter
milaGGL Mar 13, 2023
5252a62
Merge branch 'master' into mila/BloomFilter
milaGGL Mar 16, 2023
9dc9f3e
Add unchanged names to existence filter and watchFilters spec test ru…
milaGGL Mar 18, 2023
de45a95
Merge branch 'master' into mila/BloomFilter
milaGGL Mar 20, 2023
d86d788
fields_array.h: add missing template specializations for bloom filter…
dconeybe Mar 22, 2023
b761c5f
Apply bloom filter on existence filter mismatch (#10953)
milaGGL Mar 23, 2023
62afd7c
Merge branch 'master' into mila/BloomFilter
milaGGL Mar 24, 2023
08025ae
Add new goog-listen-tags for BloomFilter (#10977)
milaGGL Mar 25, 2023
3bc3a48
remove unnecessary local variable
milaGGL Mar 27, 2023
0745252
Merge remote-tracking branch 'origin/master' into mila/BloomFilter
dconeybe Mar 29, 2023
5b83bd4
Use ByteString instead of std::vector in the BloomFilter (#11038)
dconeybe Mar 30, 2023
3819fcf
Merge remote-tracking branch 'origin/master' into mila/BloomFilter
dconeybe Apr 13, 2023
7e8f921
Merge remote-tracking branch 'origin/master' into mila/BloomFilter
dconeybe Apr 26, 2023
d43007c
project.pbxproj update
dconeybe Apr 27, 2023
bd0ebba
FSTSpecTests.mm: add TargetPurposeExistenceFilterMismatchBloom
dconeybe Apr 27, 2023
d196b9a
Merge remote-tracking branch 'origin/master' into mila/BloomFilter
dconeybe May 2, 2023
bed753b
Merge remote-tracking branch 'origin/master' into mila/BloomFilter
dconeybe May 3, 2023
6435094
Merge remote-tracking branch 'origin/master' into mila/BloomFilter
dconeybe Jun 13, 2023
7979684
FIRQueryTests.mm: static_cast<int> -> size_t{1}
dconeybe Jun 13, 2023
665372e
Merge remote-tracking branch 'origin/master' into mila/BloomFilter
dconeybe Jun 16, 2023
d73d97c
Update the integration test to verify that bloom filter averted full …
dconeybe Jun 19, 2023
749ee64
Firestore/CHANGELOG.md: Add change log entry (NOTE: update with actua…
dconeybe Jun 19, 2023
be2052b
Merge remote-tracking branch 'origin/master' into mila/BloomFilter
dconeybe Jun 19, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create bloom filter class header filer (#10841)
  • Loading branch information
milaGGL authored Feb 21, 2023
commit abd5af29a2eee6a28f6d713fec80339313fb46f5
72 changes: 72 additions & 0 deletions Firestore/core/src/remote/bloom_filter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef FIRESTORE_CORE_SRC_REMOTE_BLOOM_FILTER_H_
#define FIRESTORE_CORE_SRC_REMOTE_BLOOM_FILTER_H_

#include <string>
#include <vector>
#include "absl/strings/string_view.h"

namespace firebase {
namespace firestore {
namespace remote {

class BloomFilter final {
public:
BloomFilter(std::vector<uint8_t> bitmap, int32_t padding, int32_t hash_count);

// Copyable & movable.
BloomFilter(const BloomFilter&) = default;
BloomFilter(BloomFilter&&) = default;
BloomFilter& operator=(const BloomFilter&) = default;
BloomFilter& operator=(BloomFilter&&) = default;

/**
* Check whether the given string is a possible member of the bloom filter. It
* might return false positive result, ie, the given string is not a member of
* the bloom filter, but the method returned true.
*
* @param value the string to be tested for membership.
* @return true if the given string might be contained in the bloom filter, or
* false if the given string is definitely not contained in the bloom filter.
*/
bool MightContain(absl::string_view value) const;

// Get the `bit_count_` field. Used for testing purpose.
int32_t bit_count() const {
return bit_count_;
}

private:
// The number of bits in the bloom filter. Guaranteed to be non-negative, and
// less than the max number of bits `bitmap_` can represent, i.e.,
// bitmap_.size() * 8.
int32_t bit_count_ = 0;

// The number of hash functions used to construct the filter. Guaranteed to be
// non-negative.
int32_t hash_count_ = 0;

// Bloom filter's bitmap.
std::vector<uint8_t> bitmap_;
};

} // namespace remote
} // namespace firestore
} // namespace firebase

#endif // FIRESTORE_CORE_SRC_REMOTE_BLOOM_FILTER_H_