motion-yapper 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/.travis.yml +2 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/motion-yapper.rb +1 -0
- data/lib/yapper.rb +3 -5
- data/lib/yapper/config.rb +2 -0
- data/lib/yapper/db.rb +105 -40
- data/lib/yapper/document.rb +7 -4
- data/lib/yapper/document/callbacks.rb +0 -7
- data/lib/yapper/document/{persistance.rb → persistence.rb} +27 -21
- data/lib/yapper/document/relation.rb +29 -22
- data/lib/yapper/document/selection.rb +122 -54
- data/lib/yapper/extensions.rb +12 -24
- data/lib/yapper/settings.rb +43 -0
- data/lib/yapper/timestamps.rb +2 -0
- data/lib/yapper/version.rb +1 -1
- data/{yapper.gemspec → motion-yapper.gemspec} +0 -0
- data/spec/integration/{where_spec.rb → criteria_spec.rb} +78 -10
- data/spec/integration/db_spec.rb +70 -0
- data/spec/integration/defaults_spec.rb +37 -0
- data/spec/integration/extensions_spec.rb +14 -0
- data/spec/integration/{persistance_spec.rb → persistence_spec.rb} +0 -0
- data/spec/integration/relation_spec.rb +4 -4
- data/vendor/Podfile.lock +9 -11
- data/vendor/Pods/.build/libPods-CocoaLumberjack.a +0 -0
- data/vendor/Pods/.build/libPods-NSData+MD5Digest.a +0 -0
- data/vendor/Pods/.build/libPods-YapDatabase.a +0 -0
- data/vendor/Pods/.build/libPods.a +0 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +4 -4
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
- data/vendor/Pods/{CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h → BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h} +6 -8
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +67 -32
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +99 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +98 -65
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +30 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +39 -25
- data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +8 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +1 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +3 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +4 -4
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +21 -19
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +1 -1
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +35 -31
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +8 -35
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -2
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +8 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +43 -21
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +35 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +79 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +125 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +10 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +131 -21
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +48 -107
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +2 -2
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +1 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +10 -3
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +18 -1
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +75 -24
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +4 -4
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +51 -50
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +14 -14
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +546 -546
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +67 -32
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1093 -907
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +98 -65
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +873 -748
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +39 -25
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1284 -1243
- data/vendor/Pods/{BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h → CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h} +6 -8
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{ContextFilterLogFormatter.m → DDContextFilterLogFormatter.m} +70 -70
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +253 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +30 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +127 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +1 -1
- data/vendor/Pods/CocoaLumberjack/README.markdown +52 -15
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +4 -4
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
- data/vendor/Pods/Headers/CocoaLumberjack/{ContextFilterLogFormatter.h → DDContextFilterLogFormatter.h} +6 -8
- data/vendor/Pods/Headers/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +67 -32
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +99 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +98 -65
- data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +30 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +39 -25
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +3 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +4 -4
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +21 -19
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +8 -35
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +35 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +131 -21
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +48 -107
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +2 -2
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +1 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +10 -3
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +75 -24
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +99 -0
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +2 -0
- data/vendor/Pods/Headers/____Pods-environment.h +15 -15
- data/vendor/Pods/Manifest.lock +9 -11
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +1 -1
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +2 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +1 -1
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +1 -1
- data/vendor/Pods/{Pods-Acknowledgements.markdown → Pods-acknowledgements.markdown} +0 -37
- data/vendor/Pods/{Pods-Acknowledgements.plist → Pods-acknowledgements.plist} +0 -45
- data/vendor/Pods/Pods-environment.h +15 -15
- data/vendor/Pods/Pods.xcconfig +3 -3
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +2426 -3155
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
- data/vendor/Pods/YapDatabase/README.md +3 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -2
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +8 -35
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +25 -41
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +17 -17
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +403 -134
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +32 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +8 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +8 -8
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +113 -62
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +35 -31
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +25 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +1 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +25 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +79 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +125 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +35 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +129 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +802 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +163 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +408 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +99 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +59 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +384 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +5254 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +10 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +49 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +9 -8
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +62 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +148 -45
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +18 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +2 -2
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +15 -9
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +211 -64
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +48 -107
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +10 -7
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +1 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +13 -22
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +10 -3
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +75 -24
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +725 -244
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +99 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +8 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +19 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +1 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +1 -1
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +3 -3
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +43 -21
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +4 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +3 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +5 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +4 -4
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +84 -93
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +21 -19
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +381 -209
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +131 -21
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +587 -267
- data/vendor/Pods/{Pods.bridgesupport → build-iPhoneSimulator/Pods.bridgesupport} +633 -2557
- data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +2 -1
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +2 -1
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +4 -2
- metadata +80 -108
- data/Gemfile.lock +0 -63
- data/lib/yapper/attachment.rb +0 -48
- data/lib/yapper/document/attachment.rb +0 -26
- data/lib/yapper/sync.rb +0 -134
- data/lib/yapper/sync/data.rb +0 -12
- data/lib/yapper/sync/event.rb +0 -194
- data/lib/yapper/sync/queue.rb +0 -164
- data/spec/integration/all_spec.rb +0 -40
- data/spec/integration/sync_spec.rb +0 -42
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +0 -641
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +0 -1396
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +0 -133
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +0 -327
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +0 -113
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +0 -321
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +0 -71
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +0 -150
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +0 -157
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +0 -43
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +0 -68
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +0 -143
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +0 -370
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +0 -848
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +0 -89
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +0 -167
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +0 -78
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +0 -191
- data/vendor/Pods/AFNetworking/LICENSE +0 -19
- data/vendor/Pods/AFNetworking/README.md +0 -208
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +0 -641
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +0 -133
- data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +0 -113
- data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +0 -71
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +0 -43
- data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +0 -68
- data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +0 -370
- data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +0 -89
- data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +0 -78
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +0 -109
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +0 -251
- data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +0 -641
- data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +0 -133
- data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +0 -113
- data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +0 -71
- data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
- data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +0 -43
- data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +0 -68
- data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +0 -370
- data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +0 -89
- data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +0 -78
- data/vendor/Pods/Headers/Reachability/Reachability.h +0 -109
- data/vendor/Pods/Headers/YapDatabase/YapCache.h +0 -90
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +0 -29
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +0 -37
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +0 -440
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -19
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -69
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +0 -158
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +0 -17
- data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +0 -424
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -73
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +0 -13
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +0 -121
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +0 -36
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +0 -153
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
- data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +0 -74
- data/vendor/Pods/Headers/YapDatabase/YapNull.h +0 -17
- data/vendor/Pods/Headers/YapDatabase/YapTouch.h +0 -15
- data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +0 -17
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +0 -5
- data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +0 -5
- data/vendor/Pods/Pods-AFNetworking-dummy.m +0 -5
- data/vendor/Pods/Pods-AFNetworking-prefix.pch +0 -17
- data/vendor/Pods/Pods-AFNetworking.xcconfig +0 -1
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +0 -5
- data/vendor/Pods/Pods-Reachability-dummy.m +0 -5
- data/vendor/Pods/Pods-Reachability-prefix.pch +0 -5
- data/vendor/Pods/Pods-Reachability.xcconfig +0 -1
- data/vendor/Pods/Reachability/LICENCE.txt +0 -24
- data/vendor/Pods/Reachability/README.md +0 -65
- data/vendor/Pods/Reachability/Reachability.h +0 -109
- data/vendor/Pods/Reachability/Reachability.m +0 -527
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
|
|
26
26
|
#endif
|
|
27
27
|
|
|
28
|
+
#define ExtKey_classVersion @"classVersion"
|
|
29
|
+
#define ExtKey_persistent @"persistent"
|
|
30
|
+
#define ExtKey_version_deprecated @"version"
|
|
31
|
+
#define ExtKey_versionTag @"versionTag"
|
|
28
32
|
|
|
29
33
|
/**
|
|
30
34
|
* The view is tasked with storing ordered arrays of keys.
|
|
@@ -35,6 +39,13 @@
|
|
|
35
39
|
**/
|
|
36
40
|
#define YAP_DATABASE_VIEW_MAX_PAGE_SIZE 50
|
|
37
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Declare that this class implements YapDatabaseExtensionTransaction_Hooks protocol.
|
|
44
|
+
* This is done privately, as the protocol is internal.
|
|
45
|
+
**/
|
|
46
|
+
@interface YapDatabaseViewTransaction () <YapDatabaseExtensionTransaction_Hooks>
|
|
47
|
+
@end
|
|
48
|
+
|
|
38
49
|
/**
|
|
39
50
|
* ARCHITECTURE OVERVIEW:
|
|
40
51
|
*
|
|
@@ -75,6 +86,8 @@
|
|
|
75
86
|
- (id)initWithViewConnection:(YapDatabaseViewConnection *)inViewConnection
|
|
76
87
|
databaseTransaction:(YapDatabaseReadTransaction *)inDatabaseTransaction
|
|
77
88
|
{
|
|
89
|
+
YDBLogAutoTrace();
|
|
90
|
+
|
|
78
91
|
if ((self = [super init]))
|
|
79
92
|
{
|
|
80
93
|
viewConnection = inViewConnection;
|
|
@@ -104,31 +117,63 @@
|
|
|
104
117
|
**/
|
|
105
118
|
- (BOOL)createIfNeeded
|
|
106
119
|
{
|
|
120
|
+
YDBLogAutoTrace();
|
|
121
|
+
|
|
122
|
+
int classVersion = YAP_DATABASE_VIEW_CLASS_VERSION;
|
|
123
|
+
BOOL isPersistent = [self isPersistentView];
|
|
124
|
+
|
|
125
|
+
NSString *versionTag = viewConnection->view->versionTag;
|
|
126
|
+
|
|
127
|
+
// Figure out what steps we need to take in order to register the view
|
|
128
|
+
|
|
107
129
|
BOOL needsCreateTables = NO;
|
|
108
130
|
|
|
131
|
+
BOOL oldIsPersistent = NO;
|
|
132
|
+
BOOL hasOldIsPersistent = NO;
|
|
133
|
+
|
|
134
|
+
NSString *oldVersionTag = nil;
|
|
135
|
+
|
|
109
136
|
// Check classVersion (the internal version number of YapDatabaseView implementation)
|
|
110
137
|
|
|
111
|
-
int oldClassVersion =
|
|
112
|
-
|
|
138
|
+
int oldClassVersion = 0;
|
|
139
|
+
BOOL hasOldClassVersion = [self getIntValue:&oldClassVersion forExtensionKey:ExtKey_classVersion];
|
|
113
140
|
|
|
114
|
-
if (
|
|
141
|
+
if (!hasOldClassVersion)
|
|
142
|
+
{
|
|
143
|
+
needsCreateTables = YES;
|
|
144
|
+
}
|
|
145
|
+
else if (oldClassVersion != classVersion)
|
|
146
|
+
{
|
|
147
|
+
[self dropTablesForOldClassVersion:oldClassVersion];
|
|
115
148
|
needsCreateTables = YES;
|
|
149
|
+
}
|
|
116
150
|
|
|
117
151
|
// Check persistence.
|
|
118
152
|
// Need to properly transition from persistent to non-persistent, and vice-versa.
|
|
119
153
|
|
|
120
|
-
|
|
121
|
-
BOOL hasOldIsPersistent = [self getBoolValue:&oldIsPersistent forExtensionKey:@"persistent"];
|
|
122
|
-
|
|
123
|
-
BOOL isPersistent = [self isPersistentView];
|
|
124
|
-
|
|
125
|
-
if (hasOldIsPersistent && (oldIsPersistent != isPersistent))
|
|
154
|
+
if (!needsCreateTables || hasOldClassVersion)
|
|
126
155
|
{
|
|
127
|
-
[
|
|
128
|
-
dropTablesForRegisteredName:[self registeredName]
|
|
129
|
-
withTransaction:(YapDatabaseReadWriteTransaction *)databaseTransaction];
|
|
156
|
+
hasOldIsPersistent = [self getBoolValue:&oldIsPersistent forExtensionKey:ExtKey_persistent];
|
|
130
157
|
|
|
131
|
-
|
|
158
|
+
if (hasOldIsPersistent && oldIsPersistent && !isPersistent)
|
|
159
|
+
{
|
|
160
|
+
[[viewConnection->view class]
|
|
161
|
+
dropTablesForRegisteredName:[self registeredName]
|
|
162
|
+
withTransaction:(YapDatabaseReadWriteTransaction *)databaseTransaction];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!hasOldIsPersistent || (oldIsPersistent != isPersistent))
|
|
166
|
+
{
|
|
167
|
+
needsCreateTables = YES;
|
|
168
|
+
}
|
|
169
|
+
else if (!isPersistent)
|
|
170
|
+
{
|
|
171
|
+
// We always have to create & populate the tables for non-persistent views.
|
|
172
|
+
// Even when re-registering from previous app launch.
|
|
173
|
+
needsCreateTables = YES;
|
|
174
|
+
|
|
175
|
+
oldVersionTag = [self stringValueForExtensionKey:ExtKey_versionTag];
|
|
176
|
+
}
|
|
132
177
|
}
|
|
133
178
|
|
|
134
179
|
// Create or re-populate if needed
|
|
@@ -137,36 +182,54 @@
|
|
|
137
182
|
{
|
|
138
183
|
// First time registration
|
|
139
184
|
|
|
140
|
-
[self dropTablesForOldClassVersion:oldClassVersion];
|
|
141
|
-
|
|
142
185
|
if (![self createTables]) return NO;
|
|
143
186
|
if (![self populateView]) return NO;
|
|
144
187
|
|
|
145
|
-
|
|
188
|
+
if (!hasOldClassVersion || (oldClassVersion != classVersion)) {
|
|
189
|
+
[self setIntValue:classVersion forExtensionKey:ExtKey_classVersion];
|
|
190
|
+
}
|
|
146
191
|
|
|
147
|
-
|
|
192
|
+
if (!hasOldIsPersistent || (oldIsPersistent != isPersistent)) {
|
|
193
|
+
[self setBoolValue:isPersistent forExtensionKey:ExtKey_persistent];
|
|
194
|
+
}
|
|
148
195
|
|
|
149
|
-
|
|
150
|
-
|
|
196
|
+
if (![oldVersionTag isEqualToString:versionTag]) {
|
|
197
|
+
[self setStringValue:versionTag forExtensionKey:ExtKey_versionTag];
|
|
198
|
+
}
|
|
151
199
|
}
|
|
152
200
|
else
|
|
153
201
|
{
|
|
154
202
|
// Check user-supplied config version.
|
|
155
203
|
// We may need to re-populate the database if the groupingBlock or sortingBlock changed.
|
|
156
204
|
|
|
157
|
-
|
|
158
|
-
int newVersion = viewConnection->view->version;
|
|
205
|
+
oldVersionTag = [self stringValueForExtensionKey:ExtKey_versionTag];
|
|
159
206
|
|
|
160
|
-
|
|
207
|
+
BOOL hasOldVersion_deprecated = NO;
|
|
208
|
+
if (oldVersionTag == nil)
|
|
161
209
|
{
|
|
162
|
-
|
|
210
|
+
int oldVersion_deprecated = 0;
|
|
211
|
+
hasOldVersion_deprecated = [self getIntValue:&oldVersion_deprecated
|
|
212
|
+
forExtensionKey:ExtKey_version_deprecated];
|
|
163
213
|
|
|
164
|
-
|
|
214
|
+
if (hasOldVersion_deprecated)
|
|
215
|
+
{
|
|
216
|
+
oldVersionTag = [NSString stringWithFormat:@"%d", oldVersion_deprecated];
|
|
217
|
+
}
|
|
165
218
|
}
|
|
166
219
|
|
|
167
|
-
if (!
|
|
220
|
+
if (![oldVersionTag isEqualToString:versionTag])
|
|
221
|
+
{
|
|
222
|
+
if (![self populateView]) return NO;
|
|
223
|
+
|
|
224
|
+
[self setStringValue:versionTag forExtensionKey:ExtKey_versionTag];
|
|
225
|
+
|
|
226
|
+
if (hasOldVersion_deprecated)
|
|
227
|
+
[self removeValueForExtensionKey:ExtKey_version_deprecated];
|
|
228
|
+
}
|
|
229
|
+
else if (hasOldVersion_deprecated)
|
|
168
230
|
{
|
|
169
|
-
[self
|
|
231
|
+
[self removeValueForExtensionKey:ExtKey_version_deprecated];
|
|
232
|
+
[self setStringValue:versionTag forExtensionKey:ExtKey_versionTag];
|
|
170
233
|
}
|
|
171
234
|
}
|
|
172
235
|
|
|
@@ -184,6 +247,8 @@
|
|
|
184
247
|
**/
|
|
185
248
|
- (BOOL)prepareIfNeeded
|
|
186
249
|
{
|
|
250
|
+
YDBLogAutoTrace();
|
|
251
|
+
|
|
187
252
|
if (viewConnection->group_pagesMetadata_dict && viewConnection->pageKey_group_dict)
|
|
188
253
|
{
|
|
189
254
|
// Already prepared
|
|
@@ -428,6 +493,8 @@
|
|
|
428
493
|
|
|
429
494
|
- (void)dropTablesForOldClassVersion:(int)oldClassVersion
|
|
430
495
|
{
|
|
496
|
+
YDBLogAutoTrace();
|
|
497
|
+
|
|
431
498
|
if (oldClassVersion == 1)
|
|
432
499
|
{
|
|
433
500
|
// In version 2, we switched from 'view_name_key' to 'view_name_map'.
|
|
@@ -473,6 +540,8 @@
|
|
|
473
540
|
|
|
474
541
|
- (BOOL)createTables
|
|
475
542
|
{
|
|
543
|
+
YDBLogAutoTrace();
|
|
544
|
+
|
|
476
545
|
if ([self isPersistentView])
|
|
477
546
|
{
|
|
478
547
|
sqlite3 *db = databaseTransaction->connection->db;
|
|
@@ -556,14 +625,19 @@
|
|
|
556
625
|
|
|
557
626
|
- (BOOL)populateView
|
|
558
627
|
{
|
|
628
|
+
YDBLogAutoTrace();
|
|
629
|
+
|
|
559
630
|
// Remove everything from the database
|
|
560
631
|
|
|
561
632
|
[self removeAllRowids];
|
|
562
633
|
|
|
563
634
|
// Initialize ivars
|
|
564
635
|
|
|
565
|
-
viewConnection->group_pagesMetadata_dict
|
|
566
|
-
|
|
636
|
+
if (viewConnection->group_pagesMetadata_dict == nil)
|
|
637
|
+
viewConnection->group_pagesMetadata_dict = [[NSMutableDictionary alloc] init];
|
|
638
|
+
|
|
639
|
+
if (viewConnection->pageKey_group_dict == nil)
|
|
640
|
+
viewConnection->pageKey_group_dict = [[NSMutableDictionary alloc] init];
|
|
567
641
|
|
|
568
642
|
// Enumerate the existing rows in the database and populate the view
|
|
569
643
|
|
|
@@ -585,37 +659,47 @@
|
|
|
585
659
|
BOOL needsMetadata = groupingNeedsMetadata || sortingNeedsMetadata;
|
|
586
660
|
|
|
587
661
|
NSString *(^getGroup)(NSString *collection, NSString *key, id object, id metadata);
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
{
|
|
662
|
+
|
|
663
|
+
if (view->groupingBlockType == YapDatabaseViewBlockTypeWithKey)
|
|
664
|
+
{
|
|
665
|
+
getGroup = ^(NSString *collection, NSString *key, id object, id metadata){
|
|
666
|
+
|
|
592
667
|
__unsafe_unretained YapDatabaseViewGroupingWithKeyBlock groupingBlock =
|
|
593
668
|
(YapDatabaseViewGroupingWithKeyBlock)view->groupingBlock;
|
|
594
669
|
|
|
595
670
|
return groupingBlock(collection, key);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
else if (view->groupingBlockType == YapDatabaseViewBlockTypeWithObject)
|
|
674
|
+
{
|
|
675
|
+
getGroup = ^(NSString *collection, NSString *key, id object, id metadata){
|
|
676
|
+
|
|
599
677
|
__unsafe_unretained YapDatabaseViewGroupingWithObjectBlock groupingBlock =
|
|
600
678
|
(YapDatabaseViewGroupingWithObjectBlock)view->groupingBlock;
|
|
601
679
|
|
|
602
680
|
return groupingBlock(collection, key, object);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
else if (view->groupingBlockType == YapDatabaseViewBlockTypeWithMetadata)
|
|
684
|
+
{
|
|
685
|
+
getGroup = ^(NSString *collection, NSString *key, id object, id metadata){
|
|
686
|
+
|
|
606
687
|
__unsafe_unretained YapDatabaseViewGroupingWithMetadataBlock groupingBlock =
|
|
607
688
|
(YapDatabaseViewGroupingWithMetadataBlock)view->groupingBlock;
|
|
608
689
|
|
|
609
690
|
return groupingBlock(collection, key, metadata);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
else
|
|
694
|
+
{
|
|
695
|
+
getGroup = ^(NSString *collection, NSString *key, id object, id metadata){
|
|
696
|
+
|
|
613
697
|
__unsafe_unretained YapDatabaseViewGroupingWithRowBlock groupingBlock =
|
|
614
698
|
(YapDatabaseViewGroupingWithRowBlock)view->groupingBlock;
|
|
615
699
|
|
|
616
700
|
return groupingBlock(collection, key, object, metadata);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
701
|
+
};
|
|
702
|
+
}
|
|
619
703
|
|
|
620
704
|
int flags = (YapDatabaseViewChangedObject | YapDatabaseViewChangedMetadata);
|
|
621
705
|
|
|
@@ -861,6 +945,55 @@
|
|
|
861
945
|
return YES;
|
|
862
946
|
}
|
|
863
947
|
|
|
948
|
+
- (void)repopulateView
|
|
949
|
+
{
|
|
950
|
+
YDBLogAutoTrace();
|
|
951
|
+
|
|
952
|
+
// Code overview:
|
|
953
|
+
//
|
|
954
|
+
// We could simply run the usual algorithm.
|
|
955
|
+
// That is, enumerate over every item in the database, and run pretty much the same code as
|
|
956
|
+
// in the handleUpdateObject:forCollectionKey:withMetadata:rowid:.
|
|
957
|
+
// However, this causes a potential issue where the sortingBlock will be invoked with items that
|
|
958
|
+
// no longer exist in the given group.
|
|
959
|
+
//
|
|
960
|
+
// Instead we're going to find a way around this.
|
|
961
|
+
// That way the sortingBlock works in a manner we're used to.
|
|
962
|
+
//
|
|
963
|
+
// Here's the algorithm overview:
|
|
964
|
+
//
|
|
965
|
+
// - Insert remove ops for every row & group
|
|
966
|
+
// - Remove all items from the database tables
|
|
967
|
+
// - Flush the group_pagesMetadata_dict (and related ivars)
|
|
968
|
+
// - Set the reset flag (for internal notification creation)
|
|
969
|
+
// - And then run the normal populate routine, with one exceptione handled by the isRepopulate flag.
|
|
970
|
+
//
|
|
971
|
+
// The changeset mechanism will automatically consolidate all changes to the minimum.
|
|
972
|
+
|
|
973
|
+
for (NSString *group in viewConnection->group_pagesMetadata_dict)
|
|
974
|
+
{
|
|
975
|
+
// We must add the changes in reverse order.
|
|
976
|
+
// Either that, or the change index of each item would have to be zero,
|
|
977
|
+
// because a YapDatabaseViewRowChange records the index at the moment the change happens.
|
|
978
|
+
|
|
979
|
+
[self enumerateRowidsInGroup:group
|
|
980
|
+
withOptions:NSEnumerationReverse
|
|
981
|
+
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
982
|
+
{
|
|
983
|
+
YapCollectionKey *collectionKey = [databaseTransaction collectionKeyForRowid:rowid];
|
|
984
|
+
|
|
985
|
+
[viewConnection->changes addObject:
|
|
986
|
+
[YapDatabaseViewRowChange deleteKey:collectionKey inGroup:group atIndex:index]];
|
|
987
|
+
}];
|
|
988
|
+
|
|
989
|
+
[viewConnection->changes addObject:[YapDatabaseViewSectionChange deleteGroup:group]];
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
isRepopulate = YES;
|
|
993
|
+
[self populateView];
|
|
994
|
+
isRepopulate = NO;
|
|
995
|
+
}
|
|
996
|
+
|
|
864
997
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
865
998
|
#pragma mark Accessors
|
|
866
999
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
@@ -1229,7 +1362,7 @@
|
|
|
1229
1362
|
// Calculate the offset of the corresponding page within the group.
|
|
1230
1363
|
|
|
1231
1364
|
NSUInteger pageOffset = 0;
|
|
1232
|
-
|
|
1365
|
+
NSArray *pagesMetadataForGroup = [viewConnection->group_pagesMetadata_dict objectForKey:group];
|
|
1233
1366
|
|
|
1234
1367
|
for (YapDatabaseViewPageMetadata *pageMetadata in pagesMetadataForGroup)
|
|
1235
1368
|
{
|
|
@@ -1259,7 +1392,7 @@
|
|
|
1259
1392
|
|
|
1260
1393
|
- (BOOL)getRowid:(int64_t *)rowidPtr atIndex:(NSUInteger)index inGroup:(NSString *)group
|
|
1261
1394
|
{
|
|
1262
|
-
|
|
1395
|
+
NSArray *pagesMetadataForGroup = [viewConnection->group_pagesMetadata_dict objectForKey:group];
|
|
1263
1396
|
NSUInteger pageOffset = 0;
|
|
1264
1397
|
|
|
1265
1398
|
for (YapDatabaseViewPageMetadata *pageMetadata in pagesMetadataForGroup)
|
|
@@ -1293,7 +1426,7 @@
|
|
|
1293
1426
|
// else
|
|
1294
1427
|
// return nil;
|
|
1295
1428
|
|
|
1296
|
-
|
|
1429
|
+
NSArray *pagesMetadataForGroup = [viewConnection->group_pagesMetadata_dict objectForKey:group];
|
|
1297
1430
|
|
|
1298
1431
|
__block int64_t rowid = 0;
|
|
1299
1432
|
__block BOOL found = NO;
|
|
@@ -1375,7 +1508,7 @@
|
|
|
1375
1508
|
// Add change to log
|
|
1376
1509
|
|
|
1377
1510
|
[viewConnection->changes addObject:
|
|
1378
|
-
|
|
1511
|
+
[YapDatabaseViewSectionChange insertGroup:group]];
|
|
1379
1512
|
|
|
1380
1513
|
[viewConnection->changes addObject:
|
|
1381
1514
|
[YapDatabaseViewRowChange insertKey:collectionKey inGroup:group atIndex:0]];
|
|
@@ -1627,62 +1760,54 @@
|
|
|
1627
1760
|
__unsafe_unretained YapDatabaseViewSortingWithKeyBlock sortingBlock =
|
|
1628
1761
|
(YapDatabaseViewSortingWithKeyBlock)view->sortingBlock;
|
|
1629
1762
|
|
|
1630
|
-
|
|
1631
|
-
NSString *anotherCollection = nil;
|
|
1632
|
-
[databaseTransaction getKey:&anotherKey collection:&anotherCollection forRowid:anotherRowid];
|
|
1763
|
+
YapCollectionKey *another = [databaseTransaction collectionKeyForRowid:anotherRowid];
|
|
1633
1764
|
|
|
1634
1765
|
return sortingBlock(group, collectionKey.collection, collectionKey.key,
|
|
1635
|
-
|
|
1766
|
+
another.collection, another.key);
|
|
1636
1767
|
}
|
|
1637
1768
|
else if (view->sortingBlockType == YapDatabaseViewBlockTypeWithObject)
|
|
1638
1769
|
{
|
|
1639
1770
|
__unsafe_unretained YapDatabaseViewSortingWithObjectBlock sortingBlock =
|
|
1640
1771
|
(YapDatabaseViewSortingWithObjectBlock)view->sortingBlock;
|
|
1641
1772
|
|
|
1642
|
-
|
|
1643
|
-
NSString *anotherCollection = nil;
|
|
1773
|
+
YapCollectionKey *another = nil;
|
|
1644
1774
|
id anotherObject = nil;
|
|
1645
|
-
[databaseTransaction
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
forRowid:anotherRowid];
|
|
1775
|
+
[databaseTransaction getCollectionKey:&another
|
|
1776
|
+
object:&anotherObject
|
|
1777
|
+
forRowid:anotherRowid];
|
|
1649
1778
|
|
|
1650
1779
|
return sortingBlock(group, collectionKey.collection, collectionKey.key, object,
|
|
1651
|
-
|
|
1780
|
+
another.collection, another.key, anotherObject);
|
|
1652
1781
|
}
|
|
1653
1782
|
else if (view->sortingBlockType == YapDatabaseViewBlockTypeWithMetadata)
|
|
1654
1783
|
{
|
|
1655
1784
|
__unsafe_unretained YapDatabaseViewSortingWithMetadataBlock sortingBlock =
|
|
1656
1785
|
(YapDatabaseViewSortingWithMetadataBlock)view->sortingBlock;
|
|
1657
1786
|
|
|
1658
|
-
|
|
1659
|
-
NSString *anotherCollection = nil;
|
|
1787
|
+
YapCollectionKey *another = nil;
|
|
1660
1788
|
id anotherMetadata = nil;
|
|
1661
|
-
[databaseTransaction
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
forRowid:anotherRowid];
|
|
1789
|
+
[databaseTransaction getCollectionKey:&another
|
|
1790
|
+
metadata:&anotherMetadata
|
|
1791
|
+
forRowid:anotherRowid];
|
|
1665
1792
|
|
|
1666
1793
|
return sortingBlock(group, collectionKey.collection, collectionKey.key, metadata,
|
|
1667
|
-
|
|
1794
|
+
another.collection, another.key, anotherMetadata);
|
|
1668
1795
|
}
|
|
1669
1796
|
else
|
|
1670
1797
|
{
|
|
1671
1798
|
__unsafe_unretained YapDatabaseViewSortingWithRowBlock sortingBlock =
|
|
1672
1799
|
(YapDatabaseViewSortingWithRowBlock)view->sortingBlock;
|
|
1673
1800
|
|
|
1674
|
-
|
|
1675
|
-
NSString *anotherCollection = nil;
|
|
1801
|
+
YapCollectionKey *another = nil;
|
|
1676
1802
|
id anotherObject = nil;
|
|
1677
1803
|
id anotherMetadata = nil;
|
|
1678
|
-
[databaseTransaction
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
forRowid:anotherRowid];
|
|
1804
|
+
[databaseTransaction getCollectionKey:&another
|
|
1805
|
+
object:&anotherObject
|
|
1806
|
+
metadata:&anotherMetadata
|
|
1807
|
+
forRowid:anotherRowid];
|
|
1683
1808
|
|
|
1684
1809
|
return sortingBlock(group, collectionKey.collection, collectionKey.key, object, metadata,
|
|
1685
|
-
|
|
1810
|
+
another.collection, another.key, anotherObject, anotherMetadata);
|
|
1686
1811
|
}
|
|
1687
1812
|
};
|
|
1688
1813
|
|
|
@@ -1950,8 +2075,10 @@
|
|
|
1950
2075
|
|
|
1951
2076
|
// Add change to log
|
|
1952
2077
|
|
|
2078
|
+
NSUInteger indexWithinGroup = pageOffset + indexWithinPage;
|
|
2079
|
+
|
|
1953
2080
|
[viewConnection->changes addObject:
|
|
1954
|
-
|
|
2081
|
+
[YapDatabaseViewRowChange deleteKey:collectionKey inGroup:group atIndex:indexWithinGroup]];
|
|
1955
2082
|
|
|
1956
2083
|
[viewConnection->mutatedGroups addObject:group];
|
|
1957
2084
|
|
|
@@ -2065,7 +2192,7 @@
|
|
|
2065
2192
|
numRemoved++;
|
|
2066
2193
|
|
|
2067
2194
|
[viewConnection->changes addObject:
|
|
2068
|
-
|
|
2195
|
+
[YapDatabaseViewRowChange deleteKey:collectionKey inGroup:group atIndex:(pageOffset + i)]];
|
|
2069
2196
|
}
|
|
2070
2197
|
}
|
|
2071
2198
|
|
|
@@ -2146,10 +2273,12 @@
|
|
|
2146
2273
|
[pageTableTransaction removeAllObjects];
|
|
2147
2274
|
[pageMetadataTableTransaction removeAllObjects];
|
|
2148
2275
|
}
|
|
2149
|
-
|
|
2276
|
+
|
|
2150
2277
|
for (NSString *group in viewConnection->group_pagesMetadata_dict)
|
|
2151
2278
|
{
|
|
2152
|
-
|
|
2279
|
+
if (!isRepopulate) {
|
|
2280
|
+
[viewConnection->changes addObject:[YapDatabaseViewSectionChange resetGroup:group]];
|
|
2281
|
+
}
|
|
2153
2282
|
[viewConnection->mutatedGroups addObject:group];
|
|
2154
2283
|
}
|
|
2155
2284
|
|
|
@@ -2429,7 +2558,7 @@
|
|
|
2429
2558
|
* Extensions may implement it to perform any "cleanup" before the changeset is requested.
|
|
2430
2559
|
* Remember, the changeset is requested before the commitTransaction method is invoked.
|
|
2431
2560
|
**/
|
|
2432
|
-
- (void)
|
|
2561
|
+
- (void)prepareChangeset
|
|
2433
2562
|
{
|
|
2434
2563
|
YDBLogAutoTrace();
|
|
2435
2564
|
|
|
@@ -2514,7 +2643,7 @@
|
|
|
2514
2643
|
else
|
|
2515
2644
|
{
|
|
2516
2645
|
NSString *group = [self groupForPageKey:pageKey];
|
|
2517
|
-
|
|
2646
|
+
NSArray *pagesMetadataForGroup = [viewConnection->group_pagesMetadata_dict objectForKey:group];
|
|
2518
2647
|
|
|
2519
2648
|
for (YapDatabaseViewPageMetadata *pm in pagesMetadataForGroup)
|
|
2520
2649
|
{
|
|
@@ -2865,8 +2994,8 @@
|
|
|
2865
2994
|
if (pageMetadata == nil)
|
|
2866
2995
|
{
|
|
2867
2996
|
NSString *group = [self groupForPageKey:pageKey];
|
|
2868
|
-
|
|
2869
|
-
|
|
2997
|
+
NSArray *pagesMetadataForGroup =
|
|
2998
|
+
[viewConnection->group_pagesMetadata_dict objectForKey:group];
|
|
2870
2999
|
|
|
2871
3000
|
for (YapDatabaseViewPageMetadata *pm in pagesMetadataForGroup)
|
|
2872
3001
|
{
|
|
@@ -2981,8 +3110,7 @@
|
|
|
2981
3110
|
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
|
2982
3111
|
**/
|
|
2983
3112
|
- (void)handleInsertObject:(id)object
|
|
2984
|
-
|
|
2985
|
-
inCollection:(NSString *)collection
|
|
3113
|
+
forCollectionKey:(YapCollectionKey *)collectionKey
|
|
2986
3114
|
withMetadata:(id)metadata
|
|
2987
3115
|
rowid:(int64_t)rowid
|
|
2988
3116
|
{
|
|
@@ -2990,6 +3118,9 @@
|
|
|
2990
3118
|
|
|
2991
3119
|
__unsafe_unretained YapDatabaseView *view = viewConnection->view;
|
|
2992
3120
|
|
|
3121
|
+
__unsafe_unretained NSString *collection = collectionKey.collection;
|
|
3122
|
+
__unsafe_unretained NSString *key = collectionKey.key;
|
|
3123
|
+
|
|
2993
3124
|
// Invoke the grouping block to find out if the object should be included in the view.
|
|
2994
3125
|
|
|
2995
3126
|
NSString *group = nil;
|
|
@@ -3036,8 +3167,6 @@
|
|
|
3036
3167
|
// Add key to view.
|
|
3037
3168
|
// This was an insert operation, so we know the key wasn't already in the view.
|
|
3038
3169
|
|
|
3039
|
-
YapCollectionKey *collectionKey = [[YapCollectionKey alloc] initWithCollection:collection key:key];
|
|
3040
|
-
|
|
3041
3170
|
int flags = (YapDatabaseViewChangedObject | YapDatabaseViewChangedMetadata);
|
|
3042
3171
|
|
|
3043
3172
|
[self insertRowid:rowid
|
|
@@ -3055,18 +3184,17 @@
|
|
|
3055
3184
|
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
|
3056
3185
|
**/
|
|
3057
3186
|
- (void)handleUpdateObject:(id)object
|
|
3058
|
-
|
|
3059
|
-
inCollection:(NSString *)collection
|
|
3187
|
+
forCollectionKey:(YapCollectionKey *)collectionKey
|
|
3060
3188
|
withMetadata:(id)metadata
|
|
3061
3189
|
rowid:(int64_t)rowid
|
|
3062
3190
|
{
|
|
3063
3191
|
YDBLogAutoTrace();
|
|
3064
3192
|
|
|
3065
|
-
NSParameterAssert(key != nil);
|
|
3066
|
-
NSParameterAssert(collection != nil);
|
|
3067
|
-
|
|
3068
3193
|
__unsafe_unretained YapDatabaseView *view = viewConnection->view;
|
|
3069
3194
|
|
|
3195
|
+
__unsafe_unretained NSString *collection = collectionKey.collection;
|
|
3196
|
+
__unsafe_unretained NSString *key = collectionKey.key;
|
|
3197
|
+
|
|
3070
3198
|
// Invoke the grouping block to find out if the object should be included in the view.
|
|
3071
3199
|
|
|
3072
3200
|
NSString *group = nil;
|
|
@@ -3103,8 +3231,6 @@
|
|
|
3103
3231
|
group = groupingBlock(collection, key, object, metadata);
|
|
3104
3232
|
}
|
|
3105
3233
|
}
|
|
3106
|
-
|
|
3107
|
-
YapCollectionKey *collectionKey = [[YapCollectionKey alloc] initWithCollection:collection key:key];
|
|
3108
3234
|
|
|
3109
3235
|
if (group == nil)
|
|
3110
3236
|
{
|
|
@@ -3134,16 +3260,167 @@
|
|
|
3134
3260
|
* YapDatabase extension hook.
|
|
3135
3261
|
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
|
3136
3262
|
**/
|
|
3137
|
-
- (void)
|
|
3138
|
-
forKey:(NSString *)key
|
|
3139
|
-
inCollection:(NSString *)collection
|
|
3140
|
-
withRowid:(int64_t)rowid
|
|
3263
|
+
- (void)handleReplaceObject:(id)object forCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
|
|
3141
3264
|
{
|
|
3142
3265
|
YDBLogAutoTrace();
|
|
3143
3266
|
|
|
3144
3267
|
__unsafe_unretained YapDatabaseView *view = viewConnection->view;
|
|
3145
3268
|
|
|
3146
|
-
|
|
3269
|
+
__unsafe_unretained NSString *collection = collectionKey.collection;
|
|
3270
|
+
__unsafe_unretained NSString *key = collectionKey.key;
|
|
3271
|
+
|
|
3272
|
+
// Invoke the grouping block to find out if the object should be included in the view.
|
|
3273
|
+
|
|
3274
|
+
id metadata = nil;
|
|
3275
|
+
NSString *group = nil;
|
|
3276
|
+
|
|
3277
|
+
if (view->groupingBlockType == YapDatabaseViewBlockTypeWithKey ||
|
|
3278
|
+
view->groupingBlockType == YapDatabaseViewBlockTypeWithMetadata)
|
|
3279
|
+
{
|
|
3280
|
+
// Grouping is based on the key or metadata.
|
|
3281
|
+
// Neither have changed, and thus the group hasn't changed.
|
|
3282
|
+
|
|
3283
|
+
NSString *pageKey = [self pageKeyForRowid:rowid];
|
|
3284
|
+
group = [self groupForPageKey:pageKey];
|
|
3285
|
+
|
|
3286
|
+
if (group == nil)
|
|
3287
|
+
{
|
|
3288
|
+
// Nothing to do.
|
|
3289
|
+
// The key wasn't previously in the view, and still isn't in the view.
|
|
3290
|
+
lastHandledGroup = group;
|
|
3291
|
+
return;
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3294
|
+
if (view->sortingBlockType == YapDatabaseViewBlockTypeWithKey ||
|
|
3295
|
+
view->sortingBlockType == YapDatabaseViewBlockTypeWithMetadata)
|
|
3296
|
+
{
|
|
3297
|
+
// Nothing has moved because the group hasn't changed and
|
|
3298
|
+
// nothing has changed that relates to sorting.
|
|
3299
|
+
|
|
3300
|
+
int flags = YapDatabaseViewChangedObject;
|
|
3301
|
+
NSUInteger existingIndex = [self indexForRowid:rowid inGroup:group withPageKey:pageKey];
|
|
3302
|
+
|
|
3303
|
+
[viewConnection->changes addObject:
|
|
3304
|
+
[YapDatabaseViewRowChange updateKey:collectionKey changes:flags inGroup:group atIndex:existingIndex]];
|
|
3305
|
+
}
|
|
3306
|
+
else
|
|
3307
|
+
{
|
|
3308
|
+
// Sorting is based on the object, which has changed.
|
|
3309
|
+
// So the sort order may possibly have changed.
|
|
3310
|
+
|
|
3311
|
+
// From previous if statement (above) we know:
|
|
3312
|
+
// sortingBlockType is object or row (object+metadata)
|
|
3313
|
+
|
|
3314
|
+
if (view->sortingBlockType == YapDatabaseViewBlockTypeWithRow)
|
|
3315
|
+
{
|
|
3316
|
+
// Need the metadata for the sorting block
|
|
3317
|
+
metadata = [databaseTransaction metadataForCollectionKey:collectionKey withRowid:rowid];
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
int flags = YapDatabaseViewChangedObject;
|
|
3321
|
+
|
|
3322
|
+
[self insertRowid:rowid
|
|
3323
|
+
collectionKey:collectionKey
|
|
3324
|
+
object:object
|
|
3325
|
+
metadata:metadata
|
|
3326
|
+
inGroup:group withChanges:flags isNew:NO];
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
else
|
|
3330
|
+
{
|
|
3331
|
+
// Grouping is based on object or row (object+metadata).
|
|
3332
|
+
// Invoke groupingBlock to see what the new group is.
|
|
3333
|
+
|
|
3334
|
+
NSSet *allowedCollections = view->options.allowedCollections;
|
|
3335
|
+
|
|
3336
|
+
if (!allowedCollections || [allowedCollections containsObject:collection])
|
|
3337
|
+
{
|
|
3338
|
+
if (view->groupingBlockType == YapDatabaseViewBlockTypeWithObject)
|
|
3339
|
+
{
|
|
3340
|
+
__unsafe_unretained YapDatabaseViewGroupingWithObjectBlock groupingBlock =
|
|
3341
|
+
(YapDatabaseViewGroupingWithObjectBlock)view->groupingBlock;
|
|
3342
|
+
|
|
3343
|
+
group = groupingBlock(collection, key, object);
|
|
3344
|
+
}
|
|
3345
|
+
else
|
|
3346
|
+
{
|
|
3347
|
+
__unsafe_unretained YapDatabaseViewGroupingWithRowBlock groupingBlock =
|
|
3348
|
+
(YapDatabaseViewGroupingWithRowBlock)view->groupingBlock;
|
|
3349
|
+
|
|
3350
|
+
metadata = [databaseTransaction metadataForCollectionKey:collectionKey withRowid:rowid];
|
|
3351
|
+
group = groupingBlock(collection, key, object, metadata);
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
if (group == nil)
|
|
3356
|
+
{
|
|
3357
|
+
// The key is not included in the view.
|
|
3358
|
+
// Remove key from view (if needed).
|
|
3359
|
+
|
|
3360
|
+
[self removeRowid:rowid collectionKey:collectionKey];
|
|
3361
|
+
}
|
|
3362
|
+
else
|
|
3363
|
+
{
|
|
3364
|
+
if (view->sortingBlockType == YapDatabaseViewBlockTypeWithKey ||
|
|
3365
|
+
view->sortingBlockType == YapDatabaseViewBlockTypeWithMetadata)
|
|
3366
|
+
{
|
|
3367
|
+
// Sorting is based on the key or metadata, neither of which has changed.
|
|
3368
|
+
// So if the group hasn't changed, then the sort order hasn't changed.
|
|
3369
|
+
|
|
3370
|
+
NSString *existingPageKey = [self pageKeyForRowid:rowid];
|
|
3371
|
+
NSString *existingGroup = [self groupForPageKey:existingPageKey];
|
|
3372
|
+
|
|
3373
|
+
if ([group isEqualToString:existingGroup])
|
|
3374
|
+
{
|
|
3375
|
+
// Nothing left to do.
|
|
3376
|
+
// The group didn't change, and the sort order cannot change (because the object didn't change).
|
|
3377
|
+
|
|
3378
|
+
int flags = YapDatabaseViewChangedObject;
|
|
3379
|
+
NSUInteger existingIndex = [self indexForRowid:rowid inGroup:group withPageKey:existingPageKey];
|
|
3380
|
+
|
|
3381
|
+
[viewConnection->changes addObject:
|
|
3382
|
+
[YapDatabaseViewRowChange updateKey:collectionKey
|
|
3383
|
+
changes:flags
|
|
3384
|
+
inGroup:group
|
|
3385
|
+
atIndex:existingIndex]];
|
|
3386
|
+
|
|
3387
|
+
lastHandledGroup = group;
|
|
3388
|
+
return;
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
if (metadata == nil && (view->sortingBlockType == YapDatabaseViewBlockTypeWithMetadata ||
|
|
3393
|
+
view->sortingBlockType == YapDatabaseViewBlockTypeWithRow ))
|
|
3394
|
+
{
|
|
3395
|
+
// Need the metadata for the sorting block
|
|
3396
|
+
metadata = [databaseTransaction metadataForCollectionKey:collectionKey withRowid:rowid];
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
int flags = YapDatabaseViewChangedObject;
|
|
3400
|
+
|
|
3401
|
+
[self insertRowid:rowid
|
|
3402
|
+
collectionKey:collectionKey
|
|
3403
|
+
object:object
|
|
3404
|
+
metadata:metadata
|
|
3405
|
+
inGroup:group withChanges:flags isNew:NO];
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
|
|
3409
|
+
lastHandledGroup = group;
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3412
|
+
/**
|
|
3413
|
+
* YapDatabase extension hook.
|
|
3414
|
+
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
|
3415
|
+
**/
|
|
3416
|
+
- (void)handleReplaceMetadata:(id)metadata forCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
|
|
3417
|
+
{
|
|
3418
|
+
YDBLogAutoTrace();
|
|
3419
|
+
|
|
3420
|
+
__unsafe_unretained YapDatabaseView *view = viewConnection->view;
|
|
3421
|
+
|
|
3422
|
+
__unsafe_unretained NSString *collection = collectionKey.collection;
|
|
3423
|
+
__unsafe_unretained NSString *key = collectionKey.key;
|
|
3147
3424
|
|
|
3148
3425
|
// Invoke the grouping block to find out if the object should be included in the view.
|
|
3149
3426
|
|
|
@@ -3190,7 +3467,7 @@
|
|
|
3190
3467
|
if (view->sortingBlockType == YapDatabaseViewBlockTypeWithRow)
|
|
3191
3468
|
{
|
|
3192
3469
|
// Need the object for the sorting block
|
|
3193
|
-
object = [databaseTransaction
|
|
3470
|
+
object = [databaseTransaction objectForCollectionKey:collectionKey withRowid:rowid];
|
|
3194
3471
|
}
|
|
3195
3472
|
|
|
3196
3473
|
int flags = YapDatabaseViewChangedMetadata;
|
|
@@ -3223,7 +3500,7 @@
|
|
|
3223
3500
|
__unsafe_unretained YapDatabaseViewGroupingWithRowBlock groupingBlock =
|
|
3224
3501
|
(YapDatabaseViewGroupingWithRowBlock)view->groupingBlock;
|
|
3225
3502
|
|
|
3226
|
-
object = [databaseTransaction
|
|
3503
|
+
object = [databaseTransaction objectForCollectionKey:collectionKey withRowid:rowid];
|
|
3227
3504
|
group = groupingBlock(collection, key, object, metadata);
|
|
3228
3505
|
}
|
|
3229
3506
|
}
|
|
@@ -3269,7 +3546,7 @@
|
|
|
3269
3546
|
view->sortingBlockType == YapDatabaseViewBlockTypeWithRow ))
|
|
3270
3547
|
{
|
|
3271
3548
|
// Need the object for the sorting block
|
|
3272
|
-
object = [databaseTransaction
|
|
3549
|
+
object = [databaseTransaction objectForCollectionKey:collectionKey withRowid:rowid];
|
|
3273
3550
|
}
|
|
3274
3551
|
|
|
3275
3552
|
int flags = YapDatabaseViewChangedMetadata;
|
|
@@ -3289,7 +3566,7 @@
|
|
|
3289
3566
|
* YapDatabase extension hook.
|
|
3290
3567
|
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
|
3291
3568
|
**/
|
|
3292
|
-
- (void)
|
|
3569
|
+
- (void)handleTouchObjectForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
|
|
3293
3570
|
{
|
|
3294
3571
|
YDBLogAutoTrace();
|
|
3295
3572
|
|
|
@@ -3301,7 +3578,6 @@
|
|
|
3301
3578
|
NSString *group = [self groupForPageKey:pageKey];
|
|
3302
3579
|
NSUInteger index = [self indexForRowid:rowid inGroup:group withPageKey:pageKey];
|
|
3303
3580
|
|
|
3304
|
-
YapCollectionKey *collectionKey = [[YapCollectionKey alloc] initWithCollection:collection key:key];
|
|
3305
3581
|
int flags = (YapDatabaseViewChangedObject | YapDatabaseViewChangedMetadata);
|
|
3306
3582
|
|
|
3307
3583
|
[viewConnection->changes addObject:
|
|
@@ -3313,7 +3589,7 @@
|
|
|
3313
3589
|
* YapDatabase extension hook.
|
|
3314
3590
|
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
|
3315
3591
|
**/
|
|
3316
|
-
- (void)
|
|
3592
|
+
- (void)handleTouchMetadataForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
|
|
3317
3593
|
{
|
|
3318
3594
|
YDBLogAutoTrace();
|
|
3319
3595
|
|
|
@@ -3332,7 +3608,6 @@
|
|
|
3332
3608
|
NSString *group = [self groupForPageKey:pageKey];
|
|
3333
3609
|
NSUInteger index = [self indexForRowid:rowid inGroup:group withPageKey:pageKey];
|
|
3334
3610
|
|
|
3335
|
-
YapCollectionKey *collectionKey = [[YapCollectionKey alloc] initWithCollection:collection key:key];
|
|
3336
3611
|
int flags = YapDatabaseViewChangedMetadata;
|
|
3337
3612
|
|
|
3338
3613
|
[viewConnection->changes addObject:
|
|
@@ -3345,15 +3620,10 @@
|
|
|
3345
3620
|
* YapDatabase extension hook.
|
|
3346
3621
|
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
|
3347
3622
|
**/
|
|
3348
|
-
- (void)
|
|
3623
|
+
- (void)handleRemoveObjectForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
|
|
3349
3624
|
{
|
|
3350
3625
|
YDBLogAutoTrace();
|
|
3351
3626
|
|
|
3352
|
-
NSParameterAssert(key != nil);
|
|
3353
|
-
NSParameterAssert(collection != nil);
|
|
3354
|
-
|
|
3355
|
-
YapCollectionKey *collectionKey = [[YapCollectionKey alloc] initWithCollection:collection key:key];
|
|
3356
|
-
|
|
3357
3627
|
[self removeRowid:rowid collectionKey:collectionKey];
|
|
3358
3628
|
}
|
|
3359
3629
|
|
|
@@ -3365,8 +3635,6 @@
|
|
|
3365
3635
|
{
|
|
3366
3636
|
YDBLogAutoTrace();
|
|
3367
3637
|
|
|
3368
|
-
NSParameterAssert(collection != nil);
|
|
3369
|
-
|
|
3370
3638
|
NSUInteger count = [keys count];
|
|
3371
3639
|
NSMutableDictionary *keyMappings = [NSMutableDictionary dictionaryWithCapacity:count];
|
|
3372
3640
|
|
|
@@ -3479,20 +3747,18 @@
|
|
|
3479
3747
|
int64_t rowid = 0;
|
|
3480
3748
|
if ([self getRowid:&rowid atIndex:index inGroup:group])
|
|
3481
3749
|
{
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
}
|
|
3490
|
-
else
|
|
3491
|
-
{
|
|
3492
|
-
if (collectionPtr) *collectionPtr = nil;
|
|
3493
|
-
if (keyPtr) *keyPtr = nil;
|
|
3494
|
-
return NO;
|
|
3750
|
+
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
|
3751
|
+
if (ck)
|
|
3752
|
+
{
|
|
3753
|
+
if (collectionPtr) *collectionPtr = ck.collection;
|
|
3754
|
+
if (keyPtr) *keyPtr = ck.key;
|
|
3755
|
+
return YES;
|
|
3756
|
+
}
|
|
3495
3757
|
}
|
|
3758
|
+
|
|
3759
|
+
if (collectionPtr) *collectionPtr = nil;
|
|
3760
|
+
if (keyPtr) *keyPtr = nil;
|
|
3761
|
+
return NO;
|
|
3496
3762
|
}
|
|
3497
3763
|
|
|
3498
3764
|
- (BOOL)getFirstKey:(NSString **)keyPtr collection:(NSString **)collectionPtr inGroup:(NSString *)group
|
|
@@ -3505,20 +3771,18 @@
|
|
|
3505
3771
|
int64_t rowid = 0;
|
|
3506
3772
|
if ([self getLastRowid:&rowid inGroup:group])
|
|
3507
3773
|
{
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
}
|
|
3516
|
-
else
|
|
3517
|
-
{
|
|
3518
|
-
if (collectionPtr) *collectionPtr = nil;
|
|
3519
|
-
if (keyPtr) *keyPtr = nil;
|
|
3520
|
-
return NO;
|
|
3774
|
+
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
|
3775
|
+
if (ck)
|
|
3776
|
+
{
|
|
3777
|
+
if (collectionPtr) *collectionPtr = ck.collection;
|
|
3778
|
+
if (keyPtr) *keyPtr = ck.key;
|
|
3779
|
+
return YES;
|
|
3780
|
+
}
|
|
3521
3781
|
}
|
|
3782
|
+
|
|
3783
|
+
if (collectionPtr) *collectionPtr = nil;
|
|
3784
|
+
if (keyPtr) *keyPtr = nil;
|
|
3785
|
+
return NO;
|
|
3522
3786
|
}
|
|
3523
3787
|
|
|
3524
3788
|
- (NSString *)collectionAtIndex:(NSUInteger)index inGroup:(NSString *)group
|
|
@@ -3591,7 +3855,7 @@
|
|
|
3591
3855
|
// Calculate the offset of the corresponding page within the group.
|
|
3592
3856
|
|
|
3593
3857
|
NSUInteger pageOffset = 0;
|
|
3594
|
-
|
|
3858
|
+
NSArray *pagesMetadataForGroup = [viewConnection->group_pagesMetadata_dict objectForKey:group];
|
|
3595
3859
|
|
|
3596
3860
|
for (YapDatabaseViewPageMetadata *pageMetadata in pagesMetadataForGroup)
|
|
3597
3861
|
{
|
|
@@ -3645,7 +3909,7 @@
|
|
|
3645
3909
|
return NSMakeRange(NSNotFound, 0);
|
|
3646
3910
|
}
|
|
3647
3911
|
|
|
3648
|
-
|
|
3912
|
+
NSArray *pagesMetadataForGroup = [viewConnection->group_pagesMetadata_dict objectForKey:group];
|
|
3649
3913
|
NSUInteger count = 0;
|
|
3650
3914
|
|
|
3651
3915
|
for (YapDatabaseViewPageMetadata *pageMetadata in pagesMetadataForGroup)
|
|
@@ -3683,48 +3947,43 @@
|
|
|
3683
3947
|
__unsafe_unretained YapDatabaseViewFindWithKeyBlock findBlock =
|
|
3684
3948
|
(YapDatabaseViewFindWithKeyBlock)block;
|
|
3685
3949
|
|
|
3686
|
-
|
|
3687
|
-
NSString *collection = nil;
|
|
3688
|
-
[databaseTransaction getKey:&key collection:&collection forRowid:rowid];
|
|
3950
|
+
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
|
3689
3951
|
|
|
3690
|
-
return findBlock(collection, key);
|
|
3952
|
+
return findBlock(ck.collection, ck.key);
|
|
3691
3953
|
}
|
|
3692
3954
|
else if (blockType == YapDatabaseViewBlockTypeWithObject)
|
|
3693
3955
|
{
|
|
3694
3956
|
__unsafe_unretained YapDatabaseViewFindWithObjectBlock findBlock =
|
|
3695
3957
|
(YapDatabaseViewFindWithObjectBlock)block;
|
|
3696
3958
|
|
|
3697
|
-
|
|
3698
|
-
NSString *collection = nil;
|
|
3959
|
+
YapCollectionKey *ck = nil;
|
|
3699
3960
|
id object = nil;
|
|
3700
|
-
[databaseTransaction
|
|
3961
|
+
[databaseTransaction getCollectionKey:&ck object:&object forRowid:rowid];
|
|
3701
3962
|
|
|
3702
|
-
return findBlock(collection, key, object);
|
|
3963
|
+
return findBlock(ck.collection, ck.key, object);
|
|
3703
3964
|
}
|
|
3704
3965
|
else if (blockType == YapDatabaseViewBlockTypeWithMetadata)
|
|
3705
3966
|
{
|
|
3706
3967
|
__unsafe_unretained YapDatabaseViewFindWithMetadataBlock findBlock =
|
|
3707
3968
|
(YapDatabaseViewFindWithMetadataBlock)block;
|
|
3708
3969
|
|
|
3709
|
-
|
|
3710
|
-
NSString *collection = nil;
|
|
3970
|
+
YapCollectionKey *ck = nil;
|
|
3711
3971
|
id metadata = nil;
|
|
3712
|
-
[databaseTransaction
|
|
3972
|
+
[databaseTransaction getCollectionKey:&ck metadata:&metadata forRowid:rowid];
|
|
3713
3973
|
|
|
3714
|
-
return findBlock(collection, key, metadata);
|
|
3974
|
+
return findBlock(ck.collection, ck.key, metadata);
|
|
3715
3975
|
}
|
|
3716
3976
|
else
|
|
3717
3977
|
{
|
|
3718
3978
|
__unsafe_unretained YapDatabaseViewFindWithRowBlock findBlock =
|
|
3719
3979
|
(YapDatabaseViewFindWithRowBlock)block;
|
|
3720
3980
|
|
|
3721
|
-
|
|
3722
|
-
NSString *collection = nil;
|
|
3981
|
+
YapCollectionKey *ck = nil;
|
|
3723
3982
|
id object = nil;
|
|
3724
3983
|
id metadata = nil;
|
|
3725
|
-
[databaseTransaction
|
|
3984
|
+
[databaseTransaction getCollectionKey:&ck object:&object metadata:&metadata forRowid:rowid];
|
|
3726
3985
|
|
|
3727
|
-
return findBlock(collection, key, object, metadata);
|
|
3986
|
+
return findBlock(ck.collection, ck.key, object, metadata);
|
|
3728
3987
|
}
|
|
3729
3988
|
};
|
|
3730
3989
|
|
|
@@ -3815,11 +4074,9 @@
|
|
|
3815
4074
|
|
|
3816
4075
|
[self enumerateRowidsInGroup:group usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop) {
|
|
3817
4076
|
|
|
3818
|
-
|
|
3819
|
-
NSString *collection = nil;
|
|
3820
|
-
[databaseTransaction getKey:&key collection:&collection forRowid:rowid];
|
|
4077
|
+
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
|
3821
4078
|
|
|
3822
|
-
block(collection, key, index, stop);
|
|
4079
|
+
block(ck.collection, ck.key, index, stop);
|
|
3823
4080
|
}];
|
|
3824
4081
|
}
|
|
3825
4082
|
|
|
@@ -3831,11 +4088,9 @@
|
|
|
3831
4088
|
|
|
3832
4089
|
[self enumerateRowidsInGroup:group withOptions:options usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop) {
|
|
3833
4090
|
|
|
3834
|
-
|
|
3835
|
-
NSString *collection = nil;
|
|
3836
|
-
[databaseTransaction getKey:&key collection:&collection forRowid:rowid];
|
|
4091
|
+
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
|
3837
4092
|
|
|
3838
|
-
block(collection, key, index, stop);
|
|
4093
|
+
block(ck.collection, ck.key, index, stop);
|
|
3839
4094
|
}];
|
|
3840
4095
|
}
|
|
3841
4096
|
|
|
@@ -3849,13 +4104,11 @@
|
|
|
3849
4104
|
[self enumerateRowidsInGroup:group
|
|
3850
4105
|
withOptions:options
|
|
3851
4106
|
range:range
|
|
3852
|
-
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
NSString *collection = nil;
|
|
3856
|
-
[databaseTransaction getKey:&key collection:&collection forRowid:rowid];
|
|
4107
|
+
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4108
|
+
{
|
|
4109
|
+
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
|
3857
4110
|
|
|
3858
|
-
block(collection, key, index, stop);
|
|
4111
|
+
block(ck.collection, ck.key, index, stop);
|
|
3859
4112
|
}];
|
|
3860
4113
|
}
|
|
3861
4114
|
|
|
@@ -3873,7 +4126,7 @@
|
|
|
3873
4126
|
__block BOOL stop = NO;
|
|
3874
4127
|
|
|
3875
4128
|
NSUInteger pageOffset = 0;
|
|
3876
|
-
|
|
4129
|
+
NSArray *pagesMetadataForGroup = [viewConnection->group_pagesMetadata_dict objectForKey:group];
|
|
3877
4130
|
|
|
3878
4131
|
for (YapDatabaseViewPageMetadata *pageMetadata in pagesMetadataForGroup)
|
|
3879
4132
|
{
|
|
@@ -3918,11 +4171,11 @@
|
|
|
3918
4171
|
else
|
|
3919
4172
|
index = [self numberOfKeysInGroup:group] - 1;
|
|
3920
4173
|
|
|
3921
|
-
|
|
4174
|
+
NSArray *pagesMetadataForGroup = [viewConnection->group_pagesMetadata_dict objectForKey:group];
|
|
3922
4175
|
|
|
3923
4176
|
[pagesMetadataForGroup enumerateObjectsWithOptions:options
|
|
3924
|
-
usingBlock:^(id pageMetadataObj, NSUInteger outerIdx, BOOL *outerStop)
|
|
3925
|
-
|
|
4177
|
+
usingBlock:^(id pageMetadataObj, NSUInteger outerIdx, BOOL *outerStop)
|
|
4178
|
+
{
|
|
3926
4179
|
__unsafe_unretained YapDatabaseViewPageMetadata *pageMetadata =
|
|
3927
4180
|
(YapDatabaseViewPageMetadata *)pageMetadataObj;
|
|
3928
4181
|
|
|
@@ -3958,7 +4211,7 @@
|
|
|
3958
4211
|
|
|
3959
4212
|
NSEnumerationOptions options = (inOptions & NSEnumerationReverse); // We only support NSEnumerationReverse
|
|
3960
4213
|
|
|
3961
|
-
|
|
4214
|
+
NSArray *pagesMetadataForGroup = [viewConnection->group_pagesMetadata_dict objectForKey:group];
|
|
3962
4215
|
|
|
3963
4216
|
// Helper block to fetch the pageOffset for some page.
|
|
3964
4217
|
|
|
@@ -3985,8 +4238,8 @@
|
|
|
3985
4238
|
__block NSUInteger keysLeft = range.length;
|
|
3986
4239
|
|
|
3987
4240
|
[pagesMetadataForGroup enumerateObjectsWithOptions:options
|
|
3988
|
-
usingBlock:^(id pageMetadataObj, NSUInteger pageIndex, BOOL *outerStop)
|
|
3989
|
-
|
|
4241
|
+
usingBlock:^(id pageMetadataObj, NSUInteger pageIndex, BOOL *outerStop)
|
|
4242
|
+
{
|
|
3990
4243
|
__unsafe_unretained YapDatabaseViewPageMetadata *pageMetadata =
|
|
3991
4244
|
(YapDatabaseViewPageMetadata *)pageMetadataObj;
|
|
3992
4245
|
|
|
@@ -4201,6 +4454,82 @@
|
|
|
4201
4454
|
}
|
|
4202
4455
|
}
|
|
4203
4456
|
|
|
4457
|
+
/**
|
|
4458
|
+
* This method allows you to change the groupingBlock and/or sortingBlock on-the-fly.
|
|
4459
|
+
*
|
|
4460
|
+
* Note: You must pass a different versionTag, or this method does nothing.
|
|
4461
|
+
**/
|
|
4462
|
+
- (void)setGroupingBlock:(YapDatabaseViewGroupingBlock)inGroupingBlock
|
|
4463
|
+
groupingBlockType:(YapDatabaseViewBlockType)inGroupingBlockType
|
|
4464
|
+
sortingBlock:(YapDatabaseViewSortingBlock)inSortingBlock
|
|
4465
|
+
sortingBlockType:(YapDatabaseViewBlockType)inSortingBlockType
|
|
4466
|
+
versionTag:(NSString *)inVersionTag
|
|
4467
|
+
{
|
|
4468
|
+
YDBLogAutoTrace();
|
|
4469
|
+
|
|
4470
|
+
NSAssert(inGroupingBlock != NULL, @"Invalid grouping block");
|
|
4471
|
+
NSAssert(inSortingBlock != NULL, @"Invalid grouping block");
|
|
4472
|
+
|
|
4473
|
+
NSAssert(inGroupingBlockType == YapDatabaseViewBlockTypeWithKey ||
|
|
4474
|
+
inGroupingBlockType == YapDatabaseViewBlockTypeWithObject ||
|
|
4475
|
+
inGroupingBlockType == YapDatabaseViewBlockTypeWithMetadata ||
|
|
4476
|
+
inGroupingBlockType == YapDatabaseViewBlockTypeWithRow,
|
|
4477
|
+
@"Invalid grouping block type");
|
|
4478
|
+
|
|
4479
|
+
NSAssert(inSortingBlockType == YapDatabaseViewBlockTypeWithKey ||
|
|
4480
|
+
inSortingBlockType == YapDatabaseViewBlockTypeWithObject ||
|
|
4481
|
+
inSortingBlockType == YapDatabaseViewBlockTypeWithMetadata ||
|
|
4482
|
+
inSortingBlockType == YapDatabaseViewBlockTypeWithRow,
|
|
4483
|
+
@"Invalid sorting block type");
|
|
4484
|
+
|
|
4485
|
+
if (!databaseTransaction->isReadWriteTransaction)
|
|
4486
|
+
{
|
|
4487
|
+
YDBLogWarn(@"%@ - Method only allowed in readWrite transaction", THIS_METHOD);
|
|
4488
|
+
return;
|
|
4489
|
+
}
|
|
4490
|
+
|
|
4491
|
+
NSString *newVersionTag = inVersionTag ? [inVersionTag copy] : @"";
|
|
4492
|
+
|
|
4493
|
+
__unsafe_unretained YapDatabaseView *view = viewConnection->view;
|
|
4494
|
+
|
|
4495
|
+
if ([view->versionTag isEqualToString:newVersionTag])
|
|
4496
|
+
{
|
|
4497
|
+
YDBLogWarn(@"%@ - versionTag didn't change, so not updating view", THIS_METHOD);
|
|
4498
|
+
return;
|
|
4499
|
+
}
|
|
4500
|
+
|
|
4501
|
+
view->groupingBlock = inGroupingBlock;
|
|
4502
|
+
view->groupingBlockType = inGroupingBlockType;
|
|
4503
|
+
view->sortingBlock = inSortingBlock;
|
|
4504
|
+
view->sortingBlockType = inSortingBlockType;
|
|
4505
|
+
|
|
4506
|
+
view->versionTag = newVersionTag;
|
|
4507
|
+
|
|
4508
|
+
[self repopulateView];
|
|
4509
|
+
[self setStringValue:newVersionTag forExtensionKey:ExtKey_versionTag];
|
|
4510
|
+
|
|
4511
|
+
// Notify any extensions dependent upon this one that we repopulated.
|
|
4512
|
+
|
|
4513
|
+
NSString *registeredName = [self registeredName];
|
|
4514
|
+
NSDictionary *extensionDependencies = databaseTransaction->connection->extensionDependencies;
|
|
4515
|
+
|
|
4516
|
+
[extensionDependencies enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop){
|
|
4517
|
+
|
|
4518
|
+
__unsafe_unretained NSString *extName = (NSString *)key;
|
|
4519
|
+
__unsafe_unretained NSSet *extDependencies = (NSSet *)obj;
|
|
4520
|
+
|
|
4521
|
+
if ([extDependencies containsObject:registeredName])
|
|
4522
|
+
{
|
|
4523
|
+
YapDatabaseExtensionTransaction *extTransaction = [databaseTransaction ext:extName];
|
|
4524
|
+
|
|
4525
|
+
if ([extTransaction respondsToSelector:@selector(viewDidRepopulate:)])
|
|
4526
|
+
{
|
|
4527
|
+
[(id <YapDatabaseViewDependency>)extTransaction viewDidRepopulate:registeredName];
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4530
|
+
}];
|
|
4531
|
+
}
|
|
4532
|
+
|
|
4204
4533
|
@end
|
|
4205
4534
|
|
|
4206
4535
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
@@ -4219,11 +4548,9 @@
|
|
|
4219
4548
|
// So it's likely faster to fetch just the key first.
|
|
4220
4549
|
// And if the cache misses then we're still using a fetch based on the rowid.
|
|
4221
4550
|
|
|
4222
|
-
|
|
4223
|
-
NSString *collection = nil;
|
|
4224
|
-
[databaseTransaction getKey:&key collection:&collection forRowid:rowid];
|
|
4551
|
+
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
|
4225
4552
|
|
|
4226
|
-
return [databaseTransaction
|
|
4553
|
+
return [databaseTransaction objectForCollectionKey:ck withRowid:rowid];
|
|
4227
4554
|
}
|
|
4228
4555
|
else
|
|
4229
4556
|
{
|
|
@@ -4247,11 +4574,9 @@
|
|
|
4247
4574
|
// So it's likely faster to fetch just the key first.
|
|
4248
4575
|
// And if the cache misses then we're still using a fetch based on the rowid.
|
|
4249
4576
|
|
|
4250
|
-
|
|
4251
|
-
NSString *collection = nil;
|
|
4252
|
-
[databaseTransaction getKey:&key collection:&collection forRowid:rowid];
|
|
4577
|
+
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
|
4253
4578
|
|
|
4254
|
-
return [databaseTransaction
|
|
4579
|
+
return [databaseTransaction objectForCollectionKey:ck withRowid:rowid];
|
|
4255
4580
|
}
|
|
4256
4581
|
else
|
|
4257
4582
|
{
|
|
@@ -4272,12 +4597,11 @@
|
|
|
4272
4597
|
|
|
4273
4598
|
[self enumerateRowidsInGroup:group usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop) {
|
|
4274
4599
|
|
|
4275
|
-
|
|
4276
|
-
NSString *collection = nil;
|
|
4600
|
+
YapCollectionKey *ck = nil;
|
|
4277
4601
|
id metadata = nil;
|
|
4278
|
-
[databaseTransaction
|
|
4602
|
+
[databaseTransaction getCollectionKey:&ck metadata:&metadata forRowid:rowid];
|
|
4279
4603
|
|
|
4280
|
-
block(collection, key, metadata, index, stop);
|
|
4604
|
+
block(ck.collection, ck.key, metadata, index, stop);
|
|
4281
4605
|
}];
|
|
4282
4606
|
}
|
|
4283
4607
|
|
|
@@ -4290,14 +4614,13 @@
|
|
|
4290
4614
|
|
|
4291
4615
|
[self enumerateRowidsInGroup:group
|
|
4292
4616
|
withOptions:options
|
|
4293
|
-
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
NSString *collection = nil;
|
|
4617
|
+
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4618
|
+
{
|
|
4619
|
+
YapCollectionKey *ck = nil;
|
|
4297
4620
|
id metadata = nil;
|
|
4298
|
-
[databaseTransaction
|
|
4621
|
+
[databaseTransaction getCollectionKey:&ck metadata:&metadata forRowid:rowid];
|
|
4299
4622
|
|
|
4300
|
-
block(collection, key, metadata, index, stop);
|
|
4623
|
+
block(ck.collection, ck.key, metadata, index, stop);
|
|
4301
4624
|
}];
|
|
4302
4625
|
}
|
|
4303
4626
|
|
|
@@ -4312,14 +4635,13 @@
|
|
|
4312
4635
|
[self enumerateRowidsInGroup:group
|
|
4313
4636
|
withOptions:options
|
|
4314
4637
|
range:range
|
|
4315
|
-
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
NSString *collection = nil;
|
|
4638
|
+
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4639
|
+
{
|
|
4640
|
+
YapCollectionKey *ck = nil;
|
|
4319
4641
|
id metadata = nil;
|
|
4320
|
-
[databaseTransaction
|
|
4642
|
+
[databaseTransaction getCollectionKey:&ck metadata:&metadata forRowid:rowid];
|
|
4321
4643
|
|
|
4322
|
-
block(collection, key, metadata, index, stop);
|
|
4644
|
+
block(ck.collection, ck.key, metadata, index, stop);
|
|
4323
4645
|
}];
|
|
4324
4646
|
}
|
|
4325
4647
|
|
|
@@ -4336,12 +4658,11 @@
|
|
|
4336
4658
|
|
|
4337
4659
|
[self enumerateRowidsInGroup:group usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop) {
|
|
4338
4660
|
|
|
4339
|
-
|
|
4340
|
-
NSString *collection = nil;
|
|
4661
|
+
YapCollectionKey *ck = nil;
|
|
4341
4662
|
id object = nil;
|
|
4342
|
-
[databaseTransaction
|
|
4663
|
+
[databaseTransaction getCollectionKey:&ck object:&object forRowid:rowid];
|
|
4343
4664
|
|
|
4344
|
-
block(collection, key, object, index, stop);
|
|
4665
|
+
block(ck.collection, ck.key, object, index, stop);
|
|
4345
4666
|
}];
|
|
4346
4667
|
}
|
|
4347
4668
|
|
|
@@ -4354,14 +4675,13 @@
|
|
|
4354
4675
|
|
|
4355
4676
|
[self enumerateRowidsInGroup:group
|
|
4356
4677
|
withOptions:options
|
|
4357
|
-
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
NSString *collection = nil;
|
|
4678
|
+
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4679
|
+
{
|
|
4680
|
+
YapCollectionKey *ck = nil;
|
|
4361
4681
|
id object = nil;
|
|
4362
|
-
[databaseTransaction
|
|
4682
|
+
[databaseTransaction getCollectionKey:&ck object:&object forRowid:rowid];
|
|
4363
4683
|
|
|
4364
|
-
block(collection, key, object, index, stop);
|
|
4684
|
+
block(ck.collection, ck.key, object, index, stop);
|
|
4365
4685
|
}];
|
|
4366
4686
|
}
|
|
4367
4687
|
|
|
@@ -4376,14 +4696,13 @@
|
|
|
4376
4696
|
[self enumerateRowidsInGroup:group
|
|
4377
4697
|
withOptions:options
|
|
4378
4698
|
range:range
|
|
4379
|
-
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
NSString *collection = nil;
|
|
4699
|
+
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4700
|
+
{
|
|
4701
|
+
YapCollectionKey *ck = nil;
|
|
4383
4702
|
id object = nil;
|
|
4384
|
-
[databaseTransaction
|
|
4703
|
+
[databaseTransaction getCollectionKey:&ck object:&object forRowid:rowid];
|
|
4385
4704
|
|
|
4386
|
-
block(collection, key, object, index, stop);
|
|
4705
|
+
block(ck.collection, ck.key, object, index, stop);
|
|
4387
4706
|
}];
|
|
4388
4707
|
}
|
|
4389
4708
|
|
|
@@ -4395,13 +4714,12 @@
|
|
|
4395
4714
|
|
|
4396
4715
|
[self enumerateRowidsInGroup:group usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop) {
|
|
4397
4716
|
|
|
4398
|
-
|
|
4399
|
-
NSString *collection = nil;
|
|
4717
|
+
YapCollectionKey *ck = nil;
|
|
4400
4718
|
id object = nil;
|
|
4401
4719
|
id metadata = nil;
|
|
4402
|
-
[databaseTransaction
|
|
4720
|
+
[databaseTransaction getCollectionKey:&ck object:&object metadata:&metadata forRowid:rowid];
|
|
4403
4721
|
|
|
4404
|
-
block(collection, key, object, metadata, index, stop);
|
|
4722
|
+
block(ck.collection, ck.key, object, metadata, index, stop);
|
|
4405
4723
|
}];
|
|
4406
4724
|
}
|
|
4407
4725
|
|
|
@@ -4414,15 +4732,14 @@
|
|
|
4414
4732
|
|
|
4415
4733
|
[self enumerateRowidsInGroup:group
|
|
4416
4734
|
withOptions:options
|
|
4417
|
-
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
NSString *collection = nil;
|
|
4735
|
+
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4736
|
+
{
|
|
4737
|
+
YapCollectionKey *ck = nil;
|
|
4421
4738
|
id object = nil;
|
|
4422
4739
|
id metadata = nil;
|
|
4423
|
-
[databaseTransaction
|
|
4424
|
-
|
|
4425
|
-
block(collection, key, object, metadata, index, stop);
|
|
4740
|
+
[databaseTransaction getCollectionKey:&ck object:&object metadata:&metadata forRowid:rowid];
|
|
4741
|
+
|
|
4742
|
+
block(ck.collection, ck.key, object, metadata, index, stop);
|
|
4426
4743
|
}];
|
|
4427
4744
|
}
|
|
4428
4745
|
|
|
@@ -4437,15 +4754,14 @@
|
|
|
4437
4754
|
[self enumerateRowidsInGroup:group
|
|
4438
4755
|
withOptions:options
|
|
4439
4756
|
range:range
|
|
4440
|
-
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
NSString *collection = nil;
|
|
4757
|
+
usingBlock:^(int64_t rowid, NSUInteger index, BOOL *stop)
|
|
4758
|
+
{
|
|
4759
|
+
YapCollectionKey *ck = nil;
|
|
4444
4760
|
id object = nil;
|
|
4445
4761
|
id metadata = nil;
|
|
4446
|
-
[databaseTransaction
|
|
4762
|
+
[databaseTransaction getCollectionKey:&ck object:&object metadata:&metadata forRowid:rowid];
|
|
4447
4763
|
|
|
4448
|
-
block(collection, key, object, metadata, index, stop);
|
|
4764
|
+
block(ck.collection, ck.key, object, metadata, index, stop);
|
|
4449
4765
|
}];
|
|
4450
4766
|
}
|
|
4451
4767
|
|
|
@@ -4457,6 +4773,43 @@
|
|
|
4457
4773
|
|
|
4458
4774
|
@implementation YapDatabaseViewTransaction (Mappings)
|
|
4459
4775
|
|
|
4776
|
+
/**
|
|
4777
|
+
* Performance boost.
|
|
4778
|
+
* If the object isn't in the cache, having the rowid makes for a faster fetch from sqlite.
|
|
4779
|
+
**/
|
|
4780
|
+
- (BOOL)getRowid:(int64_t *)rowidPtr
|
|
4781
|
+
collectionKey:(YapCollectionKey **)collectionKeyPtr
|
|
4782
|
+
forRow:(NSUInteger)row
|
|
4783
|
+
inSection:(NSUInteger)section
|
|
4784
|
+
withMappings:(YapDatabaseViewMappings *)mappings
|
|
4785
|
+
{
|
|
4786
|
+
if (mappings)
|
|
4787
|
+
{
|
|
4788
|
+
NSString *group = nil;
|
|
4789
|
+
NSUInteger index = 0;
|
|
4790
|
+
|
|
4791
|
+
if ([mappings getGroup:&group index:&index forRow:row inSection:section])
|
|
4792
|
+
{
|
|
4793
|
+
int64_t rowid = 0;
|
|
4794
|
+
if ([self getRowid:&rowid atIndex:index inGroup:group])
|
|
4795
|
+
{
|
|
4796
|
+
if (collectionKeyPtr)
|
|
4797
|
+
{
|
|
4798
|
+
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
|
4799
|
+
*collectionKeyPtr = ck;
|
|
4800
|
+
}
|
|
4801
|
+
|
|
4802
|
+
if (rowidPtr) *rowidPtr = rowid;
|
|
4803
|
+
return YES;
|
|
4804
|
+
}
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4808
|
+
if (rowidPtr) *rowidPtr = 0;
|
|
4809
|
+
if (collectionKeyPtr) *collectionKeyPtr = nil;
|
|
4810
|
+
return NO;
|
|
4811
|
+
}
|
|
4812
|
+
|
|
4460
4813
|
/**
|
|
4461
4814
|
* Gets the key & collection at the given indexPath, assuming the given mappings are being used.
|
|
4462
4815
|
* Returns NO if the indexPath is invalid, or the mappings aren't initialized.
|
|
@@ -4467,20 +4820,124 @@
|
|
|
4467
4820
|
atIndexPath:(NSIndexPath *)indexPath
|
|
4468
4821
|
withMappings:(YapDatabaseViewMappings *)mappings
|
|
4469
4822
|
{
|
|
4470
|
-
if (indexPath
|
|
4823
|
+
if (indexPath == nil)
|
|
4471
4824
|
{
|
|
4472
|
-
|
|
4473
|
-
|
|
4825
|
+
if (keyPtr) *keyPtr = nil;
|
|
4826
|
+
if (collectionPtr) *collectionPtr = nil;
|
|
4474
4827
|
|
|
4475
|
-
|
|
4476
|
-
{
|
|
4477
|
-
return [self getKey:keyPtr collection:collectionPtr atIndex:index inGroup:group];
|
|
4478
|
-
}
|
|
4828
|
+
return NO;
|
|
4479
4829
|
}
|
|
4480
4830
|
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4831
|
+
#if TARGET_OS_IPHONE
|
|
4832
|
+
NSUInteger section = indexPath.section;
|
|
4833
|
+
NSUInteger row = indexPath.row;
|
|
4834
|
+
#else
|
|
4835
|
+
NSUInteger section = [indexPath indexAtPosition:0];
|
|
4836
|
+
NSUInteger row = [indexPath indexAtPosition:1];
|
|
4837
|
+
#endif
|
|
4838
|
+
|
|
4839
|
+
YapCollectionKey *ck = nil;
|
|
4840
|
+
BOOL result = [self getRowid:NULL
|
|
4841
|
+
collectionKey:&ck
|
|
4842
|
+
forRow:row
|
|
4843
|
+
inSection:section
|
|
4844
|
+
withMappings:mappings];
|
|
4845
|
+
|
|
4846
|
+
if (keyPtr) *keyPtr = ck.key;
|
|
4847
|
+
if (collectionPtr) *collectionPtr = ck.collection;
|
|
4848
|
+
|
|
4849
|
+
return result;
|
|
4850
|
+
}
|
|
4851
|
+
|
|
4852
|
+
/**
|
|
4853
|
+
* Gets the key & collection at the given row & section, assuming the given mappings are being used.
|
|
4854
|
+
* Returns NO if the row or section is invalid, or the mappings aren't initialized.
|
|
4855
|
+
* Otherwise returns YES, and sets the key & collection ptr (both optional).
|
|
4856
|
+
**/
|
|
4857
|
+
- (BOOL)getKey:(NSString **)keyPtr
|
|
4858
|
+
collection:(NSString **)collectionPtr
|
|
4859
|
+
forRow:(NSUInteger)row
|
|
4860
|
+
inSection:(NSUInteger)section
|
|
4861
|
+
withMappings:(YapDatabaseViewMappings *)mappings
|
|
4862
|
+
{
|
|
4863
|
+
YapCollectionKey *ck = nil;
|
|
4864
|
+
BOOL result = [self getRowid:NULL
|
|
4865
|
+
collectionKey:&ck
|
|
4866
|
+
forRow:row
|
|
4867
|
+
inSection:section
|
|
4868
|
+
withMappings:mappings];
|
|
4869
|
+
|
|
4870
|
+
if (keyPtr) *keyPtr = ck.key;
|
|
4871
|
+
if (collectionPtr) *collectionPtr = ck.collection;
|
|
4872
|
+
|
|
4873
|
+
return result;
|
|
4874
|
+
}
|
|
4875
|
+
|
|
4876
|
+
/**
|
|
4877
|
+
* Gets the object at the given indexPath, assuming the given mappings are being used.
|
|
4878
|
+
*
|
|
4879
|
+
* Equivalent to invoking:
|
|
4880
|
+
*
|
|
4881
|
+
* NSString *collection, *key;
|
|
4882
|
+
* if ([[transaction ext:@"myView"] getKey:&key collection:&collection atIndexPath:indexPath withMappings:mappings]) {
|
|
4883
|
+
* object = [transaction objectForKey:key inCollection:collection];
|
|
4884
|
+
* }
|
|
4885
|
+
**/
|
|
4886
|
+
- (id)objectAtIndexPath:(NSIndexPath *)indexPath withMappings:(YapDatabaseViewMappings *)mappings
|
|
4887
|
+
{
|
|
4888
|
+
if (indexPath == nil)
|
|
4889
|
+
{
|
|
4890
|
+
return nil;
|
|
4891
|
+
}
|
|
4892
|
+
|
|
4893
|
+
#if TARGET_OS_IPHONE
|
|
4894
|
+
NSUInteger section = indexPath.section;
|
|
4895
|
+
NSUInteger row = indexPath.row;
|
|
4896
|
+
#else
|
|
4897
|
+
NSUInteger section = [indexPath indexAtPosition:0];
|
|
4898
|
+
NSUInteger row = [indexPath indexAtPosition:1];
|
|
4899
|
+
#endif
|
|
4900
|
+
|
|
4901
|
+
id object = nil;
|
|
4902
|
+
|
|
4903
|
+
int64_t rowid = 0;
|
|
4904
|
+
YapCollectionKey *ck = nil;
|
|
4905
|
+
|
|
4906
|
+
if ([self getRowid:&rowid collectionKey:&ck forRow:row inSection:section withMappings:mappings])
|
|
4907
|
+
{
|
|
4908
|
+
object = [databaseTransaction objectForCollectionKey:ck withRowid:rowid];
|
|
4909
|
+
}
|
|
4910
|
+
|
|
4911
|
+
return object;
|
|
4912
|
+
}
|
|
4913
|
+
|
|
4914
|
+
/**
|
|
4915
|
+
* Gets the object at the given indexPath, assuming the given mappings are being used.
|
|
4916
|
+
*
|
|
4917
|
+
* Equivalent to invoking:
|
|
4918
|
+
*
|
|
4919
|
+
* NSString *collection, *key;
|
|
4920
|
+
* if ([[transaction ext:@"view"] getKey:&key
|
|
4921
|
+
* collection:&collection
|
|
4922
|
+
* forRow:row
|
|
4923
|
+
* inSection:section
|
|
4924
|
+
* withMappings:mappings]) {
|
|
4925
|
+
* object = [transaction objectForKey:key inCollection:collection];
|
|
4926
|
+
* }
|
|
4927
|
+
**/
|
|
4928
|
+
- (id)objectAtRow:(NSUInteger)row inSection:(NSUInteger)section withMappings:(YapDatabaseViewMappings *)mappings
|
|
4929
|
+
{
|
|
4930
|
+
id object = nil;
|
|
4931
|
+
|
|
4932
|
+
int64_t rowid = 0;
|
|
4933
|
+
YapCollectionKey *ck = nil;
|
|
4934
|
+
|
|
4935
|
+
if ([self getRowid:&rowid collectionKey:&ck forRow:row inSection:section withMappings:mappings])
|
|
4936
|
+
{
|
|
4937
|
+
object = [databaseTransaction objectForCollectionKey:ck withRowid:rowid];
|
|
4938
|
+
}
|
|
4939
|
+
|
|
4940
|
+
return object;
|
|
4484
4941
|
}
|
|
4485
4942
|
|
|
4486
4943
|
/**
|
|
@@ -4502,4 +4959,28 @@
|
|
|
4502
4959
|
return nil;
|
|
4503
4960
|
}
|
|
4504
4961
|
|
|
4962
|
+
/**
|
|
4963
|
+
* Fetches the row & section for the given {collection, key} tuple, assuming the given mappings are being used.
|
|
4964
|
+
* Returns NO if the {collection, key} tuple isn't included in the view + mappings.
|
|
4965
|
+
* Otherwise returns YES, and sets the row & section (both optional).
|
|
4966
|
+
**/
|
|
4967
|
+
- (BOOL)getRow:(NSUInteger *)rowPtr
|
|
4968
|
+
section:(NSUInteger *)sectionPtr
|
|
4969
|
+
forKey:(NSString *)key
|
|
4970
|
+
inCollection:(NSString *)collection
|
|
4971
|
+
withMappings:(YapDatabaseViewMappings *)mappings
|
|
4972
|
+
{
|
|
4973
|
+
NSString *group = nil;
|
|
4974
|
+
NSUInteger index = 0;
|
|
4975
|
+
|
|
4976
|
+
if ([self getGroup:&group index:&index forKey:key inCollection:collection])
|
|
4977
|
+
{
|
|
4978
|
+
return [mappings getRow:rowPtr section:sectionPtr forIndex:index inGroup:group];
|
|
4979
|
+
}
|
|
4980
|
+
|
|
4981
|
+
if (rowPtr) *rowPtr = 0;
|
|
4982
|
+
if (sectionPtr) *sectionPtr = 0;
|
|
4983
|
+
return NO;
|
|
4984
|
+
}
|
|
4985
|
+
|
|
4505
4986
|
@end
|