33 Dict_ptr back_ptr,
int userlen,
void *userinfo);
70 short *indxp, *best_indxp = NULL;
73 int best_no = 0, no_current = 0;
80 indxp = (
short*) ((
char*) p+
DICT_bsize(p)-
sizeof(short));
87 if (dc != prev_char) {
94 if (current_size > best_size) {
95 best_size = current_size;
104 j = best_indxp - (
short*) p;
112 for (i=0; i<best_no; i++, j++)
118 info = (
char*) p + ((
short*) p)[j];
120 memcpy(&dc, info,
sizeof(dc));
121 assert(dc == best_char);
129 info_char = *info_here;
135 subptr, *info1, info1+1);
137 assert(info_here == NULL);
140 assert(info_here == NULL || info_char == *info_here);
152 short *indxp1, *indxp2;
157 indxp1 = (
short*) ((
char*) p+
DICT_bsize(p)-
sizeof(short));
158 indxp2 = (
short*) ((
char*) np+
DICT_bsize(np));
168 info1 = (
char*) p + *indxp1;
169 if (out && memcmp(out, info1,
sizeof(
Dict_char)) == 0)
173 *--indxp2 = -(info2 - np);
174 memcpy(info2, &subptr,
sizeof(
Dict_ptr));
180 memcpy(info2, userinfo, *userinfo+1);
181 info2 += *userinfo + 1;
189 *--indxp2 = info2 - np;
191 memcpy(info2, info1, slen);
203 *--indxp2 = -(info2 - np);
204 info1 = (
char*) p - *indxp1;
210 memcpy(info2, info1, slen);
218 memcpy((
char*)p + ((
char*)indxp2 - (
char*)np),
237 yaz_log(YLOG_LOG,
"checkPage failed");
238 yaz_log(YLOG_LOG,
"DICT_size(p)=%ld", (
long)
DICT_size(p));
239 yaz_log(YLOG_LOG,
"DICT_bsize(p)=%ld", (
long)
DICT_bsize(p));
240 yaz_log(YLOG_LOG,
"DICT_nodir(p)=%ld", (
long)
DICT_nodir(p));
250 Dict_ptr ptr,
int userlen,
void *userinfo)
252 int hi, lo, mid, slen, cmp = 1;
264 indxp = (
short*) ((
char*) p+
DICT_bsize(p)-
sizeof(short));
273 info = (
char*)p + indxp[-mid];
279 if (*info == userlen)
282 if (memcmp(info+1, userinfo, userlen))
285 memcpy(info+1, userinfo, userlen);
291 else if (*info > userlen)
297 memcpy(info+1, userinfo, userlen);
312 info = (
char*)p - indxp[-mid];
317 memcpy(&subptr, info,
sizeof(
Dict_ptr));
335 else if (xlen > userlen)
358 yaz_log(YLOG_FATAL,
"Unable to split page %d\n", ptr);
366 memcpy(info, &subptr,
sizeof(subptr));
386 memcpy(info, &subptr,
sizeof(subptr));
399 if (lo>hi && cmp < 0)
419 for (; indxp1 != indxp; indxp1++)
420 indxp1[0] = indxp1[1];
425 memcpy(info, str, slen);
428 memcpy(info, userinfo, userlen);
451 assert(strlen(str) > 0);
int dict_bf_touch(Dict_BFile bf, int no)
int dict_bf_readp(Dict_BFile bf, int no, void **bufp)
int dict_strlen(const Dict_char *s)
int dict_strcmp(const Dict_char *s1, const Dict_char *s2)
int dict_bf_newp(Dict_BFile bf, int no, void **bufp, int nbytes)
static Dict_ptr new_page(Dict dict, Dict_ptr back_ptr, void **pp)
static void checkPage(Dict dict, void *p)
static int dict_ins(Dict dict, const Dict_char *str, Dict_ptr back_ptr, int userlen, void *userinfo)
static int split_page(Dict dict, Dict_ptr ptr, void *p)
int dict_insert(Dict dict, const char *str, int userlen, void *userinfo)
insert item into dictionary
static void clean_page(Dict dict, Dict_ptr ptr, void *p, Dict_char *out, Dict_ptr subptr, char *userinfo)