motion-yapper 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +3 -1
- data/lib/yapper.rb +3 -3
- data/lib/yapper/db.rb +61 -4
- data/lib/yapper/document/persistence.rb +4 -0
- data/lib/yapper/document/selection.rb +13 -0
- data/lib/yapper/version.rb +1 -1
- data/motion-yapper.gemspec +1 -1
- data/spec/integration/search_spec.rb +111 -0
- data/vendor/Podfile.lock +11 -7
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -2
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +10 -7
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -2
- metadata +19 -297
- 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 +0 -41
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +0 -102
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h +0 -63
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDDispatchQueueLogFormatter.h +0 -128
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +0 -369
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +0 -99
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +0 -634
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +0 -30
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +0 -181
- data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
- data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +0 -8
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +0 -91
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +0 -23
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +0 -547
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +0 -449
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +0 -29
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +0 -37
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +0 -15
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +0 -11
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +0 -444
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +0 -11
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +0 -81
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +0 -12
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -17
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +0 -39
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +0 -32
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +0 -89
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +0 -32
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -77
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +0 -68
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +0 -158
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +0 -17
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +0 -446
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +0 -42
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +0 -35
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +0 -29
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +0 -163
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +0 -79
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +0 -99
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +0 -59
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +0 -125
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +0 -384
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +0 -149
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +0 -33
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -83
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +0 -33
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +0 -18
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +0 -58
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +0 -13
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +0 -121
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +0 -651
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +0 -127
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +0 -272
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +0 -116
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +0 -842
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +0 -63
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +0 -36
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +0 -170
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +0 -330
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +0 -498
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +0 -99
- data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +0 -74
- data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +0 -17
- data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +0 -41
- data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +0 -15
- data/vendor/Pods/CocoaLumberjack/LICENSE.txt +0 -18
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +0 -41
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +0 -100
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +0 -102
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +0 -727
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +0 -369
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +0 -1539
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +0 -99
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +0 -634
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +0 -1208
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +0 -181
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +0 -1520
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h +0 -63
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.m +0 -191
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.h +0 -128
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +0 -253
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +0 -30
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +0 -127
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +0 -7
- data/vendor/Pods/CocoaLumberjack/README.markdown +0 -74
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +0 -41
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +0 -102
- data/vendor/Pods/Headers/CocoaLumberjack/DDContextFilterLogFormatter.h +0 -63
- data/vendor/Pods/Headers/CocoaLumberjack/DDDispatchQueueLogFormatter.h +0 -128
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +0 -369
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +0 -99
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +0 -634
- data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +0 -30
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +0 -181
- data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +0 -23
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +0 -547
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +0 -449
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +0 -15
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +0 -11
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +0 -11
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +0 -81
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +0 -12
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +0 -39
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +0 -32
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +0 -89
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +0 -32
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +0 -68
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +0 -42
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +0 -35
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +0 -29
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +0 -163
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +0 -99
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +0 -59
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +0 -384
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +0 -149
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +0 -33
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +0 -33
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +0 -58
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +0 -651
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +0 -127
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +0 -272
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +0 -116
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +0 -842
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +0 -63
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +0 -330
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +0 -498
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +0 -99
- data/vendor/Pods/Headers/YapDatabase/YapSet.h +0 -41
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +0 -7
- data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +0 -5
- data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +0 -5
- data/vendor/Pods/Headers/____Pods-environment.h +0 -38
- data/vendor/Pods/Manifest.lock +0 -22
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +0 -39
- data/vendor/Pods/NSData+MD5Digest/README.md +0 -11
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +0 -5
- data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +0 -5
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +0 -7
- data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +0 -5
- data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +0 -5
- data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +0 -5
- data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +0 -5
- data/vendor/Pods/Pods-YapDatabase-dummy.m +0 -5
- data/vendor/Pods/Pods-YapDatabase-prefix.pch +0 -5
- data/vendor/Pods/Pods-YapDatabase.xcconfig +0 -1
- data/vendor/Pods/Pods-acknowledgements.markdown +0 -59
- data/vendor/Pods/Pods-acknowledgements.plist +0 -97
- data/vendor/Pods/Pods-dummy.m +0 -5
- data/vendor/Pods/Pods-environment.h +0 -38
- data/vendor/Pods/Pods-resources.sh +0 -68
- data/vendor/Pods/Pods.xcconfig +0 -5
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +0 -4807
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +0 -59
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +0 -59
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +0 -59
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +0 -59
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +0 -31
- data/vendor/Pods/YapDatabase/LICENSE.txt +0 -18
- data/vendor/Pods/YapDatabase/README.md +0 -32
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -17
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +0 -81
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +0 -159
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +0 -12
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +0 -41
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +0 -39
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +0 -1235
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +0 -32
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +0 -77
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +0 -89
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +0 -146
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +0 -32
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +0 -298
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +0 -95
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +0 -68
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +0 -1403
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +0 -444
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +0 -15
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +0 -83
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +0 -11
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +0 -46
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +0 -11
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +0 -204
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +0 -79
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +0 -125
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +0 -35
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +0 -129
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +0 -29
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +0 -802
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +0 -163
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +0 -408
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +0 -99
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +0 -59
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +0 -29
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +0 -384
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +0 -5254
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +0 -83
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +0 -18
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +0 -149
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +0 -161
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +0 -33
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +0 -331
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +0 -33
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +0 -245
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +0 -58
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +0 -1269
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +0 -94
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +0 -72
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +0 -36
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +0 -296
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +0 -27
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +0 -28
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +0 -170
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +0 -17
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +0 -272
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +0 -2500
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +0 -842
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +0 -1714
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +0 -330
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +0 -141
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +0 -127
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +0 -194
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +0 -116
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +0 -888
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +0 -63
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +0 -27
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +0 -498
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +0 -4986
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +0 -99
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +0 -8
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +0 -19
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +0 -91
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +0 -465
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +0 -29
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +0 -48
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +0 -37
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +0 -83
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +0 -158
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +0 -73
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +0 -17
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +0 -56
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +0 -446
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +0 -13
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +0 -26
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +0 -121
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +0 -74
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +0 -603
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +0 -17
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +0 -35
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +0 -15
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +0 -31
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +0 -23
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +0 -199
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +0 -42
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +0 -96
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +0 -41
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +0 -82
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +0 -547
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +0 -2013
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +0 -449
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +0 -4046
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +0 -651
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +0 -5602
- data/vendor/Pods/build-iPhoneSimulator/Pods.bridgesupport +0 -3172
- data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
@@ -1,79 +0,0 @@
|
|
1
|
-
#import <Foundation/Foundation.h>
|
2
|
-
|
3
|
-
/**
|
4
|
-
* This class represents options that may be passed to the FTS snippet function.
|
5
|
-
*
|
6
|
-
* It correlates with the snippet funtion arguments as defined in sqlite's FTS module:
|
7
|
-
* http://www.sqlite.org/fts3.html#section_4_2
|
8
|
-
*
|
9
|
-
* For example, if you were searching for the word "favorite",
|
10
|
-
* then a returned snippet may look something like this:
|
11
|
-
*
|
12
|
-
* <b>...</b>one of my <b>favorite</b> cheese pairings is<b>...</b>
|
13
|
-
**/
|
14
|
-
@interface YapDatabaseFullTextSearchSnippetOptions : NSObject <NSCopying>
|
15
|
-
|
16
|
-
|
17
|
-
+ (NSString *)defaultStartMatchText; // @"<b>"
|
18
|
-
+ (NSString *)defaultEndMatchText; // @"</b>"
|
19
|
-
+ (NSString *)defaultEllipsesText; // @"..."
|
20
|
-
|
21
|
-
+ (int)defaultNumberOfTokens; // 15
|
22
|
-
|
23
|
-
- (id)init;
|
24
|
-
|
25
|
-
/**
|
26
|
-
* The startMatchText is inserted before matched terms/phrases, and also before injected ellipses text.
|
27
|
-
* It is used to mark the beginning of special text within the snippet.
|
28
|
-
*
|
29
|
-
* If not set, it will be the defaultStartMatchText: @"<b>"
|
30
|
-
*
|
31
|
-
* @see defaultStartMatchText
|
32
|
-
**/
|
33
|
-
@property (nonatomic, copy) NSString *startMatchText;
|
34
|
-
|
35
|
-
/**
|
36
|
-
* The endMatchText is inserted after matched terms/phrases, and also after injected ellipses text.
|
37
|
-
* It is used to mark the end of special text within the snippet.
|
38
|
-
*
|
39
|
-
* If not set, it will be the defaultEndMatchText: @"</b>"
|
40
|
-
*
|
41
|
-
* @see defaultEndMatchText
|
42
|
-
**/
|
43
|
-
@property (nonatomic, copy) NSString *endMatchText;
|
44
|
-
|
45
|
-
/**
|
46
|
-
* If the full text from the column is too big, the snippets will be a small subsection of the snippet,
|
47
|
-
* centered on matching terms/phrases. When this occurs, and the snippet is truncated on the left and/or right,
|
48
|
-
* then the ellipsesText will be inserted on the left and/or right.
|
49
|
-
*
|
50
|
-
* If not set, it will be the defaultEllipsesText: @"…"
|
51
|
-
*
|
52
|
-
* @see defaultEllipsesText
|
53
|
-
* @see numberOfTokens
|
54
|
-
**/
|
55
|
-
@property (nonatomic, copy) NSString *ellipsesText;
|
56
|
-
|
57
|
-
/**
|
58
|
-
* The column name from which to extract the returned fragments of text from.
|
59
|
-
* If nil, then the text may be extracted from any column.
|
60
|
-
*
|
61
|
-
* If not set, the default value is nil.
|
62
|
-
**/
|
63
|
-
@property (nonatomic, copy) NSString *columnName;
|
64
|
-
|
65
|
-
/**
|
66
|
-
* The numberOfTokens is used as the (approximate) number of tokens to include in the returned snippet text value.
|
67
|
-
*
|
68
|
-
* If not set, it will be defaultNumberOfTokens: 15
|
69
|
-
*
|
70
|
-
* Setting this to a value of zero resets the value to the default.
|
71
|
-
* Negative values are allowed, as the snippet function automatically uses the absolute value.
|
72
|
-
*
|
73
|
-
* The maximum allowable absolute value is 64.
|
74
|
-
*
|
75
|
-
* @see defaultNumberOfTokens
|
76
|
-
**/
|
77
|
-
@property (nonatomic, assign) int numberOfTokens;
|
78
|
-
|
79
|
-
@end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
#import "YapDatabaseFullTextSearchSnippetOptions.h"
|
2
|
-
|
3
|
-
|
4
|
-
@implementation YapDatabaseFullTextSearchSnippetOptions
|
5
|
-
|
6
|
-
+ (NSString *)defaultStartMatchText {
|
7
|
-
return @"<b>";
|
8
|
-
}
|
9
|
-
|
10
|
-
+ (NSString *)defaultEndMatchText {
|
11
|
-
return @"</b>";
|
12
|
-
}
|
13
|
-
|
14
|
-
+ (NSString *)defaultEllipsesText {
|
15
|
-
return @"...";
|
16
|
-
}
|
17
|
-
|
18
|
-
+ (int)defaultNumberOfTokens {
|
19
|
-
return 15;
|
20
|
-
}
|
21
|
-
|
22
|
-
@synthesize startMatchText = startMatchText;
|
23
|
-
@synthesize endMatchText = endMatchText;
|
24
|
-
@synthesize ellipsesText = ellipsesText;
|
25
|
-
@synthesize columnName = columnName;
|
26
|
-
@synthesize numberOfTokens = numberOfTokens;
|
27
|
-
|
28
|
-
- (id)init
|
29
|
-
{
|
30
|
-
if ((self = [super init]))
|
31
|
-
{
|
32
|
-
startMatchText = [[self class] defaultStartMatchText];
|
33
|
-
endMatchText = [[self class] defaultEndMatchText];
|
34
|
-
ellipsesText = [[self class] defaultEllipsesText];
|
35
|
-
|
36
|
-
numberOfTokens = [[self class] defaultNumberOfTokens];
|
37
|
-
}
|
38
|
-
return self;
|
39
|
-
}
|
40
|
-
|
41
|
-
- (id)initForCopy
|
42
|
-
{
|
43
|
-
if ((self = [super init]))
|
44
|
-
{
|
45
|
-
// copyWithZone will fill out values for us
|
46
|
-
}
|
47
|
-
return self;
|
48
|
-
}
|
49
|
-
|
50
|
-
- (id)copyWithZone:(NSZone *)zone
|
51
|
-
{
|
52
|
-
YapDatabaseFullTextSearchSnippetOptions *copy = [[YapDatabaseFullTextSearchSnippetOptions alloc] initForCopy];
|
53
|
-
|
54
|
-
copy->startMatchText = startMatchText;
|
55
|
-
copy->endMatchText = endMatchText;
|
56
|
-
copy->ellipsesText = ellipsesText;
|
57
|
-
copy->columnName = columnName;
|
58
|
-
copy->numberOfTokens = numberOfTokens;
|
59
|
-
|
60
|
-
return copy;
|
61
|
-
}
|
62
|
-
|
63
|
-
- (void)setStartMatchText:(NSString *)text
|
64
|
-
{
|
65
|
-
if (text)
|
66
|
-
startMatchText = [text copy];
|
67
|
-
else
|
68
|
-
startMatchText = [[self class] defaultStartMatchText];
|
69
|
-
}
|
70
|
-
|
71
|
-
- (void)setEndMatchText:(NSString *)text
|
72
|
-
{
|
73
|
-
if (text)
|
74
|
-
endMatchText = [text copy];
|
75
|
-
else
|
76
|
-
endMatchText = [[self class] defaultEndMatchText];
|
77
|
-
}
|
78
|
-
|
79
|
-
- (void)setEllipsesText:(NSString *)text
|
80
|
-
{
|
81
|
-
if (text)
|
82
|
-
ellipsesText = [text copy];
|
83
|
-
else
|
84
|
-
ellipsesText = [[self class] defaultEllipsesText];
|
85
|
-
}
|
86
|
-
|
87
|
-
- (void)setNumberOfTokens:(int)count
|
88
|
-
{
|
89
|
-
if (count != 0)
|
90
|
-
numberOfTokens = count;
|
91
|
-
else
|
92
|
-
numberOfTokens = [[self class] defaultNumberOfTokens];
|
93
|
-
}
|
94
|
-
|
95
|
-
@end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
#import <Foundation/Foundation.h>
|
2
|
-
|
3
|
-
#import "YapDatabaseExtensionTransaction.h"
|
4
|
-
#import "YapDatabaseFullTextSearchSnippetOptions.h"
|
5
|
-
|
6
|
-
|
7
|
-
/**
|
8
|
-
* Welcome to YapDatabase!
|
9
|
-
*
|
10
|
-
* The project page has a wealth of documentation if you have any questions.
|
11
|
-
* https://github.com/yaptv/YapDatabase
|
12
|
-
*
|
13
|
-
* If you're new to the project you may want to check out the wiki
|
14
|
-
* https://github.com/yaptv/YapDatabase/wiki
|
15
|
-
*
|
16
|
-
* YapDatabaseFullTextSearch is an extension for performing text based search.
|
17
|
-
* Internally it uses sqlite's FTS module which was contributed by Google.
|
18
|
-
*
|
19
|
-
* After registering the extension, you can access this class within a regular transaction.
|
20
|
-
* For example:
|
21
|
-
*
|
22
|
-
* [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction){
|
23
|
-
*
|
24
|
-
* [[transaction ext:@"mySearch"] enumerateKeysMatching:@"birthday party"
|
25
|
-
* usingBlock:^(NSString *collection, NSString *key, BOOL *stop){
|
26
|
-
* // matching row...
|
27
|
-
* }]
|
28
|
-
* }];
|
29
|
-
**/
|
30
|
-
@interface YapDatabaseFullTextSearchTransaction : YapDatabaseExtensionTransaction
|
31
|
-
|
32
|
-
// Regular query matching
|
33
|
-
|
34
|
-
- (void)enumerateKeysMatching:(NSString *)query
|
35
|
-
usingBlock:(void (^)(NSString *collection, NSString *key, BOOL *stop))block;
|
36
|
-
|
37
|
-
- (void)enumerateKeysAndMetadataMatching:(NSString *)query
|
38
|
-
usingBlock:(void (^)(NSString *collection, NSString *key, id metadata, BOOL *stop))block;
|
39
|
-
|
40
|
-
- (void)enumerateKeysAndObjectsMatching:(NSString *)query
|
41
|
-
usingBlock:(void (^)(NSString *collection, NSString *key, id object, BOOL *stop))block;
|
42
|
-
|
43
|
-
- (void)enumerateRowsMatching:(NSString *)query
|
44
|
-
usingBlock:(void (^)(NSString *collection, NSString *key, id object, id metadata, BOOL *stop))block;
|
45
|
-
|
46
|
-
// Query matching + Snippets
|
47
|
-
|
48
|
-
- (void)enumerateKeysMatching:(NSString *)query
|
49
|
-
withSnippetOptions:(YapDatabaseFullTextSearchSnippetOptions *)options
|
50
|
-
usingBlock:
|
51
|
-
(void (^)(NSString *snippet, NSString *collection, NSString *key, BOOL *stop))block;
|
52
|
-
|
53
|
-
- (void)enumerateKeysAndMetadataMatching:(NSString *)query
|
54
|
-
withSnippetOptions:(YapDatabaseFullTextSearchSnippetOptions *)options
|
55
|
-
usingBlock:
|
56
|
-
(void (^)(NSString *snippet, NSString *collection, NSString *key, id metadata, BOOL *stop))block;
|
57
|
-
|
58
|
-
- (void)enumerateKeysAndObjectsMatching:(NSString *)query
|
59
|
-
withSnippetOptions:(YapDatabaseFullTextSearchSnippetOptions *)options
|
60
|
-
usingBlock:
|
61
|
-
(void (^)(NSString *snippet, NSString *collection, NSString *key, id object, BOOL *stop))block;
|
62
|
-
|
63
|
-
- (void)enumerateRowsMatching:(NSString *)query
|
64
|
-
withSnippetOptions:(YapDatabaseFullTextSearchSnippetOptions *)options
|
65
|
-
usingBlock:
|
66
|
-
(void (^)(NSString *snippet, NSString *collection, NSString *key, id object, id metadata, BOOL *stop))block;
|
67
|
-
|
68
|
-
@end
|
@@ -1,1403 +0,0 @@
|
|
1
|
-
#import "YapDatabaseFullTextSearchTransaction.h"
|
2
|
-
#import "YapDatabaseFullTextSearchPrivate.h"
|
3
|
-
#import "YapDatabaseExtensionPrivate.h"
|
4
|
-
#import "YapDatabasePrivate.h"
|
5
|
-
#import "YapDatabaseString.h"
|
6
|
-
#import "YapDatabaseLogging.h"
|
7
|
-
|
8
|
-
#if ! __has_feature(objc_arc)
|
9
|
-
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
|
10
|
-
#endif
|
11
|
-
|
12
|
-
/**
|
13
|
-
* Define log level for this file: OFF, ERROR, WARN, INFO, VERBOSE
|
14
|
-
* See YapDatabaseLogging.h for more information.
|
15
|
-
**/
|
16
|
-
#if DEBUG
|
17
|
-
static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
|
18
|
-
#else
|
19
|
-
static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
|
20
|
-
#endif
|
21
|
-
|
22
|
-
/**
|
23
|
-
* Declare that this class implements YapDatabaseExtensionTransaction_Hooks protocol.
|
24
|
-
* This is done privately, as the protocol is internal.
|
25
|
-
**/
|
26
|
-
@interface YapDatabaseFullTextSearchTransaction () <YapDatabaseExtensionTransaction_Hooks>
|
27
|
-
@end
|
28
|
-
|
29
|
-
|
30
|
-
@implementation YapDatabaseFullTextSearchTransaction
|
31
|
-
|
32
|
-
- (id)initWithFTSConnection:(YapDatabaseFullTextSearchConnection *)inFTSConnection
|
33
|
-
databaseTransaction:(YapDatabaseReadTransaction *)inDatabaseTransaction
|
34
|
-
{
|
35
|
-
if ((self = [super init]))
|
36
|
-
{
|
37
|
-
ftsConnection = inFTSConnection;
|
38
|
-
databaseTransaction = inDatabaseTransaction;
|
39
|
-
}
|
40
|
-
return self;
|
41
|
-
}
|
42
|
-
|
43
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
44
|
-
#pragma mark Extension Lifecycle
|
45
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Required override method from YapDatabaseExtensionTransaction.
|
49
|
-
*
|
50
|
-
* This method is called to create any necessary tables (if needed),
|
51
|
-
* as well as populate the view (if needed) by enumerating over the existing rows in the database.
|
52
|
-
**/
|
53
|
-
- (BOOL)createIfNeeded
|
54
|
-
{
|
55
|
-
int oldClassVersion = 0;
|
56
|
-
BOOL hasOldClassVersion = [self getIntValue:&oldClassVersion forExtensionKey:@"classVersion"];
|
57
|
-
int classVersion = YAP_DATABASE_FTS_CLASS_VERSION;
|
58
|
-
|
59
|
-
if (oldClassVersion != classVersion)
|
60
|
-
{
|
61
|
-
// First time registration (or at least for this version)
|
62
|
-
|
63
|
-
if (hasOldClassVersion) {
|
64
|
-
if (![self dropTable]) return NO;
|
65
|
-
}
|
66
|
-
|
67
|
-
if (![self createTable]) return NO;
|
68
|
-
if (![self populate]) return NO;
|
69
|
-
|
70
|
-
[self setIntValue:classVersion forExtensionKey:@"classVersion"];
|
71
|
-
|
72
|
-
int userSuppliedConfigVersion = ftsConnection->fts->version;
|
73
|
-
[self setIntValue:userSuppliedConfigVersion forExtensionKey:@"version"];
|
74
|
-
}
|
75
|
-
else
|
76
|
-
{
|
77
|
-
// Check user-supplied config version.
|
78
|
-
// We may need to re-populate the database if the groupingBlock or sortingBlock changed.
|
79
|
-
|
80
|
-
int oldVersion = [self intValueForExtensionKey:@"version"];
|
81
|
-
int newVersion = ftsConnection->fts->version;
|
82
|
-
|
83
|
-
if (oldVersion != newVersion)
|
84
|
-
{
|
85
|
-
if (![self dropTable]) return NO;
|
86
|
-
if (![self createTable]) return NO;
|
87
|
-
if (![self populate]) return NO;
|
88
|
-
|
89
|
-
[self setIntValue:newVersion forExtensionKey:@"version"];
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
return YES;
|
94
|
-
}
|
95
|
-
|
96
|
-
/**
|
97
|
-
* Required override method from YapDatabaseExtensionTransaction.
|
98
|
-
*
|
99
|
-
* This method is called to prepare the transaction for use.
|
100
|
-
*
|
101
|
-
* Remember, an extension transaction is a very short lived object.
|
102
|
-
* Thus it stores the majority of its state within the extension connection (the parent).
|
103
|
-
*
|
104
|
-
* Return YES if completed successfully, or if already prepared.
|
105
|
-
* Return NO if some kind of error occured.
|
106
|
-
**/
|
107
|
-
- (BOOL)prepareIfNeeded
|
108
|
-
{
|
109
|
-
return YES;
|
110
|
-
}
|
111
|
-
|
112
|
-
/**
|
113
|
-
* Internal method.
|
114
|
-
*
|
115
|
-
* This method is called, if needed, to drop the old table.
|
116
|
-
**/
|
117
|
-
- (BOOL)dropTable
|
118
|
-
{
|
119
|
-
sqlite3 *db = databaseTransaction->connection->db;
|
120
|
-
|
121
|
-
NSString *tableName = [self tableName];
|
122
|
-
NSString *dropTable = [NSString stringWithFormat:@"DROP TABLE IF EXISTS \"%@\";", tableName];
|
123
|
-
|
124
|
-
int status = sqlite3_exec(db, [dropTable UTF8String], NULL, NULL, NULL);
|
125
|
-
if (status != SQLITE_OK)
|
126
|
-
{
|
127
|
-
YDBLogError(@"%@ - Failed dropping FTS table (%@): %d %s",
|
128
|
-
THIS_METHOD, dropTable, status, sqlite3_errmsg(db));
|
129
|
-
return NO;
|
130
|
-
}
|
131
|
-
|
132
|
-
return YES;
|
133
|
-
}
|
134
|
-
|
135
|
-
/**
|
136
|
-
* Internal method.
|
137
|
-
*
|
138
|
-
* This method is called, if needed, to create the tables for the view.
|
139
|
-
**/
|
140
|
-
- (BOOL)createTable
|
141
|
-
{
|
142
|
-
sqlite3 *db = databaseTransaction->connection->db;
|
143
|
-
|
144
|
-
NSString *tableName = [self tableName];
|
145
|
-
|
146
|
-
YDBLogVerbose(@"Creating FTS table for registeredName(%@): %@", [self registeredName], tableName);
|
147
|
-
|
148
|
-
// CREATE VIRTUAL TABLE pages USING fts4(column1, column2, column3);
|
149
|
-
|
150
|
-
NSMutableString *createTable = [NSMutableString stringWithCapacity:100];
|
151
|
-
[createTable appendFormat:@"CREATE VIRTUAL TABLE IF NOT EXISTS \"%@\" USING fts4(", tableName];
|
152
|
-
|
153
|
-
__block NSUInteger i = 0;
|
154
|
-
|
155
|
-
NSOrderedSet *columnNames = ftsConnection->fts->columnNames;
|
156
|
-
for (NSString *columnName in columnNames)
|
157
|
-
{
|
158
|
-
if (i == 0)
|
159
|
-
[createTable appendFormat:@"\"%@\"", columnName];
|
160
|
-
else
|
161
|
-
[createTable appendFormat:@", \"%@\"", columnName];
|
162
|
-
|
163
|
-
i++;
|
164
|
-
}
|
165
|
-
|
166
|
-
NSDictionary *options = ftsConnection->fts->options;
|
167
|
-
[options enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
168
|
-
|
169
|
-
NSString *option = (NSString *)key;
|
170
|
-
NSString *value = (NSString *)obj;
|
171
|
-
|
172
|
-
if (i == 0)
|
173
|
-
[createTable appendFormat:@"%@=%@", option, value];
|
174
|
-
else
|
175
|
-
[createTable appendFormat:@", %@=%@", option, value];
|
176
|
-
|
177
|
-
i++;
|
178
|
-
}];
|
179
|
-
|
180
|
-
[createTable appendString:@");"];
|
181
|
-
|
182
|
-
int status = sqlite3_exec(db, [createTable UTF8String], NULL, NULL, NULL);
|
183
|
-
if (status != SQLITE_OK)
|
184
|
-
{
|
185
|
-
YDBLogError(@"%@ - Failed creating FTS table (%@): %d %s",
|
186
|
-
THIS_METHOD, tableName, status, sqlite3_errmsg(db));
|
187
|
-
return NO;
|
188
|
-
}
|
189
|
-
|
190
|
-
return YES;
|
191
|
-
}
|
192
|
-
|
193
|
-
/**
|
194
|
-
* Internal method.
|
195
|
-
*
|
196
|
-
* This method is called, if needed, to populate the FTS indexes.
|
197
|
-
* It does so by enumerating the rows in the database, and invoking the usual blocks and insertion methods.
|
198
|
-
**/
|
199
|
-
- (BOOL)populate
|
200
|
-
{
|
201
|
-
// Remove everything from the database
|
202
|
-
|
203
|
-
[self removeAllRowids];
|
204
|
-
|
205
|
-
// Enumerate the existing rows in the database and populate the indexes
|
206
|
-
|
207
|
-
__unsafe_unretained YapDatabaseFullTextSearch *fts = ftsConnection->fts;
|
208
|
-
|
209
|
-
BOOL needsObject = fts->blockType == YapDatabaseFullTextSearchBlockTypeWithObject ||
|
210
|
-
fts->blockType == YapDatabaseFullTextSearchBlockTypeWithRow;
|
211
|
-
|
212
|
-
BOOL needsMetadata = fts->blockType == YapDatabaseFullTextSearchBlockTypeWithMetadata ||
|
213
|
-
fts->blockType == YapDatabaseFullTextSearchBlockTypeWithRow;
|
214
|
-
|
215
|
-
if (needsObject && needsMetadata)
|
216
|
-
{
|
217
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithRowBlock block =
|
218
|
-
(YapDatabaseFullTextSearchWithRowBlock)fts->block;
|
219
|
-
|
220
|
-
[databaseTransaction _enumerateRowsInAllCollectionsUsingBlock:
|
221
|
-
^(int64_t rowid, NSString *collection, NSString *key, id object, id metadata, BOOL *stop) {
|
222
|
-
|
223
|
-
block(ftsConnection->blockDict, collection, key, object, metadata);
|
224
|
-
|
225
|
-
if ([ftsConnection->blockDict count] > 0)
|
226
|
-
{
|
227
|
-
[self addRowid:rowid isNew:YES];
|
228
|
-
[ftsConnection->blockDict removeAllObjects];
|
229
|
-
}
|
230
|
-
}];
|
231
|
-
}
|
232
|
-
else if (needsObject && !needsMetadata)
|
233
|
-
{
|
234
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithObjectBlock block =
|
235
|
-
(YapDatabaseFullTextSearchWithObjectBlock)fts->block;
|
236
|
-
|
237
|
-
[databaseTransaction _enumerateKeysAndObjectsInAllCollectionsUsingBlock:
|
238
|
-
^(int64_t rowid, NSString *collection, NSString *key, id object, BOOL *stop) {
|
239
|
-
|
240
|
-
block(ftsConnection->blockDict, collection, key, object);
|
241
|
-
|
242
|
-
if ([ftsConnection->blockDict count] > 0)
|
243
|
-
{
|
244
|
-
[self addRowid:rowid isNew:YES];
|
245
|
-
[ftsConnection->blockDict removeAllObjects];
|
246
|
-
}
|
247
|
-
}];
|
248
|
-
}
|
249
|
-
else if (!needsObject && needsMetadata)
|
250
|
-
{
|
251
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithMetadataBlock block =
|
252
|
-
(YapDatabaseFullTextSearchWithMetadataBlock)fts->block;
|
253
|
-
|
254
|
-
[databaseTransaction _enumerateKeysAndMetadataInAllCollectionsUsingBlock:
|
255
|
-
^(int64_t rowid, NSString *collection, NSString *key, id metadata, BOOL *stop) {
|
256
|
-
|
257
|
-
block(ftsConnection->blockDict, collection, key, metadata);
|
258
|
-
|
259
|
-
if ([ftsConnection->blockDict count] > 0)
|
260
|
-
{
|
261
|
-
[self addRowid:rowid isNew:YES];
|
262
|
-
[ftsConnection->blockDict removeAllObjects];
|
263
|
-
}
|
264
|
-
}];
|
265
|
-
}
|
266
|
-
else // if (!needsObject && !needsMetadata)
|
267
|
-
{
|
268
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithKeyBlock block =
|
269
|
-
(YapDatabaseFullTextSearchWithKeyBlock)fts->block;
|
270
|
-
|
271
|
-
[databaseTransaction _enumerateKeysInAllCollectionsUsingBlock:
|
272
|
-
^(int64_t rowid, NSString *collection, NSString *key, BOOL *stop) {
|
273
|
-
|
274
|
-
block(ftsConnection->blockDict, collection, key);
|
275
|
-
|
276
|
-
if ([ftsConnection->blockDict count] > 0)
|
277
|
-
{
|
278
|
-
[self addRowid:rowid isNew:YES];
|
279
|
-
[ftsConnection->blockDict removeAllObjects];
|
280
|
-
}
|
281
|
-
}];
|
282
|
-
}
|
283
|
-
|
284
|
-
return YES;
|
285
|
-
}
|
286
|
-
|
287
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
288
|
-
#pragma mark Accessors
|
289
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
290
|
-
|
291
|
-
/**
|
292
|
-
* Required override method from YapDatabaseExtensionTransaction.
|
293
|
-
**/
|
294
|
-
- (YapDatabaseReadTransaction *)databaseTransaction
|
295
|
-
{
|
296
|
-
return databaseTransaction;
|
297
|
-
}
|
298
|
-
|
299
|
-
/**
|
300
|
-
* Required override method from YapDatabaseExtensionTransaction.
|
301
|
-
**/
|
302
|
-
- (YapDatabaseExtensionConnection *)extensionConnection
|
303
|
-
{
|
304
|
-
return ftsConnection;
|
305
|
-
}
|
306
|
-
|
307
|
-
- (NSString *)registeredName
|
308
|
-
{
|
309
|
-
return [ftsConnection->fts registeredName];
|
310
|
-
}
|
311
|
-
|
312
|
-
- (NSString *)tableName
|
313
|
-
{
|
314
|
-
return [ftsConnection->fts tableName];
|
315
|
-
}
|
316
|
-
|
317
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
318
|
-
#pragma mark Logic
|
319
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
320
|
-
|
321
|
-
- (void)addRowid:(int64_t)rowid isNew:(BOOL)isNew
|
322
|
-
{
|
323
|
-
YDBLogAutoTrace();
|
324
|
-
|
325
|
-
sqlite3_stmt *statement = NULL;
|
326
|
-
if (isNew)
|
327
|
-
statement = [ftsConnection insertRowidStatement];
|
328
|
-
else
|
329
|
-
statement = [ftsConnection setRowidStatement];
|
330
|
-
|
331
|
-
if (statement == NULL)
|
332
|
-
return;
|
333
|
-
|
334
|
-
// isNew : INSERT INTO "tableName" ("rowid", "column1", "column2", ...) VALUES (?, ?, ? ...)
|
335
|
-
// !isNew : INSERT OR REPLACE INTO "tableName" ("rowid", "column1", "column2", ...) VALUES (?, ?, ? ...)
|
336
|
-
|
337
|
-
sqlite3_bind_int64(statement, 1, rowid);
|
338
|
-
|
339
|
-
int i = 2;
|
340
|
-
for (NSString *columnName in ftsConnection->fts->columnNames)
|
341
|
-
{
|
342
|
-
NSString *columnValue = [ftsConnection->blockDict objectForKey:columnName];
|
343
|
-
if (columnValue)
|
344
|
-
{
|
345
|
-
sqlite3_bind_text(statement, i, [columnValue UTF8String], -1, SQLITE_TRANSIENT);
|
346
|
-
}
|
347
|
-
|
348
|
-
i++;
|
349
|
-
}
|
350
|
-
|
351
|
-
int status = sqlite3_step(statement);
|
352
|
-
if (status != SQLITE_DONE)
|
353
|
-
{
|
354
|
-
YDBLogError(@"Error executing '%s': %d %s",
|
355
|
-
isNew ? "insertRowidStatement" : "setRowidStatement",
|
356
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
357
|
-
}
|
358
|
-
|
359
|
-
sqlite3_clear_bindings(statement);
|
360
|
-
sqlite3_reset(statement);
|
361
|
-
|
362
|
-
isMutated = YES;
|
363
|
-
}
|
364
|
-
|
365
|
-
- (void)removeRowid:(int64_t)rowid
|
366
|
-
{
|
367
|
-
YDBLogAutoTrace();
|
368
|
-
|
369
|
-
sqlite3_stmt *statement = [ftsConnection removeRowidStatement];
|
370
|
-
if (statement == NULL) return;
|
371
|
-
|
372
|
-
// DELETE FROM "tableName" WHERE "rowid" = ?;
|
373
|
-
|
374
|
-
sqlite3_bind_int64(statement, 1, rowid);
|
375
|
-
|
376
|
-
int status = sqlite3_step(statement);
|
377
|
-
if (status != SQLITE_DONE)
|
378
|
-
{
|
379
|
-
YDBLogError(@"Error executing 'removeRowidStatement': %d %s",
|
380
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
381
|
-
}
|
382
|
-
|
383
|
-
sqlite3_clear_bindings(statement);
|
384
|
-
sqlite3_reset(statement);
|
385
|
-
|
386
|
-
isMutated = YES;
|
387
|
-
}
|
388
|
-
|
389
|
-
- (void)removeRowids:(NSArray *)rowids
|
390
|
-
{
|
391
|
-
YDBLogAutoTrace();
|
392
|
-
|
393
|
-
NSUInteger count = [rowids count];
|
394
|
-
|
395
|
-
if (count == 0) return;
|
396
|
-
if (count == 1)
|
397
|
-
{
|
398
|
-
int64_t rowid = [[rowids objectAtIndex:0] longLongValue];
|
399
|
-
|
400
|
-
[self removeRowid:rowid];
|
401
|
-
return;
|
402
|
-
}
|
403
|
-
|
404
|
-
// DELETE FROM "tableName" WHERE "rowid" in (?, ?, ...);
|
405
|
-
//
|
406
|
-
// Note: We don't have to worry sqlite's max number of host parameters.
|
407
|
-
// YapDatabase gives us the rowids in batches where each batch is already capped at this number.
|
408
|
-
|
409
|
-
NSUInteger capacity = 50 + (count * 3);
|
410
|
-
NSMutableString *query = [NSMutableString stringWithCapacity:capacity];
|
411
|
-
|
412
|
-
[query appendFormat:@"DELETE FROM \"%@\" WHERE \"rowid\" IN (", [self tableName]];
|
413
|
-
|
414
|
-
NSUInteger i;
|
415
|
-
for (i = 0; i < count; i++)
|
416
|
-
{
|
417
|
-
if (i == 0)
|
418
|
-
[query appendFormat:@"?"];
|
419
|
-
else
|
420
|
-
[query appendFormat:@", ?"];
|
421
|
-
}
|
422
|
-
|
423
|
-
[query appendString:@");"];
|
424
|
-
|
425
|
-
sqlite3_stmt *statement;
|
426
|
-
|
427
|
-
int status = sqlite3_prepare_v2(databaseTransaction->connection->db, [query UTF8String], -1, &statement, NULL);
|
428
|
-
if (status != SQLITE_OK)
|
429
|
-
{
|
430
|
-
YDBLogError(@"Error creating 'removeRowids' statement: %d %s",
|
431
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
432
|
-
return;
|
433
|
-
}
|
434
|
-
|
435
|
-
for (i = 0; i < count; i++)
|
436
|
-
{
|
437
|
-
int64_t rowid = [[rowids objectAtIndex:i] longLongValue];
|
438
|
-
|
439
|
-
sqlite3_bind_int64(statement, (int)(i + 1), rowid);
|
440
|
-
}
|
441
|
-
|
442
|
-
status = sqlite3_step(statement);
|
443
|
-
if (status != SQLITE_DONE)
|
444
|
-
{
|
445
|
-
YDBLogError(@"Error executing 'removeRowids' statement: %d %s",
|
446
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
447
|
-
}
|
448
|
-
|
449
|
-
sqlite3_finalize(statement);
|
450
|
-
|
451
|
-
isMutated = YES;
|
452
|
-
}
|
453
|
-
|
454
|
-
- (void)removeAllRowids
|
455
|
-
{
|
456
|
-
YDBLogAutoTrace();
|
457
|
-
|
458
|
-
sqlite3_stmt *statement = [ftsConnection removeAllStatement];
|
459
|
-
if (statement == NULL)
|
460
|
-
return;
|
461
|
-
|
462
|
-
int status;
|
463
|
-
|
464
|
-
// DELETE FROM "tableName";
|
465
|
-
|
466
|
-
YDBLogVerbose(@"DELETE FROM '%@';", [self tableName]);
|
467
|
-
|
468
|
-
status = sqlite3_step(statement);
|
469
|
-
if (status != SQLITE_DONE)
|
470
|
-
{
|
471
|
-
YDBLogError(@"%@ (%@): Error in removeAllStatement: %d %s",
|
472
|
-
THIS_METHOD, [self registeredName],
|
473
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
474
|
-
}
|
475
|
-
|
476
|
-
sqlite3_reset(statement);
|
477
|
-
|
478
|
-
isMutated = YES;
|
479
|
-
}
|
480
|
-
|
481
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
482
|
-
#pragma mark Cleanup & Commit
|
483
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
484
|
-
|
485
|
-
/**
|
486
|
-
* Required override method from YapDatabaseExtension
|
487
|
-
**/
|
488
|
-
- (void)commitTransaction
|
489
|
-
{
|
490
|
-
// An extensionTransaction is only valid within the scope of its encompassing databaseTransaction.
|
491
|
-
// I imagine this may occasionally be misunderstood, and developers may attempt to store the extension in an ivar,
|
492
|
-
// and then use it outside the context of the database transaction block.
|
493
|
-
// Thus, this code is here as a safety net to ensure that such accidental misuse doesn't do any damage.
|
494
|
-
|
495
|
-
ftsConnection = nil; // Do not remove !
|
496
|
-
databaseTransaction = nil; // Do not remove !
|
497
|
-
}
|
498
|
-
|
499
|
-
/**
|
500
|
-
* Required override method from YapDatabaseExtension
|
501
|
-
**/
|
502
|
-
- (void)rollbackTransaction
|
503
|
-
{
|
504
|
-
// An extensionTransaction is only valid within the scope of its encompassing databaseTransaction.
|
505
|
-
// I imagine this may occasionally be misunderstood, and developers may attempt to store the extension in an ivar,
|
506
|
-
// and then use it outside the context of the database transaction block.
|
507
|
-
// Thus, this code is here as a safety net to ensure that such accidental misuse doesn't do any damage.
|
508
|
-
|
509
|
-
ftsConnection = nil; // Do not remove !
|
510
|
-
databaseTransaction = nil; // Do not remove !
|
511
|
-
}
|
512
|
-
|
513
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
514
|
-
#pragma mark YapDatabaseExtensionTransaction_Hooks
|
515
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
516
|
-
|
517
|
-
/**
|
518
|
-
* YapDatabase extension hook.
|
519
|
-
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
520
|
-
**/
|
521
|
-
- (void)handleInsertObject:(id)object
|
522
|
-
forCollectionKey:(YapCollectionKey *)collectionKey
|
523
|
-
withMetadata:(id)metadata
|
524
|
-
rowid:(int64_t)rowid
|
525
|
-
{
|
526
|
-
YDBLogAutoTrace();
|
527
|
-
|
528
|
-
__unsafe_unretained YapDatabaseFullTextSearch *fts = ftsConnection->fts;
|
529
|
-
|
530
|
-
__unsafe_unretained NSString *collection = collectionKey.collection;
|
531
|
-
__unsafe_unretained NSString *key = collectionKey.key;
|
532
|
-
|
533
|
-
// Invoke the block to find out if the object should be included in the index.
|
534
|
-
|
535
|
-
if (fts->blockType == YapDatabaseFullTextSearchBlockTypeWithKey)
|
536
|
-
{
|
537
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithKeyBlock block =
|
538
|
-
(YapDatabaseFullTextSearchWithKeyBlock)fts->block;
|
539
|
-
|
540
|
-
block(ftsConnection->blockDict, collection, key);
|
541
|
-
}
|
542
|
-
else if (fts->blockType == YapDatabaseFullTextSearchBlockTypeWithObject)
|
543
|
-
{
|
544
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithObjectBlock block =
|
545
|
-
(YapDatabaseFullTextSearchWithObjectBlock)fts->block;
|
546
|
-
|
547
|
-
block(ftsConnection->blockDict, collection, key, object);
|
548
|
-
}
|
549
|
-
else if (fts->blockType == YapDatabaseFullTextSearchBlockTypeWithMetadata)
|
550
|
-
{
|
551
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithMetadataBlock block =
|
552
|
-
(YapDatabaseFullTextSearchWithMetadataBlock)fts->block;
|
553
|
-
|
554
|
-
block(ftsConnection->blockDict, collection, key, metadata);
|
555
|
-
}
|
556
|
-
else
|
557
|
-
{
|
558
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithRowBlock block =
|
559
|
-
(YapDatabaseFullTextSearchWithRowBlock)fts->block;
|
560
|
-
|
561
|
-
block(ftsConnection->blockDict, collection, key, object, metadata);
|
562
|
-
}
|
563
|
-
|
564
|
-
if ([ftsConnection->blockDict count] == 0)
|
565
|
-
{
|
566
|
-
// This was an insert operation, so we don't have to worry about removing anything.
|
567
|
-
}
|
568
|
-
else
|
569
|
-
{
|
570
|
-
// Add values to index.
|
571
|
-
// This was an insert operation, so we know we can insert rather than update.
|
572
|
-
|
573
|
-
[self addRowid:rowid isNew:YES];
|
574
|
-
[ftsConnection->blockDict removeAllObjects];
|
575
|
-
}
|
576
|
-
}
|
577
|
-
|
578
|
-
/**
|
579
|
-
* YapDatabase extension hook.
|
580
|
-
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
581
|
-
**/
|
582
|
-
- (void)handleUpdateObject:(id)object
|
583
|
-
forCollectionKey:(YapCollectionKey *)collectionKey
|
584
|
-
withMetadata:(id)metadata
|
585
|
-
rowid:(int64_t)rowid
|
586
|
-
{
|
587
|
-
YDBLogAutoTrace();
|
588
|
-
|
589
|
-
__unsafe_unretained YapDatabaseFullTextSearch *fts = ftsConnection->fts;
|
590
|
-
|
591
|
-
__unsafe_unretained NSString *collection = collectionKey.collection;
|
592
|
-
__unsafe_unretained NSString *key = collectionKey.key;
|
593
|
-
|
594
|
-
// Invoke the block to find out if the object should be included in the index.
|
595
|
-
|
596
|
-
if (fts->blockType == YapDatabaseFullTextSearchBlockTypeWithKey)
|
597
|
-
{
|
598
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithKeyBlock block =
|
599
|
-
(YapDatabaseFullTextSearchWithKeyBlock)fts->block;
|
600
|
-
|
601
|
-
block(ftsConnection->blockDict, collection, key);
|
602
|
-
}
|
603
|
-
else if (fts->blockType == YapDatabaseFullTextSearchBlockTypeWithObject)
|
604
|
-
{
|
605
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithObjectBlock block =
|
606
|
-
(YapDatabaseFullTextSearchWithObjectBlock)fts->block;
|
607
|
-
|
608
|
-
block(ftsConnection->blockDict, collection, key, object);
|
609
|
-
}
|
610
|
-
else if (fts->blockType == YapDatabaseFullTextSearchBlockTypeWithMetadata)
|
611
|
-
{
|
612
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithMetadataBlock block =
|
613
|
-
(YapDatabaseFullTextSearchWithMetadataBlock)fts->block;
|
614
|
-
|
615
|
-
block(ftsConnection->blockDict, collection, key, metadata);
|
616
|
-
}
|
617
|
-
else
|
618
|
-
{
|
619
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithRowBlock block =
|
620
|
-
(YapDatabaseFullTextSearchWithRowBlock)fts->block;
|
621
|
-
|
622
|
-
block(ftsConnection->blockDict, collection, key, object, metadata);
|
623
|
-
}
|
624
|
-
|
625
|
-
if ([ftsConnection->blockDict count] == 0)
|
626
|
-
{
|
627
|
-
// Remove associated values from index (if needed).
|
628
|
-
// This was an update operation, so the rowid may have previously had values in the index.
|
629
|
-
|
630
|
-
[self removeRowid:rowid];
|
631
|
-
}
|
632
|
-
else
|
633
|
-
{
|
634
|
-
// Add values to index (or update them).
|
635
|
-
// This was an update operation, so we need to insert or update.
|
636
|
-
|
637
|
-
[self addRowid:rowid isNew:NO];
|
638
|
-
[ftsConnection->blockDict removeAllObjects];
|
639
|
-
}
|
640
|
-
}
|
641
|
-
|
642
|
-
/**
|
643
|
-
* YapDatabase extension hook.
|
644
|
-
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
645
|
-
**/
|
646
|
-
- (void)handleReplaceObject:(id)object forCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
|
647
|
-
{
|
648
|
-
YDBLogAutoTrace();
|
649
|
-
|
650
|
-
__unsafe_unretained YapDatabaseFullTextSearch *fts = ftsConnection->fts;
|
651
|
-
|
652
|
-
__unsafe_unretained NSString *collection = collectionKey.collection;
|
653
|
-
__unsafe_unretained NSString *key = collectionKey.key;
|
654
|
-
|
655
|
-
// Invoke the block to find out if the object should be included in the index.
|
656
|
-
|
657
|
-
id metadata = nil;
|
658
|
-
|
659
|
-
if (fts->blockType == YapDatabaseFullTextSearchBlockTypeWithKey ||
|
660
|
-
fts->blockType == YapDatabaseFullTextSearchBlockTypeWithMetadata)
|
661
|
-
{
|
662
|
-
// Index values are based on the key or metadata.
|
663
|
-
// Neither have changed, and thus the values haven't changed.
|
664
|
-
|
665
|
-
return;
|
666
|
-
}
|
667
|
-
else
|
668
|
-
{
|
669
|
-
// Index values are based on object or row (object+metadata).
|
670
|
-
// Invoke block to see what the new values are.
|
671
|
-
|
672
|
-
if (fts->blockType == YapDatabaseFullTextSearchBlockTypeWithObject)
|
673
|
-
{
|
674
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithObjectBlock block =
|
675
|
-
(YapDatabaseFullTextSearchWithObjectBlock)fts->block;
|
676
|
-
|
677
|
-
block(ftsConnection->blockDict, collection, key, object);
|
678
|
-
}
|
679
|
-
else
|
680
|
-
{
|
681
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithRowBlock block =
|
682
|
-
(YapDatabaseFullTextSearchWithRowBlock)fts->block;
|
683
|
-
|
684
|
-
metadata = [databaseTransaction metadataForCollectionKey:collectionKey withRowid:rowid];
|
685
|
-
block(ftsConnection->blockDict, collection, key, object, metadata);
|
686
|
-
}
|
687
|
-
|
688
|
-
if ([ftsConnection->blockDict count] == 0)
|
689
|
-
{
|
690
|
-
// Remove associated values from index (if needed).
|
691
|
-
// This was an update operation, so the rowid may have previously had values in the index.
|
692
|
-
|
693
|
-
[self removeRowid:rowid];
|
694
|
-
}
|
695
|
-
else
|
696
|
-
{
|
697
|
-
// Add values to index (or update them).
|
698
|
-
// This was an update operation, so we need to insert or update.
|
699
|
-
|
700
|
-
[self addRowid:rowid isNew:NO];
|
701
|
-
[ftsConnection->blockDict removeAllObjects];
|
702
|
-
}
|
703
|
-
}
|
704
|
-
}
|
705
|
-
|
706
|
-
/**
|
707
|
-
* YapDatabase extension hook.
|
708
|
-
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
709
|
-
**/
|
710
|
-
- (void)handleReplaceMetadata:(id)metadata forCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
|
711
|
-
{
|
712
|
-
YDBLogAutoTrace();
|
713
|
-
|
714
|
-
__unsafe_unretained YapDatabaseFullTextSearch *fts = ftsConnection->fts;
|
715
|
-
|
716
|
-
__unsafe_unretained NSString *collection = collectionKey.collection;
|
717
|
-
__unsafe_unretained NSString *key = collectionKey.key;
|
718
|
-
|
719
|
-
// Invoke the block to find out if the object should be included in the index.
|
720
|
-
|
721
|
-
id object = nil;
|
722
|
-
|
723
|
-
if (fts->blockType == YapDatabaseFullTextSearchBlockTypeWithKey ||
|
724
|
-
fts->blockType == YapDatabaseFullTextSearchBlockTypeWithObject)
|
725
|
-
{
|
726
|
-
// Index values are based on the key or object.
|
727
|
-
// Neither have changed, and thus the values haven't changed.
|
728
|
-
|
729
|
-
return;
|
730
|
-
}
|
731
|
-
else
|
732
|
-
{
|
733
|
-
// Index values are based on metadata or row (object+metadata).
|
734
|
-
// Invoke block to see what the new values are.
|
735
|
-
|
736
|
-
if (fts->blockType == YapDatabaseFullTextSearchBlockTypeWithMetadata)
|
737
|
-
{
|
738
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithMetadataBlock block =
|
739
|
-
(YapDatabaseFullTextSearchWithMetadataBlock)fts->block;
|
740
|
-
|
741
|
-
block(ftsConnection->blockDict, collection, key, metadata);
|
742
|
-
}
|
743
|
-
else
|
744
|
-
{
|
745
|
-
__unsafe_unretained YapDatabaseFullTextSearchWithRowBlock block =
|
746
|
-
(YapDatabaseFullTextSearchWithRowBlock)fts->block;
|
747
|
-
|
748
|
-
object = [databaseTransaction objectForCollectionKey:collectionKey withRowid:rowid];
|
749
|
-
block(ftsConnection->blockDict, collection, key, object, metadata);
|
750
|
-
}
|
751
|
-
|
752
|
-
if ([ftsConnection->blockDict count] == 0)
|
753
|
-
{
|
754
|
-
// Remove associated values from index (if needed).
|
755
|
-
// This was an update operation, so the rowid may have previously had values in the index.
|
756
|
-
|
757
|
-
[self removeRowid:rowid];
|
758
|
-
}
|
759
|
-
else
|
760
|
-
{
|
761
|
-
// Add values to index (or update them).
|
762
|
-
// This was an update operation, so we need to insert or update.
|
763
|
-
|
764
|
-
[self addRowid:rowid isNew:NO];
|
765
|
-
[ftsConnection->blockDict removeAllObjects];
|
766
|
-
}
|
767
|
-
}
|
768
|
-
}
|
769
|
-
|
770
|
-
/**
|
771
|
-
* YapDatabase extension hook.
|
772
|
-
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
773
|
-
**/
|
774
|
-
- (void)handleTouchObjectForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
|
775
|
-
{
|
776
|
-
// Nothing to do for this extension
|
777
|
-
}
|
778
|
-
|
779
|
-
/**
|
780
|
-
* YapDatabase extension hook.
|
781
|
-
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
782
|
-
**/
|
783
|
-
- (void)handleTouchMetadataForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
|
784
|
-
{
|
785
|
-
// Nothing to do for this extension
|
786
|
-
}
|
787
|
-
|
788
|
-
/**
|
789
|
-
* YapDatabase extension hook.
|
790
|
-
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
791
|
-
**/
|
792
|
-
- (void)handleRemoveObjectForCollectionKey:(YapCollectionKey *)collectionKey withRowid:(int64_t)rowid
|
793
|
-
{
|
794
|
-
YDBLogAutoTrace();
|
795
|
-
|
796
|
-
[self removeRowid:rowid];
|
797
|
-
}
|
798
|
-
|
799
|
-
/**
|
800
|
-
* YapDatabase extension hook.
|
801
|
-
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
802
|
-
**/
|
803
|
-
- (void)handleRemoveObjectsForKeys:(NSArray *)keys inCollection:(NSString *)collection withRowids:(NSArray *)rowids
|
804
|
-
{
|
805
|
-
YDBLogAutoTrace();
|
806
|
-
|
807
|
-
[self removeRowids:rowids];
|
808
|
-
}
|
809
|
-
|
810
|
-
/**
|
811
|
-
* YapDatabase extension hook.
|
812
|
-
* This method is invoked by a YapDatabaseReadWriteTransaction as a post-operation-hook.
|
813
|
-
**/
|
814
|
-
- (void)handleRemoveAllObjectsInAllCollections
|
815
|
-
{
|
816
|
-
YDBLogAutoTrace();
|
817
|
-
|
818
|
-
[self removeAllRowids];
|
819
|
-
}
|
820
|
-
|
821
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
822
|
-
#pragma mark Queries
|
823
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
824
|
-
|
825
|
-
- (void)enumerateKeysMatching:(NSString *)query
|
826
|
-
usingBlock:(void (^)(NSString *collection, NSString *key, BOOL *stop))block
|
827
|
-
{
|
828
|
-
if (block == nil) return;
|
829
|
-
if ([query length] == 0) return;
|
830
|
-
|
831
|
-
sqlite3_stmt *statement = [ftsConnection queryStatement];
|
832
|
-
if (statement == NULL) return;
|
833
|
-
|
834
|
-
BOOL stop = NO;
|
835
|
-
isMutated = NO; // mutation during enumeration protection
|
836
|
-
|
837
|
-
// SELECT "rowid" FROM "tableName" WHERE "tableName" MATCH ?;
|
838
|
-
|
839
|
-
YapDatabaseString _query; MakeYapDatabaseString(&_query, query);
|
840
|
-
sqlite3_bind_text(statement, 1, _query.str, _query.length, SQLITE_STATIC);
|
841
|
-
|
842
|
-
int status = sqlite3_step(statement);
|
843
|
-
if (status == SQLITE_ROW)
|
844
|
-
{
|
845
|
-
do
|
846
|
-
{
|
847
|
-
int64_t rowid = sqlite3_column_int64(statement, 0);
|
848
|
-
|
849
|
-
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
850
|
-
|
851
|
-
block(ck.collection, ck.key, &stop);
|
852
|
-
|
853
|
-
if (stop || isMutated) break;
|
854
|
-
|
855
|
-
} while ((status = sqlite3_step(statement)) == SQLITE_ROW);
|
856
|
-
}
|
857
|
-
|
858
|
-
if ((status != SQLITE_DONE) && !stop && !isMutated)
|
859
|
-
{
|
860
|
-
YDBLogError(@"%@ - sqlite_step error: %d %s", THIS_METHOD,
|
861
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
862
|
-
}
|
863
|
-
|
864
|
-
sqlite3_clear_bindings(statement);
|
865
|
-
sqlite3_reset(statement);
|
866
|
-
FreeYapDatabaseString(&_query);
|
867
|
-
|
868
|
-
if (isMutated && !stop)
|
869
|
-
{
|
870
|
-
@throw [databaseTransaction mutationDuringEnumerationException];
|
871
|
-
}
|
872
|
-
}
|
873
|
-
|
874
|
-
- (void)enumerateKeysAndMetadataMatching:(NSString *)query
|
875
|
-
usingBlock:(void (^)(NSString *collection, NSString *key, id metadata, BOOL *stop))block
|
876
|
-
{
|
877
|
-
if (block == nil) return;
|
878
|
-
if ([query length] == 0) return;
|
879
|
-
|
880
|
-
sqlite3_stmt *statement = [ftsConnection queryStatement];
|
881
|
-
if (statement == NULL) return;
|
882
|
-
|
883
|
-
BOOL stop = NO;
|
884
|
-
isMutated = NO; // mutation during enumeration protection
|
885
|
-
|
886
|
-
// SELECT "rowid" FROM "tableName" WHERE "tableName" MATCH ?;
|
887
|
-
|
888
|
-
YapDatabaseString _query; MakeYapDatabaseString(&_query, query);
|
889
|
-
sqlite3_bind_text(statement, 1, _query.str, _query.length, SQLITE_STATIC);
|
890
|
-
|
891
|
-
int status = sqlite3_step(statement);
|
892
|
-
if (status == SQLITE_ROW)
|
893
|
-
{
|
894
|
-
do
|
895
|
-
{
|
896
|
-
int64_t rowid = sqlite3_column_int64(statement, 0);
|
897
|
-
|
898
|
-
YapCollectionKey *ck = nil;
|
899
|
-
id metadata = nil;
|
900
|
-
[databaseTransaction getCollectionKey:&ck metadata:&metadata forRowid:rowid];
|
901
|
-
|
902
|
-
block(ck.collection, ck.key, metadata, &stop);
|
903
|
-
|
904
|
-
if (stop || isMutated) break;
|
905
|
-
|
906
|
-
} while ((status = sqlite3_step(statement)) == SQLITE_ROW);
|
907
|
-
}
|
908
|
-
|
909
|
-
if ((status != SQLITE_DONE) && !stop && !isMutated)
|
910
|
-
{
|
911
|
-
YDBLogError(@"%@ - sqlite_step error: %d %s", THIS_METHOD,
|
912
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
913
|
-
}
|
914
|
-
|
915
|
-
sqlite3_clear_bindings(statement);
|
916
|
-
sqlite3_reset(statement);
|
917
|
-
FreeYapDatabaseString(&_query);
|
918
|
-
|
919
|
-
if (isMutated && !stop)
|
920
|
-
{
|
921
|
-
@throw [databaseTransaction mutationDuringEnumerationException];
|
922
|
-
}
|
923
|
-
}
|
924
|
-
|
925
|
-
- (void)enumerateKeysAndObjectsMatching:(NSString *)query
|
926
|
-
usingBlock:(void (^)(NSString *collection, NSString *key, id object, BOOL *stop))block
|
927
|
-
{
|
928
|
-
if (block == nil) return;
|
929
|
-
if ([query length] == 0) return;
|
930
|
-
|
931
|
-
sqlite3_stmt *statement = [ftsConnection queryStatement];
|
932
|
-
if (statement == NULL) return;
|
933
|
-
|
934
|
-
BOOL stop = NO;
|
935
|
-
isMutated = NO; // mutation during enumeration protection
|
936
|
-
|
937
|
-
// SELECT "rowid" FROM "tableName" WHERE "tableName" MATCH ?;
|
938
|
-
|
939
|
-
YapDatabaseString _query; MakeYapDatabaseString(&_query, query);
|
940
|
-
sqlite3_bind_text(statement, 1, _query.str, _query.length, SQLITE_STATIC);
|
941
|
-
|
942
|
-
int status = sqlite3_step(statement);
|
943
|
-
if (status == SQLITE_ROW)
|
944
|
-
{
|
945
|
-
do
|
946
|
-
{
|
947
|
-
int64_t rowid = sqlite3_column_int64(statement, 0);
|
948
|
-
|
949
|
-
YapCollectionKey *ck = nil;
|
950
|
-
id object = nil;
|
951
|
-
[databaseTransaction getCollectionKey:&ck object:&object forRowid:rowid];
|
952
|
-
|
953
|
-
block(ck.collection, ck.key, object, &stop);
|
954
|
-
|
955
|
-
if (stop || isMutated) break;
|
956
|
-
|
957
|
-
} while ((status = sqlite3_step(statement)) == SQLITE_ROW);
|
958
|
-
}
|
959
|
-
|
960
|
-
if ((status != SQLITE_DONE) && !stop && !isMutated)
|
961
|
-
{
|
962
|
-
YDBLogError(@"%@ - sqlite_step error: %d %s", THIS_METHOD,
|
963
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
964
|
-
}
|
965
|
-
|
966
|
-
sqlite3_clear_bindings(statement);
|
967
|
-
sqlite3_reset(statement);
|
968
|
-
FreeYapDatabaseString(&_query);
|
969
|
-
|
970
|
-
if (isMutated && !stop)
|
971
|
-
{
|
972
|
-
@throw [databaseTransaction mutationDuringEnumerationException];
|
973
|
-
}
|
974
|
-
}
|
975
|
-
|
976
|
-
- (void)enumerateRowsMatching:(NSString *)query
|
977
|
-
usingBlock:(void (^)(NSString *collection, NSString *key, id object, id metadata, BOOL *stop))block
|
978
|
-
{
|
979
|
-
if (block == nil) return;
|
980
|
-
if ([query length] == 0) return;
|
981
|
-
|
982
|
-
sqlite3_stmt *statement = [ftsConnection queryStatement];
|
983
|
-
if (statement == NULL) return;
|
984
|
-
|
985
|
-
BOOL stop = NO;
|
986
|
-
isMutated = NO; // mutation during enumeration protection
|
987
|
-
|
988
|
-
// SELECT "rowid" FROM "tableName" WHERE "tableName" MATCH ?;
|
989
|
-
|
990
|
-
YapDatabaseString _query; MakeYapDatabaseString(&_query, query);
|
991
|
-
sqlite3_bind_text(statement, 1, _query.str, _query.length, SQLITE_STATIC);
|
992
|
-
|
993
|
-
int status = sqlite3_step(statement);
|
994
|
-
if (status == SQLITE_ROW)
|
995
|
-
{
|
996
|
-
do
|
997
|
-
{
|
998
|
-
int64_t rowid = sqlite3_column_int64(statement, 0);
|
999
|
-
|
1000
|
-
YapCollectionKey *ck = nil;
|
1001
|
-
id object = nil;
|
1002
|
-
id metadata = nil;
|
1003
|
-
[databaseTransaction getCollectionKey:&ck object:&object metadata:&metadata forRowid:rowid];
|
1004
|
-
|
1005
|
-
block(ck.collection, ck.key, object, metadata, &stop);
|
1006
|
-
|
1007
|
-
if (stop || isMutated) break;
|
1008
|
-
|
1009
|
-
} while ((status = sqlite3_step(statement)) == SQLITE_ROW);
|
1010
|
-
}
|
1011
|
-
|
1012
|
-
if ((status != SQLITE_DONE) && !stop && !isMutated)
|
1013
|
-
{
|
1014
|
-
YDBLogError(@"%@ - sqlite_step error: %d %s", THIS_METHOD,
|
1015
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
1016
|
-
}
|
1017
|
-
|
1018
|
-
sqlite3_clear_bindings(statement);
|
1019
|
-
sqlite3_reset(statement);
|
1020
|
-
FreeYapDatabaseString(&_query);
|
1021
|
-
|
1022
|
-
if (isMutated && !stop)
|
1023
|
-
{
|
1024
|
-
@throw [databaseTransaction mutationDuringEnumerationException];
|
1025
|
-
}
|
1026
|
-
}
|
1027
|
-
|
1028
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1029
|
-
#pragma mark Queries with Snippets
|
1030
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1031
|
-
|
1032
|
-
- (void)enumerateKeysMatching:(NSString *)query
|
1033
|
-
withSnippetOptions:(YapDatabaseFullTextSearchSnippetOptions *)inOptions
|
1034
|
-
usingBlock:
|
1035
|
-
(void (^)(NSString *snippet, NSString *collection, NSString *key, BOOL *stop))block
|
1036
|
-
{
|
1037
|
-
if (block == nil) return;
|
1038
|
-
if ([query length] == 0) return;
|
1039
|
-
|
1040
|
-
sqlite3_stmt *statement = [ftsConnection querySnippetStatement];
|
1041
|
-
if (statement == NULL) return;
|
1042
|
-
|
1043
|
-
YapDatabaseFullTextSearchSnippetOptions *options;
|
1044
|
-
if (inOptions)
|
1045
|
-
options = [inOptions copy];
|
1046
|
-
else
|
1047
|
-
options = [[YapDatabaseFullTextSearchSnippetOptions alloc] init]; // default snippet options
|
1048
|
-
|
1049
|
-
BOOL stop = NO;
|
1050
|
-
isMutated = NO; // mutation during enumeration protection
|
1051
|
-
|
1052
|
-
// SELECT "rowid", snippet("tableName", ?, ?, ?, ?, ?) FROM "tableName" WHERE "tableName" MATCH ?;
|
1053
|
-
|
1054
|
-
YapDatabaseString _startMatchText; MakeYapDatabaseString(&_startMatchText, options.startMatchText);
|
1055
|
-
sqlite3_bind_text(statement, 1, _startMatchText.str, _startMatchText.length, SQLITE_STATIC);
|
1056
|
-
|
1057
|
-
YapDatabaseString _endMatchText; MakeYapDatabaseString(&_endMatchText, options.endMatchText);
|
1058
|
-
sqlite3_bind_text(statement, 2, _endMatchText.str, _endMatchText.length, SQLITE_STATIC);
|
1059
|
-
|
1060
|
-
YapDatabaseString _ellipsesText; MakeYapDatabaseString(&_ellipsesText, options.ellipsesText);
|
1061
|
-
sqlite3_bind_text(statement, 3, _ellipsesText.str, _ellipsesText.length, SQLITE_STATIC);
|
1062
|
-
|
1063
|
-
int columnIndex = -1;
|
1064
|
-
if (options.columnName)
|
1065
|
-
{
|
1066
|
-
NSUInteger index = [ftsConnection->fts->columnNames indexOfObject:options.columnName];
|
1067
|
-
if (index == NSNotFound)
|
1068
|
-
{
|
1069
|
-
YDBLogWarn(@"Invalid snippet option: columnName(%@) not found", options.columnName);
|
1070
|
-
}
|
1071
|
-
else
|
1072
|
-
{
|
1073
|
-
columnIndex = (int)index;
|
1074
|
-
}
|
1075
|
-
}
|
1076
|
-
sqlite3_bind_int(statement, 4, columnIndex);
|
1077
|
-
sqlite3_bind_int(statement, 5, options.numberOfTokens);
|
1078
|
-
|
1079
|
-
YapDatabaseString _query; MakeYapDatabaseString(&_query, query);
|
1080
|
-
sqlite3_bind_text(statement, 6, _query.str, _query.length, SQLITE_STATIC);
|
1081
|
-
|
1082
|
-
int status = sqlite3_step(statement);
|
1083
|
-
if (status == SQLITE_ROW)
|
1084
|
-
{
|
1085
|
-
do
|
1086
|
-
{
|
1087
|
-
int64_t rowid = sqlite3_column_int64(statement, 0);
|
1088
|
-
|
1089
|
-
const unsigned char *text = sqlite3_column_text(statement, 1);
|
1090
|
-
int textSize = sqlite3_column_bytes(statement, 1);
|
1091
|
-
|
1092
|
-
NSString *snippet = [[NSString alloc] initWithBytes:text length:textSize encoding:NSUTF8StringEncoding];
|
1093
|
-
|
1094
|
-
YapCollectionKey *ck = [databaseTransaction collectionKeyForRowid:rowid];
|
1095
|
-
|
1096
|
-
block(snippet, ck.collection, ck.key, &stop);
|
1097
|
-
|
1098
|
-
if (stop || isMutated) break;
|
1099
|
-
|
1100
|
-
} while ((status = sqlite3_step(statement)) == SQLITE_ROW);
|
1101
|
-
}
|
1102
|
-
|
1103
|
-
if ((status != SQLITE_DONE) && !stop && !isMutated)
|
1104
|
-
{
|
1105
|
-
YDBLogError(@"%@ - sqlite_step error: %d %s", THIS_METHOD,
|
1106
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
1107
|
-
}
|
1108
|
-
|
1109
|
-
sqlite3_clear_bindings(statement);
|
1110
|
-
sqlite3_reset(statement);
|
1111
|
-
|
1112
|
-
FreeYapDatabaseString(&_startMatchText);
|
1113
|
-
FreeYapDatabaseString(&_endMatchText);
|
1114
|
-
FreeYapDatabaseString(&_ellipsesText);
|
1115
|
-
FreeYapDatabaseString(&_query);
|
1116
|
-
|
1117
|
-
if (isMutated && !stop)
|
1118
|
-
{
|
1119
|
-
@throw [databaseTransaction mutationDuringEnumerationException];
|
1120
|
-
}
|
1121
|
-
}
|
1122
|
-
|
1123
|
-
- (void)enumerateKeysAndMetadataMatching:(NSString *)query
|
1124
|
-
withSnippetOptions:(YapDatabaseFullTextSearchSnippetOptions *)inOptions
|
1125
|
-
usingBlock:
|
1126
|
-
(void (^)(NSString *snippet, NSString *collection, NSString *key, id metadata, BOOL *stop))block
|
1127
|
-
{
|
1128
|
-
if (block == nil) return;
|
1129
|
-
if ([query length] == 0) return;
|
1130
|
-
|
1131
|
-
sqlite3_stmt *statement = [ftsConnection querySnippetStatement];
|
1132
|
-
if (statement == NULL) return;
|
1133
|
-
|
1134
|
-
YapDatabaseFullTextSearchSnippetOptions *options;
|
1135
|
-
if (inOptions)
|
1136
|
-
options = [inOptions copy];
|
1137
|
-
else
|
1138
|
-
options = [[YapDatabaseFullTextSearchSnippetOptions alloc] init]; // default snippet options
|
1139
|
-
|
1140
|
-
BOOL stop = NO;
|
1141
|
-
isMutated = NO; // mutation during enumeration protection
|
1142
|
-
|
1143
|
-
// SELECT "rowid", snippet("tableName", ?, ?, ?, ?, ?) FROM "tableName" WHERE "tableName" MATCH ?;
|
1144
|
-
|
1145
|
-
YapDatabaseString _startMatchText; MakeYapDatabaseString(&_startMatchText, options.startMatchText);
|
1146
|
-
sqlite3_bind_text(statement, 1, _startMatchText.str, _startMatchText.length, SQLITE_STATIC);
|
1147
|
-
|
1148
|
-
YapDatabaseString _endMatchText; MakeYapDatabaseString(&_endMatchText, options.endMatchText);
|
1149
|
-
sqlite3_bind_text(statement, 2, _endMatchText.str, _endMatchText.length, SQLITE_STATIC);
|
1150
|
-
|
1151
|
-
YapDatabaseString _ellipsesText; MakeYapDatabaseString(&_ellipsesText, options.ellipsesText);
|
1152
|
-
sqlite3_bind_text(statement, 3, _ellipsesText.str, _ellipsesText.length, SQLITE_STATIC);
|
1153
|
-
|
1154
|
-
int columnIndex = -1;
|
1155
|
-
if (options.columnName)
|
1156
|
-
{
|
1157
|
-
NSUInteger index = [ftsConnection->fts->columnNames indexOfObject:options.columnName];
|
1158
|
-
if (index == NSNotFound)
|
1159
|
-
{
|
1160
|
-
YDBLogWarn(@"Invalid snippet option: columnName(%@) not found", options.columnName);
|
1161
|
-
}
|
1162
|
-
else
|
1163
|
-
{
|
1164
|
-
columnIndex = (int)index;
|
1165
|
-
}
|
1166
|
-
}
|
1167
|
-
sqlite3_bind_int(statement, 4, columnIndex);
|
1168
|
-
sqlite3_bind_int(statement, 5, options.numberOfTokens);
|
1169
|
-
|
1170
|
-
YapDatabaseString _query; MakeYapDatabaseString(&_query, query);
|
1171
|
-
sqlite3_bind_text(statement, 6, _query.str, _query.length, SQLITE_STATIC);
|
1172
|
-
|
1173
|
-
int status = sqlite3_step(statement);
|
1174
|
-
if (status == SQLITE_ROW)
|
1175
|
-
{
|
1176
|
-
do
|
1177
|
-
{
|
1178
|
-
int64_t rowid = sqlite3_column_int64(statement, 0);
|
1179
|
-
|
1180
|
-
const unsigned char *text = sqlite3_column_text(statement, 1);
|
1181
|
-
int textSize = sqlite3_column_bytes(statement, 1);
|
1182
|
-
|
1183
|
-
NSString *snippet = [[NSString alloc] initWithBytes:text length:textSize encoding:NSUTF8StringEncoding];
|
1184
|
-
|
1185
|
-
YapCollectionKey *ck = nil;
|
1186
|
-
id metadata = nil;
|
1187
|
-
[databaseTransaction getCollectionKey:&ck metadata:&metadata forRowid:rowid];
|
1188
|
-
|
1189
|
-
block(snippet, ck.collection, ck.key, metadata, &stop);
|
1190
|
-
|
1191
|
-
if (stop || isMutated) break;
|
1192
|
-
|
1193
|
-
} while ((status = sqlite3_step(statement)) == SQLITE_ROW);
|
1194
|
-
}
|
1195
|
-
|
1196
|
-
if ((status != SQLITE_DONE) && !stop && !isMutated)
|
1197
|
-
{
|
1198
|
-
YDBLogError(@"%@ - sqlite_step error: %d %s", THIS_METHOD,
|
1199
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
1200
|
-
}
|
1201
|
-
|
1202
|
-
sqlite3_clear_bindings(statement);
|
1203
|
-
sqlite3_reset(statement);
|
1204
|
-
|
1205
|
-
FreeYapDatabaseString(&_startMatchText);
|
1206
|
-
FreeYapDatabaseString(&_endMatchText);
|
1207
|
-
FreeYapDatabaseString(&_ellipsesText);
|
1208
|
-
FreeYapDatabaseString(&_query);
|
1209
|
-
|
1210
|
-
if (isMutated && !stop)
|
1211
|
-
{
|
1212
|
-
@throw [databaseTransaction mutationDuringEnumerationException];
|
1213
|
-
}
|
1214
|
-
}
|
1215
|
-
|
1216
|
-
- (void)enumerateKeysAndObjectsMatching:(NSString *)query
|
1217
|
-
withSnippetOptions:(YapDatabaseFullTextSearchSnippetOptions *)inOptions
|
1218
|
-
usingBlock:
|
1219
|
-
(void (^)(NSString *snippet, NSString *collection, NSString *key, id object, BOOL *stop))block
|
1220
|
-
{
|
1221
|
-
if (block == nil) return;
|
1222
|
-
if ([query length] == 0) return;
|
1223
|
-
|
1224
|
-
sqlite3_stmt *statement = [ftsConnection querySnippetStatement];
|
1225
|
-
if (statement == NULL) return;
|
1226
|
-
|
1227
|
-
YapDatabaseFullTextSearchSnippetOptions *options;
|
1228
|
-
if (inOptions)
|
1229
|
-
options = [inOptions copy];
|
1230
|
-
else
|
1231
|
-
options = [[YapDatabaseFullTextSearchSnippetOptions alloc] init]; // default snippet options
|
1232
|
-
|
1233
|
-
BOOL stop = NO;
|
1234
|
-
isMutated = NO; // mutation during enumeration protection
|
1235
|
-
|
1236
|
-
// SELECT "rowid", snippet("tableName", ?, ?, ?, ?, ?) FROM "tableName" WHERE "tableName" MATCH ?;
|
1237
|
-
|
1238
|
-
YapDatabaseString _startMatchText; MakeYapDatabaseString(&_startMatchText, options.startMatchText);
|
1239
|
-
sqlite3_bind_text(statement, 1, _startMatchText.str, _startMatchText.length, SQLITE_STATIC);
|
1240
|
-
|
1241
|
-
YapDatabaseString _endMatchText; MakeYapDatabaseString(&_endMatchText, options.endMatchText);
|
1242
|
-
sqlite3_bind_text(statement, 2, _endMatchText.str, _endMatchText.length, SQLITE_STATIC);
|
1243
|
-
|
1244
|
-
YapDatabaseString _ellipsesText; MakeYapDatabaseString(&_ellipsesText, options.ellipsesText);
|
1245
|
-
sqlite3_bind_text(statement, 3, _ellipsesText.str, _ellipsesText.length, SQLITE_STATIC);
|
1246
|
-
|
1247
|
-
int columnIndex = -1;
|
1248
|
-
if (options.columnName)
|
1249
|
-
{
|
1250
|
-
NSUInteger index = [ftsConnection->fts->columnNames indexOfObject:options.columnName];
|
1251
|
-
if (index == NSNotFound)
|
1252
|
-
{
|
1253
|
-
YDBLogWarn(@"Invalid snippet option: columnName(%@) not found", options.columnName);
|
1254
|
-
}
|
1255
|
-
else
|
1256
|
-
{
|
1257
|
-
columnIndex = (int)index;
|
1258
|
-
}
|
1259
|
-
}
|
1260
|
-
sqlite3_bind_int(statement, 4, columnIndex);
|
1261
|
-
sqlite3_bind_int(statement, 5, options.numberOfTokens);
|
1262
|
-
|
1263
|
-
YapDatabaseString _query; MakeYapDatabaseString(&_query, query);
|
1264
|
-
sqlite3_bind_text(statement, 6, _query.str, _query.length, SQLITE_STATIC);
|
1265
|
-
|
1266
|
-
int status = sqlite3_step(statement);
|
1267
|
-
if (status == SQLITE_ROW)
|
1268
|
-
{
|
1269
|
-
do
|
1270
|
-
{
|
1271
|
-
int64_t rowid = sqlite3_column_int64(statement, 0);
|
1272
|
-
|
1273
|
-
const unsigned char *text = sqlite3_column_text(statement, 1);
|
1274
|
-
int textSize = sqlite3_column_bytes(statement, 1);
|
1275
|
-
|
1276
|
-
NSString *snippet = [[NSString alloc] initWithBytes:text length:textSize encoding:NSUTF8StringEncoding];
|
1277
|
-
|
1278
|
-
YapCollectionKey *ck = nil;
|
1279
|
-
id object = nil;
|
1280
|
-
[databaseTransaction getCollectionKey:&ck object:&object forRowid:rowid];
|
1281
|
-
|
1282
|
-
block(snippet, ck.collection, ck.key, object, &stop);
|
1283
|
-
|
1284
|
-
if (stop || isMutated) break;
|
1285
|
-
|
1286
|
-
} while ((status = sqlite3_step(statement)) == SQLITE_ROW);
|
1287
|
-
}
|
1288
|
-
|
1289
|
-
if ((status != SQLITE_DONE) && !stop && !isMutated)
|
1290
|
-
{
|
1291
|
-
YDBLogError(@"%@ - sqlite_step error: %d %s", THIS_METHOD,
|
1292
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
1293
|
-
}
|
1294
|
-
|
1295
|
-
sqlite3_clear_bindings(statement);
|
1296
|
-
sqlite3_reset(statement);
|
1297
|
-
|
1298
|
-
FreeYapDatabaseString(&_startMatchText);
|
1299
|
-
FreeYapDatabaseString(&_endMatchText);
|
1300
|
-
FreeYapDatabaseString(&_ellipsesText);
|
1301
|
-
FreeYapDatabaseString(&_query);
|
1302
|
-
|
1303
|
-
if (isMutated && !stop)
|
1304
|
-
{
|
1305
|
-
@throw [databaseTransaction mutationDuringEnumerationException];
|
1306
|
-
}
|
1307
|
-
}
|
1308
|
-
|
1309
|
-
- (void)enumerateRowsMatching:(NSString *)query
|
1310
|
-
withSnippetOptions:(YapDatabaseFullTextSearchSnippetOptions *)inOptions
|
1311
|
-
usingBlock:
|
1312
|
-
(void (^)(NSString *snippet, NSString *collection, NSString *key, id object, id metadata, BOOL *stop))block
|
1313
|
-
{
|
1314
|
-
if (block == nil) return;
|
1315
|
-
if ([query length] == 0) return;
|
1316
|
-
|
1317
|
-
sqlite3_stmt *statement = [ftsConnection querySnippetStatement];
|
1318
|
-
if (statement == NULL) return;
|
1319
|
-
|
1320
|
-
YapDatabaseFullTextSearchSnippetOptions *options;
|
1321
|
-
if (inOptions)
|
1322
|
-
options = [inOptions copy];
|
1323
|
-
else
|
1324
|
-
options = [[YapDatabaseFullTextSearchSnippetOptions alloc] init]; // default snippet options
|
1325
|
-
|
1326
|
-
BOOL stop = NO;
|
1327
|
-
isMutated = NO; // mutation during enumeration protection
|
1328
|
-
|
1329
|
-
// SELECT "rowid", snippet("tableName", ?, ?, ?, ?, ?) FROM "tableName" WHERE "tableName" MATCH ?;
|
1330
|
-
|
1331
|
-
YapDatabaseString _startMatchText; MakeYapDatabaseString(&_startMatchText, options.startMatchText);
|
1332
|
-
sqlite3_bind_text(statement, 1, _startMatchText.str, _startMatchText.length, SQLITE_STATIC);
|
1333
|
-
|
1334
|
-
YapDatabaseString _endMatchText; MakeYapDatabaseString(&_endMatchText, options.endMatchText);
|
1335
|
-
sqlite3_bind_text(statement, 2, _endMatchText.str, _endMatchText.length, SQLITE_STATIC);
|
1336
|
-
|
1337
|
-
YapDatabaseString _ellipsesText; MakeYapDatabaseString(&_ellipsesText, options.ellipsesText);
|
1338
|
-
sqlite3_bind_text(statement, 3, _ellipsesText.str, _ellipsesText.length, SQLITE_STATIC);
|
1339
|
-
|
1340
|
-
int columnIndex = -1;
|
1341
|
-
if (options.columnName)
|
1342
|
-
{
|
1343
|
-
NSUInteger index = [ftsConnection->fts->columnNames indexOfObject:options.columnName];
|
1344
|
-
if (index == NSNotFound)
|
1345
|
-
{
|
1346
|
-
YDBLogWarn(@"Invalid snippet option: columnName(%@) not found", options.columnName);
|
1347
|
-
}
|
1348
|
-
else
|
1349
|
-
{
|
1350
|
-
columnIndex = (int)index;
|
1351
|
-
}
|
1352
|
-
}
|
1353
|
-
sqlite3_bind_int(statement, 4, columnIndex);
|
1354
|
-
sqlite3_bind_int(statement, 5, options.numberOfTokens);
|
1355
|
-
|
1356
|
-
YapDatabaseString _query; MakeYapDatabaseString(&_query, query);
|
1357
|
-
sqlite3_bind_text(statement, 6, _query.str, _query.length, SQLITE_STATIC);
|
1358
|
-
|
1359
|
-
int status = sqlite3_step(statement);
|
1360
|
-
if (status == SQLITE_ROW)
|
1361
|
-
{
|
1362
|
-
do
|
1363
|
-
{
|
1364
|
-
int64_t rowid = sqlite3_column_int64(statement, 0);
|
1365
|
-
|
1366
|
-
const unsigned char *text = sqlite3_column_text(statement, 1);
|
1367
|
-
int textSize = sqlite3_column_bytes(statement, 1);
|
1368
|
-
|
1369
|
-
NSString *snippet = [[NSString alloc] initWithBytes:text length:textSize encoding:NSUTF8StringEncoding];
|
1370
|
-
|
1371
|
-
YapCollectionKey *ck = nil;
|
1372
|
-
id object = nil;
|
1373
|
-
id metadata = nil;
|
1374
|
-
[databaseTransaction getCollectionKey:&ck object:&object metadata:&metadata forRowid:rowid];
|
1375
|
-
|
1376
|
-
block(snippet, ck.collection, ck.key, object, metadata, &stop);
|
1377
|
-
|
1378
|
-
if (stop || isMutated) break;
|
1379
|
-
|
1380
|
-
} while ((status = sqlite3_step(statement)) == SQLITE_ROW);
|
1381
|
-
}
|
1382
|
-
|
1383
|
-
if ((status != SQLITE_DONE) && !stop && !isMutated)
|
1384
|
-
{
|
1385
|
-
YDBLogError(@"%@ - sqlite_step error: %d %s", THIS_METHOD,
|
1386
|
-
status, sqlite3_errmsg(databaseTransaction->connection->db));
|
1387
|
-
}
|
1388
|
-
|
1389
|
-
sqlite3_clear_bindings(statement);
|
1390
|
-
sqlite3_reset(statement);
|
1391
|
-
|
1392
|
-
FreeYapDatabaseString(&_startMatchText);
|
1393
|
-
FreeYapDatabaseString(&_endMatchText);
|
1394
|
-
FreeYapDatabaseString(&_ellipsesText);
|
1395
|
-
FreeYapDatabaseString(&_query);
|
1396
|
-
|
1397
|
-
if (isMutated && !stop)
|
1398
|
-
{
|
1399
|
-
@throw [databaseTransaction mutationDuringEnumerationException];
|
1400
|
-
}
|
1401
|
-
}
|
1402
|
-
|
1403
|
-
@end
|