Skip to content

Commit

Permalink
Merge pull request #440 from rupertdaniel/fts-add-transaction-to-hand…
Browse files Browse the repository at this point in the history
…ler-block

Fts add transaction to handler blocks
  • Loading branch information
robbiehanson authored Mar 8, 2018
2 parents 15c3145 + db05d87 commit 9ac1bce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Testing/UnitTesting/TestYapDatabaseFullTextSearch.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (void)test
YapDatabaseConnection *connection = [database newConnection];

YapDatabaseFullTextSearchHandler *handler = [YapDatabaseFullTextSearchHandler withObjectBlock:
^(NSMutableDictionary *dict, NSString *collection, NSString *key, id object){
^(YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, id object){

[dict setObject:object forKey:@"content"];
}];
Expand Down Expand Up @@ -169,7 +169,7 @@ - (void)testSnippet
YapDatabaseConnection *connection = [database newConnection];

YapDatabaseFullTextSearchHandler *handler = [YapDatabaseFullTextSearchHandler withObjectBlock:
^(NSMutableDictionary *dict, NSString *collection, NSString *key, id object){
^(YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, id object){

[dict setObject:object forKey:@"content"];
}];
Expand Down
4 changes: 2 additions & 2 deletions Testing/UnitTesting/TestYapDatabaseSearchResultsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ - (void)_test1_parentView_withPath:(NSString *)databasePath
// Setup FTS

YapDatabaseFullTextSearchHandler *handler = [YapDatabaseFullTextSearchHandler withObjectBlock:
^(NSMutableDictionary *dict, NSString *collection, NSString *key, id object){
^(YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, id object){

[dict setObject:object forKey:@"content"];
}];
Expand Down Expand Up @@ -259,7 +259,7 @@ - (void)_test1_blocks_withPath:(NSString *)databasePath
// Setup FTS

YapDatabaseFullTextSearchHandler *handler = [YapDatabaseFullTextSearchHandler withObjectBlock:
^(NSMutableDictionary *dict, NSString *collection, NSString *key, id object){
^(YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, id object){

[dict setObject:object forKey:@"content"];
}];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#import <Foundation/Foundation.h>
#import "YapDatabaseExtensionTypes.h"

@class YapDatabaseReadTransaction;

NS_ASSUME_NONNULL_BEGIN

/**
Expand All @@ -22,16 +24,16 @@ NS_ASSUME_NONNULL_BEGIN
typedef id YapDatabaseFullTextSearchBlock; // One of YapDatabaseFullTextSearchXBlock types

typedef void (^YapDatabaseFullTextSearchWithKeyBlock)
(NSMutableDictionary *dict, NSString *collection, NSString *key);
(YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key);

typedef void (^YapDatabaseFullTextSearchWithObjectBlock)
(NSMutableDictionary *dict, NSString *collection, NSString *key, id object);
(YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, id object);

typedef void (^YapDatabaseFullTextSearchWithMetadataBlock)
(NSMutableDictionary *dict, NSString *collection, NSString *key, __nullable id metadata);
(YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, __nullable id metadata);

typedef void (^YapDatabaseFullTextSearchWithRowBlock)
(NSMutableDictionary *dict, NSString *collection, NSString *key, id object, __nullable id metadata);
(YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, id object, __nullable id metadata);

+ (instancetype)withKeyBlock:(YapDatabaseFullTextSearchWithKeyBlock)block;
+ (instancetype)withObjectBlock:(YapDatabaseFullTextSearchWithObjectBlock)block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ - (BOOL)populate
[databaseTransaction _enumerateKeysInAllCollectionsUsingBlock:
^(int64_t rowid, NSString *collection, NSString *key, BOOL __unused *stop) {

block(parentConnection->blockDict, collection, key);
block(databaseTransaction, parentConnection->blockDict, collection, key);

if ([parentConnection->blockDict count] > 0)
{
Expand All @@ -263,7 +263,7 @@ - (BOOL)populate
[databaseTransaction _enumerateKeysAndObjectsInAllCollectionsUsingBlock:
^(int64_t rowid, NSString *collection, NSString *key, id object, BOOL __unused *stop) {

block(parentConnection->blockDict, collection, key, object);
block(databaseTransaction, parentConnection->blockDict, collection, key, object);

if ([parentConnection->blockDict count] > 0)
{
Expand All @@ -280,7 +280,7 @@ - (BOOL)populate
[databaseTransaction _enumerateKeysAndMetadataInAllCollectionsUsingBlock:
^(int64_t rowid, NSString *collection, NSString *key, id metadata, BOOL __unused *stop) {

block(parentConnection->blockDict, collection, key, metadata);
block(databaseTransaction, parentConnection->blockDict, collection, key, metadata);

if ([parentConnection->blockDict count] > 0)
{
Expand All @@ -297,7 +297,7 @@ - (BOOL)populate
[databaseTransaction _enumerateRowsInAllCollectionsUsingBlock:
^(int64_t rowid, NSString *collection, NSString *key, id object, id metadata, BOOL __unused *stop) {

block(parentConnection->blockDict, collection, key, object, metadata);
block(databaseTransaction, parentConnection->blockDict, collection, key, object, metadata);

if ([parentConnection->blockDict count] > 0)
{
Expand Down Expand Up @@ -573,28 +573,28 @@ - (void)_handleChangeWithRowid:(int64_t)rowid
__unsafe_unretained YapDatabaseFullTextSearchWithKeyBlock block =
(YapDatabaseFullTextSearchWithKeyBlock)handler->block;

block(parentConnection->blockDict, collection, key);
block(databaseTransaction, parentConnection->blockDict, collection, key);
}
else if (handler->blockType == YapDatabaseBlockTypeWithObject)
{
__unsafe_unretained YapDatabaseFullTextSearchWithObjectBlock block =
(YapDatabaseFullTextSearchWithObjectBlock)handler->block;

block(parentConnection->blockDict, collection, key, object);
block(databaseTransaction, parentConnection->blockDict, collection, key, object);
}
else if (handler->blockType == YapDatabaseBlockTypeWithMetadata)
{
__unsafe_unretained YapDatabaseFullTextSearchWithMetadataBlock block =
(YapDatabaseFullTextSearchWithMetadataBlock)handler->block;

block(parentConnection->blockDict, collection, key, metadata);
block(databaseTransaction, parentConnection->blockDict, collection, key, metadata);
}
else
{
__unsafe_unretained YapDatabaseFullTextSearchWithRowBlock block =
(YapDatabaseFullTextSearchWithRowBlock)handler->block;

block(parentConnection->blockDict, collection, key, object, metadata);
block(databaseTransaction, parentConnection->blockDict, collection, key, object, metadata);
}

if ([parentConnection->blockDict count] == 0)
Expand Down

0 comments on commit 9ac1bce

Please sign in to comment.