157 char i_item[128], *i_item_ptr;
158 int i_more, i_mode, i;
161 char f_item[128], *f_item_ptr;
170 char r_item_buf[128];
190 yaz_log (YLOG_LOG,
"isc: isamc_merge begin %d " ZINT_FORMAT, cat, pp->
pos);
200 border =
get_border (is, mb, ptr, cat, firstpos);
201 while (i_more || f_more)
203 char *r_item = r_item_buf;
221 yaz_log (YLOG_LOG,
"isc: release A");
234 mb[ptr].
dirty = last_dirty;
235 mb[ptr].
offset = r_offset;
237 yaz_log (YLOG_LOG,
"isc: bound ptr=%d,offset=%d",
245 yaz_log (YLOG_LOG,
"isc: flush A %d sections", ptr);
250 memcpy (r_buf, r_buf + mb[ptr-1].
offset,
258 r_offset = mb[ptr].
offset;
262 border =
get_border (is, mb, ptr, cat, firstpos);
285 memcpy (r_item, i_item, i_item_ptr - i_item);
300 memcpy (r_item, f_item, f_item_ptr - f_item);
313 memcpy (r_item, f_item, f_item_ptr - f_item);
322 yaz_log (YLOG_FATAL,
"Inconsistent register at offset %d",
326 memcpy (r_item, i_item, i_item_ptr - i_item);
336 char *r_out_ptr = r_buf + r_offset;
337 const char *src = r_item;
341 new_offset = r_out_ptr - r_buf;
345 if (border < new_offset && border >= r_offset)
354 mb[ptr].
offset = r_offset;
362 yaz_log (YLOG_LOG,
"isc: flush B %d sections", ptr-1);
367 memcpy (r_buf, r_buf + mb[ptr-1].
offset,
374 memcpy (r_buf + mb[1].
offset, r_buf + r_offset,
375 new_offset - r_offset);
376 new_offset = (new_offset - r_offset) + mb[1].
offset;
379 border =
get_border (is, mb, ptr, cat, firstpos);
381 r_offset = new_offset;
392 for (i = 0; i < ptr; i++)
399 assert (mb[j].
offset == 0);
403 mb[ptr].
offset = r_offset;
404 for (i = 1; i < ptr; i++)
409 yaz_log (YLOG_LOG,
"isc: remap %d border=%d", i, border);
413 yaz_log (YLOG_LOG,
"isc: to %d %d", j, mb[i].
offset);
420 yaz_log (YLOG_LOG,
"isc: remap from %d to %d sections to cat %d",
423 border =
get_border (is, mb, ptr, cat, firstpos);
425 yaz_log (YLOG_LOG,
"isc: border=" ZINT_FORMAT " r_offset=%d",
429 if (mb[ptr].
offset < r_offset)
433 mb[ptr].
offset = r_offset;
437 if (cat == pp->
cat && mb[ptr].
block)
440 yaz_log (YLOG_LOG,
"isc: release C");
449 yaz_log (YLOG_LOG,
"isc: flush C, %d sections", ptr);
461 sizeof(numKeys), &numKeys);
471 flush_blocks (is, mb, ptr, r_buf, &firstpos, cat, 1, &numKeys);
477 yaz_log (YLOG_LOG,
"isc: isamc_merge return %d " ZINT_FORMAT, cat, firstpos);
479 *ipos = cat + firstpos * 8;
int bf_write(BFile bf, zint no, int offset, int nbytes, const void *buf)
writes block of bytes to file (may call exit)
static void flush_blocks(ISAMC is, struct isamc_merge_block *mb, int ptr, char *r_buf, zint *firstpos, int cat, int last, zint *numkeys)