IDZEBRA  2.2.7
Data Structures | Macros | Functions
isamb.c File Reference
#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_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

◆ CAT_MASK

#define CAT_MASK   (CAT_MAX-1)

Definition at line 68 of file isamb.c.

◆ CAT_MAX

#define CAT_MAX   4

Definition at line 67 of file isamb.c.

◆ CAT_NO

#define CAT_NO   4

Definition at line 70 of file isamb.c.

◆ decode_item_len

#define decode_item_len   decode_ptr

Definition at line 170 of file isamb.c.

◆ DST_BUF_SIZE

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

Definition at line 61 of file isamb.c.

◆ DST_ITEM_MAX

#define DST_ITEM_MAX   5000

Definition at line 54 of file isamb.c.

◆ encode_item_len

#define encode_item_len   encode_ptr

Definition at line 148 of file isamb.c.

◆ INT_ENCODE

#define INT_ENCODE   1

Definition at line 51 of file isamb.c.

◆ ISAMB_CACHE_ENTRY_SIZE

#define ISAMB_CACHE_ENTRY_SIZE   ISAMB_MAX_PAGE

Definition at line 64 of file isamb.c.

◆ ISAMB_DEBUG

#define ISAMB_DEBUG   0

Definition at line 32 of file isamb.c.

◆ ISAMB_FAC_SIZE

#define ISAMB_FAC_SIZE   4

Definition at line 75 of file isamb.c.

◆ ISAMB_MAJOR_VERSION

#define ISAMB_MAJOR_VERSION   3

Definition at line 36 of file isamb.c.

◆ ISAMB_MAX_LEVEL

#define ISAMB_MAX_LEVEL   10

Definition at line 59 of file isamb.c.

◆ ISAMB_MAX_PAGE

#define ISAMB_MAX_PAGE   32768

Definition at line 57 of file isamb.c.

◆ ISAMB_MIN_SIZE

#define ISAMB_MIN_SIZE   32

Definition at line 73 of file isamb.c.

◆ ISAMB_MINOR_VERSION_NO_ROOT

#define ISAMB_MINOR_VERSION_NO_ROOT   0

Definition at line 37 of file isamb.c.

◆ ISAMB_MINOR_VERSION_WITH_ROOT

#define ISAMB_MINOR_VERSION_WITH_ROOT   1

Definition at line 38 of file isamb.c.

◆ ISAMB_PTR_CODEC

#define ISAMB_PTR_CODEC   1

Definition at line 78 of file isamb.c.

Function Documentation

◆ cache_block()

static int cache_block ( ISAMB  b,
ISAM_P  pos,
unsigned char *  userbuf,
int  wr 
)
static

◆ check_block()

static void check_block ( ISAMB  b,
struct ISAMB_block p 
)
static

◆ close_block()

void close_block ( ISAMB  b,
struct ISAMB_block p 
)

◆ decode_ptr()

static void decode_ptr ( const char **  src,
zint pos 
)
static

◆ encode_ptr()

static void encode_ptr ( char **  dst,
zint  pos 
)
static

Definition at line 150 of file isamb.c.

References ISAMB_block::pos.

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

◆ flush_blocks()

static void flush_blocks ( ISAMB  b,
int  cat 
)
static

◆ insert_int()

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 
)

◆ insert_leaf()

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 
)

◆ 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().

◆ isamb_block_info()

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().

◆ isamb_close()

void isamb_close ( ISAMB  isamb)

◆ isamb_dump()

void isamb_dump ( ISAMB  b,
ISAM_P  pos,
void(*)(const char *str)  pr 
)

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().

◆ isamb_dump_r()

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

◆ isamb_get_int_splits()

zint isamb_get_int_splits ( ISAMB  b)

Definition at line 1659 of file isamb.c.

References ISAMB_s::number_of_int_splits.

Referenced by index_block_flush().

◆ isamb_get_leaf_splits()

zint isamb_get_leaf_splits ( ISAMB  b)

Definition at line 1664 of file isamb.c.

References ISAMB_s::number_of_leaf_splits.

Referenced by index_block_flush().

◆ isamb_get_root_ptr()

zint isamb_get_root_ptr ( ISAMB  b)

Definition at line 1669 of file isamb.c.

References ISAMB_s::root_ptr.

Referenced by recindex_open(), and zebra_sort_type().

◆ isamb_merge()

void isamb_merge ( ISAMB  b,
ISAM_P pos,
ISAMC_I stream 
)

◆ isamb_open()

ISAMB isamb_open ( BFiles  bfs,
const char *  name,
int  writeflag,
ISAMC_M method,
int  cache 
)

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_open2()

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_pp_close()

void isamb_pp_close ( ISAMB_PP  pp)

◆ isamb_pp_close_x()

void isamb_pp_close_x ( ISAMB_PP  pp,
zint size,
zint blocks 
)

◆ isamb_pp_forward()

int isamb_pp_forward ( ISAMB_PP  pp,
void *  buf,
const void *  untilb 
)

◆ isamb_pp_open()

ISAMB_PP isamb_pp_open ( ISAMB  isamb,
ISAM_P  pos,
int  scope 
)

◆ isamb_pp_open_x()

ISAMB_PP isamb_pp_open_x ( ISAMB  isamb,
ISAM_P  pos,
int *  level,
int  scope 
)

◆ isamb_pp_pos()

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().

◆ isamb_pp_read()

int isamb_pp_read ( ISAMB_PP  pp,
void *  buf 
)

◆ isamb_set_cache_size()

void isamb_set_cache_size ( ISAMB  b,
int  v 
)

Definition at line 200 of file isamb.c.

References ISAMB_s::cache_size.

Referenced by main().

◆ isamb_set_int_count()

void isamb_set_int_count ( ISAMB  b,
int  v 
)

Definition at line 195 of file isamb.c.

References ISAMB_s::enable_int_count.

Referenced by main().

◆ isamb_set_root_ptr()

void isamb_set_root_ptr ( ISAMB  b,
zint  root_ptr 
)

Definition at line 1674 of file isamb.c.

References ISAMB_s::root_ptr.

Referenced by recindex_close(), and zebra_sort_close().

◆ isamb_unlink()

int isamb_unlink ( ISAMB  b,
ISAM_P  pos 
)

◆ new_block()

struct ISAMB_block* new_block ( ISAMB  b,
int  leaf,
int  cat 
)

◆ new_int()

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().

◆ new_leaf()

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().

◆ open_block()

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