Commit Graph
388 Commits
Author SHA1 Message Date
Gil 38d9643a00 Disallow empty document fields (#4229)
Port of firebase/firebase-android-sdk#643.

Also make error messages align with Android's.
2019-11-04 17:03:10 -06:00
wu-hui 2f53582530 Various minor fixes to make SDK compile on Linux (#4185) 2019-11-04 14:39:44 -05:00
Gil 3ea7197090 Port FSTQueryCacheTests to C++ (#4160)
* Move FSTQueryCacheTests files to Firestore/core

* Rewrite QueryCache tests in C++

* Fix test flake in local store tests

This doesn't affect production because we always set the additional
references pointer there, but it's technically optional and some tests
don't do this.
2019-11-02 09:09:25 -05:00
Brian Chen 251a70f26a Make IN queries publicly available (#4174) 2019-10-29 14:13:02 -07:00
Brian Chen 441d7eda8b Change id to NSArray<id> for IN queries (#4182) 2019-10-28 22:22:37 -07:00
Konstantin Varlamov 8b23a3266d Remove Objective-C serializers and make local/ and remote/ (almost) fully C++ (#4151)
There are more sources that can be `.cc` now (e.g., in API); these are left for a follow-up PR.

The dependency on Objective-C proto library cannot be removed just yet due to current lack of pretty-printing support for Nanopb.
2019-10-23 20:56:44 -04:00
Gil 6fd815a5ed Port FSTRemoteDocumentCacheTests to C++ (#4136) 2019-10-23 12:28:16 -07:00
Konstantin Varlamov 2c53bb9139 C++ migration: use C++ serializer for communicating with the local store (#4116)
After this PR is merged, the Objective-C serializers can be completely removed from the project. Also, this PR changes the `Message` class quite a bit; it's probably in its final form now.

I did some performance testing locally and came to the conclusion that replacing Objective-C serializers with their C++ versions brings no performance downgrade; actually, there seems to be a very slight improvement. I tested writing large batches and reading large collections:
* both are network-dominated; wall time is about twice longer than CPU time;
* serialization represents a pretty small percentage of the total CPU time;
* for writing, C++ serialization is a little more efficient, taking ~6% of total CPU time, compared to ~8% in the Objective-C version. I've seen similar results for reading.

All integration tests pass, under Address Sanitizer as well.
2019-10-22 21:52:55 -04:00
Gil 3f1fbe7e9a Migrate FSTPersistenceTestHelpers to C++ (#4122)
* Move FSTPersistenceHelpers to core/test/.../local

* Rewrite persistence_testing in C++

* Migrate from FSTPersistenceTestHelpers to C++ persistence_testing

* Rename .mm to .cc where possible in IndexManager tests

* Remove Objective-C gunk from index_manager_test.h
2019-10-21 20:12:46 -07:00
Konstantin Varlamov 0f2a0bfeef Use C++ serializer for communicating with the backend (#4013)
Replace all uses of `FSTSerializerBeta` in `remote_objc_bridge.{h,mm}` with the C++ `Serializer`. Also, make most of `remote/` sources pure C++ and remove no-longer-used methods in `FSTSerializerBeta`. All integration tests pass, under Address Sanitizer as well.

Unfortunately, pretty-printing is still delegated to Objective-C, so that `remote_objc_bridge.mm` still has to be an Objective-C++ source (and which prevents inlining `remote_objc_bridge` into the streams).

#no-changelog Will add a changelog entry when local serializer is ported, too.
2019-10-18 17:58:14 -04:00
Gil b1be1a9c70 Ensure that projectIDs are validated (#4073)
* Avoid priming the backend for emulator tests

* Validate that nil project ids are rejected
2019-10-17 10:03:01 -07:00
Gil 11de159e8e Migrate FSTRemoteEventTests to C++ (#3965)
* move (unchanged) into Firestore/core

* split out TestTargetMetadataProvider

... also rename to not start with "test".

* rewrite in C++
2019-10-04 11:55:20 -07:00
Konstantin Varlamov 893002541b Serializer: implement encoding and decoding of Target (#3932) 2019-10-03 19:05:05 -04:00
Sebastian Schmidt 41c411e8f4 Add QueryData.with() helpers (#3991) 2019-10-03 14:52:12 -07:00
Gil b37ab3b433 Migrate FSTViewSnapshotTests to C++ (#3919)
* view_snapshot_test: move (unchanged) from FSTViewSnapshotTest.mm

* view_snapshot_test: automated changes

* view_snapshot_test: sync_project.rb generated changes

* view_snapshot_test: manual fixes

* view_snapshot_test: shorten DocumentViewChange::Type
2019-09-30 19:55:03 -07:00
Gil 7d06d34e05 Migrate tests written as C++ into the C++ tree (#3917)
* field_transform_test: move into Firestore/core

* field_transform_test: project changes

* transform_operation_test: move into Firestore/core

* transform_operation_test: project changes
2019-09-30 18:07:59 -07:00
Gil 62c4fa30d2 Migrate FSTQueryListenerTests to C++ (#3901) 2019-09-30 13:17:53 -07:00
Gil 9ec602efcb Migrate FSTViewTests to C++ (#3900)
* Add view testing utilities

* Copy FSTViewTests.mm to view_test.cc unchanged

* Migrate FSTViewTests to C++
2019-09-30 11:26:42 -07:00
Gil 971445ce35 Add cross-platform support for creating Executors (#3897)
* Add Executor::CreateSerial

... a standard way to create an Executor for most cases where we don't
care about the implementation.

* Add ExecutorForTesting/AsyncQueueForTesting

Uses Executor::CreateSerial to do the heavy lifting.

* Use AsyncQueueForTesting

* Avoid direct references to ExecutorLibdispatch in prod code

* Rewrite time_testing in terms of absl::Time

* Migrate async_test_util's now to time_testing

* Fix AddressSanitizer stack-buffer-underflow error

This was reading random data off the stack until it hit a negative
integer's worth of data. The test passed because this was generating the
input and expected values, which were much longer than expected given
the input.
2019-09-26 10:41:36 -07:00
Brian Chen b1eb602ef4 Rename spec test functions (#3895) 2019-09-20 16:30:11 -04:00
Brian Chen 9d230de9c0 Adding onSnapshotsInSync (not public) (#3850) 2019-09-20 14:15:57 -04:00
wu-hui b48636bf52 Port local store to C++ 2/2 (#3865)
Complete LocalStore port.
2019-09-18 14:00:32 -04:00
Marek Gilbert 3e939a7ee2 Merge branch 'firestore-master' 2019-09-13 12:41:25 -07:00
wu-hui dff57b6048 Enable -Werror for Firestore XCode project (#3836) 2019-09-13 12:39:18 -07:00
Brian Chen 941133705a Port persistence spec test (#3844) 2019-09-13 11:56:47 -07:00
Gil 6ad473ae04 Merge persistence-master to master (#3829)
* Port FSTMemoryPersistence to C++ (#3754)

* Add local::Persistence

* Add MemoryPersistence

* Add MemoryEagerReferenceDelegate

* Make LruDelegate extend ReferenceDelegate

This enables downcasting to LruDelegate in tests that need to do so.

* Add MemoryLruReferenceDelegate

* Don't double-count document key size.

* Port FSTLevelDB to C++ (#3755)

* Add LevelDbPersistence

Note that Apple-specific initialization has been partitioned off in
anticipation of being able to run this code on non-Apple platforms.

* Add LevelDbLruReferenceDelegate

* Migrate to C++ Persistence (1/2) (#3756)

* Use C++ Persistence classes in FSTLocalStore

* Remove ReferenceDelegateBridge

* Cut src over to C++ persistence types

* Remove Objective-C requirement from some classes

... that no longer require it.

* Migrate to C++ Persistence (2/2) (#3757)

* Remove LruDelegateBridge

* Update test initialization of persistence components

In particular, ensure that there's always an owner for the Persistence
instance, which wasn't always handled explicitly in the Objective-C
version of the tests.

* Largely mechanical changes to tests

* Remove Objective-C persistence classes

* Forward declare util::Status when possible (#3761)

* Add a header dedicated to forward declarations for util::Status

* Use status_fwd.h wherever possible
2019-09-12 14:28:10 -07:00
wu-hui 1ce982de85 Port FSTSyncEngine to C++ SyncEngine 2/2 (#3741) 2019-09-05 18:40:58 -04:00
Sebastian Schmidt f0f0aeba20 Don't persist documents that we already have (#3650) 2019-09-05 15:36:29 -07:00
Gil 58cae6c573 Misc Objective-C cleanups (#3751)
* Clean up references to Firestore.pbrpc

We're no longer using Objective-C gRPC services and this is no longer generated.

* Remove no longer existing entries from xcgmock
2019-09-04 11:39:13 -07:00
Gil e374338b83 Fix removal of view references in FSTLocalStore (#3737) 2019-09-02 20:07:28 -07:00
wu-hui c5b5a44603 Rename shutdown to terminate and publish it. (#3694)
* Rename shutdown to terminate and publish it.

* Addressing feedbacks
2019-08-27 11:51:01 -04:00
Gil aa326a47ce Migrate FSTLRUGarbageCollector to C++ LruGarbageCollector (#3685)
* Add ReferenceDelegate

* Remove Objective-C crutches from model/types.h and query_cache.h

* Add C++ LruGarbageCollector

* Add delegate bridges for LruDelegate and ReferenceDelegate

* Migrate from FSTLRUGarbageCollector to C++ LruGarbageCollector
2019-08-26 21:56:15 -07:00
Gil 5cdff78f2b Migrate FSTView to C++ View (#3684)
* Add C++ ViewChange

* Migrate FSTViewChange to C++ ViewChange

* Add C++ View

* Migrate FSTView to C++ View
2019-08-26 19:39:54 -07:00
wu-hui 7870c73b7c Port FSTFirestoreClient to C++ 2/2 (#3657)
* firestore_client + FSTFirestoreClient becomes delegate.

* fix comment

* addressing comment

* use new instead make_shared

* reformat

* Update references to firestore client

* Addressing comments#2

* addressing comments #3

* add std::move

* remove deleted header.

* fix cmake build error.
2019-08-26 15:48:18 -04:00
Gil 49de84aa5c Migrate FSTMutationBatch to C++ MutationBatch (#3673) 2019-08-25 17:40:31 -07:00
Gil 1971af49c9 Partially migrate stream tokens from NSData to ByteString (#3643)
* Convert stream tokens from NSData to ByteString

Note that this persists in using protobuf's conflation of empty and null
strings.

* Rename remote_event.mm to .cc
2019-08-22 15:18:11 -07:00
Brian Chen c7777be93c Retrying transactions with backoff (#3599) 2019-08-21 11:12:09 -07:00
Gil 2e5e8b5676 Migrate FSTQueryData to C++ QueryData (#3595)
* Migrate FSTQueryData to C++ QueryData

* Remove FSTQueryData
2019-08-20 14:56:32 -07:00
wu-hui ea3b589ac0 Port waitForPendingWrites (#3619)
* port waitForPendingWrites

* addressing comments #1

* remove commented line

* another change to disable network
2019-08-20 16:18:02 -04:00
Gil 6b36c0671a Migrate from NSData to nanopb::ByteString for resume tokens (#3592) 2019-08-19 12:22:56 -07:00
Gil aefd4323a2 Remove Objective-C immutable sets and maps (#3590)
* Remove Firestore/third_party/Immutable

* Update podspec and sync_project

* Project updates
2019-08-19 09:09:20 -07:00
Gil dd7fbf885e Migrate FSTMutationTests to C++ (#3571)
* Tidy up mutation_test.cc ahead of filling it out

* Move FSTUserDataConverter tests out of FSTMutationTests

* Add operator<< for Document

The compiler won't apply the one for MaybeDocument.

* Port FSTMutationTests to C++

* Delete FSTMutationTests
2019-08-19 08:21:43 -07:00
Gil e64663a907 Convert Filters to polymorphic value types (#3568) 2019-08-16 13:31:05 -07:00
Marek Gilbert cd8619b817 Merge branch 'firestore-master' 2019-08-16 10:09:38 -07:00
Gil 22a68f8197 Fix flakiness in Firestore integration tests (#3612)
The problem was essentially that each test instance was deleting the
documents directory which contains all persistent data for all
instances.

Unfortunately our tests aren't entirely deterministic and rarely one
test would overlap with another. When this happened the setup code for
the next test would delete the data out from underneath the previous
one.

Before this fix we'd see frequent travis failures and I would see an
occasional local failure (1 out of ~5 runs). With this fix I've seen no
failures in 30 cycles.
2019-08-16 07:52:50 -07:00
Marek Gilbert ffc455650d Merge branch 'master' into firestore-master 2019-08-16 07:25:07 -07:00
Gil 22b9c9006b Convert TransformOperations to polymorphic value types (#3567)
* Rename transform_operation{s,}

* Convert TransformOperation to a polymorphic value class

* fixup! Convert TransformOperation to a polymorphic value class

* Remove ServerTimestampTransform::Get
2019-08-16 07:23:57 -07:00
Gil 9c35050270 Migrate FSTMutation to C++ Mutations (#3564)
* Nontrivial edits

* Mostly mechanical edits

* Remove FSTMutation
2019-08-14 23:18:47 -07:00
wu-hui 7b0159667e allow unlisten after shutdown (#3594) 2019-08-14 22:40:53 -04:00
Gil 0b8e99154f Prepare for migrating FSTMutation to C++ Mutations (#3551)
* Finish porting Precondition to C++.

* Finish port of FieldTransform to C++

* Add ToString to all TransformOperations

* Rename Precondition::IsNone to is_none to match other is_type helpers

* Finish port of SnapshotVersion to C++

* Add is_type accessors to FieldValue

* Add nanopb::MakeStringView(const pb_bytes_array_t*)

* Remove DummyOperation from transform_operations_test
2019-08-14 11:16:23 -07:00