From 535d43a558edf79920bb3293afd2e24d2702a3e7 Mon Sep 17 00:00:00 2001 From: cherylEnkidu <96084918+cherylEnkidu@users.noreply.github.com> Date: Fri, 4 Jul 2025 14:05:34 -0400 Subject: [PATCH 01/20] Upgrade c++14 to c++17 in cmake (#15073) --- Firestore/core/src/local/leveldb_remote_document_cache.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firestore/core/src/local/leveldb_remote_document_cache.cc b/Firestore/core/src/local/leveldb_remote_document_cache.cc index 842d42bb43c..6c6452ca032 100644 --- a/Firestore/core/src/local/leveldb_remote_document_cache.cc +++ b/Firestore/core/src/local/leveldb_remote_document_cache.cc @@ -195,8 +195,8 @@ MutableDocumentMap LevelDbRemoteDocumentCache::GetAllExisting( tasks.AwaitAll(); MutableDocumentMap map; - for (const auto& entry : results.Result()) { - map = map.insert(entry.first, entry.second); + for (const auto& [key, doc] : results.Result()) { + map = map.insert(key, doc); } return map; } From b759c82d327b04bf51b664b2f0dd488a041ca5f2 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 8 Jul 2025 16:34:08 -0400 Subject: [PATCH 02/20] remove c++17 feature --- Firestore/core/src/local/leveldb_remote_document_cache.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firestore/core/src/local/leveldb_remote_document_cache.cc b/Firestore/core/src/local/leveldb_remote_document_cache.cc index 6c6452ca032..842d42bb43c 100644 --- a/Firestore/core/src/local/leveldb_remote_document_cache.cc +++ b/Firestore/core/src/local/leveldb_remote_document_cache.cc @@ -195,8 +195,8 @@ MutableDocumentMap LevelDbRemoteDocumentCache::GetAllExisting( tasks.AwaitAll(); MutableDocumentMap map; - for (const auto& [key, doc] : results.Result()) { - map = map.insert(key, doc); + for (const auto& entry : results.Result()) { + map = map.insert(entry.first, entry.second); } return map; } From 0307e93ff3469b8670a6ee27428744d7c99553e8 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Mon, 16 Mar 2026 16:44:06 -0400 Subject: [PATCH 03/20] fix ruby build --- scripts/cocoapods_cxx17_patch.rb | 45 ++++++++++++++++++++++++++++++++ scripts/pod_lib_lint.rb | 6 +++++ 2 files changed, 51 insertions(+) create mode 100644 scripts/cocoapods_cxx17_patch.rb diff --git a/scripts/cocoapods_cxx17_patch.rb b/scripts/cocoapods_cxx17_patch.rb new file mode 100644 index 00000000000..4111bb0327e --- /dev/null +++ b/scripts/cocoapods_cxx17_patch.rb @@ -0,0 +1,45 @@ +# Copyright 2024 Google +# +# 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. + +module CocoapodsCXX17Patch + def self.apply_patch + Pod::HooksManager.register('cocoapods-cxx17-patch', :post_install) do |context| + targets_to_patch = ['BoringSSL-GRPC', 'gRPC-C++', 'abseil'] + context.pods_project.targets.each do |target| + if targets_to_patch.any? { |name| target.name.start_with?(name) } + target.build_configurations.each do |config| + config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17' + config.build_settings['CLANG_CXX_LIBRARY'] = 'libc++' + end + end + end + end + end +end + +if defined?(Pod::HooksManager) + CocoapodsCXX17Patch.apply_patch +else + # Hook into require to apply the patch once cocoapods is loaded + module Kernel + alias_method :original_require, :require + def require(name) + result = original_require(name) + if name == 'cocoapods' + CocoapodsCXX17Patch.apply_patch + end + result + end + end +end diff --git a/scripts/pod_lib_lint.rb b/scripts/pod_lib_lint.rb index ffe67e54955..a192e10c880 100755 --- a/scripts/pod_lib_lint.rb +++ b/scripts/pod_lib_lint.rb @@ -88,6 +88,12 @@ def main(args) # by the shell when the command is copy-pasted, preventing unintended brace expansion. puts command.map { |arg| arg =~ /[{}]/ ? "'#{arg}'" : arg }.join(' ') + # Inject C++17 patch for pods that require it into RUBYOPT + patch_file = File.expand_path('cocoapods_cxx17_patch.rb', __dir__) + if File.exist?(patch_file) + ENV['RUBYOPT'] = "#{ENV['RUBYOPT']} -r#{patch_file}" + end + # Run the lib lint command in a thread. pod_lint_status = 1 t = Thread.new do From c223f92838b0d60d1c5d45994af83f38a4670a21 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Mon, 16 Mar 2026 17:00:14 -0400 Subject: [PATCH 04/20] add copyright --- scripts/cocoapods_cxx17_patch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cocoapods_cxx17_patch.rb b/scripts/cocoapods_cxx17_patch.rb index 4111bb0327e..16c478ae11e 100644 --- a/scripts/cocoapods_cxx17_patch.rb +++ b/scripts/cocoapods_cxx17_patch.rb @@ -1,4 +1,4 @@ -# Copyright 2024 Google +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From ca584186800a47765ce426730165a98efb83d216 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 17 Mar 2026 12:32:59 -0400 Subject: [PATCH 05/20] patch the testing app --- Firestore/Example/Podfile | 5 ++++ IntegrationTesting/ClientApp/Podfile | 5 ++++ scripts/cocoapods_cxx17_patch.rb | 34 +++++++--------------------- scripts/install_prereqs.sh | 4 ++++ 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/Firestore/Example/Podfile b/Firestore/Example/Podfile index a5f91374557..639410ac643 100644 --- a/Firestore/Example/Podfile +++ b/Firestore/Example/Podfile @@ -1,6 +1,7 @@ # Copyright 2017 Google LLC require 'pathname' +require_relative '../../scripts/cocoapods_cxx17_patch.rb' # Uncomment the next two lines for pre-release testing on internal repo #source 'sso://cpdc-internal/firebase' @@ -188,3 +189,7 @@ if is_platform(:tvos) end end end + +post_install do |installer| + CocoapodsCXX17Patch.apply_patch(installer) +end diff --git a/IntegrationTesting/ClientApp/Podfile b/IntegrationTesting/ClientApp/Podfile index bd0676baa94..7839940f4f7 100644 --- a/IntegrationTesting/ClientApp/Podfile +++ b/IntegrationTesting/ClientApp/Podfile @@ -1,3 +1,4 @@ +require_relative '../../scripts/cocoapods_cxx17_patch.rb' source 'https://github.com/firebase/SpecsDev.git' source 'https://github.com/firebase/SpecsStaging.git' source 'https://cdn.cocoapods.org/' @@ -31,3 +32,7 @@ target 'ClientApp-CocoaPods' do pod 'FirebasePerformance', :path => '../../' pod 'Firebase', :path => '../../' end + +post_install do |installer| + CocoapodsCXX17Patch.apply_patch(installer) +end diff --git a/scripts/cocoapods_cxx17_patch.rb b/scripts/cocoapods_cxx17_patch.rb index 16c478ae11e..1823259fc21 100644 --- a/scripts/cocoapods_cxx17_patch.rb +++ b/scripts/cocoapods_cxx17_patch.rb @@ -1,4 +1,4 @@ -# Copyright 2024 Google LLC +# Copyright 2025 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,33 +13,15 @@ # limitations under the License. module CocoapodsCXX17Patch - def self.apply_patch - Pod::HooksManager.register('cocoapods-cxx17-patch', :post_install) do |context| - targets_to_patch = ['BoringSSL-GRPC', 'gRPC-C++', 'abseil'] - context.pods_project.targets.each do |target| - if targets_to_patch.any? { |name| target.name.start_with?(name) } - target.build_configurations.each do |config| - config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17' - config.build_settings['CLANG_CXX_LIBRARY'] = 'libc++' - end + def self.apply_patch(installer) + targets_to_patch = ['BoringSSL-GRPC', 'gRPC-C++', 'abseil'] + installer.pods_project.targets.each do |target| + if targets_to_patch.any? { |name| target.name.start_with?(name) } + target.build_configurations.each do |config| + config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17' + config.build_settings['CLANG_CXX_LIBRARY'] = 'libc++' end end end end end - -if defined?(Pod::HooksManager) - CocoapodsCXX17Patch.apply_patch -else - # Hook into require to apply the patch once cocoapods is loaded - module Kernel - alias_method :original_require, :require - def require(name) - result = original_require(name) - if name == 'cocoapods' - CocoapodsCXX17Patch.apply_patch - end - result - end - end -end diff --git a/scripts/install_prereqs.sh b/scripts/install_prereqs.sh index 14e6b05d798..37e0e971524 100755 --- a/scripts/install_prereqs.sh +++ b/scripts/install_prereqs.sh @@ -64,6 +64,10 @@ if [[ "$method" != "cmake" ]]; then scripts/setup_bundler.sh fi +if [[ -f "$(pwd)/scripts/cocoapods_cxx17_patch.rb" ]]; then + export RUBYOPT="-r$(pwd)/scripts/cocoapods_cxx17_patch.rb" +fi + case "$project-$platform-$method" in FirebasePod-iOS-*) From 92b67c4fc25c5fbb86140fc5981157d203ddbc93 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Wed, 1 Apr 2026 16:09:57 -0400 Subject: [PATCH 06/20] fix more bugs --- scripts/cocoapods_cxx17_patch.rb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/cocoapods_cxx17_patch.rb b/scripts/cocoapods_cxx17_patch.rb index 1823259fc21..d900ae801a2 100644 --- a/scripts/cocoapods_cxx17_patch.rb +++ b/scripts/cocoapods_cxx17_patch.rb @@ -14,14 +14,24 @@ module CocoapodsCXX17Patch def self.apply_patch(installer) - targets_to_patch = ['BoringSSL-GRPC', 'gRPC-C++', 'abseil'] - installer.pods_project.targets.each do |target| - if targets_to_patch.any? { |name| target.name.start_with?(name) } - target.build_configurations.each do |config| - config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17' - config.build_settings['CLANG_CXX_LIBRARY'] = 'libc++' + targets_to_patch = ['BoringSSL-GRPC', 'gRPC-C++', 'abseil', 'Pods-'] + projects = [] + if installer.respond_to?(:pods_project) && installer.pods_project + projects << installer.pods_project + elsif installer.respond_to?(:generated_projects) + projects = installer.generated_projects + end + + projects.each do |project| + project.targets.each do |target| + if targets_to_patch.any? { |name| target.name.start_with?(name) } + target.build_configurations.each do |config| + config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17' + config.build_settings['CLANG_CXX_LIBRARY'] = 'libc++' + end end end + project.save if installer.respond_to?(:generated_projects) # Save subprojects end end end From 4fced8564d34339fa333239c81546f4f93d4aa74 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Thu, 2 Apr 2026 17:13:18 -0400 Subject: [PATCH 07/20] add patch --- Firestore/Example/Podfile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Firestore/Example/Podfile b/Firestore/Example/Podfile index 639410ac643..af9586235a6 100644 --- a/Firestore/Example/Podfile +++ b/Firestore/Example/Podfile @@ -33,6 +33,44 @@ post_install do |installer| if !$?.success? raise "sync_project.rb failed with status #{$?.exitstatus}" end + # Apply C++17 patch to all pod targets in generated projects + projects = installer.respond_to?(:generated_projects) ? installer.generated_projects : [installer.pods_project].compact + projects.each do |project| + project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17' + config.build_settings['CLANG_CXX_LIBRARY'] = 'libc++' + end + end + project.save if installer.respond_to?(:generated_projects) + end + + # Clean up duplicate C++ standards and suppress deprecation warnings in xcconfig files + podfile_dir = Pathname.new(__FILE__).dirname + installer.aggregate_targets.each do |target| + ['debug', 'release'].each do |config_type| + path = podfile_dir.join("Pods/Target Support Files/#{target.name}/#{target.name}.#{config_type}.xcconfig") + if File.exist?(path) + content = File.read(path) + modified = false + + if content.include?('c++14 c++17') + content.gsub!('c++14 c++17', 'c++17') + modified = true + end + + if content.include?('-Werror') && !content.include?('-Wno-deprecated-declarations') + content.gsub!('-Werror', '-Werror -Wno-deprecated-declarations') + modified = true + end + + if modified + File.write(path, content) + puts "Fixed up xcconfig: #{File.basename(path)}" + end + end + end + end end # Returns true if the user has explicitly requested local sources or if this is From e5e934c06cac6c7b8090a64572e63b192a21b5f9 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Fri, 10 Apr 2026 16:48:28 -0400 Subject: [PATCH 08/20] update the deployment target of macos --- Firestore/Example/Firestore.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Firestore/Example/Firestore.xcodeproj/project.pbxproj b/Firestore/Example/Firestore.xcodeproj/project.pbxproj index 993a66b8eb9..7642e25a5ff 100644 --- a/Firestore/Example/Firestore.xcodeproj/project.pbxproj +++ b/Firestore/Example/Firestore.xcodeproj/project.pbxproj @@ -6399,6 +6399,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.google.Firestore-IntegrationTests-macOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + MACOSX_DEPLOYMENT_TARGET = 11.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Firestore_Example_macOS.app/Contents/MacOS/Firestore_Example_macOS"; WARNING_CFLAGS = ( "$(inherited)", @@ -6429,6 +6430,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.google.Firestore-IntegrationTests-macOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + MACOSX_DEPLOYMENT_TARGET = 11.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Firestore_Example_macOS.app/Contents/MacOS/Firestore_Example_macOS"; WARNING_CFLAGS = ( "$(inherited)", From d827cdff030332478f12ff033e12590663eaa944 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Wed, 1 Apr 2026 14:22:41 -0400 Subject: [PATCH 09/20] use failed tests to verify the restriction --- Firestore/Swift/Tests/Integration/PipelineTests.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Firestore/Swift/Tests/Integration/PipelineTests.swift b/Firestore/Swift/Tests/Integration/PipelineTests.swift index 5cfcc69743d..020ae026bfb 100644 --- a/Firestore/Swift/Tests/Integration/PipelineTests.swift +++ b/Firestore/Swift/Tests/Integration/PipelineTests.swift @@ -276,6 +276,7 @@ class PipelineIntegrationTests: FSTIntegrationTestCase { } func testSupportsCollectionGroupAsSource() async throws { + XCTAssertTrue(false, "Intentional failure for testing") let db = firestore() let rootCollForTest = collectionRef() From a7b9a4de2551906542f03bd1030b417d3c3d08db Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Wed, 1 Apr 2026 16:57:18 -0400 Subject: [PATCH 10/20] introduce cache system --- .github/workflows/sdk.firestore.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/sdk.firestore.yml b/.github/workflows/sdk.firestore.yml index a13aef0e4fe..fd036ba5bfd 100644 --- a/.github/workflows/sdk.firestore.yml +++ b/.github/workflows/sdk.firestore.yml @@ -333,6 +333,14 @@ jobs: restore-keys: | ${{ runner.os }}-pods-${{ matrix.target }}- + - name: Cache Pods + uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: Firestore/Example/Pods + key: ${{ runner.os }}-pods-${{ matrix.target }}-${{ hashFiles('Firestore/Example/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods-${{ matrix.target }}- + # 'FirestoreEnterprise' is used as product name for `build.sh` to select the enterprise build variant. `install_prereqs.sh` does not require this distinction, so 'Firestore' is used. - name: Setup build run: scripts/install_prereqs.sh Firestore ${{ matrix.target }} xcodebuild @@ -398,6 +406,14 @@ jobs: restore-keys: | ${{ runner.os }}-pods-${{ matrix.target }}- + - name: Cache Pods + uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: Firestore/Example/Pods + key: ${{ runner.os }}-pods-${{ matrix.target }}-${{ hashFiles('Firestore/Example/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods-${{ matrix.target }}- + # 'FirestoreEnterprise' is used as product name for `build.sh` to select the enterprise build variant. `install_prereqs.sh` does not require this distinction, so 'Firestore' is used. - name: Setup build run: scripts/install_prereqs.sh Firestore ${{ matrix.target }} xcodebuild @@ -479,6 +495,14 @@ jobs: restore-keys: | ${{ runner.os }}-pods-${{ matrix.target }}- + - name: Cache Pods + uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: Firestore/Example/Pods + key: ${{ runner.os }}-pods-${{ matrix.target }}-${{ hashFiles('Firestore/Example/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods-${{ matrix.target }}- + - name: Setup build # 'FirestoreEnterprise' is used as product name for `build.sh` to select the enterprise build variant. `install_prereqs.sh` does not require this distinction, so 'Firestore' is used. run: scripts/install_prereqs.sh Firestore ${{ matrix.target }} xcodebuild From 76e2e4dae44cce0fee5c2fbb9039c51547ff04c5 Mon Sep 17 00:00:00 2001 From: cherylEnkidu <96084918+cherylEnkidu@users.noreply.github.com> Date: Thu, 2 Apr 2026 11:47:32 -0400 Subject: [PATCH 11/20] Update PipelineTests.swift Remove the intentional failure --- Firestore/Swift/Tests/Integration/PipelineTests.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Firestore/Swift/Tests/Integration/PipelineTests.swift b/Firestore/Swift/Tests/Integration/PipelineTests.swift index 020ae026bfb..5cfcc69743d 100644 --- a/Firestore/Swift/Tests/Integration/PipelineTests.swift +++ b/Firestore/Swift/Tests/Integration/PipelineTests.swift @@ -276,7 +276,6 @@ class PipelineIntegrationTests: FSTIntegrationTestCase { } func testSupportsCollectionGroupAsSource() async throws { - XCTAssertTrue(false, "Intentional failure for testing") let db = firestore() let rootCollForTest = collectionRef() From 85535ac317a69f27de620cf6d2c78f5abb36b3e7 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 7 Apr 2026 17:13:11 -0400 Subject: [PATCH 12/20] add retry logic for only the failing test --- Firestore/Swift/Tests/Integration/DatabaseTests.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Firestore/Swift/Tests/Integration/DatabaseTests.swift b/Firestore/Swift/Tests/Integration/DatabaseTests.swift index 0304a87c264..e665a1b863f 100644 --- a/Firestore/Swift/Tests/Integration/DatabaseTests.swift +++ b/Firestore/Swift/Tests/Integration/DatabaseTests.swift @@ -21,6 +21,10 @@ import FirebaseCore import FirebaseFirestore class DatabaseTests: FSTIntegrationTestCase { + func testIntentionalFailure() async throws { + XCTFail("Intentional failure to test CI retry logic") + } + func testCanStillUseDisablePersistenceSettings() async throws { let settings = db.settings settings.isPersistenceEnabled = false From 29b47c5816b8e974e95f46e011fa0e4f38ab3cb6 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 7 Apr 2026 17:44:22 -0400 Subject: [PATCH 13/20] move the intentional failing test --- .../AggregationIntegrationTests.swift | 4 + .../Tests/Integration/DatabaseTests.swift | 133 +++++++++++++++++- 2 files changed, 135 insertions(+), 2 deletions(-) diff --git a/Firestore/Swift/Tests/Integration/AggregationIntegrationTests.swift b/Firestore/Swift/Tests/Integration/AggregationIntegrationTests.swift index ae5f86b8e9c..e3adda09e57 100644 --- a/Firestore/Swift/Tests/Integration/AggregationIntegrationTests.swift +++ b/Firestore/Swift/Tests/Integration/AggregationIntegrationTests.swift @@ -18,6 +18,10 @@ import FirebaseFirestore import Foundation class AggregationIntegrationTests: FSTIntegrationTestCase { + func testIntentionalFailure() async throws { + XCTFail("Intentional failure to test CI retry logic") + } + func testCount() async throws { let collection = collectionRef() try await collection.addDocument(data: [:]) diff --git a/Firestore/Swift/Tests/Integration/DatabaseTests.swift b/Firestore/Swift/Tests/Integration/DatabaseTests.swift index e665a1b863f..0fc50e30cac 100644 --- a/Firestore/Swift/Tests/Integration/DatabaseTests.swift +++ b/Firestore/Swift/Tests/Integration/DatabaseTests.swift @@ -21,8 +21,137 @@ import FirebaseCore import FirebaseFirestore class DatabaseTests: FSTIntegrationTestCase { - func testIntentionalFailure() async throws { - XCTFail("Intentional failure to test CI retry logic") + func testCanStillUseDisablePersistenceSettings() async throws { + let settings = db.settings + settings.isPersistenceEnabled = false + db.settings = settings + + try await db.document("coll/doc").setData(["foo": "bar"]) + let result = try? await db.document("coll/doc").getDocument(source: .cache) + XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) + } + + func testCanStillUseEnablePersistenceSettings() async throws { + let settings = db.settings + settings.isPersistenceEnabled = true + db.settings = settings + + try await db.document("coll/doc").setData(["foo": "bar"]) + let result = try? await db.document("coll/doc").getDocument(source: .cache) + XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) + } + + func testCanUseMemoryCacheSettings() async throws { + let settings = db.settings + settings.cacheSettings = MemoryCacheSettings() + db.settings = settings + + try await db.document("coll/doc").setData(["foo": "bar"]) + let result = try? await db.document("coll/doc").getDocument(source: .cache) + XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) + } + + func testCanGetDocumentWithMemoryLruGCEnabled() async throws { + let settings = db.settings + settings + .cacheSettings = + MemoryCacheSettings( + garbageCollectorSettings: MemoryLRUGCSettings(sizeBytes: 2_000_000) + ) + db.settings = settings + + try await db.document("coll/doc").setData(["foo": "bar"]) + let result = try? await db.document("coll/doc").getDocument(source: .cache) + XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) + } + + func testCannotGetDocumentWithMemoryEagerGCEnabled() async throws { + let settings = db.settings + settings + .cacheSettings = + MemoryCacheSettings(garbageCollectorSettings: MemoryEagerGCSetting()) + db.settings = settings + + try await db.document("coll/doc").setData(["foo": "bar"]) + let result = try? await db.document("coll/doc").getDocument(source: .cache) + XCTAssertNil(result) + } + + func testCanUsePersistentCacheSettings() async throws { + let settings = db.settings + settings.cacheSettings = PersistentCacheSettings() + db.settings = settings + + try await db.document("coll/doc").setData(["foo": "bar"]) + let result = try? await db.document("coll/doc").getDocument(source: .cache) + XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) + } + + func testCanSetCacheSettingsMultipleTimes() async throws { + let settings = db.settings + settings.cacheSettings = PersistentCacheSettings() + settings.cacheSettings = MemoryCacheSettings() + db.settings = settings + + try await db.document("coll/doc").setData(["foo": "bar"]) + let result = try? await db.document("coll/doc").getDocument(source: .cache) + XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) + } + + func testGetValidPersistentCacheIndexManager() async throws { + // [FIRApp resetApps] is an internal api, while Swift test can only test again public api. + // So `FirebaseApp.configure()` can only be called once for the whole test class. + FirebaseApp.configure() + + let db1 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB1") + let settings1 = db1.settings + settings1.cacheSettings = PersistentCacheSettings() + db1.settings = settings1 + + XCTAssertNotNil(db1.persistentCacheIndexManager) + + // Use persistent disk cache (default) + let db2 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB2") + XCTAssertNotNil(db2.persistentCacheIndexManager) + + // Disable persistent disk cache + let db3 = Firestore.firestore(database: "SwiftMemoryCacheIndexManagerDB1") + let settings3 = db3.settings + settings3.cacheSettings = MemoryCacheSettings() + db3.settings = settings3 + XCTAssertNil(db3.persistentCacheIndexManager) + + // Disable persistent disk cache (deprecated) + let db4 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB4") + let settings4 = db4.settings + settings4.isPersistenceEnabled = false + db4.settings = settings4 + XCTAssertNil(db4.persistentCacheIndexManager) + + let db5 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB5") + let settings5 = db5.settings + settings5.cacheSettings = PersistentCacheSettings() + db5.settings = settings5 + XCTAssertEqual(db5.persistentCacheIndexManager, db5.persistentCacheIndexManager) + + // Use persistent disk cache (default) + let db6 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB6") + XCTAssertEqual(db6.persistentCacheIndexManager, db6.persistentCacheIndexManager) + + let db7 = Firestore.firestore(database: "SwiftMemoryCacheIndexManagerDB2") + let settings7 = db7.settings + settings7.cacheSettings = PersistentCacheSettings() + db7.settings = settings7 + XCTAssertNotEqual(db5.persistentCacheIndexManager, db7.persistentCacheIndexManager) + XCTAssertNotEqual(db6.persistentCacheIndexManager, db7.persistentCacheIndexManager) + + // Use persistent disk cache (default) + let db8 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB8") + XCTAssertNotEqual(db5.persistentCacheIndexManager, db8.persistentCacheIndexManager) + XCTAssertNotEqual(db6.persistentCacheIndexManager, db8.persistentCacheIndexManager) + XCTAssertNotEqual(db7.persistentCacheIndexManager, db8.persistentCacheIndexManager) + } +>>>>>>> a45d986d9 (move the intentional failing test) } func testCanStillUseDisablePersistenceSettings() async throws { From 8d80a710e56a3a8767d446777c72a5a4c09d30fd Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Thu, 9 Apr 2026 16:53:02 -0400 Subject: [PATCH 14/20] remove the test --- .../Swift/Tests/Integration/AggregationIntegrationTests.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Firestore/Swift/Tests/Integration/AggregationIntegrationTests.swift b/Firestore/Swift/Tests/Integration/AggregationIntegrationTests.swift index e3adda09e57..ae5f86b8e9c 100644 --- a/Firestore/Swift/Tests/Integration/AggregationIntegrationTests.swift +++ b/Firestore/Swift/Tests/Integration/AggregationIntegrationTests.swift @@ -18,10 +18,6 @@ import FirebaseFirestore import Foundation class AggregationIntegrationTests: FSTIntegrationTestCase { - func testIntentionalFailure() async throws { - XCTFail("Intentional failure to test CI retry logic") - } - func testCount() async throws { let collection = collectionRef() try await collection.addDocument(data: [:]) From 7e1e86097f98320208cdf8d18fea2334f5f881ec Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Mon, 13 Apr 2026 12:32:31 -0400 Subject: [PATCH 15/20] remove script --- Firestore/Example/Podfile | 12 +-------- IntegrationTesting/ClientApp/Podfile | 5 ---- scripts/cocoapods_cxx17_patch.rb | 37 ---------------------------- scripts/install_prereqs.sh | 3 --- scripts/pod_lib_lint.rb | 5 ---- 5 files changed, 1 insertion(+), 61 deletions(-) delete mode 100644 scripts/cocoapods_cxx17_patch.rb diff --git a/Firestore/Example/Podfile b/Firestore/Example/Podfile index af9586235a6..fc14b726f2e 100644 --- a/Firestore/Example/Podfile +++ b/Firestore/Example/Podfile @@ -33,17 +33,7 @@ post_install do |installer| if !$?.success? raise "sync_project.rb failed with status #{$?.exitstatus}" end - # Apply C++17 patch to all pod targets in generated projects - projects = installer.respond_to?(:generated_projects) ? installer.generated_projects : [installer.pods_project].compact - projects.each do |project| - project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17' - config.build_settings['CLANG_CXX_LIBRARY'] = 'libc++' - end - end - project.save if installer.respond_to?(:generated_projects) - end + # Clean up duplicate C++ standards and suppress deprecation warnings in xcconfig files podfile_dir = Pathname.new(__FILE__).dirname diff --git a/IntegrationTesting/ClientApp/Podfile b/IntegrationTesting/ClientApp/Podfile index 7839940f4f7..bd0676baa94 100644 --- a/IntegrationTesting/ClientApp/Podfile +++ b/IntegrationTesting/ClientApp/Podfile @@ -1,4 +1,3 @@ -require_relative '../../scripts/cocoapods_cxx17_patch.rb' source 'https://github.com/firebase/SpecsDev.git' source 'https://github.com/firebase/SpecsStaging.git' source 'https://cdn.cocoapods.org/' @@ -32,7 +31,3 @@ target 'ClientApp-CocoaPods' do pod 'FirebasePerformance', :path => '../../' pod 'Firebase', :path => '../../' end - -post_install do |installer| - CocoapodsCXX17Patch.apply_patch(installer) -end diff --git a/scripts/cocoapods_cxx17_patch.rb b/scripts/cocoapods_cxx17_patch.rb deleted file mode 100644 index d900ae801a2..00000000000 --- a/scripts/cocoapods_cxx17_patch.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2025 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. - -module CocoapodsCXX17Patch - def self.apply_patch(installer) - targets_to_patch = ['BoringSSL-GRPC', 'gRPC-C++', 'abseil', 'Pods-'] - projects = [] - if installer.respond_to?(:pods_project) && installer.pods_project - projects << installer.pods_project - elsif installer.respond_to?(:generated_projects) - projects = installer.generated_projects - end - - projects.each do |project| - project.targets.each do |target| - if targets_to_patch.any? { |name| target.name.start_with?(name) } - target.build_configurations.each do |config| - config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17' - config.build_settings['CLANG_CXX_LIBRARY'] = 'libc++' - end - end - end - project.save if installer.respond_to?(:generated_projects) # Save subprojects - end - end -end diff --git a/scripts/install_prereqs.sh b/scripts/install_prereqs.sh index 37e0e971524..4171a2ff652 100755 --- a/scripts/install_prereqs.sh +++ b/scripts/install_prereqs.sh @@ -64,9 +64,6 @@ if [[ "$method" != "cmake" ]]; then scripts/setup_bundler.sh fi -if [[ -f "$(pwd)/scripts/cocoapods_cxx17_patch.rb" ]]; then - export RUBYOPT="-r$(pwd)/scripts/cocoapods_cxx17_patch.rb" -fi case "$project-$platform-$method" in diff --git a/scripts/pod_lib_lint.rb b/scripts/pod_lib_lint.rb index a192e10c880..c51cf0dae00 100755 --- a/scripts/pod_lib_lint.rb +++ b/scripts/pod_lib_lint.rb @@ -88,11 +88,6 @@ def main(args) # by the shell when the command is copy-pasted, preventing unintended brace expansion. puts command.map { |arg| arg =~ /[{}]/ ? "'#{arg}'" : arg }.join(' ') - # Inject C++17 patch for pods that require it into RUBYOPT - patch_file = File.expand_path('cocoapods_cxx17_patch.rb', __dir__) - if File.exist?(patch_file) - ENV['RUBYOPT'] = "#{ENV['RUBYOPT']} -r#{patch_file}" - end # Run the lib lint command in a thread. pod_lint_status = 1 From cea649f481c1039b340bea33a9d399a50ae3e3ab Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Mon, 13 Apr 2026 12:46:36 -0400 Subject: [PATCH 16/20] remove unnecessary code --- Firestore/Example/Podfile | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/Firestore/Example/Podfile b/Firestore/Example/Podfile index fc14b726f2e..639410ac643 100644 --- a/Firestore/Example/Podfile +++ b/Firestore/Example/Podfile @@ -33,34 +33,6 @@ post_install do |installer| if !$?.success? raise "sync_project.rb failed with status #{$?.exitstatus}" end - - - # Clean up duplicate C++ standards and suppress deprecation warnings in xcconfig files - podfile_dir = Pathname.new(__FILE__).dirname - installer.aggregate_targets.each do |target| - ['debug', 'release'].each do |config_type| - path = podfile_dir.join("Pods/Target Support Files/#{target.name}/#{target.name}.#{config_type}.xcconfig") - if File.exist?(path) - content = File.read(path) - modified = false - - if content.include?('c++14 c++17') - content.gsub!('c++14 c++17', 'c++17') - modified = true - end - - if content.include?('-Werror') && !content.include?('-Wno-deprecated-declarations') - content.gsub!('-Werror', '-Werror -Wno-deprecated-declarations') - modified = true - end - - if modified - File.write(path, content) - puts "Fixed up xcconfig: #{File.basename(path)}" - end - end - end - end end # Returns true if the user has explicitly requested local sources or if this is From 370429caf48b2ed13c06c1046e930ac6e7f3a595 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Wed, 24 Jun 2026 17:07:48 -0400 Subject: [PATCH 17/20] Refactor C++17 build configurations for local development. Set CLANG_CXX_LANGUAGE_STANDARD = c++17 specifically for abseil targets in Podfile and suppress deprecated warnings for integration tests in sync_project.rb --- Firestore/Example/Firestore.xcodeproj/project.pbxproj | 2 -- scripts/install_prereqs.sh | 1 - scripts/pod_lib_lint.rb | 1 - 3 files changed, 4 deletions(-) diff --git a/Firestore/Example/Firestore.xcodeproj/project.pbxproj b/Firestore/Example/Firestore.xcodeproj/project.pbxproj index 7642e25a5ff..993a66b8eb9 100644 --- a/Firestore/Example/Firestore.xcodeproj/project.pbxproj +++ b/Firestore/Example/Firestore.xcodeproj/project.pbxproj @@ -6399,7 +6399,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.google.Firestore-IntegrationTests-macOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - MACOSX_DEPLOYMENT_TARGET = 11.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Firestore_Example_macOS.app/Contents/MacOS/Firestore_Example_macOS"; WARNING_CFLAGS = ( "$(inherited)", @@ -6430,7 +6429,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.google.Firestore-IntegrationTests-macOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - MACOSX_DEPLOYMENT_TARGET = 11.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Firestore_Example_macOS.app/Contents/MacOS/Firestore_Example_macOS"; WARNING_CFLAGS = ( "$(inherited)", diff --git a/scripts/install_prereqs.sh b/scripts/install_prereqs.sh index 4171a2ff652..14e6b05d798 100755 --- a/scripts/install_prereqs.sh +++ b/scripts/install_prereqs.sh @@ -64,7 +64,6 @@ if [[ "$method" != "cmake" ]]; then scripts/setup_bundler.sh fi - case "$project-$platform-$method" in FirebasePod-iOS-*) diff --git a/scripts/pod_lib_lint.rb b/scripts/pod_lib_lint.rb index c51cf0dae00..ffe67e54955 100755 --- a/scripts/pod_lib_lint.rb +++ b/scripts/pod_lib_lint.rb @@ -88,7 +88,6 @@ def main(args) # by the shell when the command is copy-pasted, preventing unintended brace expansion. puts command.map { |arg| arg =~ /[{}]/ ? "'#{arg}'" : arg }.join(' ') - # Run the lib lint command in a thread. pod_lint_status = 1 t = Thread.new do From a29f519a29b5eaf7ddf3ec62ad7bca375e84b8d7 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 15 Sep 2026 16:28:35 -0400 Subject: [PATCH 18/20] replace deprecated feature --- .../core/src/api/collection_reference.cc | 5 +- Firestore/core/src/api/document_snapshot.cc | 12 ++--- Firestore/core/src/api/load_bundle_task.cc | 5 +- Firestore/core/src/bundle/bundle_loader.cc | 13 ++--- Firestore/core/src/bundle/bundle_reader.cc | 9 ++-- Firestore/core/src/core/query.cc | 15 +++--- Firestore/core/src/core/sync_engine.cc | 24 +++++---- Firestore/core/src/core/transaction.cc | 11 ++-- Firestore/core/src/core/view.cc | 51 +++++++++--------- .../core/src/local/leveldb_bundle_cache.cc | 13 ++--- .../local/leveldb_document_overlay_cache.cc | 22 ++++---- .../core/src/local/leveldb_index_manager.cc | 23 ++++---- .../core/src/local/leveldb_mutation_queue.cc | 11 ++-- .../core/src/local/leveldb_target_cache.cc | 9 ++-- .../core/src/local/memory_bundle_cache.cc | 13 ++--- .../local/memory_document_overlay_cache.cc | 5 +- .../core/src/local/memory_index_manager.cc | 9 ++-- .../core/src/local/memory_mutation_queue.cc | 11 ++-- Firestore/core/src/model/document_key.cc | 5 +- Firestore/core/src/model/field_index.cc | 6 ++- Firestore/core/src/model/object_value.cc | 11 ++-- Firestore/core/src/model/patch_mutation.cc | 9 ++-- .../core/src/model/server_timestamp_util.cc | 8 +-- .../core/src/model/transform_operation.cc | 53 ++++++++++--------- Firestore/core/src/remote/datastore.cc | 9 ++-- Firestore/core/src/remote/grpc_stream.cc | 13 ++--- Firestore/core/src/remote/remote_event.cc | 43 +++++++-------- Firestore/core/src/remote/serializer.cc | 25 ++++----- Firestore/core/src/remote/stream.cc | 9 ++-- Firestore/core/src/util/comparison.h | 5 +- Firestore/core/src/util/iterator_adaptors.h | 3 +- Firestore/core/src/util/to_string.h | 4 +- Firestore/core/src/util/type_traits.h | 10 ++-- .../test/unit/util/iterator_adaptors_test.cc | 32 +++++------ 34 files changed, 267 insertions(+), 239 deletions(-) diff --git a/Firestore/core/src/api/collection_reference.cc b/Firestore/core/src/api/collection_reference.cc index a6d8f731965..46619cf1799 100644 --- a/Firestore/core/src/api/collection_reference.cc +++ b/Firestore/core/src/api/collection_reference.cc @@ -16,6 +16,7 @@ #include "Firestore/core/src/api/collection_reference.h" +#include #include #include "Firestore/core/src/api/document_reference.h" @@ -67,10 +68,10 @@ const std::string& CollectionReference::collection_id() const { return query().path().last_segment(); } -absl::optional CollectionReference::parent() const { +std::optional CollectionReference::parent() const { ResourcePath parent_path = query().path().PopLast(); if (parent_path.empty()) { - return absl::nullopt; + return std::nullopt; } else { return DocumentReference(DocumentKey(std::move(parent_path)), firestore()); } diff --git a/Firestore/core/src/api/document_snapshot.cc b/Firestore/core/src/api/document_snapshot.cc index ee1eb681c66..49a2dd04a3c 100644 --- a/Firestore/core/src/api/document_snapshot.cc +++ b/Firestore/core/src/api/document_snapshot.cc @@ -16,12 +16,12 @@ #include "Firestore/core/src/api/document_snapshot.h" +#include #include #include "Firestore/core/src/api/document_reference.h" #include "Firestore/core/src/model/resource_path.h" #include "Firestore/core/src/util/hashing.h" -#include "absl/types/optional.h" namespace firebase { namespace firestore { @@ -44,13 +44,13 @@ DocumentSnapshot DocumentSnapshot::FromNoDocument( std::shared_ptr firestore, model::DocumentKey key, SnapshotMetadata metadata) { - return DocumentSnapshot{std::move(firestore), std::move(key), absl::nullopt, + return DocumentSnapshot{std::move(firestore), std::move(key), std::nullopt, std::move(metadata)}; } DocumentSnapshot::DocumentSnapshot(std::shared_ptr firestore, model::DocumentKey document_key, - absl::optional document, + std::optional document, SnapshotMetadata metadata) : firestore_{std::move(firestore)}, internal_key_{std::move(document_key)}, @@ -67,7 +67,7 @@ bool DocumentSnapshot::exists() const { return internal_document_.has_value(); } -const absl::optional& DocumentSnapshot::internal_document() const { +const std::optional& DocumentSnapshot::internal_document() const { return internal_document_; } @@ -79,10 +79,10 @@ const std::string& DocumentSnapshot::document_id() const { return internal_key_.path().last_segment(); } -absl::optional DocumentSnapshot::GetValue( +std::optional DocumentSnapshot::GetValue( const FieldPath& field_path) const { return internal_document_ ? (*internal_document_)->field(field_path) - : absl::nullopt; + : std::nullopt; } bool operator==(const DocumentSnapshot& lhs, const DocumentSnapshot& rhs) { diff --git a/Firestore/core/src/api/load_bundle_task.cc b/Firestore/core/src/api/load_bundle_task.cc index e0da2ae6e94..c98fd9472ed 100644 --- a/Firestore/core/src/api/load_bundle_task.cc +++ b/Firestore/core/src/api/load_bundle_task.cc @@ -17,6 +17,7 @@ #include "Firestore/core/src/api/load_bundle_task.h" #include +#include #include #include "Firestore/core/src/util/autoid.h" @@ -66,7 +67,7 @@ void LoadBundleTask::RemoveObserver(const LoadBundleHandle& handle) { } if (last_observer_.has_value() && last_observer_.value().first == handle) { - last_observer_ = absl::nullopt; + last_observer_ = std::nullopt; } } @@ -74,7 +75,7 @@ void LoadBundleTask::RemoveAllObservers() { std::lock_guard lock(mutex_); observers_.clear(); - last_observer_ = absl::nullopt; + last_observer_ = std::nullopt; } void LoadBundleTask::SetSuccess(LoadBundleTaskProgress success_progress) { diff --git a/Firestore/core/src/bundle/bundle_loader.cc b/Firestore/core/src/bundle/bundle_loader.cc index 5f56ddcf2cd..1707409e60b 100644 --- a/Firestore/core/src/bundle/bundle_loader.cc +++ b/Firestore/core/src/bundle/bundle_loader.cc @@ -17,6 +17,7 @@ #include "Firestore/core/src/bundle/bundle_loader.h" #include +#include #include #include "Firestore/core/include/firebase/firestore/firestore_errors.h" @@ -62,7 +63,7 @@ Status BundleLoader::AddElementInternal(const BundleElement& element) { document_metadata.key(), MutableDocument::NoDocument(document_metadata.key(), document_metadata.read_time())); - current_document_ = absl::nullopt; + current_document_ = std::nullopt; } break; } @@ -77,7 +78,7 @@ Status BundleLoader::AddElementInternal(const BundleElement& element) { } documents_ = documents_.insert(document.key(), document.document()); - current_document_ = absl::nullopt; + current_document_ = std::nullopt; break; } @@ -90,7 +91,7 @@ Status BundleLoader::AddElementInternal(const BundleElement& element) { return Status::OK(); } -StatusOr> BundleLoader::AddElement( +StatusOr> BundleLoader::AddElement( std::unique_ptr element_ptr, uint64_t byte_size) { HARD_ASSERT(element_ptr->element_type() != BundleElement::Type::Metadata, "Unexpected bundle metadata element."); @@ -106,17 +107,17 @@ StatusOr> BundleLoader::AddElement( // Document has only been partially loaded, no progress to report. if (before_count == documents_.size()) { - return {absl::nullopt}; + return {std::nullopt}; } LoadBundleTaskProgress progress{ documents_.size(), metadata_.total_documents(), bytes_loaded_, metadata_.total_bytes(), LoadBundleTaskState::kInProgress}; - return {absl::make_optional(std::move(progress))}; + return {std::make_optional(std::move(progress))}; } StatusOr BundleLoader::ApplyChanges() { - if (current_document_ != absl::nullopt) { + if (current_document_ != std::nullopt) { return StatusOr( Status(Error::kErrorInvalidArgument, "Bundled documents end with a document metadata " diff --git a/Firestore/core/src/bundle/bundle_reader.cc b/Firestore/core/src/bundle/bundle_reader.cc index 2f087aa5e36..df0e76f8200 100644 --- a/Firestore/core/src/bundle/bundle_reader.cc +++ b/Firestore/core/src/bundle/bundle_reader.cc @@ -17,6 +17,7 @@ #include "Firestore/core/src/bundle/bundle_reader.h" #include +#include #include "absl/memory/memory.h" #include "absl/strings/numbers.h" @@ -96,22 +97,22 @@ std::unique_ptr BundleReader::ReadNextElement() { return result; } -absl::optional BundleReader::ReadLengthPrefix() { +std::optional BundleReader::ReadLengthPrefix() { // length string of size 16 indicates an element about 1PB, which is // impossible for valid bundles. StreamReadResult result = input_->ReadUntil('{', 16); if (!result.ok()) { reader_status_.Update(result.status()); - return absl::nullopt; + return std::nullopt; } // Underlying stream is closed, and there happens to be no more data to // process. if (result.eof() && result.ValueOrDie().empty()) { - return absl::nullopt; + return std::nullopt; } - return absl::make_optional(std::move(result).ValueOrDie()); + return std::make_optional(std::move(result).ValueOrDie()); } void BundleReader::ReadJsonToBuffer(size_t required_size) { diff --git a/Firestore/core/src/core/query.cc b/Firestore/core/src/core/query.cc index ade33d8b940..3598ade2896 100644 --- a/Firestore/core/src/core/query.cc +++ b/Firestore/core/src/core/query.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include "Firestore/core/src/core/bound.h" @@ -80,7 +81,7 @@ const std::set Query::InequalityFilterFields() const { return result; } -absl::optional Query::FindOpInsideFilters( +std::optional Query::FindOpInsideFilters( const std::vector& ops) const { for (const auto& filter : filters_) { for (const auto& field_filter : filter.GetFlattenedFilters()) { @@ -89,7 +90,7 @@ absl::optional Query::FindOpInsideFilters( } } } - return absl::nullopt; + return std::nullopt; } std::shared_ptr> Query::CalculateNormalizedOrderBys() @@ -236,7 +237,7 @@ bool Query::MatchesOrderBy(const Document& doc) const { const FieldPath& field_path = order_by.field(); // order by key always matches if (field_path != FieldPath::KeyFieldPath() && - doc->field(field_path) == absl::nullopt) { + doc->field(field_path) == std::nullopt) { return false; } } @@ -316,13 +317,13 @@ Target Query::ToTarget(const std::vector& order_bys) const { // We need to swap the cursors to match the now-flipped query ordering. auto new_start_at = end_at_ - ? absl::optional{Bound::FromValue( + ? std::optional{Bound::FromValue( end_at_->position(), end_at_->inclusive())} - : absl::nullopt; + : std::nullopt; auto new_end_at = start_at_ - ? absl::optional{Bound::FromValue( + ? std::optional{Bound::FromValue( start_at_->position(), start_at_->inclusive())} - : absl::nullopt; + : std::nullopt; return Target(path(), collection_group(), filters(), new_order_bys, limit_, new_start_at, new_end_at); diff --git a/Firestore/core/src/core/sync_engine.cc b/Firestore/core/src/core/sync_engine.cc index defa08ead0b..9be41f97b53 100644 --- a/Firestore/core/src/core/sync_engine.cc +++ b/Firestore/core/src/core/sync_engine.cc @@ -16,6 +16,8 @@ #include "Firestore/core/src/core/sync_engine.h" +#include + #include "Firestore/core/include/firebase/firestore/firestore_errors.h" #include "Firestore/core/src/bundle/bundle_element.h" #include "Firestore/core/src/bundle/bundle_loader.h" @@ -140,7 +142,7 @@ ViewSnapshot SyncEngine::InitializeViewAndComputeSnapshot( // If there are already queries mapped to the target id, create a synthesized // target change to apply the sync state from those queries to the new query. auto current_sync_state = SyncState::None; - absl::optional synthesized_current_change; + std::optional synthesized_current_change; if (queries_by_target_.find(target_id) != queries_by_target_.end()) { const QueryOrPipeline& mirror_query = queries_by_target_[target_id][0]; current_sync_state = @@ -248,7 +250,7 @@ void SyncEngine::WriteMutations(std::vector&& mutations, mutation_callbacks_[current_user_].insert( std::make_pair(result.batch_id(), std::move(callback))); - EmitNewSnapshotsAndNotifyLocalStore(result.changes(), absl::nullopt); + EmitNewSnapshotsAndNotifyLocalStore(result.changes(), std::nullopt); remote_store_->FillWritePipeline(); } @@ -307,7 +309,7 @@ void SyncEngine::HandleCredentialChange(const credentials::User& user) { // Notify local store and emit any resulting events from swapping out the // mutation queue. DocumentMap changes = local_store_->HandleUserChange(user); - EmitNewSnapshotsAndNotifyLocalStore(changes, absl::nullopt); + EmitNewSnapshotsAndNotifyLocalStore(changes, std::nullopt); } // Notify remote store so it can restart its streams. @@ -407,7 +409,7 @@ void SyncEngine::HandleSuccessfulWrite( TriggerPendingWriteCallbacks(batch_result.batch().batch_id()); DocumentMap changes = local_store_->AcknowledgeBatch(batch_result); - EmitNewSnapshotsAndNotifyLocalStore(changes, absl::nullopt); + EmitNewSnapshotsAndNotifyLocalStore(changes, std::nullopt); } void SyncEngine::HandleRejectedWrite( @@ -430,7 +432,7 @@ void SyncEngine::HandleRejectedWrite( TriggerPendingWriteCallbacks(batch_id); - EmitNewSnapshotsAndNotifyLocalStore(changes, absl::nullopt); + EmitNewSnapshotsAndNotifyLocalStore(changes, std::nullopt); } void SyncEngine::HandleOnlineStateChange(model::OnlineState online_state) { @@ -512,7 +514,7 @@ void SyncEngine::FailOutstandingPendingWriteCallbacks( void SyncEngine::EmitNewSnapshotsAndNotifyLocalStore( const DocumentMap& changes, - const absl::optional& maybe_remote_event) { + const std::optional& maybe_remote_event) { std::vector new_snapshots; std::vector document_changes_in_all_views; @@ -530,7 +532,7 @@ void SyncEngine::EmitNewSnapshotsAndNotifyLocalStore( view_doc_changes); } - absl::optional target_changes; + std::optional target_changes; bool targetIsPendingReset = false; if (maybe_remote_event.has_value()) { const RemoteEvent& remote_event = maybe_remote_event.value(); @@ -631,7 +633,7 @@ void SyncEngine::RemoveLimboTarget(const DocumentKey& key) { PumpEnqueuedLimboResolutions(); } -absl::optional SyncEngine::ReadIntoLoader( +std::optional SyncEngine::ReadIntoLoader( const bundle::BundleMetadata& metadata, bundle::BundleReader& reader, api::LoadBundleTask& result_task) { @@ -645,7 +647,7 @@ absl::optional SyncEngine::ReadIntoLoader( LOG_WARN("Failed to GetNextElement() from bundle with error %s", reader.reader_status().error_message()); result_task.SetError(reader.reader_status()); - return absl::nullopt; + return std::nullopt; } // No more elements from reader. @@ -661,7 +663,7 @@ absl::optional SyncEngine::ReadIntoLoader( LOG_WARN("Failed to AddElement() to bundle loader with error %s", maybe_progress.status().error_message()); result_task.SetError(maybe_progress.status()); - return absl::nullopt; + return std::nullopt; } if (maybe_progress.ValueOrDie().has_value()) { @@ -705,7 +707,7 @@ void SyncEngine::LoadBundle(std::shared_ptr reader, } EmitNewSnapshotsAndNotifyLocalStore(changes.ConsumeValueOrDie(), - absl::nullopt); + std::nullopt); result_task->SetSuccess(SuccessProgress(bundle_metadata)); } diff --git a/Firestore/core/src/core/transaction.cc b/Firestore/core/src/core/transaction.cc index cb14ea656c1..833e78c479b 100644 --- a/Firestore/core/src/core/transaction.cc +++ b/Firestore/core/src/core/transaction.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -65,7 +66,7 @@ Status Transaction::RecordVersion(const Document& doc) { HARD_FAIL("Unexpected document type in transaction: %s", doc.ToString()); } - absl::optional existing_version = GetVersion(doc->key()); + std::optional existing_version = GetVersion(doc->key()); if (existing_version.has_value()) { if (doc_version != existing_version.value()) { // This transaction will fail no matter what. @@ -129,7 +130,7 @@ void Transaction::WriteMutations(std::vector&& mutations) { } Precondition Transaction::CreatePrecondition(const DocumentKey& key) { - absl::optional version = GetVersion(key); + std::optional version = GetVersion(key); if (written_docs_.count(key) == 0 && version.has_value()) { if (version.value() == SnapshotVersion::None()) { return Precondition::Exists(false); @@ -143,7 +144,7 @@ Precondition Transaction::CreatePrecondition(const DocumentKey& key) { StatusOr Transaction::CreateUpdatePrecondition( const DocumentKey& key) { - absl::optional version = GetVersion(key); + std::optional version = GetVersion(key); // The first time a document is written, we want to take into account the // read time and existence. if (written_docs_.count(key) == 0 && version.has_value()) { @@ -243,13 +244,13 @@ void Transaction::EnsureCommitNotCalled() { "update callback has been invoked."); } -absl::optional Transaction::GetVersion( +std::optional Transaction::GetVersion( const DocumentKey& key) const { auto found = read_versions_.find(key); if (found != read_versions_.end()) { return found->second; } - return absl::nullopt; + return std::nullopt; } } // namespace core diff --git a/Firestore/core/src/core/view.cc b/Firestore/core/src/core/view.cc index e1ccb6b838b..bcdcd4b0631 100644 --- a/Firestore/core/src/core/view.cc +++ b/Firestore/core/src/core/view.cc @@ -17,6 +17,7 @@ #include "Firestore/core/src/core/view.h" #include // For std::sort +#include #include #include @@ -39,13 +40,13 @@ using remote::TargetChange; using util::ComparisonResult; // MARK: - Helper Functions for View -absl::optional View::GetLimit(const QueryOrPipeline& query) { +std::optional View::GetLimit(const QueryOrPipeline& query) { if (query.IsPipeline()) { - absl::optional limit = GetLastEffectiveLimit(query.pipeline()); + std::optional limit = GetLastEffectiveLimit(query.pipeline()); if (limit) { return limit; } - return absl::nullopt; + return std::nullopt; } else { const auto& q = query.query(); if (q.has_limit_to_first()) { @@ -53,25 +54,25 @@ absl::optional View::GetLimit(const QueryOrPipeline& query) { } else if (q.has_limit_to_last()) { return -q.limit(); // Negative to indicate limitToLast } - return absl::nullopt; + return std::nullopt; } } LimitType View::GetLimitType(const QueryOrPipeline& query) { if (query.IsPipeline()) { - absl::optional limit = GetLastEffectiveLimit(query.pipeline()); + std::optional limit = GetLastEffectiveLimit(query.pipeline()); return limit > 0 ? LimitType::First : LimitType::Last; } else { return query.query().limit_type(); } } -std::pair, absl::optional> +std::pair, std::optional> View::GetLimitEdges(const QueryOrPipeline& query, const model::DocumentSet& old_document_set) { - absl::optional limit_opt = GetLimit(query); + std::optional limit_opt = GetLimit(query); if (!limit_opt) { - return {absl::nullopt, absl::nullopt}; + return {std::nullopt, std::nullopt}; } int32_t limit_val = *limit_opt; @@ -81,22 +82,22 @@ View::GetLimitEdges(const QueryOrPipeline& query, // The GetLimit function already encodes this as a negative number. if (limit_val > 0 && old_document_set.size() == static_cast(limit_val)) { - return {old_document_set.GetLastDocument(), absl::nullopt}; + return {old_document_set.GetLastDocument(), std::nullopt}; } else if (limit_val < 0 && old_document_set.size() == static_cast(-limit_val)) { - return {absl::nullopt, old_document_set.GetFirstDocument()}; + return {std::nullopt, old_document_set.GetFirstDocument()}; } } else { const auto& q = query.query(); if (q.has_limit_to_first() && old_document_set.size() == static_cast(q.limit())) { - return {old_document_set.GetLastDocument(), absl::nullopt}; + return {old_document_set.GetLastDocument(), std::nullopt}; } else if (q.has_limit_to_last() && old_document_set.size() == static_cast(q.limit())) { - return {absl::nullopt, old_document_set.GetFirstDocument()}; + return {std::nullopt, old_document_set.GetFirstDocument()}; } } - return {absl::nullopt, absl::nullopt}; + return {std::nullopt, std::nullopt}; } // MARK: - LimboDocumentChange @@ -160,7 +161,7 @@ ComparisonResult View::Compare(const Document& lhs, const Document& rhs) const { ViewDocumentChanges View::ComputeDocumentChanges( const DocumentMap& doc_changes, - const absl::optional& previous_changes) const { + const std::optional& previous_changes) const { DocumentViewChangeSet change_set; if (previous_changes) { change_set = previous_changes->change_set(); @@ -175,16 +176,16 @@ ViewDocumentChanges View::ComputeDocumentChanges( bool needs_refill = false; auto limit_edges = GetLimitEdges(query_, old_document_set); - absl::optional last_doc_in_limit = limit_edges.first; - absl::optional first_doc_in_limit = limit_edges.second; + std::optional last_doc_in_limit = limit_edges.first; + std::optional first_doc_in_limit = limit_edges.second; for (const auto& kv : doc_changes) { const DocumentKey& key = kv.first; - absl::optional old_doc = old_document_set.GetDocument(key); - absl::optional new_doc = query_.Matches(kv.second) - ? absl::optional{kv.second} - : absl::nullopt; + std::optional old_doc = old_document_set.GetDocument(key); + std::optional new_doc = query_.Matches(kv.second) + ? std::optional{kv.second} + : std::nullopt; bool old_doc_had_pending_mutations = old_doc && old_mutated_keys.contains(key); @@ -291,7 +292,7 @@ ViewDocumentChanges View::ComputeDocumentChanges( auto abs_limit = std::abs(limit.value()); if (abs_limit < static_cast(new_document_set.size())) { for (size_t i = new_document_set.size() - abs_limit; i > 0; --i) { - absl::optional found = + std::optional found = limit_type == LimitType::First ? new_document_set.GetLastDocument() : new_document_set.GetFirstDocument(); @@ -327,7 +328,7 @@ bool View::ShouldWaitForSyncedDocument(const Document& new_doc, } ViewChange View::ApplyChanges(const ViewDocumentChanges& doc_changes, - const absl::optional& target_change, + const std::optional& target_change, bool targetIsPendingReset) { HARD_ASSERT(!doc_changes.needs_refill(), "Cannot apply changes that need a refill"); @@ -365,7 +366,7 @@ ViewChange View::ApplyChanges(const ViewDocumentChanges& doc_changes, if (changes.empty() && !sync_state_changed) { // No changes. - return ViewChange(absl::nullopt, std::move(limbo_changes)); + return ViewChange(std::nullopt, std::move(limbo_changes)); } else { bool has_cached_results = target_change.has_value() && !target_change->resume_token().empty(); @@ -395,7 +396,7 @@ ViewChange View::ApplyOnlineStateChange(OnlineState online_state) { mutated_keys_, /* needs_refill= */ false)); } else { // No effect, just return a no-op ViewChange. - return ViewChange(absl::nullopt, {}); + return ViewChange(std::nullopt, {}); } } @@ -426,7 +427,7 @@ bool View::ShouldBeInLimbo(const DocumentKey& key) const { * Updates synced_documents_ and current based on the given change. */ void View::ApplyTargetChange( - const absl::optional& maybe_target_change) { + const std::optional& maybe_target_change) { if (maybe_target_change.has_value()) { const TargetChange& target_change = maybe_target_change.value(); diff --git a/Firestore/core/src/local/leveldb_bundle_cache.cc b/Firestore/core/src/local/leveldb_bundle_cache.cc index 9af27373b34..a8c9c08cc16 100644 --- a/Firestore/core/src/local/leveldb_bundle_cache.cc +++ b/Firestore/core/src/local/leveldb_bundle_cache.cc @@ -16,6 +16,7 @@ #include "Firestore/core/src/local/leveldb_bundle_cache.h" +#include #include #include "Firestore/core/src/bundle/bundle_metadata.h" @@ -39,14 +40,14 @@ LevelDbBundleCache::LevelDbBundleCache(LevelDbPersistence* db, : db_(NOT_NULL(db)), serializer_(NOT_NULL(serializer)) { } -absl::optional LevelDbBundleCache::GetBundleMetadata( +std::optional LevelDbBundleCache::GetBundleMetadata( const std::string& bundle_id) const { auto key = LevelDbBundleKey::Key(bundle_id); std::string encoded; auto done = db_->current_transaction()->Get(key, &encoded); if (!done.ok()) { - return absl::nullopt; + return std::nullopt; } nanopb::StringReader reader{encoded}; @@ -61,7 +62,7 @@ absl::optional LevelDbBundleCache::GetBundleMetadata( HARD_FAIL("BundleMetadata proto failed to decode: %s", reader.status().ToString()); } - return absl::make_optional(std::move(bundle)); + return std::make_optional(std::move(bundle)); } void LevelDbBundleCache::SaveBundleMetadata(const BundleMetadata& metadata) { @@ -69,14 +70,14 @@ void LevelDbBundleCache::SaveBundleMetadata(const BundleMetadata& metadata) { db_->current_transaction()->Put(key, serializer_->EncodeBundle(metadata)); } -absl::optional LevelDbBundleCache::GetNamedQuery( +std::optional LevelDbBundleCache::GetNamedQuery( const std::string& query_name) const { auto key = LevelDbNamedQueryKey::Key(query_name); std::string encoded; auto done = db_->current_transaction()->Get(key, &encoded); if (!done.ok()) { - return absl::nullopt; + return std::nullopt; } nanopb::StringReader reader{encoded}; @@ -91,7 +92,7 @@ absl::optional LevelDbBundleCache::GetNamedQuery( HARD_FAIL("NamedQuery proto failed to decode: %s", reader.status().ToString()); } - return absl::make_optional(std::move(named_query)); + return std::make_optional(std::move(named_query)); } void LevelDbBundleCache::SaveNamedQuery(const NamedQuery& query) { diff --git a/Firestore/core/src/local/leveldb_document_overlay_cache.cc b/Firestore/core/src/local/leveldb_document_overlay_cache.cc index 80588e8d2ae..bae21d2291b 100644 --- a/Firestore/core/src/local/leveldb_document_overlay_cache.cc +++ b/Firestore/core/src/local/leveldb_document_overlay_cache.cc @@ -16,6 +16,7 @@ #include "Firestore/core/src/local/leveldb_document_overlay_cache.h" +#include #include #include @@ -28,7 +29,6 @@ #include "Firestore/core/src/util/hard_assert.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" namespace firebase { namespace firestore { @@ -52,7 +52,7 @@ LevelDbDocumentOverlayCache::LevelDbDocumentOverlayCache( user_id_(user.is_authenticated() ? user.uid() : "") { } -absl::optional LevelDbDocumentOverlayCache::GetOverlay( +std::optional LevelDbDocumentOverlayCache::GetOverlay( const DocumentKey& document_key) const { const std::string key_prefix = LevelDbDocumentOverlayKey::KeyPrefix(user_id_, document_key); @@ -61,13 +61,13 @@ absl::optional LevelDbDocumentOverlayCache::GetOverlay( it->Seek(key_prefix); if (!it->Valid() || !absl::StartsWith(it->key(), key_prefix)) { - return absl::nullopt; + return std::nullopt; } LevelDbDocumentOverlayKey key; HARD_ASSERT(key.Decode(it->key())); if (key.document_key() != document_key) { - return absl::nullopt; + return std::nullopt; } return ParseOverlay(key, it->value()); @@ -90,7 +90,7 @@ OverlayByDocumentKeyMap LevelDbDocumentOverlayCache::GetOverlays( OverlayByDocumentKeyMap result; ForEachKeyInCollection( collection, since_batch_id, [&](LevelDbDocumentOverlayKey&& key) { - absl::optional overlay = GetOverlay(key); + std::optional overlay = GetOverlay(key); HARD_ASSERT(overlay.has_value()); result[std::move(key).document_key()] = std::move(overlay).value(); }); @@ -101,7 +101,7 @@ OverlayByDocumentKeyMap LevelDbDocumentOverlayCache::GetOverlays( absl::string_view collection_group, int since_batch_id, std::size_t count) const { - absl::optional current_batch_id; + std::optional current_batch_id; OverlayByDocumentKeyMap result; ForEachKeyInCollectionGroup( collection_group, since_batch_id, @@ -115,7 +115,7 @@ OverlayByDocumentKeyMap LevelDbDocumentOverlayCache::GetOverlays( current_batch_id = key.largest_batch_id(); } - absl::optional overlay = GetOverlay(key); + std::optional overlay = GetOverlay(key); HARD_ASSERT(overlay.has_value()); result[std::move(key).document_key()] = std::move(overlay).value(); return ForEachKeyAction::kKeepGoing; @@ -180,7 +180,7 @@ void LevelDbDocumentOverlayCache::SaveOverlay(int largest_batch_id, transaction->Put(LevelDbDocumentOverlayLargestBatchIdIndexKey::Key(key), ""); transaction->Put(LevelDbDocumentOverlayCollectionIndexKey::Key(key), ""); - absl::optional collection_group_index_key = + std::optional collection_group_index_key = LevelDbDocumentOverlayCollectionGroupIndexKey::Key(key); if (collection_group_index_key.has_value()) { transaction->Put(std::move(collection_group_index_key).value(), ""); @@ -212,7 +212,7 @@ void LevelDbDocumentOverlayCache::DeleteOverlay( transaction->Delete(LevelDbDocumentOverlayLargestBatchIdIndexKey::Key(key)); transaction->Delete(LevelDbDocumentOverlayCollectionIndexKey::Key(key)); - absl::optional collection_group_index_key = + std::optional collection_group_index_key = LevelDbDocumentOverlayCollectionGroupIndexKey::Key(key); if (collection_group_index_key.has_value()) { transaction->Delete(std::move(collection_group_index_key).value()); @@ -287,13 +287,13 @@ void LevelDbDocumentOverlayCache::ForEachKeyInCollectionGroup( } } -absl::optional LevelDbDocumentOverlayCache::GetOverlay( +std::optional LevelDbDocumentOverlayCache::GetOverlay( const LevelDbDocumentOverlayKey& key) const { auto it = db_->current_transaction()->NewIterator(); const std::string encoded_key = key.Encode(); it->Seek(encoded_key); if (!it->Valid() || it->key() != encoded_key) { - return absl::nullopt; + return std::nullopt; } return ParseOverlay(key, it->value()); } diff --git a/Firestore/core/src/local/leveldb_index_manager.cc b/Firestore/core/src/local/leveldb_index_manager.cc index 0455bf88898..b37c72b7b21 100644 --- a/Firestore/core/src/local/leveldb_index_manager.cc +++ b/Firestore/core/src/local/leveldb_index_manager.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -439,7 +440,7 @@ std::vector LevelDbIndexManager::GetFieldIndexes() const { return result; } -absl::optional LevelDbIndexManager::GetFieldIndex( +std::optional LevelDbIndexManager::GetFieldIndex( const core::Target& target) const { HARD_ASSERT(started_, "IndexManager not started"); @@ -451,10 +452,10 @@ absl::optional LevelDbIndexManager::GetFieldIndex( std::vector collection_indexes = GetFieldIndexes(collection_group); if (collection_indexes.empty()) { - return absl::nullopt; + return std::nullopt; } - absl::optional result; + std::optional result; for (FieldIndex index : collection_indexes) { if (target_index_matcher.ServedByIndex(index)) { if (!result.has_value() || @@ -540,7 +541,7 @@ IndexManager::IndexType LevelDbIndexManager::GetIndexType( const auto sub_targets = GetSubTargets(target); for (const Target& sub_target : sub_targets) { - absl::optional index = GetFieldIndex(sub_target); + std::optional index = GetFieldIndex(sub_target); if (!index) { result = IndexManager::IndexType::NONE; break; @@ -563,13 +564,13 @@ IndexManager::IndexType LevelDbIndexManager::GetIndexType( return result; } -absl::optional> +std::optional> LevelDbIndexManager::GetDocumentsMatchingTarget(const core::Target& target) { std::vector> indexes; for (const auto& sub_target : GetSubTargets(target)) { auto index_opt = GetFieldIndex(sub_target); if (!index_opt.has_value()) { - return absl::nullopt; + return std::nullopt; } indexes.emplace_back(sub_target, index_opt.value()); } @@ -754,10 +755,10 @@ std::vector LevelDbIndexManager::CreateRange( return ranges; } -absl::optional +std::optional LevelDbIndexManager::GetNextCollectionGroupToUpdate() const { if (next_index_to_update_.empty()) { - return absl::nullopt; + return std::nullopt; } return next_index_to_update_.top()->collection_group(); @@ -832,7 +833,7 @@ std::set LevelDbIndexManager::ComputeIndexEntries( std::set results; auto directional_value = EncodeDirectionalElements(index, document); - if (directional_value == absl::nullopt) { + if (directional_value == std::nullopt) { return results; } @@ -858,13 +859,13 @@ std::set LevelDbIndexManager::ComputeIndexEntries( return results; } -absl::optional LevelDbIndexManager::EncodeDirectionalElements( +std::optional LevelDbIndexManager::EncodeDirectionalElements( const FieldIndex& index, const model::Document& document) { IndexEncodingBuffer index_buffer; for (const auto& segment : index.GetDirectionalSegments()) { auto field = document->field(segment.field_path()); if (!field.has_value()) { - return absl::nullopt; + return std::nullopt; } index::WriteIndexValue(field.value(), index_buffer.ForKind(segment.kind())); } diff --git a/Firestore/core/src/local/leveldb_mutation_queue.cc b/Firestore/core/src/local/leveldb_mutation_queue.cc index b21d0f1bfe4..01e36f415ae 100644 --- a/Firestore/core/src/local/leveldb_mutation_queue.cc +++ b/Firestore/core/src/local/leveldb_mutation_queue.cc @@ -17,6 +17,7 @@ #include "Firestore/core/src/local/leveldb_mutation_queue.h" #include +#include #include #include "Firestore/core/src/core/query.h" @@ -332,7 +333,7 @@ LevelDbMutationQueue::AllMutationBatchesAffectingQuery(const Query& query) { return AllMutationBatchesWithIds(unique_batch_ids); } -absl::optional LevelDbMutationQueue::LookupMutationBatch( +std::optional LevelDbMutationQueue::LookupMutationBatch( model::BatchId batch_id) { std::string key = mutation_batch_key(batch_id); @@ -340,7 +341,7 @@ absl::optional LevelDbMutationQueue::LookupMutationBatch( Status status = db_->current_transaction()->Get(key, &value); if (!status.ok()) { if (status.IsNotFound()) { - return absl::nullopt; + return std::nullopt; } HARD_FAIL("Lookup mutation batch (%s, %s) failed with status: %s", user_id_, batch_id, status.ToString()); @@ -349,7 +350,7 @@ absl::optional LevelDbMutationQueue::LookupMutationBatch( return ParseMutationBatch(value); } -absl::optional +std::optional LevelDbMutationQueue::NextMutationBatchAfterBatchId(model::BatchId batch_id) { BatchId next_batch_id = batch_id + 1; @@ -360,12 +361,12 @@ LevelDbMutationQueue::NextMutationBatchAfterBatchId(model::BatchId batch_id) { LevelDbMutationKey row_key; if (!it->Valid() || !row_key.Decode(it->key())) { // Past the last row in the DB or out of the mutations table - return absl::nullopt; + return std::nullopt; } if (row_key.user_id() != user_id_) { // Jumped past the last mutation for this user - return absl::nullopt; + return std::nullopt; } HARD_ASSERT(row_key.batch_id() >= next_batch_id, diff --git a/Firestore/core/src/local/leveldb_target_cache.cc b/Firestore/core/src/local/leveldb_target_cache.cc index bcdd1d32876..e83cff38fb5 100644 --- a/Firestore/core/src/local/leveldb_target_cache.cc +++ b/Firestore/core/src/local/leveldb_target_cache.cc @@ -16,6 +16,7 @@ #include "Firestore/core/src/local/leveldb_target_cache.h" +#include #include #include #include @@ -48,7 +49,7 @@ using model::TargetId; using nanopb::Message; using nanopb::StringReader; -absl::optional> +std::optional> LevelDbTargetCache::TryReadMetadata(leveldb::DB* db) { std::string key = LevelDbTargetGlobalKey::Key(); std::string value; @@ -60,7 +61,7 @@ LevelDbTargetCache::TryReadMetadata(leveldb::DB* db) { auto result = Message::TryParse(&reader); if (!reader.ok()) { if (reader.status().code() == Error::kErrorNotFound) { - return absl::nullopt; + return std::nullopt; } else { HARD_FAIL("ReadMetadata: failed loading key %s with status: %s", key, reader.status().ToString()); @@ -138,7 +139,7 @@ void LevelDbTargetCache::RemoveTarget(const TargetData& target_data) { SaveMetadata(); } -absl::optional LevelDbTargetCache::GetTarget( +std::optional LevelDbTargetCache::GetTarget( const core::TargetOrPipeline& target_or_pipeline) { // Scan the query-target index starting with a prefix starting with the given // target's or pipeline's canonical_id. Note that this is a scan rather than @@ -190,7 +191,7 @@ absl::optional LevelDbTargetCache::GetTarget( } } - return absl::nullopt; + return std::nullopt; } void LevelDbTargetCache::EnumerateSequenceNumbers( diff --git a/Firestore/core/src/local/memory_bundle_cache.cc b/Firestore/core/src/local/memory_bundle_cache.cc index 6637afb3dd1..b04c2eab722 100644 --- a/Firestore/core/src/local/memory_bundle_cache.cc +++ b/Firestore/core/src/local/memory_bundle_cache.cc @@ -16,6 +16,7 @@ #include "Firestore/core/src/local/memory_bundle_cache.h" +#include #include namespace firebase { @@ -25,26 +26,26 @@ namespace local { using bundle::BundleMetadata; using bundle::NamedQuery; -absl::optional MemoryBundleCache::GetBundleMetadata( +std::optional MemoryBundleCache::GetBundleMetadata( const std::string& bundle_id) const { auto got = bundles_.find(bundle_id); if (got == bundles_.end()) { - return absl::nullopt; + return std::nullopt; } - return absl::make_optional(got->second); + return std::make_optional(got->second); } void MemoryBundleCache::SaveBundleMetadata(const BundleMetadata& metadata) { bundles_[metadata.bundle_id()] = metadata; } -absl::optional MemoryBundleCache::GetNamedQuery( +std::optional MemoryBundleCache::GetNamedQuery( const std::string& query_name) const { auto got = named_queries_.find(query_name); if (got == named_queries_.end()) { - return absl::nullopt; + return std::nullopt; } - return absl::make_optional(got->second); + return std::make_optional(got->second); } void MemoryBundleCache::SaveNamedQuery(const NamedQuery& query) { diff --git a/Firestore/core/src/local/memory_document_overlay_cache.cc b/Firestore/core/src/local/memory_document_overlay_cache.cc index ede9cf4ab38..3002d9b7a99 100644 --- a/Firestore/core/src/local/memory_document_overlay_cache.cc +++ b/Firestore/core/src/local/memory_document_overlay_cache.cc @@ -18,6 +18,7 @@ #include #include +#include #include "Firestore/core/src/util/hard_assert.h" @@ -33,11 +34,11 @@ using model::Overlay; using model::OverlayByDocumentKeyMap; using model::ResourcePath; -absl::optional MemoryDocumentOverlayCache::GetOverlay( +std::optional MemoryDocumentOverlayCache::GetOverlay( const DocumentKey& key) const { const auto overlays_iter = overlays_.find(key); if (overlays_iter == overlays_.end()) { - return absl::nullopt; + return std::nullopt; } else { return overlays_iter->second; } diff --git a/Firestore/core/src/local/memory_index_manager.cc b/Firestore/core/src/local/memory_index_manager.cc index 9789a918950..3858486d3d7 100644 --- a/Firestore/core/src/local/memory_index_manager.cc +++ b/Firestore/core/src/local/memory_index_manager.cc @@ -17,6 +17,7 @@ #include "Firestore/core/src/local/memory_index_manager.h" #include +#include #include #include #include @@ -107,15 +108,15 @@ IndexManager::IndexType MemoryIndexManager::GetIndexType(const core::Target&) { return IndexManager::IndexType::NONE; } -absl::optional> +std::optional> MemoryIndexManager::GetDocumentsMatchingTarget(const core::Target&) { // Field indices are not supported with memory persistence. - return absl::nullopt; + return std::nullopt; } -absl::optional MemoryIndexManager::GetNextCollectionGroupToUpdate() +std::optional MemoryIndexManager::GetNextCollectionGroupToUpdate() const { - return absl::nullopt; + return std::nullopt; } void MemoryIndexManager::UpdateCollectionGroup(const std::string&, diff --git a/Firestore/core/src/local/memory_mutation_queue.cc b/Firestore/core/src/local/memory_mutation_queue.cc index 3fc4866c1c3..f8884534a8d 100644 --- a/Firestore/core/src/local/memory_mutation_queue.cc +++ b/Firestore/core/src/local/memory_mutation_queue.cc @@ -16,6 +16,7 @@ #include "Firestore/core/src/local/memory_mutation_queue.h" +#include #include #include "Firestore/core/src/core/query.h" @@ -207,7 +208,7 @@ MemoryMutationQueue::AllMutationBatchesAffectingQuery(const Query& query) { return AllMutationBatchesWithIds(unique_batch_ids); } -absl::optional +std::optional MemoryMutationQueue::NextMutationBatchAfterBatchId(BatchId batch_id) { BatchId next_batch_id = batch_id + 1; @@ -216,7 +217,7 @@ MemoryMutationQueue::NextMutationBatchAfterBatchId(BatchId batch_id) { int raw_index = IndexOfBatchId(next_batch_id); size_t index = raw_index < 0 ? 0 : static_cast(raw_index); if (queue_.size() <= index) { - return absl::nullopt; + return std::nullopt; } return queue_[index]; @@ -226,15 +227,15 @@ BatchId MemoryMutationQueue::GetHighestUnacknowledgedBatchId() { return IsEmpty() ? kBatchIdUnknown : next_batch_id_ - 1; } -absl::optional MemoryMutationQueue::LookupMutationBatch( +std::optional MemoryMutationQueue::LookupMutationBatch( BatchId batch_id) { if (queue_.empty()) { - return absl::nullopt; + return std::nullopt; } int index = IndexOfBatchId(batch_id); if (index < 0 || static_cast(index) >= queue_.size()) { - return absl::nullopt; + return std::nullopt; } const MutationBatch& batch = queue_[index]; diff --git a/Firestore/core/src/model/document_key.cc b/Firestore/core/src/model/document_key.cc index f57c5502864..131a38b5c0b 100644 --- a/Firestore/core/src/model/document_key.cc +++ b/Firestore/core/src/model/document_key.cc @@ -16,6 +16,7 @@ #include "Firestore/core/src/model/document_key.h" +#include #include #include @@ -113,10 +114,10 @@ bool DocumentKey::HasCollectionGroup(absl::string_view collection_group) const { collection_id_opt.value() == collection_group; } -absl::optional DocumentKey::GetCollectionGroup() const { +std::optional DocumentKey::GetCollectionGroup() const { const size_t size = path().size(); if (size < 2) { - return absl::nullopt; + return std::nullopt; } return path()[size - 2]; } diff --git a/Firestore/core/src/model/field_index.cc b/Firestore/core/src/model/field_index.cc index 4cf58e4d988..6f512a7b5f3 100644 --- a/Firestore/core/src/model/field_index.cc +++ b/Firestore/core/src/model/field_index.cc @@ -16,6 +16,8 @@ #include "Firestore/core/src/model/field_index.h" +#include + namespace firebase { namespace firestore { namespace model { @@ -118,7 +120,7 @@ util::ComparisonResult FieldIndex::SemanticCompare(const FieldIndex& left, return util::ComparisonResult::Same; } -absl::optional FieldIndex::GetArraySegment() const { +std::optional FieldIndex::GetArraySegment() const { for (const auto& segment : segments_) { if (segment.kind() == Segment::kContains) { // Firestore queries can only have a single ArrayContains/ArrayContainsAny @@ -126,7 +128,7 @@ absl::optional FieldIndex::GetArraySegment() const { return segment; } } - return absl::nullopt; + return std::nullopt; } } // namespace model diff --git a/Firestore/core/src/model/object_value.cc b/Firestore/core/src/model/object_value.cc index 1509cd0fd9a..9c9b33b07e6 100644 --- a/Firestore/core/src/model/object_value.cc +++ b/Firestore/core/src/model/object_value.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -261,7 +262,7 @@ FieldMask ObjectValue::ExtractFieldMask( return FieldMask(std::move(fields)); } -absl::optional ObjectValue::Get( +std::optional ObjectValue::Get( const FieldPath& path) const { if (path.empty()) { return *value_; @@ -271,16 +272,16 @@ absl::optional ObjectValue::Get( for (const std::string& segment : path) { google_firestore_v1_MapValue_FieldsEntry* entry = FindEntry(nested_value, segment); - if (!entry) return absl::nullopt; + if (!entry) return std::nullopt; nested_value = entry->value; } return nested_value; } -absl::optional ObjectValue::Get( +std::optional ObjectValue::Get( const std::string& key) const { google_firestore_v1_MapValue_FieldsEntry* entry = FindEntry(*value_, key); - if (!entry) return absl::nullopt; + if (!entry) return std::nullopt; return entry->value; } @@ -308,7 +309,7 @@ void ObjectValue::SetAll(TransformMap data) { for (auto& it : data) { const FieldPath& path = it.first; - absl::optional> value = + std::optional> value = std::move(it.second); if (!parent.IsImmediateParentOf(path)) { diff --git a/Firestore/core/src/model/patch_mutation.cc b/Firestore/core/src/model/patch_mutation.cc index abc5716b7f6..786bcb1fcf3 100644 --- a/Firestore/core/src/model/patch_mutation.cc +++ b/Firestore/core/src/model/patch_mutation.cc @@ -17,6 +17,7 @@ #include "Firestore/core/src/model/patch_mutation.h" #include +#include #include #include @@ -96,9 +97,9 @@ void PatchMutation::Rep::ApplyToRemoteDocument( .SetHasCommittedMutations(); } -absl::optional PatchMutation::Rep::ApplyToLocalView( +std::optional PatchMutation::Rep::ApplyToLocalView( MutableDocument& document, - absl::optional previous_mask, + std::optional previous_mask, const Timestamp& local_write_time) const { VerifyKeyMatches(document); @@ -113,7 +114,7 @@ absl::optional PatchMutation::Rep::ApplyToLocalView( document.ConvertToFoundDocument(document.version()).SetHasLocalMutations(); if (!previous_mask.has_value()) { - return absl::nullopt; + return std::nullopt; } std::set merged_set(previous_mask.value().begin(), @@ -134,7 +135,7 @@ TransformMap PatchMutation::Rep::GetPatch() const { if (value) { result[path] = DeepClone(*value); } else { - result[path] = absl::nullopt; + result[path] = std::nullopt; } } } diff --git a/Firestore/core/src/model/server_timestamp_util.cc b/Firestore/core/src/model/server_timestamp_util.cc index 80a413d9a5d..8eddead7d78 100644 --- a/Firestore/core/src/model/server_timestamp_util.cc +++ b/Firestore/core/src/model/server_timestamp_util.cc @@ -16,6 +16,8 @@ #include "Firestore/core/src/model/server_timestamp_util.h" +#include + #include "Firestore/core/src/model/value_util.h" #include "Firestore/core/src/nanopb/nanopb_util.h" #include "Firestore/core/src/util/hard_assert.h" @@ -34,7 +36,7 @@ const char kServerTimestampSentinel[] = "server_timestamp"; Message EncodeServerTimestamp( const Timestamp& local_write_time, - absl::optional previous_value) { + std::optional previous_value) { // We should avoid storing deeply nested server timestamp map values // because we never use the intermediate "previous values". // For example: @@ -112,7 +114,7 @@ google_protobuf_Timestamp GetLocalWriteTime( HARD_FAIL("LocalWriteTime not found"); } -absl::optional GetPreviousValue( +std::optional GetPreviousValue( const google_firestore_v1_Value& value) { for (size_t i = 0; i < value.map_value.fields_count; ++i) { const auto& field = value.map_value.fields[i]; @@ -126,7 +128,7 @@ absl::optional GetPreviousValue( } } - return absl::nullopt; + return std::nullopt; } } // namespace model diff --git a/Firestore/core/src/model/transform_operation.cc b/Firestore/core/src/model/transform_operation.cc index 42466ac6891..84dba9f8c8a 100644 --- a/Firestore/core/src/model/transform_operation.cc +++ b/Firestore/core/src/model/transform_operation.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -69,21 +70,21 @@ class ServerTimestampTransform::Rep : public TransformOperation::Rep { } Message ApplyToLocalView( - const absl::optional& previous_value, + const std::optional& previous_value, const Timestamp& local_write_time) const override { return EncodeServerTimestamp(local_write_time, previous_value); } Message ApplyToRemoteDocument( - const absl::optional&, + const std::optional&, Message transform_result) const override { return transform_result; } - absl::optional> ComputeBaseValue( - const absl::optional&) const override { + std::optional> ComputeBaseValue( + const std::optional&) const override { // Server timestamps are idempotent and don't require a base value. - return absl::nullopt; + return std::nullopt; } bool Equals(const TransformOperation::Rep& other) const override { @@ -125,13 +126,13 @@ class ArrayTransform::Rep : public TransformOperation::Rep { } Message ApplyToLocalView( - const absl::optional& previous_value, + const std::optional& previous_value, const Timestamp&) const override { return Apply(previous_value); } Message ApplyToRemoteDocument( - const absl::optional& previous_value, + const std::optional& previous_value, Message) const override { // The server just sends null as the transform result for array operations, // so we have to calculate a result the same as we do for local @@ -139,10 +140,10 @@ class ArrayTransform::Rep : public TransformOperation::Rep { return Apply(previous_value); } - absl::optional> ComputeBaseValue( - const absl::optional&) const override { + std::optional> ComputeBaseValue( + const std::optional&) const override { // Array transforms are idempotent and don't require a base value. - return absl::nullopt; + return std::nullopt; } google_firestore_v1_ArrayValue elements() const { @@ -164,10 +165,10 @@ class ArrayTransform::Rep : public TransformOperation::Rep { * google_firestore_v1_Value. */ Message CoercedFieldValueArray( - const absl::optional& value) const; + const std::optional& value) const; Message Apply( - const absl::optional& previous_value) const; + const std::optional& previous_value) const; Type type_; nanopb::Message elements_; @@ -236,7 +237,7 @@ std::string ArrayTransform::Rep::ToString() const { Message ArrayTransform::Rep::CoercedFieldValueArray( - const absl::optional& value) const { + const std::optional& value) const { if (IsArray(value)) { return DeepClone(value->array_value); } else { @@ -246,7 +247,7 @@ ArrayTransform::Rep::CoercedFieldValueArray( } Message ArrayTransform::Rep::Apply( - const absl::optional& previous_value) const { + const std::optional& previous_value) const { Message array_value = CoercedFieldValueArray(previous_value); if (type_ == Type::ArrayUnion) { @@ -304,14 +305,14 @@ class NumericTransform::Rep : public TransformOperation::Rep { } Message ApplyToRemoteDocument( - const absl::optional&, + const std::optional&, Message transform_result) const override { return transform_result; } - absl::optional> ComputeBaseValue( - const absl::optional&) const override { - return absl::nullopt; + std::optional> ComputeBaseValue( + const std::optional&) const override { + return std::nullopt; } double OperandAsDouble() const { @@ -376,11 +377,11 @@ class NumericIncrementTransform::Rep : public NumericTransform::Rep { } Message ApplyToLocalView( - const absl::optional& previous_value, + const std::optional& previous_value, const Timestamp& local_write_time) const override; - absl::optional> ComputeBaseValue( - const absl::optional& previous_value) + std::optional> ComputeBaseValue( + const std::optional& previous_value) const override { if (IsNumber(previous_value)) { return DeepClone(*previous_value); @@ -424,7 +425,7 @@ class NumericMinimumTransform::Rep : public NumericTransform::Rep { } Message ApplyToLocalView( - const absl::optional& previous_value, + const std::optional& previous_value, const Timestamp& local_write_time) const override; std::string ToString() const override { @@ -458,7 +459,7 @@ class NumericMaximumTransform::Rep : public NumericTransform::Rep { } Message ApplyToLocalView( - const absl::optional& previous_value, + const std::optional& previous_value, const Timestamp& local_write_time) const override; std::string ToString() const override { @@ -500,7 +501,7 @@ int64_t SafeIncrement(int64_t x, int64_t y) { Message NumericIncrementTransform::Rep::ApplyToLocalView( - const absl::optional& previous_value, + const std::optional& previous_value, const Timestamp& /* local_write_time */) const { auto base_value = ComputeBaseValue(previous_value); Message result; @@ -525,7 +526,7 @@ NumericIncrementTransform::Rep::ApplyToLocalView( Message NumericMinimumTransform::Rep::ApplyToLocalView( - const absl::optional& previous_value, + const std::optional& previous_value, const Timestamp& /* local_write_time */) const { if (!IsNumber(previous_value)) { return DeepClone(*operand_); @@ -565,7 +566,7 @@ NumericMinimumTransform::Rep::ApplyToLocalView( Message NumericMaximumTransform::Rep::ApplyToLocalView( - const absl::optional& previous_value, + const std::optional& previous_value, const Timestamp& /* local_write_time */) const { if (!IsNumber(previous_value)) { return DeepClone(*operand_); diff --git a/Firestore/core/src/remote/datastore.cc b/Firestore/core/src/remote/datastore.cc index c8b58e09325..b95e5e8aa97 100644 --- a/Firestore/core/src/remote/datastore.cc +++ b/Firestore/core/src/remote/datastore.cc @@ -16,6 +16,7 @@ #include "Firestore/core/src/remote/datastore.h" +#include #include #include #include @@ -380,8 +381,8 @@ void Datastore::ResumeRpcWithCredentials(const OnCredentials& on_credentials) { auto credentials = std::make_shared(); auto done = [weak_this, credentials, on_credentials]( - const absl::optional>& auth, - const absl::optional& app_check) { + const std::optional>& auth, + const std::optional& app_check) { auto strong_this = weak_this.lock(); if (!strong_this) { return; @@ -421,11 +422,11 @@ void Datastore::ResumeRpcWithCredentials(const OnCredentials& on_credentials) { }; auth_credentials_->GetToken( - [done](const StatusOr& auth) { done(auth, absl::nullopt); }); + [done](const StatusOr& auth) { done(auth, std::nullopt); }); app_check_credentials_->GetToken( [done](const StatusOr& app_check) { - done(absl::nullopt, app_check.ValueOrDie()); // AppCheck never fails + done(std::nullopt, app_check.ValueOrDie()); // AppCheck never fails }); } diff --git a/Firestore/core/src/remote/grpc_stream.cc b/Firestore/core/src/remote/grpc_stream.cc index 5101c36fb64..9f7269ed401 100644 --- a/Firestore/core/src/remote/grpc_stream.cc +++ b/Firestore/core/src/remote/grpc_stream.cc @@ -18,6 +18,7 @@ #include #include +#include #include "Firestore/core/src/remote/grpc_connection.h" #include "Firestore/core/src/remote/grpc_util.h" @@ -57,15 +58,15 @@ using Type = GrpcCompletion::Type; namespace internal { -absl::optional BufferedWriter::EnqueueWrite( +std::optional BufferedWriter::EnqueueWrite( grpc::ByteBuffer&& message, const grpc::WriteOptions& options) { queue_.push({std::move(message), options}); return TryStartWrite(); } -absl::optional BufferedWriter::TryStartWrite() { +std::optional BufferedWriter::TryStartWrite() { if (queue_.empty() || has_active_write_) { - return absl::nullopt; + return std::nullopt; } has_active_write_ = true; @@ -74,7 +75,7 @@ absl::optional BufferedWriter::TryStartWrite() { return {std::move(message)}; } -absl::optional BufferedWriter::DequeueNextWrite() { +std::optional BufferedWriter::DequeueNextWrite() { has_active_write_ = false; return TryStartWrite(); } @@ -145,7 +146,7 @@ void GrpcStream::WriteLast(grpc::ByteBuffer&& message) { MaybeWrite(buffered_writer_.EnqueueWrite(std::move(message), options)); } -void GrpcStream::MaybeWrite(absl::optional maybe_write) { +void GrpcStream::MaybeWrite(std::optional maybe_write) { if (!maybe_write) { return; } @@ -261,7 +262,7 @@ bool GrpcStream::WriteAndFinish(grpc::ByteBuffer&& message) { } bool GrpcStream::TryLastWrite(grpc::ByteBuffer&& message) { - absl::optional maybe_write = + std::optional maybe_write = buffered_writer_.EnqueueWrite(std::move(message)); // Only bother with the last write if there is no active write at the moment. if (!maybe_write) { diff --git a/Firestore/core/src/remote/remote_event.cc b/Firestore/core/src/remote/remote_event.cc index 88a72991798..9b172aecadb 100644 --- a/Firestore/core/src/remote/remote_event.cc +++ b/Firestore/core/src/remote/remote_event.cc @@ -16,6 +16,7 @@ #include "Firestore/core/src/remote/remote_event.h" +#include #include #include @@ -219,9 +220,9 @@ create_existence_filter_mismatch_info_for_testing_hooks( int local_cache_count, const ExistenceFilterWatchChange& existence_filter, const DatabaseId& database_id, - absl::optional bloom_filter, + std::optional bloom_filter, BloomFilterApplicationStatus status) { - absl::optional bloom_filter_info; + std::optional bloom_filter_info; if (existence_filter.filter().bloom_filter_parameters().has_value()) { const BloomFilterParameters& bloom_filter_parameters = existence_filter.filter().bloom_filter_parameters().value(); @@ -237,7 +238,7 @@ create_existence_filter_mismatch_info_for_testing_hooks( std::move(bloom_filter_info)}; } -absl::optional GetSingleDocumentPath( +std::optional GetSingleDocumentPath( const core::TargetOrPipeline target_or_pipeline) { if (target_or_pipeline.IsPipeline()) { if (core::GetPipelineSourceType(target_or_pipeline.pipeline()) == @@ -252,10 +253,10 @@ absl::optional GetSingleDocumentPath( return target_or_pipeline.target().path(); } - return absl::nullopt; + return std::nullopt; } -absl::optional> GetDocumentPaths( +std::optional> GetDocumentPaths( const core::TargetOrPipeline target_or_pipeline) { if (target_or_pipeline.IsPipeline()) { if (core::GetPipelineSourceType(target_or_pipeline.pipeline()) == @@ -274,7 +275,7 @@ absl::optional> GetDocumentPaths( return std::vector{target_or_pipeline.target().path()}; } - return absl::nullopt; + return std::nullopt; } } // namespace @@ -284,7 +285,7 @@ void WatchChangeAggregator::HandleExistenceFilter( TargetId target_id = existence_filter.target_id(); int expected_count = existence_filter.filter().count(); - absl::optional target_data = TargetDataForActiveTarget(target_id); + std::optional target_data = TargetDataForActiveTarget(target_id); if (target_data) { const core::TargetOrPipeline& target_or_pipeline = target_data->target_or_pipeline(); @@ -294,7 +295,7 @@ void WatchChangeAggregator::HandleExistenceFilter( int current_size = GetCurrentDocumentCountForTarget(target_id); if (current_size != expected_count) { // Apply bloom filter to identify and mark removed documents. - absl::optional bloom_filter = + std::optional bloom_filter = ParseBloomFilter(existence_filter); BloomFilterApplicationStatus status = bloom_filter.has_value() @@ -339,12 +340,12 @@ void WatchChangeAggregator::HandleExistenceFilter( } } -absl::optional WatchChangeAggregator::ParseBloomFilter( +std::optional WatchChangeAggregator::ParseBloomFilter( const ExistenceFilterWatchChange& existence_filter) { - const absl::optional& bloom_filter_parameters = + const std::optional& bloom_filter_parameters = existence_filter.filter().bloom_filter_parameters(); if (!bloom_filter_parameters.has_value()) { - return absl::nullopt; + return std::nullopt; } util::StatusOr maybe_bloom_filter = @@ -354,13 +355,13 @@ absl::optional WatchChangeAggregator::ParseBloomFilter( if (!maybe_bloom_filter.ok()) { LOG_WARN("Creating BloomFilter failed: %s", maybe_bloom_filter.status().error_message()); - return absl::nullopt; + return std::nullopt; } BloomFilter bloom_filter = std::move(maybe_bloom_filter).ValueOrDie(); if (bloom_filter.bit_count() == 0) { - return absl::nullopt; + return std::nullopt; } return bloom_filter; @@ -393,7 +394,7 @@ int WatchChangeAggregator::FilterRemovedDocuments( if (!bloom_filter.MightContain(document_path)) { RemoveDocumentFromTarget(target_id, key, - /*updatedDocument=*/absl::nullopt); + /*updatedDocument=*/std::nullopt); removalCount++; } } @@ -408,7 +409,7 @@ RemoteEvent WatchChangeAggregator::CreateRemoteEvent( TargetId target_id = entry.first; TargetState& target_state = entry.second; - absl::optional target_data = + std::optional target_data = TargetDataForActiveTarget(target_id); if (target_data) { auto doc_paths = GetDocumentPaths(target_data->target_or_pipeline()); @@ -447,7 +448,7 @@ RemoteEvent WatchChangeAggregator::CreateRemoteEvent( bool is_only_limbo_target = true; for (TargetId target_id : entry.second) { - absl::optional target_data = + std::optional target_data = TargetDataForActiveTarget(target_id); if (target_data && target_data->purpose() != QueryPurpose::LimboResolution) { @@ -496,7 +497,7 @@ void WatchChangeAggregator::AddDocumentToTarget( void WatchChangeAggregator::RemoveDocumentFromTarget( TargetId target_id, const DocumentKey& key, - const absl::optional& updated_document) { + const std::optional& updated_document) { if (!IsActiveTarget(target_id)) { return; } @@ -540,15 +541,15 @@ TargetState& WatchChangeAggregator::EnsureTargetState(TargetId target_id) { } bool WatchChangeAggregator::IsActiveTarget(TargetId target_id) const { - return TargetDataForActiveTarget(target_id) != absl::nullopt; + return TargetDataForActiveTarget(target_id) != std::nullopt; } -absl::optional WatchChangeAggregator::TargetDataForActiveTarget( +std::optional WatchChangeAggregator::TargetDataForActiveTarget( TargetId target_id) const { auto target_state = target_states_.find(target_id); return target_state != target_states_.end() && target_state->second.IsPending() - ? absl::optional{} + ? std::optional{} : target_metadata_provider_->GetTargetDataForTarget(target_id); } @@ -567,7 +568,7 @@ void WatchChangeAggregator::ResetTarget(TargetId target_id) { target_metadata_provider_->GetRemoteKeysForTarget(target_id); for (const DocumentKey& key : existing_keys) { - RemoveDocumentFromTarget(target_id, key, absl::nullopt); + RemoveDocumentFromTarget(target_id, key, std::nullopt); } } diff --git a/Firestore/core/src/remote/serializer.cc b/Firestore/core/src/remote/serializer.cc index 992e51bb207..c63f314ac62 100644 --- a/Firestore/core/src/remote/serializer.cc +++ b/Firestore/core/src/remote/serializer.cc @@ -16,6 +16,7 @@ #include "Firestore/core/src/remote/serializer.h" +#include #include #include @@ -178,10 +179,10 @@ FieldPath InvalidFieldPath() { return FieldPath::EmptyPath(); } -absl::optional NotNoneVersionOrNullOpt( +std::optional NotNoneVersionOrNullOpt( const SnapshotVersion& version) { if (version == SnapshotVersion::None()) { - return absl::nullopt; + return std::nullopt; } else { return version; } @@ -843,13 +844,13 @@ Target Serializer::DecodeStructuredQuery( limit = query.limit.value; } - absl::optional start_at; + std::optional start_at; if (query.start_at.values_count > 0) { bool inclusive = query.start_at.before; start_at = Bound::FromValue(DecodeCursorValue(query.start_at), inclusive); } - absl::optional end_at; + std::optional end_at; if (query.end_at.values_count > 0) { bool inclusive = !query.end_at.before; end_at = Bound::FromValue(DecodeCursorValue(query.end_at), inclusive); @@ -1521,7 +1522,7 @@ std::unique_ptr Serializer::DecodeDocumentRemove( return absl::make_unique(std::vector{}, std::move(removed_target_ids), - std::move(key), absl::nullopt); + std::move(key), std::nullopt); } std::unique_ptr Serializer::DecodeExistenceFilterWatchChange( @@ -1533,7 +1534,7 @@ std::unique_ptr Serializer::DecodeExistenceFilterWatchChange( ExistenceFilter Serializer::DecodeExistenceFilter( const google_firestore_v1_ExistenceFilter& filter) const { if (!filter.has_unchanged_names) { - return {filter.count, absl::nullopt}; + return {filter.count, std::nullopt}; } int32_t hash_count = filter.unchanged_names.hash_count; @@ -1576,7 +1577,7 @@ api::PipelineSnapshot Serializer::DecodePipelineResponse( results.reserve(message->results_count); for (pb_size_t i = 0; i < message->results_count; ++i) { - absl::optional key; + std::optional key; if (message->results[i].name != nullptr) { key = DecodeKey(context, message->results[i].name); } @@ -1596,11 +1597,11 @@ api::PipelineSnapshot Serializer::DecodePipelineResponse( return api::PipelineSnapshot(std::move(results), execution_time); } -absl::optional Serializer::DecodePipelineTarget( +std::optional Serializer::DecodePipelineTarget( util::ReadContext* context, const google_firestore_v1_Target_PipelineQueryTarget& proto) const { if (!context->status().ok()) { - return absl::nullopt; + return std::nullopt; } if (proto.which_pipeline_type != @@ -1608,7 +1609,7 @@ absl::optional Serializer::DecodePipelineTarget( context->Fail( StringFormat("Unknown pipeline_type in PipelineQueryTarget: %d", proto.which_pipeline_type)); - return absl::nullopt; + return std::nullopt; } const auto& pipeline_proto = proto.structured_pipeline.pipeline; @@ -1618,7 +1619,7 @@ absl::optional Serializer::DecodePipelineTarget( for (pb_size_t i = 0; i < pipeline_proto.stages_count; ++i) { auto stage_ptr = DecodeStage(context, pipeline_proto.stages[i]); if (!context->status().ok()) { - return absl::nullopt; + return std::nullopt; } decoded_stages.push_back(std::move(stage_ptr)); } @@ -1774,7 +1775,7 @@ api::Ordering Serializer::DecodeOrdering( } std::shared_ptr decoded_expr = nullptr; - absl::optional decoded_direction; + std::optional decoded_direction; const auto& map_value = proto_value.map_value; for (pb_size_t i = 0; i < map_value.fields_count; ++i) { diff --git a/Firestore/core/src/remote/stream.cc b/Firestore/core/src/remote/stream.cc index 130b440dd9b..fc9ccacf4cc 100644 --- a/Firestore/core/src/remote/stream.cc +++ b/Firestore/core/src/remote/stream.cc @@ -17,6 +17,7 @@ #include "Firestore/core/src/remote/stream.h" #include +#include #include #include "Firestore/core/include/firebase/firestore/firestore_errors.h" @@ -118,8 +119,8 @@ void Stream::RequestCredentials() { int initial_close_count = close_count_; auto done = [weak_this, credentials, initial_close_count]( - const absl::optional>& auth, - const absl::optional& app_check) { + const std::optional>& auth, + const std::optional& app_check) { auto strong_this = weak_this.lock(); if (!strong_this) { return; @@ -156,11 +157,11 @@ void Stream::RequestCredentials() { }; auth_credentials_provider_->GetToken( - [done](const StatusOr& auth) { done(auth, absl::nullopt); }); + [done](const StatusOr& auth) { done(auth, std::nullopt); }); app_check_credentials_provider_->GetToken( [done](const StatusOr& app_check) { - done(absl::nullopt, app_check.ValueOrDie()); // AppCheck never fails + done(std::nullopt, app_check.ValueOrDie()); // AppCheck never fails }); } diff --git a/Firestore/core/src/util/comparison.h b/Firestore/core/src/util/comparison.h index 01092e55c5c..47e298916a7 100644 --- a/Firestore/core/src/util/comparison.h +++ b/Firestore/core/src/util/comparison.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -223,13 +224,13 @@ namespace impl { /** * Checks wither the type T has a `CompareTo` member. */ -template > +template > struct has_compare_to : public std::false_type {}; template struct has_compare_to< T, - absl::void_t().CompareTo(std::declval()))>> + std::void_t().CompareTo(std::declval()))>> : public std::true_type {}; /** diff --git a/Firestore/core/src/util/iterator_adaptors.h b/Firestore/core/src/util/iterator_adaptors.h index 16a022454ce..d34c211eda6 100644 --- a/Firestore/core/src/util/iterator_adaptors.h +++ b/Firestore/core/src/util/iterator_adaptors.h @@ -24,7 +24,6 @@ #include #include "absl/base/port.h" -#include "absl/meta/type_traits.h" namespace firebase { namespace firestore { @@ -419,7 +418,7 @@ struct container_traits { template struct test_size_type : std::false_type {}; template - struct test_size_type> + struct test_size_type> : std::true_type {}; // Conditional provisioning of a size_type which defaults to size_t. diff --git a/Firestore/core/src/util/to_string.h b/Firestore/core/src/util/to_string.h index 9ec456d8339..360a210fed7 100644 --- a/Firestore/core/src/util/to_string.h +++ b/Firestore/core/src/util/to_string.h @@ -104,11 +104,11 @@ namespace impl { // Checks whether the given type `T` defines a member function `ToString` -template > +template > struct has_to_string : std::false_type {}; template -struct has_to_string().ToString())>> +struct has_to_string().ToString())>> : std::true_type {}; template diff --git a/Firestore/core/src/util/type_traits.h b/Firestore/core/src/util/type_traits.h index 131256c1836..5d55bb2c186 100644 --- a/Firestore/core/src/util/type_traits.h +++ b/Firestore/core/src/util/type_traits.h @@ -20,32 +20,30 @@ #include #include -#include "absl/meta/type_traits.h" - namespace firebase { namespace firestore { namespace util { // is_iterable -template > +template > struct is_iterable : std::false_type {}; template struct is_iterable< T, - absl::void_t().begin(), std::declval().end())>> + std::void_t().begin(), std::declval().end())>> : std::true_type {}; // is_associative_container -template > +template > struct is_associative_container : std::false_type {}; template struct is_associative_container< T, - absl::void_t())>> + std::void_t())>> : std::true_type {}; } // namespace util diff --git a/Firestore/core/test/unit/util/iterator_adaptors_test.cc b/Firestore/core/test/unit/util/iterator_adaptors_test.cc index 1b77e515d07..04c5a712e63 100644 --- a/Firestore/core/test/unit/util/iterator_adaptors_test.cc +++ b/Firestore/core/test/unit/util/iterator_adaptors_test.cc @@ -1085,26 +1085,26 @@ TEST_F(IteratorAdaptorTest, ViewTypeParameterConstVsNonConst) { typedef value_view_type::type VVC; // key_view: - KV ABSL_ATTRIBUTE_UNUSED kv1 = key_view(m); // lvalue - KVC ABSL_ATTRIBUTE_UNUSED kv2 = key_view(m); // conversion to const - KVC ABSL_ATTRIBUTE_UNUSED kv3 = key_view(cm); // const from const lvalue - KVC ABSL_ATTRIBUTE_UNUSED kv4 = key_view(M()); // const from rvalue + [[maybe_unused]] KV kv1 = key_view(m); // lvalue + [[maybe_unused]] KVC kv2 = key_view(m); // conversion to const + [[maybe_unused]] KVC kv3 = key_view(cm); // const from const lvalue + [[maybe_unused]] KVC kv4 = key_view(M()); // const from rvalue // Direct initialization (without key_view function) - KV ABSL_ATTRIBUTE_UNUSED kv5(m); - KVC ABSL_ATTRIBUTE_UNUSED kv6(m); - KVC ABSL_ATTRIBUTE_UNUSED kv7(cm); - KVC ABSL_ATTRIBUTE_UNUSED kv8((M())); + [[maybe_unused]] KV kv5(m); + [[maybe_unused]] KVC kv6(m); + [[maybe_unused]] KVC kv7(cm); + [[maybe_unused]] KVC kv8((M())); // value_view: - VV ABSL_ATTRIBUTE_UNUSED vv1 = value_view(m); // lvalue - VVC ABSL_ATTRIBUTE_UNUSED vv2 = value_view(m); // conversion to const - VVC ABSL_ATTRIBUTE_UNUSED vv3 = value_view(cm); // const from const lvalue - VVC ABSL_ATTRIBUTE_UNUSED vv4 = value_view(M()); // const from rvalue + [[maybe_unused]] VV vv1 = value_view(m); // lvalue + [[maybe_unused]] VVC vv2 = value_view(m); // conversion to const + [[maybe_unused]] VVC vv3 = value_view(cm); // const from const lvalue + [[maybe_unused]] VVC vv4 = value_view(M()); // const from rvalue // Direct initialization (without value_view function) - VV ABSL_ATTRIBUTE_UNUSED vv5(m); - VVC ABSL_ATTRIBUTE_UNUSED vv6(m); - VVC ABSL_ATTRIBUTE_UNUSED vv7(cm); - VVC ABSL_ATTRIBUTE_UNUSED vv8((M())); + [[maybe_unused]] VV vv5(m); + [[maybe_unused]] VVC vv6(m); + [[maybe_unused]] VVC vv7(cm); + [[maybe_unused]] VVC vv8((M())); } TEST_F(IteratorAdaptorTest, EmptyAndSize) { From 9dd9b551382253627fd9ac6a66ab54f44029f9b5 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 15 Sep 2026 16:44:29 -0400 Subject: [PATCH 19/20] Revert changes to sdk.firestore.yml, Podfile, and DatabaseTests.swift to match main --- .github/workflows/sdk.firestore.yml | 24 ---- Firestore/Example/Podfile | 5 - .../Tests/Integration/DatabaseTests.swift | 133 ------------------ 3 files changed, 162 deletions(-) diff --git a/.github/workflows/sdk.firestore.yml b/.github/workflows/sdk.firestore.yml index fd036ba5bfd..a13aef0e4fe 100644 --- a/.github/workflows/sdk.firestore.yml +++ b/.github/workflows/sdk.firestore.yml @@ -333,14 +333,6 @@ jobs: restore-keys: | ${{ runner.os }}-pods-${{ matrix.target }}- - - name: Cache Pods - uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 - with: - path: Firestore/Example/Pods - key: ${{ runner.os }}-pods-${{ matrix.target }}-${{ hashFiles('Firestore/Example/Podfile.lock') }} - restore-keys: | - ${{ runner.os }}-pods-${{ matrix.target }}- - # 'FirestoreEnterprise' is used as product name for `build.sh` to select the enterprise build variant. `install_prereqs.sh` does not require this distinction, so 'Firestore' is used. - name: Setup build run: scripts/install_prereqs.sh Firestore ${{ matrix.target }} xcodebuild @@ -406,14 +398,6 @@ jobs: restore-keys: | ${{ runner.os }}-pods-${{ matrix.target }}- - - name: Cache Pods - uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 - with: - path: Firestore/Example/Pods - key: ${{ runner.os }}-pods-${{ matrix.target }}-${{ hashFiles('Firestore/Example/Podfile.lock') }} - restore-keys: | - ${{ runner.os }}-pods-${{ matrix.target }}- - # 'FirestoreEnterprise' is used as product name for `build.sh` to select the enterprise build variant. `install_prereqs.sh` does not require this distinction, so 'Firestore' is used. - name: Setup build run: scripts/install_prereqs.sh Firestore ${{ matrix.target }} xcodebuild @@ -495,14 +479,6 @@ jobs: restore-keys: | ${{ runner.os }}-pods-${{ matrix.target }}- - - name: Cache Pods - uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 - with: - path: Firestore/Example/Pods - key: ${{ runner.os }}-pods-${{ matrix.target }}-${{ hashFiles('Firestore/Example/Podfile.lock') }} - restore-keys: | - ${{ runner.os }}-pods-${{ matrix.target }}- - - name: Setup build # 'FirestoreEnterprise' is used as product name for `build.sh` to select the enterprise build variant. `install_prereqs.sh` does not require this distinction, so 'Firestore' is used. run: scripts/install_prereqs.sh Firestore ${{ matrix.target }} xcodebuild diff --git a/Firestore/Example/Podfile b/Firestore/Example/Podfile index 639410ac643..a5f91374557 100644 --- a/Firestore/Example/Podfile +++ b/Firestore/Example/Podfile @@ -1,7 +1,6 @@ # Copyright 2017 Google LLC require 'pathname' -require_relative '../../scripts/cocoapods_cxx17_patch.rb' # Uncomment the next two lines for pre-release testing on internal repo #source 'sso://cpdc-internal/firebase' @@ -189,7 +188,3 @@ if is_platform(:tvos) end end end - -post_install do |installer| - CocoapodsCXX17Patch.apply_patch(installer) -end diff --git a/Firestore/Swift/Tests/Integration/DatabaseTests.swift b/Firestore/Swift/Tests/Integration/DatabaseTests.swift index 0fc50e30cac..0304a87c264 100644 --- a/Firestore/Swift/Tests/Integration/DatabaseTests.swift +++ b/Firestore/Swift/Tests/Integration/DatabaseTests.swift @@ -21,139 +21,6 @@ import FirebaseCore import FirebaseFirestore class DatabaseTests: FSTIntegrationTestCase { - func testCanStillUseDisablePersistenceSettings() async throws { - let settings = db.settings - settings.isPersistenceEnabled = false - db.settings = settings - - try await db.document("coll/doc").setData(["foo": "bar"]) - let result = try? await db.document("coll/doc").getDocument(source: .cache) - XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) - } - - func testCanStillUseEnablePersistenceSettings() async throws { - let settings = db.settings - settings.isPersistenceEnabled = true - db.settings = settings - - try await db.document("coll/doc").setData(["foo": "bar"]) - let result = try? await db.document("coll/doc").getDocument(source: .cache) - XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) - } - - func testCanUseMemoryCacheSettings() async throws { - let settings = db.settings - settings.cacheSettings = MemoryCacheSettings() - db.settings = settings - - try await db.document("coll/doc").setData(["foo": "bar"]) - let result = try? await db.document("coll/doc").getDocument(source: .cache) - XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) - } - - func testCanGetDocumentWithMemoryLruGCEnabled() async throws { - let settings = db.settings - settings - .cacheSettings = - MemoryCacheSettings( - garbageCollectorSettings: MemoryLRUGCSettings(sizeBytes: 2_000_000) - ) - db.settings = settings - - try await db.document("coll/doc").setData(["foo": "bar"]) - let result = try? await db.document("coll/doc").getDocument(source: .cache) - XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) - } - - func testCannotGetDocumentWithMemoryEagerGCEnabled() async throws { - let settings = db.settings - settings - .cacheSettings = - MemoryCacheSettings(garbageCollectorSettings: MemoryEagerGCSetting()) - db.settings = settings - - try await db.document("coll/doc").setData(["foo": "bar"]) - let result = try? await db.document("coll/doc").getDocument(source: .cache) - XCTAssertNil(result) - } - - func testCanUsePersistentCacheSettings() async throws { - let settings = db.settings - settings.cacheSettings = PersistentCacheSettings() - db.settings = settings - - try await db.document("coll/doc").setData(["foo": "bar"]) - let result = try? await db.document("coll/doc").getDocument(source: .cache) - XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) - } - - func testCanSetCacheSettingsMultipleTimes() async throws { - let settings = db.settings - settings.cacheSettings = PersistentCacheSettings() - settings.cacheSettings = MemoryCacheSettings() - db.settings = settings - - try await db.document("coll/doc").setData(["foo": "bar"]) - let result = try? await db.document("coll/doc").getDocument(source: .cache) - XCTAssertEqual(["foo": "bar"], result?.data() as! [String: String]) - } - - func testGetValidPersistentCacheIndexManager() async throws { - // [FIRApp resetApps] is an internal api, while Swift test can only test again public api. - // So `FirebaseApp.configure()` can only be called once for the whole test class. - FirebaseApp.configure() - - let db1 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB1") - let settings1 = db1.settings - settings1.cacheSettings = PersistentCacheSettings() - db1.settings = settings1 - - XCTAssertNotNil(db1.persistentCacheIndexManager) - - // Use persistent disk cache (default) - let db2 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB2") - XCTAssertNotNil(db2.persistentCacheIndexManager) - - // Disable persistent disk cache - let db3 = Firestore.firestore(database: "SwiftMemoryCacheIndexManagerDB1") - let settings3 = db3.settings - settings3.cacheSettings = MemoryCacheSettings() - db3.settings = settings3 - XCTAssertNil(db3.persistentCacheIndexManager) - - // Disable persistent disk cache (deprecated) - let db4 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB4") - let settings4 = db4.settings - settings4.isPersistenceEnabled = false - db4.settings = settings4 - XCTAssertNil(db4.persistentCacheIndexManager) - - let db5 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB5") - let settings5 = db5.settings - settings5.cacheSettings = PersistentCacheSettings() - db5.settings = settings5 - XCTAssertEqual(db5.persistentCacheIndexManager, db5.persistentCacheIndexManager) - - // Use persistent disk cache (default) - let db6 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB6") - XCTAssertEqual(db6.persistentCacheIndexManager, db6.persistentCacheIndexManager) - - let db7 = Firestore.firestore(database: "SwiftMemoryCacheIndexManagerDB2") - let settings7 = db7.settings - settings7.cacheSettings = PersistentCacheSettings() - db7.settings = settings7 - XCTAssertNotEqual(db5.persistentCacheIndexManager, db7.persistentCacheIndexManager) - XCTAssertNotEqual(db6.persistentCacheIndexManager, db7.persistentCacheIndexManager) - - // Use persistent disk cache (default) - let db8 = Firestore.firestore(database: "SwiftPersistentCacheIndexManagerDB8") - XCTAssertNotEqual(db5.persistentCacheIndexManager, db8.persistentCacheIndexManager) - XCTAssertNotEqual(db6.persistentCacheIndexManager, db8.persistentCacheIndexManager) - XCTAssertNotEqual(db7.persistentCacheIndexManager, db8.persistentCacheIndexManager) - } ->>>>>>> a45d986d9 (move the intentional failing test) - } - func testCanStillUseDisablePersistenceSettings() async throws { let settings = db.settings settings.isPersistenceEnabled = false From efe09cdf551328a3a267f3346d4c6d9b6819143d Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 15 Sep 2026 16:58:23 -0400 Subject: [PATCH 20/20] format --- Firestore/core/src/core/view.cc | 4 ++-- Firestore/core/src/local/leveldb_index_manager.cc | 4 ++-- Firestore/core/src/local/memory_mutation_queue.cc | 4 ++-- Firestore/core/src/remote/serializer.cc | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Firestore/core/src/core/view.cc b/Firestore/core/src/core/view.cc index bcdcd4b0631..fefa34adbba 100644 --- a/Firestore/core/src/core/view.cc +++ b/Firestore/core/src/core/view.cc @@ -184,8 +184,8 @@ ViewDocumentChanges View::ComputeDocumentChanges( std::optional old_doc = old_document_set.GetDocument(key); std::optional new_doc = query_.Matches(kv.second) - ? std::optional{kv.second} - : std::nullopt; + ? std::optional{kv.second} + : std::nullopt; bool old_doc_had_pending_mutations = old_doc && old_mutated_keys.contains(key); diff --git a/Firestore/core/src/local/leveldb_index_manager.cc b/Firestore/core/src/local/leveldb_index_manager.cc index b37c72b7b21..e62a0da7bd7 100644 --- a/Firestore/core/src/local/leveldb_index_manager.cc +++ b/Firestore/core/src/local/leveldb_index_manager.cc @@ -755,8 +755,8 @@ std::vector LevelDbIndexManager::CreateRange( return ranges; } -std::optional -LevelDbIndexManager::GetNextCollectionGroupToUpdate() const { +std::optional LevelDbIndexManager::GetNextCollectionGroupToUpdate() + const { if (next_index_to_update_.empty()) { return std::nullopt; } diff --git a/Firestore/core/src/local/memory_mutation_queue.cc b/Firestore/core/src/local/memory_mutation_queue.cc index f8884534a8d..0df7c5b4104 100644 --- a/Firestore/core/src/local/memory_mutation_queue.cc +++ b/Firestore/core/src/local/memory_mutation_queue.cc @@ -208,8 +208,8 @@ MemoryMutationQueue::AllMutationBatchesAffectingQuery(const Query& query) { return AllMutationBatchesWithIds(unique_batch_ids); } -std::optional -MemoryMutationQueue::NextMutationBatchAfterBatchId(BatchId batch_id) { +std::optional MemoryMutationQueue::NextMutationBatchAfterBatchId( + BatchId batch_id) { BatchId next_batch_id = batch_id + 1; // The requested batch_id may still be out of range so normalize it to the diff --git a/Firestore/core/src/remote/serializer.cc b/Firestore/core/src/remote/serializer.cc index c63f314ac62..cf40520b167 100644 --- a/Firestore/core/src/remote/serializer.cc +++ b/Firestore/core/src/remote/serializer.cc @@ -16,9 +16,9 @@ #include "Firestore/core/src/remote/serializer.h" -#include #include #include +#include #include #include