motion-yapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +63 -0
- data/README.md +16 -0
- data/Rakefile +20 -0
- data/app/app_delegate.rb +5 -0
- data/lib/yapper.rb +30 -0
- data/lib/yapper/attachment.rb +48 -0
- data/lib/yapper/bson.rb +20 -0
- data/lib/yapper/config.rb +18 -0
- data/lib/yapper/db.rb +151 -0
- data/lib/yapper/document.rb +54 -0
- data/lib/yapper/document/attachment.rb +26 -0
- data/lib/yapper/document/callbacks.rb +86 -0
- data/lib/yapper/document/persistance.rb +171 -0
- data/lib/yapper/document/relation.rb +84 -0
- data/lib/yapper/document/selection.rb +100 -0
- data/lib/yapper/extensions.rb +80 -0
- data/lib/yapper/log.rb +5 -0
- data/lib/yapper/sync.rb +134 -0
- data/lib/yapper/sync/data.rb +12 -0
- data/lib/yapper/sync/event.rb +194 -0
- data/lib/yapper/sync/queue.rb +164 -0
- data/lib/yapper/timestamps.rb +16 -0
- data/lib/yapper/version.rb +3 -0
- data/lib/yapper/yapper.rb +2 -0
- data/spec/helpers/time_helper.rb +3 -0
- data/spec/integration/all_spec.rb +40 -0
- data/spec/integration/callback_spec.rb +87 -0
- data/spec/integration/db_spec.rb +40 -0
- data/spec/integration/find_spec.rb +51 -0
- data/spec/integration/persistance_spec.rb +118 -0
- data/spec/integration/relation_spec.rb +174 -0
- data/spec/integration/sync_spec.rb +42 -0
- data/spec/integration/timestamps_spec.rb +34 -0
- data/spec/integration/types_spec.rb +23 -0
- data/spec/integration/when_spec.rb +29 -0
- data/spec/integration/where_spec.rb +132 -0
- data/vendor/Podfile.lock +24 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +1396 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +327 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +321 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +150 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +157 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +143 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +848 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +167 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +191 -0
- data/vendor/Pods/AFNetworking/LICENSE +19 -0
- data/vendor/Pods/AFNetworking/README.md +208 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/CocoaLumberjack/LICENSE.txt +18 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1353 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +601 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +1083 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1479 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +7 -0
- data/vendor/Pods/CocoaLumberjack/README.markdown +37 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/Headers/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Headers/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/Headers/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/Headers/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +17 -0
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-environment.h +38 -0
- data/vendor/Pods/Manifest.lock +24 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +39 -0
- data/vendor/Pods/NSData+MD5Digest/README.md +11 -0
- data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-AFNetworking-dummy.m +5 -0
- data/vendor/Pods/Pods-AFNetworking-prefix.pch +17 -0
- data/vendor/Pods/Pods-AFNetworking.xcconfig +1 -0
- data/vendor/Pods/Pods-Acknowledgements.markdown +96 -0
- data/vendor/Pods/Pods-Acknowledgements.plist +142 -0
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
- data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
- data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-YapDatabase-dummy.m +5 -0
- data/vendor/Pods/Pods-YapDatabase-prefix.pch +5 -0
- data/vendor/Pods/Pods-YapDatabase.xcconfig +1 -0
- data/vendor/Pods/Pods-dummy.m +5 -0
- data/vendor/Pods/Pods-environment.h +38 -0
- data/vendor/Pods/Pods-resources.sh +68 -0
- data/vendor/Pods/Pods.bridgesupport +5096 -0
- data/vendor/Pods/Pods.xcconfig +5 -0
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +5536 -0
- data/vendor/Pods/Reachability/LICENCE.txt +24 -0
- data/vendor/Pods/Reachability/README.md +65 -0
- data/vendor/Pods/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Reachability/Reachability.m +527 -0
- data/vendor/Pods/YapDatabase/LICENSE.txt +18 -0
- data/vendor/Pods/YapDatabase/README.md +30 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +175 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +966 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +146 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +298 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +95 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +1352 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +46 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +180 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +149 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +184 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +1166 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +296 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +28 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +2494 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +1567 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +141 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +186 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +191 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +897 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +4505 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +90 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +453 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +48 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +83 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +26 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +121 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +74 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +603 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +20 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +194 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +96 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +82 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +2022 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +3874 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +5282 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +13 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -0
- data/yapper.gemspec +24 -0
- metadata +458 -0
@@ -0,0 +1,897 @@
|
|
1
|
+
#import "YapDatabaseViewConnection.h"
|
2
|
+
#import "YapDatabaseViewPrivate.h"
|
3
|
+
#import "YapDatabaseExtensionPrivate.h"
|
4
|
+
#import "YapDatabasePrivate.h"
|
5
|
+
#import "YapDatabaseViewPage.h"
|
6
|
+
#import "YapDatabaseViewChange.h"
|
7
|
+
#import "YapDatabaseViewChangePrivate.h"
|
8
|
+
#import "YapCollectionKey.h"
|
9
|
+
#import "YapCache.h"
|
10
|
+
#import "YapDatabaseString.h"
|
11
|
+
#import "YapDatabaseLogging.h"
|
12
|
+
|
13
|
+
#if ! __has_feature(objc_arc)
|
14
|
+
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
|
15
|
+
#endif
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Define log level for this file: OFF, ERROR, WARN, INFO, VERBOSE
|
19
|
+
* See YapDatabaseLogging.h for more information.
|
20
|
+
**/
|
21
|
+
#if DEBUG
|
22
|
+
static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
|
23
|
+
#else
|
24
|
+
static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
|
25
|
+
#endif
|
26
|
+
|
27
|
+
static NSString *const key_dirtyMaps = @"dirtyMaps";
|
28
|
+
static NSString *const key_dirtyPages = @"dirtyPages";
|
29
|
+
static NSString *const key_reset = @"reset";
|
30
|
+
static NSString *const key_group_pagesMetadata_dict = @"group_pagesMetadata_dict";
|
31
|
+
static NSString *const key_pageKey_group_dict = @"pageKey_group_dict";
|
32
|
+
static NSString *const key_changes = @"changes";
|
33
|
+
|
34
|
+
@implementation YapDatabaseViewConnection
|
35
|
+
{
|
36
|
+
id sharedKeySetForInternalChangeset;
|
37
|
+
id sharedKeySetForExternalChangeset;
|
38
|
+
|
39
|
+
sqlite3_stmt *mapTable_getPageKeyForRowidStatement;
|
40
|
+
sqlite3_stmt *mapTable_setPageKeyForRowidStatement;
|
41
|
+
sqlite3_stmt *mapTable_removeForRowidStatement;
|
42
|
+
sqlite3_stmt *mapTable_removeAllStatement;
|
43
|
+
|
44
|
+
sqlite3_stmt *pageTable_getDataForPageKeyStatement;
|
45
|
+
sqlite3_stmt *pageTable_insertForPageKeyStatement;
|
46
|
+
sqlite3_stmt *pageTable_updateAllForPageKeyStatement;
|
47
|
+
sqlite3_stmt *pageTable_updatePageForPageKeyStatement;
|
48
|
+
sqlite3_stmt *pageTable_updateLinkForPageKeyStatement;
|
49
|
+
sqlite3_stmt *pageTable_removeForPageKeyStatement;
|
50
|
+
sqlite3_stmt *pageTable_removeAllStatement;
|
51
|
+
}
|
52
|
+
|
53
|
+
@synthesize view = view;
|
54
|
+
|
55
|
+
- (id)initWithView:(YapDatabaseView *)inView databaseConnection:(YapDatabaseConnection *)inDbC
|
56
|
+
{
|
57
|
+
if ((self = [super init]))
|
58
|
+
{
|
59
|
+
view = inView;
|
60
|
+
databaseConnection = inDbC;
|
61
|
+
|
62
|
+
mapCache = [[YapCache alloc] initWithKeyClass:[NSNumber class]];
|
63
|
+
pageCache = [[YapCache alloc] initWithKeyClass:[NSString class]];
|
64
|
+
|
65
|
+
sharedKeySetForInternalChangeset = [NSDictionary sharedKeySetForKeys:[self internalChangesetKeys]];
|
66
|
+
sharedKeySetForExternalChangeset = [NSDictionary sharedKeySetForKeys:[self externalChangesetKeys]];
|
67
|
+
}
|
68
|
+
return self;
|
69
|
+
}
|
70
|
+
|
71
|
+
- (void)dealloc
|
72
|
+
{
|
73
|
+
sqlite_finalize_null(&mapTable_getPageKeyForRowidStatement);
|
74
|
+
sqlite_finalize_null(&mapTable_setPageKeyForRowidStatement);
|
75
|
+
sqlite_finalize_null(&mapTable_removeForRowidStatement);
|
76
|
+
sqlite_finalize_null(&mapTable_removeAllStatement);
|
77
|
+
|
78
|
+
sqlite_finalize_null(&pageTable_getDataForPageKeyStatement);
|
79
|
+
sqlite_finalize_null(&pageTable_insertForPageKeyStatement);
|
80
|
+
sqlite_finalize_null(&pageTable_updateAllForPageKeyStatement);
|
81
|
+
sqlite_finalize_null(&pageTable_updatePageForPageKeyStatement);
|
82
|
+
sqlite_finalize_null(&pageTable_updateLinkForPageKeyStatement);
|
83
|
+
sqlite_finalize_null(&pageTable_removeForPageKeyStatement);
|
84
|
+
sqlite_finalize_null(&pageTable_removeAllStatement);
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Required override method from YapDatabaseExtensionConnection
|
89
|
+
**/
|
90
|
+
- (void)_flushMemoryWithLevel:(int)level
|
91
|
+
{
|
92
|
+
if (level >= YapDatabaseConnectionFlushMemoryLevelMild)
|
93
|
+
{
|
94
|
+
[mapCache removeAllObjects];
|
95
|
+
[pageCache removeAllObjects];
|
96
|
+
}
|
97
|
+
|
98
|
+
if (level >= YapDatabaseConnectionFlushMemoryLevelModerate)
|
99
|
+
{
|
100
|
+
sqlite_finalize_null(&mapTable_setPageKeyForRowidStatement);
|
101
|
+
sqlite_finalize_null(&mapTable_removeForRowidStatement);
|
102
|
+
sqlite_finalize_null(&mapTable_removeAllStatement);
|
103
|
+
|
104
|
+
sqlite_finalize_null(&pageTable_insertForPageKeyStatement);
|
105
|
+
sqlite_finalize_null(&pageTable_updateAllForPageKeyStatement);
|
106
|
+
sqlite_finalize_null(&pageTable_updatePageForPageKeyStatement);
|
107
|
+
sqlite_finalize_null(&pageTable_updateLinkForPageKeyStatement);
|
108
|
+
sqlite_finalize_null(&pageTable_removeForPageKeyStatement);
|
109
|
+
sqlite_finalize_null(&pageTable_removeAllStatement);
|
110
|
+
}
|
111
|
+
|
112
|
+
if (level >= YapDatabaseConnectionFlushMemoryLevelFull)
|
113
|
+
{
|
114
|
+
sqlite_finalize_null(&mapTable_getPageKeyForRowidStatement);
|
115
|
+
|
116
|
+
sqlite_finalize_null(&pageTable_getDataForPageKeyStatement);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
121
|
+
#pragma mark Accessors
|
122
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Required override method from YapDatabaseExtensionConnection.
|
126
|
+
**/
|
127
|
+
- (YapDatabaseExtension *)extension
|
128
|
+
{
|
129
|
+
return view;
|
130
|
+
}
|
131
|
+
|
132
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
133
|
+
#pragma mark Transactions
|
134
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Required override method from YapDatabaseExtensionConnection.
|
138
|
+
**/
|
139
|
+
- (id)newReadTransaction:(YapDatabaseReadTransaction *)databaseTransaction
|
140
|
+
{
|
141
|
+
YapDatabaseViewTransaction *transaction =
|
142
|
+
[[YapDatabaseViewTransaction alloc] initWithViewConnection:self
|
143
|
+
databaseTransaction:databaseTransaction];
|
144
|
+
|
145
|
+
return transaction;
|
146
|
+
}
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Required override method from YapDatabaseExtensionConnection.
|
150
|
+
**/
|
151
|
+
- (id)newReadWriteTransaction:(YapDatabaseReadWriteTransaction *)databaseTransaction
|
152
|
+
{
|
153
|
+
YapDatabaseViewTransaction *transaction =
|
154
|
+
[[YapDatabaseViewTransaction alloc] initWithViewConnection:self
|
155
|
+
databaseTransaction:databaseTransaction];
|
156
|
+
|
157
|
+
[self prepareForReadWriteTransaction];
|
158
|
+
return transaction;
|
159
|
+
}
|
160
|
+
|
161
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
162
|
+
#pragma mark Utilities
|
163
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
164
|
+
|
165
|
+
- (NSMutableDictionary *)group_pagesMetadata_dict_deepCopy:(NSDictionary *)in_group_pagesMetadata_dict
|
166
|
+
{
|
167
|
+
NSMutableDictionary *deepCopy = [NSMutableDictionary dictionaryWithCapacity:[in_group_pagesMetadata_dict count]];
|
168
|
+
|
169
|
+
[in_group_pagesMetadata_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
170
|
+
|
171
|
+
__unsafe_unretained NSString *group = (NSString *)key;
|
172
|
+
__unsafe_unretained NSMutableArray *pagesMetadata = (NSMutableArray *)obj;
|
173
|
+
|
174
|
+
// We need a mutable copy of the pages array,
|
175
|
+
// and we need a copy of each YapDatabaseViewPageMetadata object within the pages array.
|
176
|
+
|
177
|
+
NSMutableArray *pagesMetadataDeepCopy = [[NSMutableArray alloc] initWithArray:pagesMetadata copyItems:YES];
|
178
|
+
|
179
|
+
[deepCopy setObject:pagesMetadataDeepCopy forKey:group];
|
180
|
+
}];
|
181
|
+
|
182
|
+
return deepCopy;
|
183
|
+
}
|
184
|
+
|
185
|
+
- (void)sanitizeDirtyPages
|
186
|
+
{
|
187
|
+
NSNull *nsnull = [NSNull null];
|
188
|
+
|
189
|
+
for (NSString *pageKey in [dirtyPages allKeys])
|
190
|
+
{
|
191
|
+
YapDatabaseViewPage *page = [dirtyPages objectForKey:pageKey];
|
192
|
+
|
193
|
+
if ((id)page != nsnull)
|
194
|
+
{
|
195
|
+
[dirtyPages setObject:[page copy] forKey:pageKey];
|
196
|
+
}
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
201
|
+
#pragma mark Changeset Architecture
|
202
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Initializes any ivars that a read-write transaction may need.
|
206
|
+
**/
|
207
|
+
- (void)prepareForReadWriteTransaction
|
208
|
+
{
|
209
|
+
if (dirtyMaps == nil)
|
210
|
+
dirtyMaps = [[NSMutableDictionary alloc] init];
|
211
|
+
if (dirtyPages == nil)
|
212
|
+
dirtyPages = [[NSMutableDictionary alloc] init];
|
213
|
+
if (dirtyLinks == nil)
|
214
|
+
dirtyLinks = [[NSMutableDictionary alloc] init];
|
215
|
+
if (changes == nil)
|
216
|
+
changes = [[NSMutableArray alloc] init];
|
217
|
+
if (mutatedGroups == nil)
|
218
|
+
mutatedGroups = [[NSMutableSet alloc] init];
|
219
|
+
}
|
220
|
+
|
221
|
+
/**
|
222
|
+
* Invoked by our YapDatabaseViewTransaction at the completion of the rollbackTransaction method.
|
223
|
+
**/
|
224
|
+
- (void)postRollbackCleanup
|
225
|
+
{
|
226
|
+
YDBLogAutoTrace();
|
227
|
+
|
228
|
+
group_pagesMetadata_dict = nil;
|
229
|
+
pageKey_group_dict = nil;
|
230
|
+
|
231
|
+
[mapCache removeAllObjects];
|
232
|
+
[pageCache removeAllObjects];
|
233
|
+
|
234
|
+
[dirtyMaps removeAllObjects];
|
235
|
+
[dirtyPages removeAllObjects];
|
236
|
+
[dirtyLinks removeAllObjects];
|
237
|
+
reset = NO;
|
238
|
+
|
239
|
+
[changes removeAllObjects];
|
240
|
+
}
|
241
|
+
|
242
|
+
/**
|
243
|
+
* Invoked by our YapDatabaseViewTransaction at the completion of the commitTransaction method.
|
244
|
+
**/
|
245
|
+
- (void)postCommitCleanup
|
246
|
+
{
|
247
|
+
// This code is best understood alongside the getExternalChangeset:internalChangeset: method (below).
|
248
|
+
|
249
|
+
// Both dirtyKeys & dirtyPages are sent in the internalChangeset.
|
250
|
+
// So we need completely new versions of them.
|
251
|
+
|
252
|
+
if ([dirtyMaps count] > 0)
|
253
|
+
dirtyMaps = nil;
|
254
|
+
|
255
|
+
if ([dirtyPages count] > 0)
|
256
|
+
dirtyPages = nil;
|
257
|
+
|
258
|
+
// dirtyLinks isn't part of the changeset.
|
259
|
+
// So it's safe to simply reset.
|
260
|
+
|
261
|
+
[dirtyLinks removeAllObjects];
|
262
|
+
|
263
|
+
// The changes log is copied into the external changeset.
|
264
|
+
// So it's safe to simply reset.
|
265
|
+
|
266
|
+
[changes removeAllObjects];
|
267
|
+
[mutatedGroups removeAllObjects];
|
268
|
+
|
269
|
+
reset = NO;
|
270
|
+
}
|
271
|
+
|
272
|
+
- (NSArray *)internalChangesetKeys
|
273
|
+
{
|
274
|
+
return @[ key_dirtyMaps,
|
275
|
+
key_dirtyPages,
|
276
|
+
key_reset,
|
277
|
+
key_group_pagesMetadata_dict,
|
278
|
+
key_pageKey_group_dict ];
|
279
|
+
}
|
280
|
+
|
281
|
+
- (NSArray *)externalChangesetKeys
|
282
|
+
{
|
283
|
+
return @[ key_changes ];
|
284
|
+
}
|
285
|
+
|
286
|
+
- (void)getInternalChangeset:(NSMutableDictionary **)internalChangesetPtr
|
287
|
+
externalChangeset:(NSMutableDictionary **)externalChangesetPtr
|
288
|
+
hasDiskChanges:(BOOL *)hasDiskChangesPtr
|
289
|
+
{
|
290
|
+
YDBLogAutoTrace();
|
291
|
+
|
292
|
+
NSMutableDictionary *internalChangeset = nil;
|
293
|
+
NSMutableDictionary *externalChangeset = nil;
|
294
|
+
BOOL hasDiskChanges = NO;
|
295
|
+
|
296
|
+
if ([dirtyMaps count] || [dirtyPages count] || [dirtyLinks count] || reset)
|
297
|
+
{
|
298
|
+
hasDiskChanges = view->options.isPersistent;
|
299
|
+
internalChangeset = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySetForInternalChangeset];
|
300
|
+
|
301
|
+
if ([dirtyMaps count] > 0)
|
302
|
+
{
|
303
|
+
[internalChangeset setObject:dirtyMaps forKey:key_dirtyMaps];
|
304
|
+
}
|
305
|
+
if ([dirtyPages count] > 0)
|
306
|
+
{
|
307
|
+
[self sanitizeDirtyPages];
|
308
|
+
[internalChangeset setObject:dirtyPages forKey:key_dirtyPages];
|
309
|
+
}
|
310
|
+
|
311
|
+
if (reset)
|
312
|
+
{
|
313
|
+
[internalChangeset setObject:@(reset) forKey:key_reset];
|
314
|
+
}
|
315
|
+
|
316
|
+
NSMutableDictionary *group_pagesMetadata_dict_copy;
|
317
|
+
NSMutableDictionary *pageKey_group_dict_copy;
|
318
|
+
|
319
|
+
group_pagesMetadata_dict_copy = [self group_pagesMetadata_dict_deepCopy:group_pagesMetadata_dict];
|
320
|
+
pageKey_group_dict_copy = [pageKey_group_dict mutableCopy];
|
321
|
+
|
322
|
+
[internalChangeset setObject:group_pagesMetadata_dict_copy forKey:key_group_pagesMetadata_dict];
|
323
|
+
[internalChangeset setObject:pageKey_group_dict_copy forKey:key_pageKey_group_dict];
|
324
|
+
}
|
325
|
+
|
326
|
+
if ([changes count])
|
327
|
+
{
|
328
|
+
externalChangeset = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySetForExternalChangeset];
|
329
|
+
|
330
|
+
[externalChangeset setObject:[changes copy] forKey:key_changes];
|
331
|
+
}
|
332
|
+
|
333
|
+
*internalChangesetPtr = internalChangeset;
|
334
|
+
*externalChangesetPtr = externalChangeset;
|
335
|
+
*hasDiskChangesPtr = hasDiskChanges;
|
336
|
+
}
|
337
|
+
|
338
|
+
- (void)processChangeset:(NSDictionary *)changeset
|
339
|
+
{
|
340
|
+
YDBLogAutoTrace();
|
341
|
+
|
342
|
+
NSMutableDictionary *changeset_group_pagesMetadata_dict = [changeset objectForKey:key_group_pagesMetadata_dict];
|
343
|
+
NSMutableDictionary *changeset_pageKey_group_dict = [changeset objectForKey:key_pageKey_group_dict];
|
344
|
+
|
345
|
+
NSDictionary *changeset_dirtyMaps = [changeset objectForKey:key_dirtyMaps];
|
346
|
+
NSDictionary *changeset_dirtyPages = [changeset objectForKey:key_dirtyPages];
|
347
|
+
|
348
|
+
BOOL changeset_reset = [[changeset objectForKey:key_reset] boolValue];
|
349
|
+
|
350
|
+
// Perform proper deep copies
|
351
|
+
//
|
352
|
+
// Note: we make copies from changeset_dirtyPages on demand below via:
|
353
|
+
// - [pageCache setObject:[page copy] forKey:pageKey];
|
354
|
+
|
355
|
+
changeset_group_pagesMetadata_dict = [self group_pagesMetadata_dict_deepCopy:changeset_group_pagesMetadata_dict];
|
356
|
+
changeset_pageKey_group_dict = [changeset_pageKey_group_dict mutableCopy];
|
357
|
+
|
358
|
+
// Store new top level objects
|
359
|
+
|
360
|
+
group_pagesMetadata_dict = changeset_group_pagesMetadata_dict;
|
361
|
+
pageKey_group_dict = changeset_pageKey_group_dict;
|
362
|
+
|
363
|
+
// Update mapCache
|
364
|
+
|
365
|
+
if (changeset_reset && ([changeset_dirtyMaps count] == 0))
|
366
|
+
{
|
367
|
+
[mapCache removeAllObjects];
|
368
|
+
}
|
369
|
+
else if ([changeset_dirtyMaps count] > 0)
|
370
|
+
{
|
371
|
+
NSUInteger removeCapacity = [mapCache count];
|
372
|
+
NSUInteger updateCapacity = MIN([mapCache count], [changeset_dirtyMaps count]);
|
373
|
+
|
374
|
+
NSMutableArray *keysToRemove = [NSMutableArray arrayWithCapacity:removeCapacity];
|
375
|
+
NSMutableArray *keysToUpdate = [NSMutableArray arrayWithCapacity:updateCapacity];
|
376
|
+
|
377
|
+
[mapCache enumerateKeysWithBlock:^(id key, BOOL *stop) {
|
378
|
+
|
379
|
+
// Order matters.
|
380
|
+
// Consider the following database change:
|
381
|
+
//
|
382
|
+
// [transaction removeAllObjects];
|
383
|
+
// [transaction setObject:obj forKey:key];
|
384
|
+
|
385
|
+
if ([changeset_dirtyMaps objectForKey:key])
|
386
|
+
[keysToUpdate addObject:key];
|
387
|
+
else if (changeset_reset)
|
388
|
+
[keysToRemove addObject:key];
|
389
|
+
}];
|
390
|
+
|
391
|
+
[mapCache removeObjectsForKeys:keysToRemove];
|
392
|
+
|
393
|
+
NSNull *nsnull = [NSNull null];
|
394
|
+
|
395
|
+
for (NSString *key in keysToUpdate)
|
396
|
+
{
|
397
|
+
NSString *pageKey = [changeset_dirtyMaps objectForKey:key];
|
398
|
+
|
399
|
+
if ((id)pageKey == nsnull)
|
400
|
+
[mapCache removeObjectForKey:key];
|
401
|
+
else
|
402
|
+
[mapCache setObject:pageKey forKey:key];
|
403
|
+
}
|
404
|
+
}
|
405
|
+
|
406
|
+
// Update pageCache
|
407
|
+
|
408
|
+
if (changeset_reset && ([changeset_dirtyPages count] == 0))
|
409
|
+
{
|
410
|
+
[pageCache removeAllObjects];
|
411
|
+
}
|
412
|
+
else if ([changeset_dirtyPages count])
|
413
|
+
{
|
414
|
+
NSUInteger removeCapacity = [pageCache count];
|
415
|
+
NSUInteger updateCapacity = MIN([pageCache count], [changeset_dirtyPages count]);
|
416
|
+
|
417
|
+
NSMutableArray *keysToRemove = [NSMutableArray arrayWithCapacity:removeCapacity];
|
418
|
+
NSMutableArray *keysToUpdate = [NSMutableArray arrayWithCapacity:updateCapacity];
|
419
|
+
|
420
|
+
[pageCache enumerateKeysWithBlock:^(id key, BOOL *stop) {
|
421
|
+
|
422
|
+
// Order matters.
|
423
|
+
// Consider the following database change:
|
424
|
+
//
|
425
|
+
// [transaction removeAllObjects];
|
426
|
+
// [transaction setObject:obj forKey:key];
|
427
|
+
|
428
|
+
if ([changeset_dirtyPages objectForKey:key])
|
429
|
+
[keysToUpdate addObject:key];
|
430
|
+
else if (changeset_reset)
|
431
|
+
[keysToRemove addObject:key];
|
432
|
+
}];
|
433
|
+
|
434
|
+
[pageCache removeObjectsForKeys:keysToRemove];
|
435
|
+
|
436
|
+
NSNull *nsnull = [NSNull null];
|
437
|
+
|
438
|
+
for (NSString *pageKey in keysToUpdate)
|
439
|
+
{
|
440
|
+
YapDatabaseViewPage *page = [changeset_dirtyPages objectForKey:pageKey];
|
441
|
+
|
442
|
+
// Each viewConnection needs its own independent mutable copy of the page.
|
443
|
+
// Mutable pages cannot be shared between multiple view connections.
|
444
|
+
|
445
|
+
if ((id)page == nsnull)
|
446
|
+
[pageCache removeObjectForKey:pageKey];
|
447
|
+
else
|
448
|
+
[pageCache setObject:[page copy] forKey:pageKey];
|
449
|
+
}
|
450
|
+
}
|
451
|
+
}
|
452
|
+
|
453
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
454
|
+
#pragma mark Changeset Inspection
|
455
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
456
|
+
|
457
|
+
/**
|
458
|
+
* Gets an exact list of changes that happend to the view, translating groups to sections as requested.
|
459
|
+
* See the header file for more information.
|
460
|
+
**/
|
461
|
+
- (void)getSectionChanges:(NSArray **)sectionChangesPtr
|
462
|
+
rowChanges:(NSArray **)rowChangesPtr
|
463
|
+
forNotifications:(NSArray *)notifications
|
464
|
+
withMappings:(YapDatabaseViewMappings *)mappings
|
465
|
+
{
|
466
|
+
if (mappings == nil)
|
467
|
+
{
|
468
|
+
YDBLogWarn(@"%@ - mappings parameter is nil", THIS_METHOD);
|
469
|
+
|
470
|
+
if (sectionChangesPtr) *sectionChangesPtr = nil;
|
471
|
+
if (rowChangesPtr) *rowChangesPtr = nil;
|
472
|
+
|
473
|
+
return;
|
474
|
+
}
|
475
|
+
if (mappings.snapshotOfLastUpdate == UINT64_MAX)
|
476
|
+
{
|
477
|
+
NSString *reason = [NSString stringWithFormat:
|
478
|
+
@"ViewConnection[%p, RegisteredName=%@] was asked for changes, but given bad mappings.",
|
479
|
+
self, view.registeredName];
|
480
|
+
|
481
|
+
NSDictionary *userInfo = @{ NSLocalizedRecoverySuggestionErrorKey:
|
482
|
+
@"The given mappings have not been properly initialized."
|
483
|
+
@" You need to invoke [mappings updateWithTransaction:transaction] once in order to initialize"
|
484
|
+
@" the mappings object. You should do this after invoking"
|
485
|
+
@" [databaseConnection beginLongLivedReadTransaction]. For example code, please see"
|
486
|
+
@" YapDatabaseViewMappings.h, or see the wiki: https://github.com/yaptv/YapDatabase/wiki/Views"};
|
487
|
+
|
488
|
+
@throw [NSException exceptionWithName:@"YapDatabaseException" reason:reason userInfo:userInfo];
|
489
|
+
}
|
490
|
+
|
491
|
+
NSString *registeredName = self.view.registeredName;
|
492
|
+
NSMutableArray *all_changes = [NSMutableArray array];
|
493
|
+
|
494
|
+
for (NSNotification *notification in notifications)
|
495
|
+
{
|
496
|
+
NSDictionary *changeset =
|
497
|
+
[[notification.userInfo objectForKey:YapDatabaseExtensionsKey] objectForKey:registeredName];
|
498
|
+
|
499
|
+
NSArray *changeset_changes = [changeset objectForKey:key_changes];
|
500
|
+
|
501
|
+
[all_changes addObjectsFromArray:changeset_changes];
|
502
|
+
}
|
503
|
+
|
504
|
+
YapDatabaseViewMappings *originalMappings = [mappings copy];
|
505
|
+
__block BOOL isLongLivedReadTransaction = NO;
|
506
|
+
|
507
|
+
[databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
508
|
+
|
509
|
+
isLongLivedReadTransaction = transaction.connection.isInLongLivedReadTransaction;
|
510
|
+
[mappings updateWithTransaction:transaction];
|
511
|
+
}];
|
512
|
+
|
513
|
+
if ([notifications count] > 0)
|
514
|
+
{
|
515
|
+
NSDictionary *firstChangeset = [[notifications objectAtIndex:0] userInfo];
|
516
|
+
NSDictionary *lastChangeset = [[notifications lastObject] userInfo];
|
517
|
+
|
518
|
+
uint64_t firstSnapshot = [[firstChangeset objectForKey:YapDatabaseSnapshotKey] unsignedLongLongValue];
|
519
|
+
uint64_t lastSnapshot = [[lastChangeset objectForKey:YapDatabaseSnapshotKey] unsignedLongLongValue];
|
520
|
+
|
521
|
+
if ((originalMappings.snapshotOfLastUpdate != (firstSnapshot - 1)) ||
|
522
|
+
(mappings.snapshotOfLastUpdate != lastSnapshot))
|
523
|
+
{
|
524
|
+
NSString *reason = [NSString stringWithFormat:
|
525
|
+
@"ViewConnection[%p, RegisteredName=%@] was asked for changes,"
|
526
|
+
@" but given mismatched mappings & notifications.", self, view.registeredName];
|
527
|
+
|
528
|
+
NSString *failureReason = [NSString stringWithFormat:
|
529
|
+
@"preMappings.snapshotOfLastUpdate: expected(%llu) != found(%llu), "
|
530
|
+
@"postMappings.snapshotOfLastUpdate: expected(%llu) != found(%llu), "
|
531
|
+
@"isLongLivedReadTransaction = %@",
|
532
|
+
originalMappings.snapshotOfLastUpdate, (firstSnapshot - 1),
|
533
|
+
mappings.snapshotOfLastUpdate, lastSnapshot,
|
534
|
+
(isLongLivedReadTransaction ? @"YES" : @"NO")];
|
535
|
+
|
536
|
+
NSString *suggestion = [NSString stringWithFormat:
|
537
|
+
@"When you initialize the database, the snapshot (uint64) is set to zero."
|
538
|
+
@" Every read-write transaction (that makes modifications) increments the snapshot."
|
539
|
+
@" Now, when you ask the viewConnection for a changeset, "
|
540
|
+
@" you need to pass matching mappings & notifications. That is, the mappings need to represent the"
|
541
|
+
@" database at snapshot X, and the notifications need to represent the database at snapshots"
|
542
|
+
@" @[ X+1, X+2, ...]. This does not appear to be the case. This most often happens when the"
|
543
|
+
@" databaseConnection isn't using a longLivedReadTransaction. And this happens by accident"
|
544
|
+
@" most often when you use a databaseConnection, which is in a longLivedReadTransaction, to perform"
|
545
|
+
@" a read-write transaction. Doing so implicitly forces the connection out of the"
|
546
|
+
@" longLivedReadTransaction, and moves it to the most recent snapshot. If this is the case,"
|
547
|
+
@" be sure to use a separate connection for your read-write transaction."];
|
548
|
+
|
549
|
+
NSDictionary *userInfo = @{
|
550
|
+
NSLocalizedFailureReasonErrorKey: failureReason,
|
551
|
+
NSLocalizedRecoverySuggestionErrorKey: suggestion };
|
552
|
+
|
553
|
+
// If we don't throw the exception here,
|
554
|
+
// then you'll just get an exception later from the tableView or collectionView.
|
555
|
+
// It will look something like this:
|
556
|
+
//
|
557
|
+
// > Invalid update: invalid number of rows in section X. The number of rows contained in an
|
558
|
+
// > existing section after the update (Y) must be equal to the number of rows contained in that section
|
559
|
+
// > before the update (Z), plus or minus the number of rows inserted or deleted from that
|
560
|
+
// > section (# inserted, # deleted).
|
561
|
+
//
|
562
|
+
// In order to guarantee you DON'T get an exception (either from YapDatabase or from Apple),
|
563
|
+
// then you need to follow the instructions for setting up your connection, mappings, & notifications.
|
564
|
+
//
|
565
|
+
// For complete code samples, check out the wiki:
|
566
|
+
// https://github.com/yaptv/YapDatabase/wiki/Views
|
567
|
+
//
|
568
|
+
// You may be tempted to simply comment out the exception below.
|
569
|
+
// If you do, you're not fixing the root cause of your problem.
|
570
|
+
// Furthermore, you're simply trading this exception, which comes with documented steps on how
|
571
|
+
// to fix the problem, for an exception from Apple which will be even harder to diagnose.
|
572
|
+
|
573
|
+
@throw [NSException exceptionWithName:@"YapDatabaseException" reason:reason userInfo:userInfo];
|
574
|
+
}
|
575
|
+
|
576
|
+
if (!isLongLivedReadTransaction)
|
577
|
+
{
|
578
|
+
YDBLogWarn(@"%@ - The databaseConnection is NOT in a longLivedReadTransaction."
|
579
|
+
@" It needs to be in order to guarantee"
|
580
|
+
@" (A) you can provide a stable data-source for your UI thread and"
|
581
|
+
@" (B) you can get changesets which match the movement from one"
|
582
|
+
@" stable data-source state to another. If you think your databaseConnection IS"
|
583
|
+
@" in a longLivedReadTransaction, then perhaps you aborted it by accident."
|
584
|
+
@" This generally happens when you use a databaseConnection,"
|
585
|
+
@" which is in a longLivedReadTransaction, to perform a read-write transaction."
|
586
|
+
@" Doing so implicitly forces the connection out of the longLivedReadTransaction,"
|
587
|
+
@" and moves it to the most recent snapshot. If this is the case,"
|
588
|
+
@" be sure to use a separate connection for your read-write transaction.", THIS_METHOD);
|
589
|
+
}
|
590
|
+
}
|
591
|
+
|
592
|
+
[YapDatabaseViewChange getSectionChanges:sectionChangesPtr
|
593
|
+
rowChanges:rowChangesPtr
|
594
|
+
withOriginalMappings:originalMappings
|
595
|
+
finalMappings:mappings
|
596
|
+
fromChanges:all_changes];
|
597
|
+
}
|
598
|
+
|
599
|
+
/**
|
600
|
+
* A simple YES/NO query to see if the view changed at all, inclusive of all groups.
|
601
|
+
**/
|
602
|
+
- (BOOL)hasChangesForNotifications:(NSArray *)notifications
|
603
|
+
{
|
604
|
+
NSString *registeredName = self.view.registeredName;
|
605
|
+
|
606
|
+
for (NSNotification *notification in notifications)
|
607
|
+
{
|
608
|
+
NSDictionary *changeset =
|
609
|
+
[[notification.userInfo objectForKey:YapDatabaseExtensionsKey] objectForKey:registeredName];
|
610
|
+
|
611
|
+
NSArray *changeset_changes = [changeset objectForKey:key_changes];
|
612
|
+
|
613
|
+
if ([changeset_changes count] > 0)
|
614
|
+
{
|
615
|
+
return YES;
|
616
|
+
}
|
617
|
+
}
|
618
|
+
|
619
|
+
return NO;
|
620
|
+
}
|
621
|
+
|
622
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
623
|
+
#pragma mark Statements - KeyTable
|
624
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
625
|
+
|
626
|
+
- (sqlite3_stmt *)mapTable_getPageKeyForRowidStatement
|
627
|
+
{
|
628
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
629
|
+
|
630
|
+
if (mapTable_getPageKeyForRowidStatement == NULL)
|
631
|
+
{
|
632
|
+
NSString *string = [NSString stringWithFormat:
|
633
|
+
@"SELECT \"pageKey\" FROM \"%@\" WHERE \"rowid\" = ?;", [view mapTableName]];
|
634
|
+
|
635
|
+
sqlite3 *db = databaseConnection->db;
|
636
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
637
|
+
|
638
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &mapTable_getPageKeyForRowidStatement, NULL);
|
639
|
+
if (status != SQLITE_OK)
|
640
|
+
{
|
641
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
642
|
+
}
|
643
|
+
|
644
|
+
FreeYapDatabaseString(&stmt);
|
645
|
+
}
|
646
|
+
|
647
|
+
return mapTable_getPageKeyForRowidStatement;
|
648
|
+
}
|
649
|
+
|
650
|
+
- (sqlite3_stmt *)mapTable_setPageKeyForRowidStatement
|
651
|
+
{
|
652
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
653
|
+
|
654
|
+
if (mapTable_setPageKeyForRowidStatement == NULL)
|
655
|
+
{
|
656
|
+
NSString *string = [NSString stringWithFormat:
|
657
|
+
@"INSERT OR REPLACE INTO \"%@\" (\"rowid\", \"pageKey\") VALUES (?, ?);", [view mapTableName]];
|
658
|
+
|
659
|
+
sqlite3 *db = databaseConnection->db;
|
660
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
661
|
+
|
662
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &mapTable_setPageKeyForRowidStatement, NULL);
|
663
|
+
if (status != SQLITE_OK)
|
664
|
+
{
|
665
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
666
|
+
}
|
667
|
+
|
668
|
+
FreeYapDatabaseString(&stmt);
|
669
|
+
}
|
670
|
+
|
671
|
+
return mapTable_setPageKeyForRowidStatement;
|
672
|
+
}
|
673
|
+
|
674
|
+
- (sqlite3_stmt *)mapTable_removeForRowidStatement
|
675
|
+
{
|
676
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
677
|
+
|
678
|
+
if (mapTable_removeForRowidStatement == NULL)
|
679
|
+
{
|
680
|
+
NSString *string = [NSString stringWithFormat:
|
681
|
+
@"DELETE FROM \"%@\" WHERE \"rowid\" = ?;", [view mapTableName]];
|
682
|
+
|
683
|
+
sqlite3 *db = databaseConnection->db;
|
684
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
685
|
+
|
686
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &mapTable_removeForRowidStatement, NULL);
|
687
|
+
if (status != SQLITE_OK)
|
688
|
+
{
|
689
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
690
|
+
}
|
691
|
+
|
692
|
+
FreeYapDatabaseString(&stmt);
|
693
|
+
}
|
694
|
+
|
695
|
+
return mapTable_removeForRowidStatement;
|
696
|
+
}
|
697
|
+
|
698
|
+
- (sqlite3_stmt *)mapTable_removeAllStatement
|
699
|
+
{
|
700
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
701
|
+
|
702
|
+
if (mapTable_removeAllStatement == NULL)
|
703
|
+
{
|
704
|
+
NSString *string = [NSString stringWithFormat:
|
705
|
+
@"DELETE FROM \"%@\";", [view mapTableName]];
|
706
|
+
|
707
|
+
sqlite3 *db = databaseConnection->db;
|
708
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
709
|
+
|
710
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &mapTable_removeAllStatement, NULL);
|
711
|
+
if (status != SQLITE_OK)
|
712
|
+
{
|
713
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
714
|
+
}
|
715
|
+
|
716
|
+
FreeYapDatabaseString(&stmt);
|
717
|
+
}
|
718
|
+
|
719
|
+
return mapTable_removeAllStatement;
|
720
|
+
}
|
721
|
+
|
722
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
723
|
+
#pragma mark Statements - PageTable
|
724
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
725
|
+
|
726
|
+
- (sqlite3_stmt *)pageTable_getDataForPageKeyStatement
|
727
|
+
{
|
728
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
729
|
+
|
730
|
+
if (pageTable_getDataForPageKeyStatement == NULL)
|
731
|
+
{
|
732
|
+
NSString *string = [NSString stringWithFormat:
|
733
|
+
@"SELECT \"data\" FROM \"%@\" WHERE \"pageKey\" = ?;", [view pageTableName]];
|
734
|
+
|
735
|
+
sqlite3 *db = databaseConnection->db;
|
736
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
737
|
+
|
738
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_getDataForPageKeyStatement, NULL);
|
739
|
+
if (status != SQLITE_OK)
|
740
|
+
{
|
741
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
742
|
+
}
|
743
|
+
|
744
|
+
FreeYapDatabaseString(&stmt);
|
745
|
+
}
|
746
|
+
|
747
|
+
return pageTable_getDataForPageKeyStatement;
|
748
|
+
}
|
749
|
+
|
750
|
+
- (sqlite3_stmt *)pageTable_insertForPageKeyStatement
|
751
|
+
{
|
752
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
753
|
+
|
754
|
+
if (pageTable_insertForPageKeyStatement == NULL)
|
755
|
+
{
|
756
|
+
NSString *string = [NSString stringWithFormat:
|
757
|
+
@"INSERT INTO \"%@\""
|
758
|
+
@" (\"pageKey\", \"group\", \"prevPageKey\", \"count\", \"data\") VALUES (?, ?, ?, ?, ?);",
|
759
|
+
[view pageTableName]];
|
760
|
+
|
761
|
+
sqlite3 *db = databaseConnection->db;
|
762
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
763
|
+
|
764
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_insertForPageKeyStatement, NULL);
|
765
|
+
if (status != SQLITE_OK)
|
766
|
+
{
|
767
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
768
|
+
}
|
769
|
+
|
770
|
+
FreeYapDatabaseString(&stmt);
|
771
|
+
}
|
772
|
+
|
773
|
+
return pageTable_insertForPageKeyStatement;
|
774
|
+
}
|
775
|
+
|
776
|
+
- (sqlite3_stmt *)pageTable_updateAllForPageKeyStatement
|
777
|
+
{
|
778
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
779
|
+
|
780
|
+
if (pageTable_updateAllForPageKeyStatement == NULL)
|
781
|
+
{
|
782
|
+
NSString *string = [NSString stringWithFormat:
|
783
|
+
@"UPDATE \"%@\" SET \"prevPageKey\" = ?, \"count\" = ?, \"data\" = ? WHERE \"pageKey\" = ?;",
|
784
|
+
[view pageTableName]];
|
785
|
+
|
786
|
+
sqlite3 *db = databaseConnection->db;
|
787
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
788
|
+
|
789
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_updateAllForPageKeyStatement, NULL);
|
790
|
+
if (status != SQLITE_OK)
|
791
|
+
{
|
792
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
793
|
+
}
|
794
|
+
|
795
|
+
FreeYapDatabaseString(&stmt);
|
796
|
+
}
|
797
|
+
|
798
|
+
return pageTable_updateAllForPageKeyStatement;
|
799
|
+
}
|
800
|
+
|
801
|
+
- (sqlite3_stmt *)pageTable_updatePageForPageKeyStatement
|
802
|
+
{
|
803
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
804
|
+
|
805
|
+
if (pageTable_updatePageForPageKeyStatement == NULL)
|
806
|
+
{
|
807
|
+
NSString *string = [NSString stringWithFormat:
|
808
|
+
@"UPDATE \"%@\" SET \"count\" = ?, \"data\" = ? WHERE \"pageKey\" = ?;", [view pageTableName]];
|
809
|
+
|
810
|
+
sqlite3 *db = databaseConnection->db;
|
811
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
812
|
+
|
813
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_updatePageForPageKeyStatement, NULL);
|
814
|
+
if (status != SQLITE_OK)
|
815
|
+
{
|
816
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
817
|
+
}
|
818
|
+
|
819
|
+
FreeYapDatabaseString(&stmt);
|
820
|
+
}
|
821
|
+
|
822
|
+
return pageTable_updatePageForPageKeyStatement;
|
823
|
+
}
|
824
|
+
|
825
|
+
- (sqlite3_stmt *)pageTable_updateLinkForPageKeyStatement
|
826
|
+
{
|
827
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
828
|
+
|
829
|
+
if (pageTable_updateLinkForPageKeyStatement == NULL)
|
830
|
+
{
|
831
|
+
NSString *string = [NSString stringWithFormat:
|
832
|
+
@"UPDATE \"%@\" SET \"prevPageKey\" = ? WHERE \"pageKey\" = ?;", [view pageTableName]];
|
833
|
+
|
834
|
+
sqlite3 *db = databaseConnection->db;
|
835
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
836
|
+
|
837
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_updateLinkForPageKeyStatement, NULL);
|
838
|
+
if (status != SQLITE_OK)
|
839
|
+
{
|
840
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
841
|
+
}
|
842
|
+
|
843
|
+
FreeYapDatabaseString(&stmt);
|
844
|
+
}
|
845
|
+
|
846
|
+
return pageTable_updateLinkForPageKeyStatement;
|
847
|
+
}
|
848
|
+
|
849
|
+
- (sqlite3_stmt *)pageTable_removeForPageKeyStatement
|
850
|
+
{
|
851
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
852
|
+
|
853
|
+
if (pageTable_removeForPageKeyStatement == NULL)
|
854
|
+
{
|
855
|
+
NSString *string = [NSString stringWithFormat:
|
856
|
+
@"DELETE FROM \"%@\" WHERE \"pageKey\" = ?;", [view pageTableName]];
|
857
|
+
|
858
|
+
sqlite3 *db = databaseConnection->db;
|
859
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
860
|
+
|
861
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_removeForPageKeyStatement, NULL);
|
862
|
+
if (status != SQLITE_OK)
|
863
|
+
{
|
864
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
865
|
+
}
|
866
|
+
|
867
|
+
FreeYapDatabaseString(&stmt);
|
868
|
+
}
|
869
|
+
|
870
|
+
return pageTable_removeForPageKeyStatement;
|
871
|
+
}
|
872
|
+
|
873
|
+
- (sqlite3_stmt *)pageTable_removeAllStatement
|
874
|
+
{
|
875
|
+
NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
|
876
|
+
|
877
|
+
if (pageTable_removeAllStatement == NULL)
|
878
|
+
{
|
879
|
+
NSString *string = [NSString stringWithFormat:
|
880
|
+
@"DELETE FROM \"%@\";", [view pageTableName]];
|
881
|
+
|
882
|
+
sqlite3 *db = databaseConnection->db;
|
883
|
+
YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
|
884
|
+
|
885
|
+
int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_removeAllStatement, NULL);
|
886
|
+
if (status != SQLITE_OK)
|
887
|
+
{
|
888
|
+
YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
|
889
|
+
}
|
890
|
+
|
891
|
+
FreeYapDatabaseString(&stmt);
|
892
|
+
}
|
893
|
+
|
894
|
+
return pageTable_removeAllStatement;
|
895
|
+
}
|
896
|
+
|
897
|
+
@end
|