IDZEBRA
2.2.7
|
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <yaz/log.h>
#include <yaz/snprintf.h>
#include <yaz/xmalloc.h>
#include <idzebra/isamb.h>
Go to the source code of this file.
Data Structures | |
struct | ISAMB_head |
struct | ISAMB_cache_entry |
struct | ISAMB_file |
struct | ISAMB_s |
struct | ISAMB_block |
struct | ISAMB_PP_s |
Macros | |
#define | ISAMB_DEBUG 0 |
#define | ISAMB_MAJOR_VERSION 3 |
#define | ISAMB_MINOR_VERSION_NO_ROOT 0 |
#define | ISAMB_MINOR_VERSION_WITH_ROOT 1 |
#define | INT_ENCODE 1 |
#define | DST_ITEM_MAX 5000 |
#define | ISAMB_MAX_PAGE 32768 |
#define | ISAMB_MAX_LEVEL 10 |
#define | DST_BUF_SIZE (2*ISAMB_MAX_PAGE+DST_ITEM_MAX+100) |
#define | ISAMB_CACHE_ENTRY_SIZE ISAMB_MAX_PAGE |
#define | CAT_MAX 4 |
#define | CAT_MASK (CAT_MAX-1) |
#define | CAT_NO 4 |
#define | ISAMB_MIN_SIZE 32 |
#define | ISAMB_FAC_SIZE 4 |
#define | ISAMB_PTR_CODEC 1 |
#define | encode_item_len encode_ptr |
#define | decode_item_len decode_ptr |
Functions | |
static void | encode_ptr (char **dst, zint pos) |
static void | decode_ptr (const char **src, zint *pos) |
void | isamb_set_int_count (ISAMB b, int v) |
void | isamb_set_cache_size (ISAMB b, int v) |
ISAMB | isamb_open2 (BFiles bfs, const char *name, int writeflag, ISAMC_M *method, int cache, int no_cat, int *sizes, int use_root_ptr) |
ISAMB | isamb_open (BFiles bfs, const char *name, int writeflag, ISAMC_M *method, int cache) |
static void | flush_blocks (ISAMB b, int cat) |
static int | cache_block (ISAMB b, ISAM_P pos, unsigned char *userbuf, int wr) |
void | isamb_close (ISAMB isamb) |
static struct ISAMB_block * | open_block (ISAMB b, ISAM_P pos) |
struct ISAMB_block * | new_block (ISAMB b, int leaf, int cat) |
struct ISAMB_block * | new_leaf (ISAMB b, int cat) |
struct ISAMB_block * | new_int (ISAMB b, int cat) |
static void | check_block (ISAMB b, struct ISAMB_block *p) |
void | close_block (ISAMB b, struct ISAMB_block *p) |
int | insert_sub (ISAMB b, struct ISAMB_block **p, void *new_item, int *mode, ISAMC_I *stream, struct ISAMB_block **sp, void *sub_item, int *sub_size, const void *max_item) |
int | insert_int (ISAMB b, struct ISAMB_block *p, void *lookahead_item, int *mode, ISAMC_I *stream, struct ISAMB_block **sp, void *split_item, int *split_size, const void *last_max_item) |
int | insert_leaf (ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, int *lookahead_mode, ISAMC_I *stream, struct ISAMB_block **sp2, void *sub_item, int *sub_size, const void *max_item) |
int | isamb_unlink (ISAMB b, ISAM_P pos) |
void | isamb_merge (ISAMB b, ISAM_P *pos, ISAMC_I *stream) |
ISAMB_PP | isamb_pp_open_x (ISAMB isamb, ISAM_P pos, int *level, int scope) |
ISAMB_PP | isamb_pp_open (ISAMB isamb, ISAM_P pos, int scope) |
void | isamb_pp_close_x (ISAMB_PP pp, zint *size, zint *blocks) |
int | isamb_block_info (ISAMB isamb, int cat) |
void | isamb_pp_close (ISAMB_PP pp) |
static void | isamb_dump_r (ISAMB b, ISAM_P pos, void(*pr)(const char *str), int level) |
void | isamb_dump (ISAMB b, ISAM_P pos, void(*pr)(const char *str)) |
int | isamb_pp_read (ISAMB_PP pp, void *buf) |
void | isamb_pp_pos (ISAMB_PP pp, double *current, double *total) |
int | isamb_pp_forward (ISAMB_PP pp, void *buf, const void *untilb) |
zint | isamb_get_int_splits (ISAMB b) |
zint | isamb_get_leaf_splits (ISAMB b) |
zint | isamb_get_root_ptr (ISAMB b) |
void | isamb_set_root_ptr (ISAMB b, zint root_ptr) |
#define decode_item_len decode_ptr |
#define DST_BUF_SIZE (2*ISAMB_MAX_PAGE+DST_ITEM_MAX+100) |
#define encode_item_len encode_ptr |
#define ISAMB_CACHE_ENTRY_SIZE ISAMB_MAX_PAGE |
Definition at line 383 of file isamb.c.
References ISAMB_file::bf, bf_read(), bf_write(), ISAMB_head::block_size, ISAMB_cache_entry::buf, ISAMB_s::cache, ISAMB_file::cache_entries, ISAMB_s::cache_size, CAT_MASK, CAT_MAX, ISAMB_cache_entry::dirty, ISAMB_s::file, ISAMB_file::head, ISAMB_CACHE_ENTRY_SIZE, ISAMB_s::log_io, ISAMB_cache_entry::next, and ISAMB_cache_entry::pos.
Referenced by close_block(), new_block(), and open_block().
|
static |
Definition at line 626 of file isamb.c.
References ISAMB_block::bytes, ISAMB_block::cat, CAT_MASK, ISAMC_M_s::codec, ISAM_CODEC::decode, decode_item_len, decode_ptr(), DST_ITEM_MAX, ISAMB_block::leaf, ISAMB_s::method, ISAMB_block::pos, ISAM_CODEC::reset, ISAMB_block::size, ISAM_CODEC::start, and ISAM_CODEC::stop.
Referenced by close_block().
void close_block | ( | ISAMB | b, |
struct ISAMB_block * | p | ||
) |
Definition at line 667 of file isamb.c.
References ISAMB_file::bf, bf_write(), ISAMB_head::block_offset, ISAMB_block::buf, cache_block(), ISAMB_block::cat, CAT_MAX, check_block(), ISAMC_M_s::codec, ISAMB_block::decodeClientData, ISAMB_block::deleted, ISAMB_block::dirty, encode_ptr(), ISAMB_s::file, ISAMB_head::free_list, ISAMB_file::head, ISAMB_file::head_dirty, ISAMB_block::leaf, ISAMB_s::log_freelist, ISAMB_s::log_io, ISAMB_s::method, ISAMB_block::no_items, ISAMB_block::offset, ISAMB_block::pos, ISAMB_block::size, ISAM_CODEC::stop, and ZINT_FORMAT.
Referenced by insert_int(), insert_leaf(), isamb_dump_r(), isamb_merge(), isamb_pp_close_x(), isamb_pp_forward(), and isamb_unlink().
|
static |
Definition at line 172 of file isamb.c.
References ISAMB_block::pos.
Referenced by check_block(), insert_int(), isamb_dump_r(), isamb_open2(), isamb_pp_forward(), isamb_pp_open_x(), isamb_unlink(), and open_block().
|
static |
Definition at line 150 of file isamb.c.
References ISAMB_block::pos.
Referenced by close_block(), insert_int(), isamb_close(), and isamb_merge().
|
static |
Definition at line 366 of file isamb.c.
References ISAMB_file::bf, bf_write(), ISAMB_cache_entry::buf, ISAMB_file::cache_entries, ISAMB_block::cat, ISAMB_cache_entry::dirty, ISAMB_s::file, ISAMB_s::log_io, ISAMB_cache_entry::next, and ISAMB_cache_entry::pos.
Referenced by isamb_close().
int insert_int | ( | ISAMB | b, |
struct ISAMB_block * | p, | ||
void * | lookahead_item, | ||
int * | mode, | ||
ISAMC_I * | stream, | ||
struct ISAMB_block ** | sp, | ||
void * | split_item, | ||
int * | split_size, | ||
const void * | last_max_item | ||
) |
Definition at line 716 of file isamb.c.
References ISAMB_head::block_max, ISAMB_head::block_size, ISAMB_block::bytes, ISAMB_block::cat, close_block(), ISAMC_M_s::codec, ISAMC_M_s::compare_item, ISAM_CODEC::decode, decode_item_len, decode_ptr(), ISAMB_block::dirty, DST_BUF_SIZE, DST_ITEM_MAX, ISAMB_s::enable_int_count, ISAM_CODEC::encode, encode_item_len, encode_ptr(), ISAMB_s::file, ISAMB_file::head, insert_sub(), ISAMB_s::method, new_int(), ISAMB_block::no_items, ISAMB_s::number_of_int_splits, open_block(), ISAMB_block::pos, ISAM_CODEC::reset, ISAMB_block::size, ISAM_CODEC::start, and ISAM_CODEC::stop.
Referenced by insert_sub().
int insert_leaf | ( | ISAMB | b, |
struct ISAMB_block ** | sp1, | ||
void * | lookahead_item, | ||
int * | lookahead_mode, | ||
ISAMC_I * | stream, | ||
struct ISAMB_block ** | sp2, | ||
void * | sub_item, | ||
int * | sub_size, | ||
const void * | max_item | ||
) |
Definition at line 922 of file isamb.c.
References ISAMB_head::block_max, ISAMB_block::bytes, ISAMB_block::cat, ISAMC_I_s::clientData, close_block(), ISAMC_M_s::codec, ISAMC_M_s::compare_item, ISAM_CODEC::decode, ISAMB_block::deleted, ISAMB_block::dirty, DST_BUF_SIZE, DST_ITEM_MAX, ISAM_CODEC::encode, ISAMB_s::file, ISAMB_file::head, ISAMB_s::method, new_leaf(), ISAMB_s::no_cat, ISAMB_block::no_items, ISAMB_s::number_of_leaf_splits, ISAMC_I_s::read_item, ISAM_CODEC::reset, ISAMB_block::size, ISAM_CODEC::start, and ISAM_CODEC::stop.
Referenced by insert_sub().
int insert_sub | ( | ISAMB | b, |
struct ISAMB_block ** | p, | ||
void * | new_item, | ||
int * | mode, | ||
ISAMC_I * | stream, | ||
struct ISAMB_block ** | sp, | ||
void * | sub_item, | ||
int * | sub_size, | ||
const void * | max_item | ||
) |
Definition at line 1210 of file isamb.c.
References insert_int(), insert_leaf(), and ISAMB_block::leaf.
Referenced by insert_int(), and isamb_merge().
int isamb_block_info | ( | ISAMB | isamb, |
int | cat | ||
) |
Definition at line 1422 of file isamb.c.
References ISAMB_head::block_size, ISAMB_block::cat, ISAMB_s::file, and ISAMB_file::head.
Referenced by zebra_register_statistics().
void isamb_close | ( | ISAMB | isamb | ) |
Definition at line 455 of file isamb.c.
References ISAMB_s::accessed_nodes, ISAMB_file::bf, bf_close(), bf_write(), ISAMB_head::block_max, ISAMB_head::block_size, DST_BUF_SIZE, encode_ptr(), ISAMB_s::file, ISAMB_head::first_block, flush_blocks(), ISAMB_head::free_list, ISAMB_file::head, ISAMB_file::head_dirty, ISAMB_MAJOR_VERSION, ISAMB_MINOR_VERSION_WITH_ROOT, ISAMB_head::last_block, ISAMB_s::method, ISAMB_s::minor_version, ISAMB_s::no_cat, ISAMB_cache_entry::pos, ISAMB_s::returned_numbers, ISAMB_s::root_ptr, ISAMB_s::skipped_nodes, ISAMB_s::skipped_numbers, and ZINT_FORMAT.
Referenced by isamb_open2(), main(), recindex_close(), zebra_register_close(), and zebra_sort_close().
Definition at line 1498 of file isamb.c.
References isamb_dump_r(), and ISAMB_block::pos.
Referenced by bench_insert(), recindex_close(), tst_insert(), tst_minsert(), and tst_random().
Definition at line 1435 of file isamb.c.
References ISAMB_head::block_max, ISAMB_block::buf, ISAMB_block::bytes, ISAMB_block::cat, close_block(), ISAMC_M_s::codec, ISAM_CODEC::decode, decode_item_len, decode_ptr(), ISAMB_block::decodeClientData, DST_ITEM_MAX, ISAMB_s::file, ISAMB_file::head, ISAMB_block::leaf, ISAMC_M_s::log_item, ISAMB_s::method, ISAMB_block::no_items, ISAMB_block::offset, open_block(), ISAMB_block::pos, ISAMB_block::size, ISAM_CODEC::start, ISAM_CODEC::stop, and ZINT_FORMAT.
Referenced by isamb_dump().
Definition at line 1659 of file isamb.c.
References ISAMB_s::number_of_int_splits.
Referenced by index_block_flush().
Definition at line 1664 of file isamb.c.
References ISAMB_s::number_of_leaf_splits.
Referenced by index_block_flush().
Definition at line 1669 of file isamb.c.
References ISAMB_s::root_ptr.
Referenced by recindex_open(), and zebra_sort_type().
Definition at line 1266 of file isamb.c.
References ISAMB_block::bytes, ISAMB_s::cache, ISAMB_block::cat, ISAMC_I_s::clientData, close_block(), ISAMC_M_s::codec, DST_ITEM_MAX, ISAM_CODEC::encode, encode_item_len, encode_ptr(), insert_sub(), isamb_unlink(), ISAMB_s::method, new_int(), ISAMB_block::no_items, open_block(), ISAMB_block::pos, ISAMC_I_s::read_item, ISAM_CODEC::reset, ISAMB_block::size, ISAM_CODEC::start, and ISAM_CODEC::stop.
Referenced by bench_insert(), heap_inpb(), index_block_flush(), recindex_write_indx(), tst_append(), tst_forward(), tst_insert(), tst_minsert(), tst_random(), tst_x(), zebra_sort_add(), and zebra_sort_delete().
Definition at line 351 of file isamb.c.
References CAT_NO, ISAMB_FAC_SIZE, ISAMB_MIN_SIZE, and isamb_open2().
Referenced by main(), and zebra_register_open().
ISAMB isamb_open2 | ( | BFiles | bfs, |
const char * | name, | ||
int | writeflag, | ||
ISAMC_M * | method, | ||
int | cache, | ||
int | no_cat, | ||
int * | sizes, | ||
int | use_root_ptr | ||
) |
Definition at line 205 of file isamb.c.
References ISAMB_s::accessed_nodes, ISAMB_file::bf, bf_open(), bf_read(), ISAMB_s::bfs, ISAMB_head::block_max, ISAMB_head::block_offset, ISAMB_head::block_size, ISAMB_s::cache, ISAMB_file::cache_entries, ISAMB_s::cache_size, CAT_MAX, decode_ptr(), DST_BUF_SIZE, ISAMB_s::enable_int_count, ISAMB_s::file, ISAMB_head::first_block, ISAMB_head::free_list, ISAMB_file::head, ISAMB_file::head_dirty, ISAMB_CACHE_ENTRY_SIZE, isamb_close(), ISAMB_MAJOR_VERSION, ISAMB_MAX_LEVEL, ISAMB_MINOR_VERSION_NO_ROOT, ISAMB_MINOR_VERSION_WITH_ROOT, ISAMB_head::last_block, ISAMB_s::log_freelist, ISAMB_s::log_io, ISAMB_s::method, ISAMB_s::minor_version, ISAMB_s::no_cat, ISAMB_s::number_of_int_splits, ISAMB_s::number_of_leaf_splits, ISAMB_block::pos, ISAMB_s::returned_numbers, ISAMB_s::root_ptr, ISAMB_s::skipped_nodes, and ISAMB_s::skipped_numbers.
Referenced by isamb_open(), recindex_open(), and zebra_sort_type().
void isamb_pp_close | ( | ISAMB_PP | pp | ) |
Definition at line 1429 of file isamb.c.
References isamb_pp_close_x().
Referenced by delete_w_all_handle(), r_close(), recindex_read_indx(), rset_trunc_r(), tst_forward(), tst_insert(), tst_random(), zebra_recid_to_sysno(), zebra_record_check(), zebra_sort_close(), and zebra_sortf_rewind().
Definition at line 1392 of file isamb.c.
References ISAMB_s::accessed_nodes, ISAMB_PP_s::accessed_nodes, ISAMB_PP_s::block, close_block(), ISAMB_PP_s::isamb, ISAMB_PP_s::level, ISAMB_PP_s::maxlevel, ISAMB_PP_s::no_blocks, ISAMB_s::returned_numbers, ISAMB_PP_s::returned_numbers, ISAMB_block::size, ISAMB_s::skipped_nodes, ISAMB_PP_s::skipped_nodes, ISAMB_s::skipped_numbers, ISAMB_PP_s::skipped_numbers, ISAMB_PP_s::total_size, and ZINT_FORMAT.
Referenced by inv_stat_handle(), and isamb_pp_close().
int isamb_pp_forward | ( | ISAMB_PP | pp, |
void * | buf, | ||
const void * | untilb | ||
) |
Definition at line 1525 of file isamb.c.
References ISAMB_PP_s::block, ISAMB_block::buf, ISAMB_block::bytes, close_block(), ISAMC_M_s::codec, ISAMC_M_s::compare_item, ISAM_CODEC::decode, decode_item_len, decode_ptr(), ISAMB_block::decodeClientData, DST_ITEM_MAX, ISAMB_PP_s::isamb, ISAMB_block::leaf, ISAMB_PP_s::level, ISAMB_s::method, ISAMB_PP_s::no_blocks, ISAMB_block::offset, open_block(), ISAMB_block::pos, ISAM_CODEC::reset, ISAMB_PP_s::returned_numbers, ISAMB_PP_s::scope, ISAMB_block::size, ISAM_CODEC::start, ISAM_CODEC::stop, and ISAMB_PP_s::total_size.
Referenced by isamb_pp_read(), r_forward(), recindex_read_indx(), tst_forward(), zebra_recid_to_sysno(), zebra_record_check(), and zebra_sort_read().
Definition at line 1387 of file isamb.c.
References isamb_pp_open_x(), ISAMB_block::pos, and scope.
Referenced by delete_w_all_handle(), r_open(), recindex_read_indx(), rset_trunc_r(), tst_forward(), tst_insert(), tst_random(), zebra_recid_to_sysno(), zebra_record_check(), and zebra_sort_read().
Definition at line 1345 of file isamb.c.
References ISAMB_PP_s::accessed_nodes, ISAMB_PP_s::block, ISAMB_block::bytes, decode_ptr(), ISAMB_PP_s::isamb, ISAMB_MAX_LEVEL, ISAMB_block::leaf, ISAMB_PP_s::level, ISAMB_PP_s::maxlevel, ISAMB_PP_s::no_blocks, ISAMB_block::offset, open_block(), ISAMB_block::pos, ISAMB_PP_s::pos, ISAMB_PP_s::returned_numbers, ISAMB_PP_s::scope, scope, ISAMB_block::size, ISAMB_PP_s::skipped_nodes, ISAMB_PP_s::skipped_numbers, and ISAMB_PP_s::total_size.
Referenced by inv_stat_handle(), and isamb_pp_open().
void isamb_pp_pos | ( | ISAMB_PP | pp, |
double * | current, | ||
double * | total | ||
) |
Definition at line 1509 of file isamb.c.
References ISAMB_PP_s::block, ISAMB_DEBUG, ISAMB_block::no_items, ISAMB_PP_s::returned_numbers, and ZINT_FORMAT.
Referenced by r_pos().
int isamb_pp_read | ( | ISAMB_PP | pp, |
void * | buf | ||
) |
Definition at line 1503 of file isamb.c.
References ISAMB_block::buf, and isamb_pp_forward().
Referenced by delete_w_all_handle(), inv_stat_handle(), r_read(), r_read_filter(), rset_trunc_r(), tst_insert(), tst_random(), and zebra_recid_to_sysno().
void isamb_set_cache_size | ( | ISAMB | b, |
int | v | ||
) |
void isamb_set_int_count | ( | ISAMB | b, |
int | v | ||
) |
Definition at line 1674 of file isamb.c.
References ISAMB_s::root_ptr.
Referenced by recindex_close(), and zebra_sort_close().
Definition at line 1225 of file isamb.c.
References ISAMB_block::bytes, close_block(), ISAMC_M_s::codec, ISAM_CODEC::decode, decode_item_len, decode_ptr(), ISAMB_block::deleted, DST_ITEM_MAX, isamb_unlink(), ISAMB_block::leaf, ISAMB_s::method, ISAMB_block::offset, open_block(), ISAMB_block::pos, ISAM_CODEC::reset, ISAMB_block::size, ISAM_CODEC::start, and ISAM_CODEC::stop.
Referenced by delete_w_handle(), isamb_merge(), isamb_unlink(), and tst_forward().
struct ISAMB_block* new_block | ( | ISAMB | b, |
int | leaf, | ||
int | cat | ||
) |
Definition at line 564 of file isamb.c.
References ISAMB_file::bf, bf_read(), ISAMB_head::block_offset, ISAMB_head::block_size, ISAMB_block::buf, ISAMB_block::bytes, cache_block(), ISAMB_block::cat, CAT_MASK, CAT_MAX, ISAMC_M_s::codec, ISAMB_block::decodeClientData, ISAMB_block::deleted, ISAMB_block::dirty, ISAMB_s::file, ISAMB_head::free_list, ISAMB_file::head, ISAMB_file::head_dirty, ISAMB_head::last_block, ISAMB_block::leaf, ISAMB_s::log_freelist, ISAMB_s::log_io, ISAMB_s::method, ISAMB_block::no_items, ISAMB_block::offset, ISAMB_block::pos, ISAMB_block::size, ISAM_CODEC::start, zebra_exit(), and ZINT_FORMAT.
Referenced by new_int(), and new_leaf().
struct ISAMB_block* new_int | ( | ISAMB | b, |
int | cat | ||
) |
Definition at line 621 of file isamb.c.
References ISAMB_block::cat, and new_block().
Referenced by insert_int(), and isamb_merge().
struct ISAMB_block* new_leaf | ( | ISAMB | b, |
int | cat | ||
) |
Definition at line 615 of file isamb.c.
References ISAMB_block::cat, and new_block().
Referenced by insert_leaf().
|
static |
Definition at line 521 of file isamb.c.
References ISAMB_file::bf, bf_read(), ISAMB_head::block_offset, ISAMB_head::block_size, ISAMB_block::buf, ISAMB_block::bytes, cache_block(), ISAMB_block::cat, CAT_MASK, CAT_MAX, ISAMB_block::cbuf, ISAMC_M_s::codec, decode_ptr(), ISAMB_block::decodeClientData, ISAMB_block::deleted, ISAMB_block::dirty, ISAMB_s::file, ISAMB_file::head, ISAMB_block::leaf, ISAMB_s::log_io, ISAMB_s::method, ISAMB_block::no_items, ISAMB_block::offset, ISAMB_block::pos, ISAMB_block::size, ISAM_CODEC::start, zebra_exit(), and ZINT_FORMAT.
Referenced by insert_int(), isamb_dump_r(), isamb_merge(), isamb_pp_forward(), isamb_pp_open_x(), and isamb_unlink().