1/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
3/**
4 * @copyright 2013 Couchbase, Inc.
5 *
6 * @author Filipe Manana  <filipe@couchbase.com>
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 * use this file except in compliance with the License. You may obtain a copy of
10 * the License at
11 *
12 *  http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 **/
20
21#ifndef _VIEW_FILE_SORTER_H
22#define _VIEW_FILE_SORTER_H
23
24#include "config.h"
25#include <libcouchstore/visibility.h>
26#include "../file_sorter.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32
33    /*
34     * Sort a file containing records of btree operations for a view btree.
35     */
36    LIBCOUCHSTORE_API
37    file_sorter_error_t sort_view_kvs_ops_file(const char *file_path,
38                                               const char *tmp_dir);
39
40    /*
41     * Sort a file containing view records for a view btree.
42     */
43    LIBCOUCHSTORE_API
44    file_sorter_error_t sort_view_kvs_file(const char *file_path,
45                                           const char *tmp_dir,
46                                           file_merger_feed_record_t callback,
47                                           void *user_ctx);
48
49    /*
50     * Sort a file containing records of btree operations for a view id
51     * btree (back index).
52     */
53    LIBCOUCHSTORE_API
54    file_sorter_error_t sort_view_ids_ops_file(const char *file_path,
55                                               const char *tmp_dir);
56
57    /*
58     * Sort a file containing records for a view id btree (back index).
59     */
60    LIBCOUCHSTORE_API
61    file_sorter_error_t sort_view_ids_file(const char *file_path,
62                                           const char *tmp_dir,
63                                           file_merger_feed_record_t callback,
64                                           void *user_ctx);
65
66    /*
67     * Sort a file containing records for a spatial index.
68     */
69    LIBCOUCHSTORE_API
70    file_sorter_error_t sort_spatial_kvs_file(const char *file_path,
71                                              const char *tmp_dir,
72                                              const double *mbb,
73                                              const uint16_t dimension);
74
75    /* Record file sorter */
76    typedef file_sorter_error_t (*sort_record_fn)(const char *file_path,
77                                                  const char *tmp_dir,
78                                                  file_merger_feed_record_t callback,
79                                                  void *user_ctx);
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif
86