IDZEBRA  2.1.2
Data Structures | Macros | Functions
isamb.c File Reference
#include <stdlib.h>
#include <string.h>
#include <yaz/log.h>
#include <yaz/xmalloc.h>
#include <idzebra/isamb.h>
#include <assert.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_blockopen_block (ISAMB b, ISAM_P pos)
 
struct ISAMB_blocknew_block (ISAMB b, int leaf, int cat)
 
struct ISAMB_blocknew_leaf (ISAMB b, int cat)
 
struct ISAMB_blocknew_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)
 

Macro Definition Documentation

#define CAT_MASK   (CAT_MAX-1)

Definition at line 67 of file isamb.c.

Referenced by cache_block(), check_block(), new_block(), and open_block().

#define CAT_MAX   4

Definition at line 66 of file isamb.c.

Referenced by cache_block(), close_block(), isamb_open2(), new_block(), and open_block().

#define CAT_NO   4

Definition at line 69 of file isamb.c.

Referenced by isamb_open().

#define decode_item_len   decode_ptr

Definition at line 169 of file isamb.c.

Referenced by check_block(), insert_int(), isamb_dump_r(), isamb_pp_forward(), and isamb_unlink().

#define DST_BUF_SIZE   (2*ISAMB_MAX_PAGE+DST_ITEM_MAX+100)

Definition at line 60 of file isamb.c.

Referenced by insert_int(), insert_leaf(), isamb_close(), and isamb_open2().

#define DST_ITEM_MAX   5000
#define encode_item_len   encode_ptr

Definition at line 147 of file isamb.c.

Referenced by insert_int(), and isamb_merge().

#define INT_ENCODE   1

Definition at line 50 of file isamb.c.

#define ISAMB_CACHE_ENTRY_SIZE   ISAMB_MAX_PAGE

Definition at line 63 of file isamb.c.

Referenced by cache_block(), and isamb_open2().

#define ISAMB_DEBUG   0

Definition at line 31 of file isamb.c.

Referenced by isamb_pp_pos().

#define ISAMB_FAC_SIZE   4

Definition at line 74 of file isamb.c.

Referenced by isamb_open().

#define ISAMB_MAJOR_VERSION   3

Definition at line 35 of file isamb.c.

Referenced by isamb_close(), and isamb_open2().

#define ISAMB_MAX_LEVEL   10

Definition at line 58 of file isamb.c.

Referenced by isamb_open2(), and isamb_pp_open_x().

#define ISAMB_MAX_PAGE   32768

Definition at line 56 of file isamb.c.

#define ISAMB_MIN_SIZE   32

Definition at line 72 of file isamb.c.

Referenced by isamb_open().

#define ISAMB_MINOR_VERSION_NO_ROOT   0

Definition at line 36 of file isamb.c.

Referenced by isamb_open2().

#define ISAMB_MINOR_VERSION_WITH_ROOT   1

Definition at line 37 of file isamb.c.

Referenced by isamb_close(), and isamb_open2().

#define ISAMB_PTR_CODEC   1

Definition at line 77 of file isamb.c.

Function Documentation

static int cache_block ( ISAMB  b,
ISAM_P  pos,
unsigned char *  userbuf,
int  wr 
)
static
static void check_block ( ISAMB  b,
struct ISAMB_block p 
)
static
void close_block ( ISAMB  b,
struct ISAMB_block p 
)
static void decode_ptr ( const char **  src,
zint pos 
)
static
static void encode_ptr ( char **  dst,
zint  pos 
)
static

Definition at line 149 of file isamb.c.

References ISAMB_block::pos.

Referenced by close_block(), insert_int(), isamb_close(), and isamb_merge().

static void flush_blocks ( ISAMB  b,
int  cat 
)
static
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 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 1209 of file isamb.c.

References insert_int(), insert_leaf(), and ISAMB_block::leaf.

Referenced by close_block(), insert_int(), and isamb_merge().

int isamb_block_info ( ISAMB  isamb,
int  cat 
)

Definition at line 1421 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)
void isamb_dump ( ISAMB  b,
ISAM_P  pos,
void(*)(const char *str)  pr 
)

Definition at line 1496 of file isamb.c.

References isamb_dump_r().

Referenced by bench_insert(), recindex_close(), tst_insert(), tst_minsert(), and tst_random().

static void isamb_dump_r ( ISAMB  b,
ISAM_P  pos,
void(*)(const char *str)  pr,
int  level 
)
static
zint isamb_get_int_splits ( ISAMB  b)

Definition at line 1657 of file isamb.c.

References ISAMB_s::number_of_int_splits.

Referenced by index_block_flush().

zint isamb_get_leaf_splits ( ISAMB  b)

Definition at line 1662 of file isamb.c.

References ISAMB_s::number_of_leaf_splits.

Referenced by index_block_flush().

zint isamb_get_root_ptr ( ISAMB  b)

Definition at line 1667 of file isamb.c.

References ISAMB_s::root_ptr.

Referenced by recindex_open(), and zebra_sort_type().

void isamb_merge ( ISAMB  b,
ISAM_P pos,
ISAMC_I stream 
)
ISAMB isamb_open ( BFiles  bfs,
const char *  name,
int  writeflag,
ISAMC_M method,
int  cache 
)

Definition at line 350 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 
)
void isamb_pp_close ( ISAMB_PP  pp)
void isamb_pp_close_x ( ISAMB_PP  pp,
zint size,
zint blocks 
)
int isamb_pp_forward ( ISAMB_PP  pp,
void *  buf,
const void *  untilb 
)
ISAMB_PP isamb_pp_open ( ISAMB  isamb,
ISAM_P  pos,
int  scope 
)
ISAMB_PP isamb_pp_open_x ( ISAMB  isamb,
ISAM_P  pos,
int *  level,
int  scope 
)
void isamb_pp_pos ( ISAMB_PP  pp,
double *  current,
double *  total 
)

Definition at line 1507 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 
)
void isamb_set_cache_size ( ISAMB  b,
int  v 
)

Definition at line 199 of file isamb.c.

References ISAMB_s::cache_size.

Referenced by main().

void isamb_set_int_count ( ISAMB  b,
int  v 
)

Definition at line 194 of file isamb.c.

References ISAMB_s::enable_int_count.

Referenced by main().

void isamb_set_root_ptr ( ISAMB  b,
zint  root_ptr 
)

Definition at line 1672 of file isamb.c.

References ISAMB_s::root_ptr.

Referenced by recindex_close(), and zebra_sort_close().

int isamb_unlink ( ISAMB  b,
ISAM_P  pos 
)
struct ISAMB_block* new_block ( ISAMB  b,
int  leaf,
int  cat 
)
struct ISAMB_block* new_int ( ISAMB  b,
int  cat 
)

Definition at line 620 of file isamb.c.

References new_block().

Referenced by insert_int(), and isamb_merge().

struct ISAMB_block* new_leaf ( ISAMB  b,
int  cat 
)

Definition at line 614 of file isamb.c.

References new_block().

Referenced by insert_leaf().

static struct ISAMB_block* open_block ( ISAMB  b,
ISAM_P  pos 
)
static