1% Licensed under the Apache License, Version 2.0 (the "License"); you may not
2% use this file except in compliance with the License. You may obtain a copy of
3% the License at
4%
5%   http://www.apache.org/licenses/LICENSE-2.0
6%
7% Unless required by applicable law or agreed to in writing, software
8% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10% License for the specific language governing permissions and limitations under
11% the License.
12
13-define(LATEST_SPATIAL_DISK_VERSION, 2).
14
15% The counterpart to #spatial_group in the view server is #group
16-record(spatial_group, {
17    sig=nil,
18    % XXX vmx 2011-11-30: CouchDB doesn't need 'db' any more.
19    %     Check if/why GeoCouch still needs it.
20    db=nil,
21    % Store the name of the database where the design doc came
22    % from. This is used to determine if a foreign design doc was used
23    dbname = nil,
24    fd=nil,
25    name, % design document ID
26    def_lang,
27    design_options=[],
28    indexes,
29    lib,
30    id_btree=nil, % the back-index
31    current_seq=0,
32    purge_seq=0
33%    waiting_delayed_commit=nil
34    }).
35
36% It's the tree strucure of the spatial index
37% The counterpart to #spatial in the view server is #view
38-record(spatial, {
39    root_dir=nil,
40    seq=0,
41    treepos=nil,
42    treeheight=0, % height of the tree
43    def=nil, % The function in the query/view server
44    index_names=[],
45    id_num=0, % comes from couch_spatial_group requirements
46    update_seq=0, % comes from couch_spatial_group requirements
47    purge_seq=0, % comes from couch_spatial_group requirements
48    % Store the FD from the group within the index as well, so we don't have
49    % to pass on the group when we only want the FD to write to/read from
50    fd=nil
51}).
52
53% The counterpart to #spatial_index_header in the view server is #index_header
54-record(spatial_index_header, {
55    seq=0,
56    purge_seq=0,
57    id_btree_state=nil, % pointer/position in file to back-index
58    % One #spatial record for every index that is stripped by the information
59    % that can be retrieved from a Design Document or during runtime.
60    % Only the fields that need to persisted will have sane values
61    index_states=nil,
62    disk_version = ?LATEST_SPATIAL_DISK_VERSION
63}).
64
65% The counterpart to #spatial_query_args in the view server is
66% #view_query_args
67-record(spatial_query_args, {
68    bbox=nil,
69    stale=update_after :: update_after | ok | false,
70    count=false,
71    % Bounds of the cartesian plane
72    bounds=nil,
73    limit = 10000000000, % Huge number to simplify logic
74    skip = 0
75}).
76
77% The counterpart to #spatial_fold_helper_funs in the view server is
78% #view__fold_helper_funs
79-record(spatial_fold_helper_funs, {
80    start_response,
81    send_row
82}).
83