Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove scope and collection cache #512

Merged
merged 3 commits into from
Dec 7, 2023
Merged

Remove scope and collection cache #512

merged 3 commits into from
Dec 7, 2023

Conversation

pasin
Copy link
Contributor

@pasin pasin commented Dec 6, 2023

  • Removed scope and collection cache in the CBLDatabase implementation. This change made CBL-C inline with the other platforms’ implementation. Plus, it makes the implementation much more simpler.

  • CBLDatabase still caches the (internal) default collection used for default collection based APIs (Most are the deprecated APIs). Once we remove those deprecated API, we may not need to have it.

  • When caching the internal default collection in the CBLDatabase, to prevent the retain cycle, call CBLCollection’s adopt(db) function to release the database instance in the CBLCollection object.

  • The database instance inside CBLCollection and CBLScope will not be invalidated. This makes several part of the code that needs the database instance much simplier as it doesn’t need to take care the case when the database is null.

  • Made changes to the tests as needed. Plus, fix XCode analyzer warning in QueryTest.cc about setting nullptr to listenerToken.

  • Fixed wrong information about default collection in CBLCollection. (We will need to fix this in 3.1 branch as well).

  • Updated LiteCore to 3.2.0-115 otherwise it’s not buildable on XCode 15. Need to fix LogTest as now the log files have two header lines.

* Removed scope and collection cache in the CBLDatabase implementation. This change made CBL-C inline with the other platforms’ implementation. Plus, it makes the implementation much more simpler.

* CBLDatabase still caches the (internal) default collection used for default collection based APIs (Most are the deprecated APIs). Once we remove those deprecated API, we may not need to have it.

* When caching the internal default collection in the CBLDatabase, to prevent the retain cycle, call CBLCollection’s adopt(db) function to release the database instance in the CBLCollection object.

* The database instance inside CBLCollection and CBLScope will not be invalidated. This makes several part of the code that needs the database instance much simplier as it doesn’t need to take care the case when the database is null.

* Made changes to the tests as needed. Plus, fix XCode analyzer warning in QueryTest.cc about setting nullptr to listenerToken.

* Fixed wrong information about default collection in CBLCollection. (We will need to fix this in 3.1 branch as well).

* Updated LiteCore to 3.2.0-115 otherwise it’s not buildable on XCode 15. Need to fix LogTest as now the log files have two header lines.
@cbl-bot
Copy link

cbl-bot commented Dec 7, 2023

Code Coverage Results:

Branches Functions Instantiations Lines Regions
76.34 92.94 45.14 89.48 85.43

@pasin pasin requested a review from velicuvlad December 7, 2023 03:57
}
return collection;
Retained<CBLCollection> CBLDatabase::createCBLCollection(C4Collection* c4col, CBLScope* scope) {
return new CBLCollection(c4col, scope, const_cast<CBLDatabase*>(this));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to have this instead of the every call of createCBLCollection for both getCollection and createCollection, similar to Scope implementation, having returning new. Would that be a bit more readable?

It won't make much of a difference... I might just be picky

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can be done.

As database in collection will not be invalidated anymore, we don’t need to explicitly retaining the database in a couple of places.
@pasin pasin merged commit d1962c4 into master Dec 7, 2023
6 checks passed
@pasin pasin deleted the task/CBL-5250 branch December 7, 2023 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants