28 #include <yaz/xmalloc.h>
29 #include <yaz/snprintf.h>
35 #define SORT_MAX_TERM 110
36 #define SORT_MAX_MULTI 4096
38 #define SORT_IDX_BLOCKSIZE 64
52 memcpy(&a1, b,
sizeof(a1));
62 memcpy(&a1, a,
sizeof(a1));
63 memcpy(&b1, b,
sizeof(b1));
86 memcpy(&a1, *src,
sizeof(a1));
90 strcpy(*dst, a1.
term);
91 *dst += strlen(a1.
term) + 1;
98 memcpy(&a1, *src,
sizeof(a1));
116 strcpy(a1.
term, *src);
117 slen = 1 + strlen(a1.
term);
121 memcpy(*dst, &a1,
sizeof(a1));
136 memcpy(*dst, &a1,
sizeof(a1));
164 memcpy(*dst, &s->
st,
sizeof(s->
st));
165 *dst +=
sizeof(s->
st);
237 int isam_block_size = 4096;
257 sf = (
struct sortFile *) xmalloc(
sizeof(*sf));
264 yaz_snprintf(fname,
sizeof(fname),
"sort%d",
id);
265 yaz_log(YLOG_DEBUG,
"sort idx %s wr=%d", fname, si->
write_flag);
287 yaz_snprintf(fname,
sizeof(fname),
"sortb%d",
id);
303 isam_block_size = 32768;
307 yaz_snprintf(fname,
sizeof(fname),
"sortm%d",
id);
349 else if (sf->
isam_pp && new_sysno <= si->sysno)
352 si->
sysno = new_sysno;
360 if (!sf || !sf->
u.
bf)
383 isamc_i.clientData = &s;
398 if (!sf || !sf->
u.
bf)
404 len = strlen(wrbuf_buf(wrbuf));
408 memcpy(si->
entry_buf, wrbuf_buf(wrbuf), len);
422 len = wrbuf_len(wrbuf);
426 wrbuf_buf(wrbuf)[len-1] =
'\0';
428 memcpy(s.
st.
term, wrbuf_buf(wrbuf), len);
434 isamc_i.clientData = &s;
447 len = wrbuf_len(wrbuf);
451 wrbuf_buf(wrbuf)[len-1] =
'\0';
453 memcpy(s.
st.
term, wrbuf_buf(wrbuf), len);
459 isamc_i.clientData = &s;
504 st_untilbuf.
term[0] =
'\0';
int bf_read(BFile bf, zint no, int offset, int nbytes, void *buf)
read from block file (may call exit)
void bf_close(BFile bf)
closes a Block file (may call exit)
BFile bf_open(BFiles bfs, const char *name, int block_size, int wflag)
opens and returns a Block file handle
int bf_write(BFile bf, zint no, int offset, int nbytes, const void *buf)
writes block of bytes to file (may call exit)
ISAMB_PP isamb_pp_open(ISAMB isamb, ISAM_P pos, int scope)
zint isamb_get_root_ptr(ISAMB b)
void isamb_close(ISAMB isamb)
void isamb_set_root_ptr(ISAMB b, zint root_ptr)
int isamb_pp_forward(ISAMB_PP pp, void *buf, const void *untilbuf)
ISAMB isamb_open2(BFiles bfs, const char *name, int writeflag, ISAMC_M *method, int cache, int no_cat, int *sizes, int use_root_ptr)
void isamb_pp_close(ISAMB_PP pp)
void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *data)
zint rec_sysno_to_int(zint sysno)
int zebra_sort_read(zebra_sort_index_t si, zint *section_id, WRBUF w)
reads sort entry
void zebra_sort_close(zebra_sort_index_t si)
frees sort handle
static void zebra_sortf_rewind(struct sortFile *sf)
static void sort_term_code_reset(void *p)
static void * sort_term_code_start(void)
static int sort_term_compare(const void *a, const void *b)
zebra_sort_index_t zebra_sort_open(BFiles bfs, int write_flag, int type)
creates sort handle
int zebra_sort_type(zebra_sort_index_t si, int id)
sets type for sort usage
static void sort_term_code_stop(void *p)
static void sort_term_encode1(void *p, char **dst, const char **src)
static void sort_term_log_item(int level, const void *b, const char *txt)
static int sort_term_code_read(void *vp, char **dst, int *insertMode)
#define SORT_IDX_BLOCKSIZE
static void sort_term_decode2(void *p, char **dst, const char **src)
static void sort_term_decode1(void *p, char **dst, const char **src)
void zebra_sort_sysno(zebra_sort_index_t si, zint sysno)
sets sort system number for read / add / delete
void zebra_sort_delete(zebra_sort_index_t si, zint section_id)
delete sort entry
static void sort_term_encode2(void *p, char **dst, const char **src)
void zebra_sort_add(zebra_sort_index_t si, zint section_id, WRBUF wrbuf)
adds multi-map content to sort file
#define ZEBRA_SORT_TYPE_ISAMB
struct zebra_sort_index * zebra_sort_index_t
sort index handle
#define ZEBRA_SORT_TYPE_FLAT
#define ZEBRA_SORT_TYPE_MULTI
#define SORT_IDX_ENTRYSIZE
int(* compare_item)(const void *a, const void *b)
void(* log_item)(int logmask, const void *p, const char *txt)
void(* decode)(void *p, char **dst, const char **src)
void(* encode)(void *p, char **dst, const char **src)
char term[SORT_MAX_MULTI]
struct sortFile * current_file
void zebra_zint_decode(const char **src, zint *pos)
void zebra_zint_encode(char **dst, zint pos)