IDZEBRA  2.2.7
Data Structures | Macros | Functions
sortidx.c File Reference
#include <assert.h>
#include <string.h>
#include <yaz/log.h>
#include <yaz/xmalloc.h>
#include <yaz/snprintf.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

◆ SORT_IDX_BLOCKSIZE

#define SORT_IDX_BLOCKSIZE   64

Definition at line 38 of file sortidx.c.

◆ SORT_MAX_MULTI

#define SORT_MAX_MULTI   4096

Definition at line 36 of file sortidx.c.

◆ SORT_MAX_TERM

#define SORT_MAX_TERM   110

Definition at line 35 of file sortidx.c.

Function Documentation

◆ sort_term_code_read()

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

◆ sort_term_code_reset()

static void sort_term_code_reset ( void *  p)
static

Definition at line 140 of file sortidx.c.

Referenced by zebra_sort_type().

◆ sort_term_code_start()

static void* sort_term_code_start ( void  )
static

Definition at line 77 of file sortidx.c.

Referenced by zebra_sort_type().

◆ sort_term_code_stop()

static void sort_term_code_stop ( void *  p)
static

Definition at line 144 of file sortidx.c.

Referenced by zebra_sort_type().

◆ sort_term_compare()

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

Definition at line 58 of file sortidx.c.

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

Referenced by zebra_sort_type().

◆ sort_term_decode1()

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

◆ sort_term_decode2()

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

◆ sort_term_encode1()

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

Definition at line 82 of file sortidx.c.

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

Referenced by zebra_sort_type().

◆ sort_term_encode2()

static void sort_term_encode2 ( void *  p,
char **  dst,
const char **  src 
)
static

◆ sort_term_log_item()

static void sort_term_log_item ( int  level,
const void *  b,
const char *  txt 
)
static

Definition at line 48 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().

◆ zebra_sort_add()

void zebra_sort_add ( zebra_sort_index_t  si,
zint  section_id,
WRBUF  w 
)

◆ zebra_sort_close()

void zebra_sort_close ( zebra_sort_index_t  si)

◆ zebra_sort_delete()

void zebra_sort_delete ( zebra_sort_index_t  si,
zint  section_id 
)

◆ zebra_sort_open()

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

◆ zebra_sort_read()

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

◆ zebra_sort_sysno()

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

◆ zebra_sort_type()

int zebra_sort_type ( zebra_sort_index_t  si,
int  type 
)

◆ zebra_sortf_rewind()

static void zebra_sortf_rewind ( struct sortFile sf)
static

Definition at line 331 of file sortidx.c.

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

Referenced by zebra_sort_sysno().