/
CBLView+Internal.h
104 lines (74 loc) · 2.96 KB
/
CBLView+Internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// CBLView+Internal.h
// CouchbaseLite
//
// Created by Jens Alfke on 12/8/11.
// Copyright (c) 2011-2013 Couchbase, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CBLDatabase+Internal.h"
#import "CBLView.h"
#import "CBLQuery.h"
#import "CBL_ViewStorage.h"
@class CBForestMapReduceIndex;
extern NSString* const kCBLViewChangeNotification;
typedef enum {
kCBLViewCollationUnicode,
kCBLViewCollationRaw,
kCBLViewCollationASCII
} CBLViewCollation;
BOOL CBLQueryRowValueIsEntireDoc(id value);
@interface CBLView () <CBL_ViewStorageDelegate>
{
@private
CBLDatabase* __weak _weakDB;
id<CBL_ViewStorage> _storage;
NSString* _name;
}
- (instancetype) initWithDatabase: (CBLDatabase*)db name: (NSString*)name create: (BOOL)create;
- (void) close;
/** Current total rows in the view. The index will not be updated when accessing this property. */
@property (readonly) NSUInteger currentTotalRows;
/** The map block alredy registered with the view. Unlike the public .mapBlock property, this
will not look for a design document or compile a function therein. */
@property (readonly) CBLMapBlock registeredMapBlock;
@property (readonly) SequenceNumber lastSequenceChangedAt;
@property (readonly) id<CBL_ViewStorage> storage;
@property (nonatomic) CBLViewCollation collation;
@property (readonly) NSArray* viewsInGroup;
@property (nonatomic) BOOL isDesignDoc;
/** Updates the view's index (incrementally) if necessary.
If the index is updated, the other views in the viewGroup will be updated as a bonus.
@return 200 if updated, 304 if already up-to-date, else an error code */
- (CBLStatus) _updateIndex;
/** Updates the view's index (incrementally) if necessary. No other groups will be updated.
@return 200 if updated, 304 if already up-to-date, else an error code */
- (CBLStatus) updateIndexAlone;
- (CBLStatus) updateIndexes: (NSArray*)views;
#if DEBUG // for unit tests only
- (void) forgetMapBlock;
#endif
@end
@interface CBLView (Querying)
/** Queries the view. Does NOT first update the index. */
- (CBLQueryEnumerator*) _queryWithOptions: (CBLQueryOptions*)options
status: (CBLStatus*)outStatus;
@end
@interface CBLQueryEnumerator ()
- (instancetype) initWithSequenceNumber: (SequenceNumber)sequenceNumber
rows: (NSArray*)rows;
- (instancetype) initWithDatabase: (CBLDatabase*)database
view: (CBLView*)view
sequenceNumber: (SequenceNumber)sequenceNumber
rows: (NSArray*)rows;
- (void) setDatabase: (CBLDatabase*)database
view: (CBLView*)view;
- (CBLQueryRow*) generateNextRow;
- (void) sortUsingDescriptors: (NSArray*)sortDescriptors
skip: (NSUInteger)skip
limit: (NSUInteger)limit;
@end
@interface CBLQueryRow ()
- (void) moveToDatabase: (CBLDatabase*)database view: (CBLView*)view;
- (void) _clearDatabase;
@end