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    fd=nil,
22    name, % design document ID
23    def_lang,
24    design_options=[],
25    indexes,
26    lib,
27    id_btree=nil, % the back-index
28    current_seq=0,
29    purge_seq=0
30%    waiting_delayed_commit=nil
31    }).
32
33% It's the tree strucure of the spatial index
34% The counterpart to #spatial in the view server is #view
35-record(spatial, {
36    root_dir=nil,
37    seq=0,
38    treepos=nil,
39    treeheight=0, % height of the tree
40    def=nil, % The function in the query/view server
41    index_names=[],
42    id_num=0, % comes from couch_spatial_group requirements
43    update_seq=0, % comes from couch_spatial_group requirements
44    purge_seq=0, % comes from couch_spatial_group requirements
45    % Store the FD from the group within the index as well, so we don't have
46    % to pass on the group when we only want the FD to write to/read from
47    fd=nil
48}).
49
50% The counterpart to #spatial_index_header in the view server is #index_header
51-record(spatial_index_header, {
52    seq=0,
53    purge_seq=0,
54    id_btree_state=nil, % pointer/position in file to back-index
55    % One #spatial record for every index that is stripped by the information
56    % that can be retrieved from a Design Document or during runtime.
57    % Only the fields that need to persisted will have sane values
58    index_states=nil,
59    disk_version = ?LATEST_SPATIAL_DISK_VERSION
60}).
61
62% The counterpart to #spatial_query_args in the view server is
63% #view_query_args
64-record(spatial_query_args, {
65    bbox=nil,
66    stale=nil,
67    count=false,
68    % Bounds of the cartesian plane
69    bounds=nil,
70    limit = 10000000000, % Huge number to simplify logic
71    skip = 0
72}).
73
74% The counterpart to #spatial_fold_helper_funs in the view server is
75% #view__fold_helper_funs
76-record(spatial_fold_helper_funs, {
77    start_response,
78    send_row
79}).
80