1e4df0e62SVolker Mische% Licensed under the Apache License, Version 2.0 (the "License"); you may not
2e4df0e62SVolker Mische% use this file except in compliance with the License. You may obtain a copy of
3e4df0e62SVolker Mische% the License at
4e4df0e62SVolker Mische%
5e4df0e62SVolker Mische%   http://www.apache.org/licenses/LICENSE-2.0
6e4df0e62SVolker Mische%
7e4df0e62SVolker Mische% Unless required by applicable law or agreed to in writing, software
8e4df0e62SVolker Mische% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9e4df0e62SVolker Mische% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10e4df0e62SVolker Mische% License for the specific language governing permissions and limitations under
11e4df0e62SVolker Mische% the License.
12e4df0e62SVolker Mische
13e4df0e62SVolker Mische-define(LATEST_SPATIAL_DISK_VERSION, 2).
14e4df0e62SVolker Mische
15e4df0e62SVolker Mische% The counterpart to #spatial_group in the view server is #mrst
16e4df0e62SVolker Mische-record(spatial_state, {
17e4df0e62SVolker Mische    sig = nil,
18e4df0e62SVolker Mische    fd = nil,
19e4df0e62SVolker Mische    db_name=nil,
20e4df0e62SVolker Mische    idx_name = nil,
21e4df0e62SVolker Mische    language = nil,
22e4df0e62SVolker Mische    design_options=[],
23e4df0e62SVolker Mische    views,
24e4df0e62SVolker Mische    lib,
25e4df0e62SVolker Mische    id_btree = nil,
26e4df0e62SVolker Mische    update_seq = 0,
27e4df0e62SVolker Mische    purge_seq = 0,
28e4df0e62SVolker Mische    query_server=nil,
29e4df0e62SVolker Mische
30e4df0e62SVolker Mische    first_build,
31e4df0e62SVolker Mische    partial_resp_pid,
32e4df0e62SVolker Mische    doc_acc,
33e4df0e62SVolker Mische    doc_queue,
34e4df0e62SVolker Mische    write_queue,
35e4df0e62SVolker Mische    ref_counter
36e4df0e62SVolker Mische}).
37e4df0e62SVolker Mische
38e4df0e62SVolker Mische-record(spatial_header, {
39e4df0e62SVolker Mische    seq=0,
40e4df0e62SVolker Mische    purge_seq=0,
41e4df0e62SVolker Mische    id_btree_state=nil, % pointer/position in file to back-index
42e4df0e62SVolker Mische    % One #spatial record for every index that is stripped by the information
43e4df0e62SVolker Mische    % that can be retrieved from a Design Document or during runtime.
44e4df0e62SVolker Mische    % Only the fields that need to persisted will have sane values
45e4df0e62SVolker Mische    view_states=nil,
46e4df0e62SVolker Mische    disk_version = ?LATEST_SPATIAL_DISK_VERSION
47e4df0e62SVolker Mische}).
48e4df0e62SVolker Mische
49e4df0e62SVolker Mische% The counterpart to #spatial_query_args in the view server is
50e4df0e62SVolker Mische% #view_query_args
51e4df0e62SVolker Mische-record(spatial_args, {
52e4df0e62SVolker Mische    bbox = nil,
53e4df0e62SVolker Mische    stale = false,
54e4df0e62SVolker Mische    count = false,
55e4df0e62SVolker Mische    limit = 10000000000, % Huge number to simplify logic
56e4df0e62SVolker Mische    skip = 0,
578f6d728cSVolker Mische    % a multidimensional bounding box
588f6d728cSVolker Mische    range = [] :: [{number()|nil, number()|nil}],
59e4df0e62SVolker Mische    extra,
60e4df0e62SVolker Mische    preflight_fun
61e4df0e62SVolker Mische}).
62e4df0e62SVolker Mische
63e4df0e62SVolker Mische
64e4df0e62SVolker Mische% It's the tree strucure of the spatial index
65e4df0e62SVolker Mische% The counterpart to #spatial in the view server is #view
66e4df0e62SVolker Mische-record(spatial, {
67e4df0e62SVolker Mische    root_dir=nil,
68e4df0e62SVolker Mische    seq=0,
6970c86024SVolker Mische    vtree = nil,
70e4df0e62SVolker Mische    def=nil, % The function in the query/view server
71e4df0e62SVolker Mische    view_names=[],
72e4df0e62SVolker Mische    id_num=0, % comes from couch_spatial_group requirements
73e4df0e62SVolker Mische    update_seq=0, % comes from couch_spatial_group requirements
74e4df0e62SVolker Mische    purge_seq=0, % comes from couch_spatial_group requirements
75e4df0e62SVolker Mische    % Store the FD from the group within the index as well, so we don't have
76e4df0e62SVolker Mische    % to pass on the group when we only want the FD to write to/read from
77e4df0e62SVolker Mische    fd=nil
78e4df0e62SVolker Mische}).
79e4df0e62SVolker Mische
80e4df0e62SVolker Mische
81e4df0e62SVolker Mische% The counterpart to #spatial_fold_helper_funs in the view server is
82e4df0e62SVolker Mische% #view__fold_helper_funs
83e4df0e62SVolker Mische%-record(spatial_fold_helper_funs, {
84e4df0e62SVolker Mische%    start_response,
85e4df0e62SVolker Mische%    send_row
86e4df0e62SVolker Mische%}).
8770c86024SVolker Mische
8870c86024SVolker Mische% `#vtree_state` is a subset of the #vtree record that contains the
8970c86024SVolker Mische% information that is stored in the header. It contains the information
9070c86024SVolker Mische% that can't be retrieved from other sources (as e.g. the Design Document
9170c86024SVolker Mische% or some configuration setting.
9270c86024SVolker Mische-record(vtree_state, {
9370c86024SVolker Mische          root = nil,
94283da2dcSVolker Mische          kp_chunk_threshold = 2000,
95283da2dcSVolker Mische          kv_chunk_threshold = 2000,
96283da2dcSVolker Mische          min_fill_rate = 0.4
9770c86024SVolker Mische}).