IDZEBRA  2.1.2
Data Structures | Macros | Functions
sortidx.c File Reference
#include <assert.h>
#include <string.h>
#include <yaz/log.h>
#include <yaz/xmalloc.h>
#include <idzebra/isamb.h>
#include <idzebra/bfile.h>
#include <sortidx.h>
#include "recindex.h"

Go to the source code of this file.

Data Structures

struct  sort_term
 
struct  sort_term_stream
 
struct  sortFileHead
 
struct  sortFile
 
struct  zebra_sort_index
 

Macros

#define SORT_MAX_TERM   110
 
#define SORT_MAX_MULTI   4096
 
#define SORT_IDX_BLOCKSIZE   64
 

Functions

static void sort_term_log_item (int level, const void *b, const char *txt)
 
static int sort_term_compare (const void *a, const void *b)
 
static void * sort_term_code_start (void)
 
static void sort_term_encode1 (void *p, char **dst, const char **src)
 
static void sort_term_encode2 (void *p, char **dst, const char **src)
 
static void sort_term_decode1 (void *p, char **dst, const char **src)
 
static void sort_term_decode2 (void *p, char **dst, const char **src)
 
static void sort_term_code_reset (void *p)
 
static void sort_term_code_stop (void *p)
 
static int sort_term_code_read (void *vp, char **dst, int *insertMode)
 
zebra_sort_index_t zebra_sort_open (BFiles bfs, int write_flag, int type)
 creates sort handle More...
 
void zebra_sort_close (zebra_sort_index_t si)
 frees sort handle More...
 
int zebra_sort_type (zebra_sort_index_t si, int id)
 sets type for sort usage More...
 
static void zebra_sortf_rewind (struct sortFile *sf)
 
void zebra_sort_sysno (zebra_sort_index_t si, zint sysno)
 sets sort system number for read / add / delete More...
 
void zebra_sort_delete (zebra_sort_index_t si, zint section_id)
 delete sort entry More...
 
void zebra_sort_add (zebra_sort_index_t si, zint section_id, WRBUF wrbuf)
 adds multi-map content to sort file More...
 
int zebra_sort_read (zebra_sort_index_t si, zint *section_id, WRBUF w)
 reads sort entry More...
 

Macro Definition Documentation

#define SORT_IDX_BLOCKSIZE   64

Definition at line 37 of file sortidx.c.

Referenced by zebra_sort_type().

#define SORT_MAX_MULTI   4096

Definition at line 35 of file sortidx.c.

Referenced by zebra_sort_add().

#define SORT_MAX_TERM   110

Definition at line 34 of file sortidx.c.

Referenced by zebra_sort_add().

Function Documentation

static int sort_term_code_read ( void *  vp,
char **  dst,
int *  insertMode 
)
static
static void sort_term_code_reset ( void *  p)
static

Definition at line 139 of file sortidx.c.

Referenced by zebra_sort_type().

static void* sort_term_code_start ( void  )
static

Definition at line 76 of file sortidx.c.

Referenced by zebra_sort_type().

static void sort_term_code_stop ( void *  p)
static

Definition at line 143 of file sortidx.c.

Referenced by zebra_sort_type().

static int sort_term_compare ( const void *  a,
const void *  b 
)
static

Definition at line 57 of file sortidx.c.

References sort_term::section_id, and sort_term::sysno.

Referenced by zebra_sort_type().

static void sort_term_decode1 ( void *  p,
char **  dst,
const char **  src 
)
static
static void sort_term_decode2 ( void *  p,
char **  dst,
const char **  src 
)
static
static void sort_term_encode1 ( void *  p,
char **  dst,
const char **  src 
)
static

Definition at line 81 of file sortidx.c.

References sort_term::sysno, sort_term::term, and zebra_zint_encode().

Referenced by zebra_sort_type().

static void sort_term_encode2 ( void *  p,
char **  dst,
const char **  src 
)
static
static void sort_term_log_item ( int  level,
const void *  b,
const char *  txt 
)
static

Definition at line 47 of file sortidx.c.

References sort_term::length, sort_term::section_id, sort_term::sysno, sort_term::term, and ZINT_FORMAT.

Referenced by zebra_sort_type().

void zebra_sort_add ( zebra_sort_index_t  si,
zint  section_id,
WRBUF  w 
)
void zebra_sort_close ( zebra_sort_index_t  si)
void zebra_sort_delete ( zebra_sort_index_t  si,
zint  section_id 
)
zebra_sort_index_t zebra_sort_open ( BFiles  bfs,
int  write_flag,
int  sort_type 
)

creates sort handle

Parameters
bfsblock files handle
write_flag(0=read-only, 1=write and read)
sort_typeone of ZEBRA_SORT_TYPE_..
Returns
sort index handle

Definition at line 196 of file sortidx.c.

References zebra_sort_index::bfs, zebra_sort_index::current_file, zebra_sort_index::entry_buf, zebra_sort_index::files, SORT_IDX_ENTRYSIZE, zebra_sort_index::type, and zebra_sort_index::write_flag.

Referenced by zebra_register_open().

int zebra_sort_read ( zebra_sort_index_t  si,
zint section_id,
WRBUF  w 
)

reads sort entry

Parameters
sisort index handle
section_idoutput section ID (may be NULL and it will not be set)
wresulting buffer
Return values
0could not be read
1could be read (found)

Definition at line 469 of file sortidx.c.

References sortFile::bf, bf_read(), zebra_sort_index::current_file, sortFile::isam_p, sortFile::isam_pp, sortFile::isamb, isamb_pp_forward(), isamb_pp_open(), sort_term::length, sort_term::section_id, SORT_IDX_ENTRYSIZE, sort_term::sysno, zebra_sort_index::sysno, sort_term::term, zebra_sort_index::type, sortFile::u, ZEBRA_SORT_TYPE_FLAT, ZEBRA_SORT_TYPE_ISAMB, and ZEBRA_SORT_TYPE_MULTI.

Referenced by perform_facet_sort(), resultSetInsertSort(), and sort_fetch().

void zebra_sort_sysno ( zebra_sort_index_t  si,
zint  sysno 
)

sets sort system number for read / add / delete

Parameters
sisort index handle
sysnosystem number

Definition at line 339 of file sortidx.c.

References zebra_sort_index::files, sortFile::isam_pp, sortFile::next, sortFile::no_deleted, sortFile::no_inserted, rec_sysno_to_int(), zebra_sort_index::sysno, and zebra_sortf_rewind().

Referenced by extract_flush_sort_keys(), perform_facet_sort(), resultSetInsertSort(), and sort_fetch().

int zebra_sort_type ( zebra_sort_index_t  si,
int  type 
)
static void zebra_sortf_rewind ( struct sortFile sf)
static

Definition at line 330 of file sortidx.c.

References sortFile::isam_pp, isamb_pp_close(), sortFile::no_deleted, and sortFile::no_inserted.

Referenced by zebra_sort_sysno().