Commit Graph

59 Commits

Author SHA1 Message Date
Mark Rowe 152697d199 Add the linking objects property type. 2016-06-06 11:49:29 -07:00
Thomas Goyne f4e5049f47 Add basic string formatting for error messages
The main motivation for this is that building error messages via string
concatenation is tedious and makes it hard to judge what the actual message
looks like when there are a lot of parts being inserted, to the extent that
I've been tempted to leave out some potentially useful information because the
code was getting unwieldy.

It also has some small functional benefits: bools are printed as true/false
rather than 1/0, and it is optimized for minimizing the compiled size.
Currently it cuts ~30 KB off librealm-object-store.dylib even with the addition
of new functionality.
2016-06-03 13:19:42 -07:00
Mark Rowe 8685390345 Merge pull request #77 from realm/mar/results-leak
Fix move-assigning to a Results that has a notifier to not leak the Realm
2016-06-01 13:07:45 -07:00
Mark Rowe 65a748de0c Fix move-assigning to a `Results` that has a notifier to not leak the
`Realm`, and moving from a `Results` to not result in a use-after-free.

The compiler generated move-assignment operator resulted in `m_notifier`
being assigned to without first calling `CollectionNotifier::unregister`.
This left a retain cycle in place, causing the `Realm` and other objects
to leak.

`ResultsNotifier` keeps track of which `Results` it should update when a
new `TableView` becomes available. When `Results` move-assignment
operator and move-constructor transfer ownership of the
`ResultsNotifier` to a new instance they also need to update its target
so it won't attempt to update the moved-from `Results`.
2016-05-31 19:03:29 -07:00
Thomas Goyne 840c46f8f3 Upgrade to core 1.0.0 and update the file exception translation to match
File::AccessError is now thrown for all file-related exceptions which don't
have more specific types (rather than std::runtime_error), which requires some
changes to how exception messages are built when translating them to get nice
results.

Also add `Realm::write_copy()` which just wraps `Group::write()` with error
translation.
2016-05-23 10:28:04 -07:00
Thomas Goyne db55770bfa Move the notifications fuzzer to the tests directory 2016-05-11 16:08:30 -07:00
Mark Rowe ef1c6ddc63 Add support for fine-grained notifications from backlink TVs 2016-05-11 16:08:30 -07:00
Thomas Goyne 03108713ee Make PropertyType an enum class 2016-05-11 16:08:30 -07:00
Thomas Goyne 4cf5d5db4c Report modification paths as pre-delete/inserts as required for UITableView 2016-05-11 16:08:30 -07:00
Thomas Goyne d8a69b87dc Improve change calculation performance for nontrivial object graphs
Skip doing any checking at all if none of the tables reachable from the root
table have been modified (which can happen if the table version was bumped due
to insertions, unrelated backlinks, or unlinked-to rows being deleted in linked
tables).

Add cycle checking rather than relying on the max depth to handle it, as the
worst case was O(N^16) if the cycle involved a LinkList of size N.

Track which rows have been confirmed to have not been modified.

Cache the information about the links for each of the relevant tables as
checking the table schema can get somewhat expensive.
2016-05-11 16:08:30 -07:00
Thomas Goyne f9364b50a4 Return the correct iterator from ChunkedVector::erase()
When a chunk is removed entirely it should return an iterator to the first
element in the next chunk, not the last.
2016-05-11 16:08:30 -07:00
Thomas Goyne 4df552ba2d Clean up old move info even when the row being deleted is the last one 2016-05-11 16:08:30 -07:00
Thomas Goyne 3218740fd9 Fix the check for a deleted LV in ListNotifier::add_required_change_info() 2016-05-11 16:08:30 -07:00
Thomas Goyne 632d757014 Always deliver results to the correct SharedGroup
If there are multiple Realm instances for a single file on a single thread due
to disabling caching we need to actually deliver the results to the appropriate
SharedGroup for each notifier rather than delivering them all to the first one.
2016-05-11 16:08:30 -07:00
Thomas Goyne c0350b9001 Rename CollectionChangeIndices to CollectionChangeSet 2016-05-11 16:08:30 -07:00
Thomas Goyne 953e1b15a8 Rename BackgroundCollection to CollectionNotifier 2016-05-11 16:08:30 -07:00
Thomas Goyne 238e9e3b6b Fix tracking of which tables need change info with multiple source notifier versions 2016-05-11 16:08:30 -07:00
Thomas Goyne 155d949793 Only track inserts and deletes for tables being queried directly
# Conflicts:
#	src/collection_notifications.cpp
#	src/collection_notifications.hpp
2016-05-11 16:08:30 -07:00
Thomas Goyne a86265f4dc Move CollectionChangeBuilder to background_collection.hpp 2016-05-11 16:08:30 -07:00
Thomas Goyne bc78c02e9d Fix quadratic runtime of move_last_over() parsing 2016-05-11 16:08:30 -07:00
Thomas Goyne 7a75e2bae2 Use a better data structure for IndexSet
Switch to a chunked vector-of-vectors which makes mid-insertions on large sets
much faster, and cache the begin/end/count for each chunk to make lookups much
more cache-friendly.
2016-05-11 16:08:30 -07:00
Thomas Goyne f051337cd3 Rename erase_and_unshift() to erase_or_unshift() 2016-05-11 16:08:30 -07:00
Thomas Goyne dd336120b2 Fix compilation with GCC 4.9 2016-05-11 16:08:30 -07:00
Thomas Goyne bab5540cf6 Fix incorrect results when the second-to-last row is deleted 2016-05-11 16:08:30 -07:00
Thomas Goyne 20d9da973b Make List and Results notifications more consistent
Deliver the initial results for both of them and include the changeset
in the initial delivery for both, rather than having them behave weirdly
differently.
2016-05-11 16:08:30 -07:00
Thomas Goyne 7a74a22558 Fix tracking of modifications after linkview moves 2016-05-11 16:08:30 -07:00
Thomas Goyne ef632804ef Clean up stale moves for linkviews even without a merge 2016-05-11 16:08:30 -07:00
Thomas Goyne feed7c3479 Update moves when there is another move to exactly the previous move target 2016-05-11 16:08:30 -07:00
Thomas Goyne 0a3158ce74 Fix marking deletions when chaining move_last_over() 2016-05-11 16:08:30 -07:00
Thomas Goyne 1289c4806c Fix handling of move_last_over() on the second-to-last row 2016-05-11 16:08:30 -07:00
Thomas Goyne edc0d1fc4a Improve and expand the changeset calculation tests 2016-05-11 16:08:30 -07:00
Thomas Goyne 0e11a791e9 Improve and expand the IndexSet tests
This gets index_set.cpp back up to 100% line coverage from just the
targeted unit tests.
2016-05-11 16:08:30 -07:00
Thomas Goyne dc7ddfae84 Treat Results from LinkViews as if they were sorted for diff calculations 2016-05-11 16:08:30 -07:00
Thomas Goyne 71911ee221 Add support for wrapping a LinkView in a Results 2016-05-11 16:08:30 -07:00
Thomas Goyne 88a3b6ed00 Speed up the IndexSet combining operations 2016-05-11 16:08:30 -07:00
Thomas Goyne 7f5277a97b Run RealmCoordinator::on_change() on a different thread when using tsan 2016-05-11 16:08:30 -07:00
Thomas Goyne c6def6b814 Don't parse the transaction logs on the background thread if no change info is needed 2016-05-11 16:08:30 -07:00
Thomas Goyne 9503a3fc03 Always send an empty changeset to the first call of a Results notification callback 2016-05-11 16:08:30 -07:00
Thomas Goyne e65ad4d413 Discard moves which are turned into no-ops when merging 2016-05-11 16:08:30 -07:00
Thomas Goyne cfb9f0635c Fix calculation of moves for unsorted queries 2016-05-11 16:08:30 -07:00
Thomas Goyne d22c65f28a Partially split out the code for calculating changesets from the struct for delivering them 2016-05-11 16:08:30 -07:00
Thomas Goyne 424f4e829f Prioritize modified rows when calculating changes for sorted results 2016-05-11 16:08:30 -07:00
Thomas Goyne a428f813d5 Skip calling callbacks if two commits cancel each other out when merged 2016-05-11 16:08:30 -07:00
Thomas Goyne e25e4c2dcd Rework handling of mixed move_last_over() and modifications to actually work 2016-05-11 16:08:30 -07:00
Thomas Goyne d46f2c65ba Refactor the transaction log parsers to eliminate some duplication 2016-05-11 16:08:30 -07:00
Thomas Goyne f4aaa7c9de Add fine-grained notifications for Results 2016-05-11 16:08:30 -07:00
Thomas Goyne 6609bcaed7 Add fine-grained notifications for List 2016-05-11 16:08:30 -07:00
Thomas Goyne 8f7ec85605 Add minimal transaction log parsing tests 2016-05-11 16:08:30 -07:00
Thomas Goyne fafc4232ad Rewrite the code coverage generation
Make lcov/gcovr an optional dependency that's only needed for Coverage
configurations, remove some pointless noisy messages when not generating
coverage, and generally simplify the whole thing.
2016-05-06 15:23:30 -07:00
Thomas Goyne 7ab91ea75e Add cmake target to generate a code coverage report 2016-05-06 12:37:59 -07:00