More work on multi-map for sort
[idzebra-moved-to-github.git] / include / sortidx.h
1 /* This file is part of the Zebra server.
2    Copyright (C) 1995-2008 Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20 #ifndef SORTIDX_H
21 #define SORTIDX_H
22
23 #include <yaz/yconfig.h>
24 #include <idzebra/version.h>
25 #include <idzebra/bfile.h>
26 #include <yaz/wrbuf.h>
27
28 YAZ_BEGIN_CDECL
29
30 #define SORT_IDX_ENTRYSIZE 64
31
32 /** \var zebra_sort_index_t
33     \brief sort index handle
34 */
35 typedef struct zebra_sort_index *zebra_sort_index_t;
36
37 #define ZEBRA_SORT_TYPE_FLAT 1
38 #define ZEBRA_SORT_TYPE_ISAMB 2
39 #define ZEBRA_SORT_TYPE_MULTI 3
40
41 struct zebra_sort_ent {
42     int num;
43     WRBUF wrbuf;
44 };
45
46 /** \brief creates sort handle
47     \param bfs block files handle
48     \param write_flag (0=read-only, 1=write and read)
49     \param sort_type one of ZEBRA_SORT_TYPE_..
50     \return sort index handle
51 */
52 zebra_sort_index_t zebra_sort_open(BFiles bfs, int write_flag, int sort_type);
53
54 /** \brief frees sort handle
55 */
56 void zebra_sort_close(zebra_sort_index_t si);
57
58 /** \brief sets type for sort usage
59     \param si sort index handle
60     \param type opaque type .. A sort file for each type is created
61 */
62 int zebra_sort_type(zebra_sort_index_t si, int type);
63
64 /** \brief sets sort system number for read / add / delete
65     \param si sort index handle
66     \param sysno system number
67 */
68 void zebra_sort_sysno(zebra_sort_index_t si, zint sysno);
69
70 /** \brief adds content to sort file
71     \param si sort index handle
72     \param buf buffer content
73     \param len length
74
75     zebra_sort_type and zebra_sort_sysno must be called prior to this
76 */
77 void zebra_sort_add(zebra_sort_index_t si, const char *buf, int len);
78
79
80 /** \brief adds multi-map content to sort file
81     \param si sort index handle
82     \param ent multi-map value
83
84     zebra_sort_type and zebra_sort_sysno must be called prior to this
85 */
86 void zebra_sort_add_ent(zebra_sort_index_t si, struct zebra_sort_ent *ent);
87
88
89 /** \brief delete sort entry
90     \param si sort index handle
91
92     zebra_sort_type and zebra_sort_sysno must be called prior to this
93 */
94 void zebra_sort_delete(zebra_sort_index_t si);
95
96 /** \brief reads sort entry
97     \param si sort index handle
98     \param buf resulting buffer
99     \retval 0 could not be read
100     \retval 1 could be read (found)
101 */
102 int zebra_sort_read(zebra_sort_index_t si, WRBUF w);
103
104 YAZ_END_CDECL
105
106 #endif
107 /*
108  * Local variables:
109  * c-basic-offset: 4
110  * indent-tabs-mode: nil
111  * End:
112  * vim: shiftwidth=4 tabstop=8 expandtab
113  */
114