IDZEBRA  2.1.2
Data Structures | Macros | Enumerations | Functions
records.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <yaz/yaz-util.h>
#include <idzebra/bfile.h>
#include "recindex.h"

Go to the source code of this file.

Data Structures

struct  records_info
 
struct  records_info::records_head
 
struct  record_cache_entry
 
struct  record_index_entry
 

Macros

#define REC_BLOCK_TYPES   2
 
#define REC_HEAD_MAGIC   "recindex"
 
#define REC_VERSION   5
 
#define FAKE_OFFSET   0
 
#define USUAL_RANGE   6000000000LL
 

Enumerations

enum  recordCacheFlag { recordFlagNop, recordFlagWrite, recordFlagNew, recordFlagDelete }
 

Functions

Record rec_cp (Record rec)
 
static zint rec_sysno_to_ext (zint sysno)
 
zint rec_sysno_to_int (zint sysno)
 
static void rec_tmp_expand (Records p, int size)
 
static ZEBRA_RES rec_release_blocks (Records p, zint sysno)
 
static ZEBRA_RES rec_delete_single (Records p, Record rec)
 
static ZEBRA_RES rec_write_tmp_buf (Records p, int size, zint *sysnos)
 
int rec_check_compression_method (int compression_method)
 check whether a compression method is supported More...
 
Records rec_open (BFiles bfs, int rw, int compression_method)
 opens records system More...
 
static void rec_encode_unsigned (unsigned n, unsigned char *buf, int *len)
 
static void rec_decode_unsigned (unsigned *np, unsigned char *buf, int *len)
 
static void rec_encode_zint (zint n, unsigned char *buf, int *len)
 
static void rec_decode_zint (zint *np, unsigned char *buf, int *len)
 
static void rec_cache_flush_block1 (Records p, Record rec, Record last_rec, char **out_buf, int *out_size, int *out_offset)
 
static ZEBRA_RES rec_flush_shared (Records p, short ref_count, zint *sysnos, char *out_buf, int out_offset)
 
static ZEBRA_RES rec_write_multiple (Records p, int saveCount)
 
static ZEBRA_RES rec_cache_flush (Records p, int saveCount)
 
static Recordrec_cache_lookup (Records p, zint sysno, enum recordCacheFlag flag)
 
static ZEBRA_RES rec_cache_insert (Records p, Record rec, enum recordCacheFlag flag)
 
ZEBRA_RES rec_close (Records *pp)
 
static Record rec_get_int (Records p, zint sysno)
 
Record rec_get (Records p, zint sysno)
 gets record - with given system number More...
 
Record rec_get_root (Records p)
 gets root record More...
 
Record rec_get_next (Records p, Record rec)
 gets next record - with given records More...
 
static Record rec_new_int (Records p)
 
Record rec_new (Records p)
 creates new record (to be written to file storage) More...
 
ZEBRA_RES rec_del (Records p, Record *recpp)
 marks record for deletion (on file storage) More...
 
ZEBRA_RES rec_put (Records p, Record *recpp)
 puts record (writes into file storage) More...
 
void rec_free (Record *recpp)
 frees record (from memory) More...
 
char * rec_strdup (const char *s, size_t *len)
 
void rec_prstat (Records records, int verbose)
 

Macro Definition Documentation

#define FAKE_OFFSET   0

Definition at line 114 of file records.c.

Referenced by rec_sysno_to_ext(), and rec_sysno_to_int().

#define REC_BLOCK_TYPES   2
#define REC_HEAD_MAGIC   "recindex"

Definition at line 55 of file records.c.

Referenced by rec_open().

#define REC_VERSION   5

Definition at line 56 of file records.c.

Referenced by rec_open().

#define USUAL_RANGE   6000000000LL

Definition at line 115 of file records.c.

Referenced by rec_sysno_to_ext(), and rec_sysno_to_int().

Enumeration Type Documentation

Enumerator
recordFlagNop 
recordFlagWrite 
recordFlagNew 
recordFlagDelete 

Definition at line 96 of file records.c.

Function Documentation

static ZEBRA_RES rec_cache_flush ( Records  p,
int  saveCount 
)
static
static void rec_cache_flush_block1 ( Records  p,
Record  rec,
Record  last_rec,
char **  out_buf,
int *  out_size,
int *  out_offset 
)
static
static ZEBRA_RES rec_cache_insert ( Records  p,
Record  rec,
enum recordCacheFlag  flag 
)
static
static Record* rec_cache_lookup ( Records  p,
zint  sysno,
enum recordCacheFlag  flag 
)
static
int rec_check_compression_method ( int  compression_method)

check whether a compression method is supported

Parameters
compression_method(REC_COMPRESS_..)
Return values
0if method is unsupported
1if method is supported

Definition at line 286 of file records.c.

References REC_COMPRESS_BZIP2, REC_COMPRESS_NONE, and REC_COMPRESS_ZLIB.

Referenced by zebra_register_open().

ZEBRA_RES rec_close ( Records pp)
Record rec_cp ( Record  rec)

Definition at line 1055 of file records.c.

References record_info::info, REC_NO_INFO, record_info::size, and record_info::sysno.

Referenced by rec_cache_insert(), and rec_get_int().

static void rec_decode_unsigned ( unsigned *  np,
unsigned char *  buf,
int *  len 
)
static

Definition at line 415 of file records.c.

Referenced by rec_get_int().

static void rec_decode_zint ( zint np,
unsigned char *  buf,
int *  len 
)
static

Definition at line 445 of file records.c.

Referenced by rec_get_int().

ZEBRA_RES rec_del ( Records  p,
Record recpp 
)

marks record for deletion (on file storage)

Parameters
precords handle
recpprecord pointer
Returns
ZEBRA_OK / ZEBRA_FAIL

Definition at line 1000 of file records.c.

References records_info::head, records_info::mutex, records_info::records_head::no_records, rec_cache_insert(), rec_cache_lookup(), rec_free(), recordFlagDelete, zebra_mutex_lock(), zebra_mutex_unlock(), and ZEBRA_OK.

Referenced by delete_w_all_handle(), zebra_extract_record_stream(), and zebraExplain_removeDatabase().

static ZEBRA_RES rec_delete_single ( Records  p,
Record  rec 
)
static
static void rec_encode_unsigned ( unsigned  n,
unsigned char *  buf,
int *  len 
)
static

Definition at line 402 of file records.c.

Referenced by rec_cache_flush_block1().

static void rec_encode_zint ( zint  n,
unsigned char *  buf,
int *  len 
)
static

Definition at line 432 of file records.c.

Referenced by rec_cache_flush_block1().

static ZEBRA_RES rec_flush_shared ( Records  p,
short  ref_count,
zint sysnos,
char *  out_buf,
int  out_offset 
)
static
void rec_free ( Record recpp)
Record rec_get ( Records  p,
zint  sysno 
)
static Record rec_get_int ( Records  p,
zint  sysno 
)
static
Record rec_get_next ( Records  p,
Record  rec 
)

gets next record - with given records

Parameters
precords handle
recrecord
Returns
record pointer (or NULL on error)

Definition at line 942 of file records.c.

References records_info::head, records_info::records_head::index_last, record_index_entry::next, rec_get(), rec_sysno_to_ext(), rec_sysno_to_int(), and record_info::sysno.

Referenced by zebra_register_check().

Record rec_get_root ( Records  p)

gets root record

Parameters
precords handle
Returns
record pointer (or NULL on error)

Definition at line 937 of file records.c.

References rec_get(), and rec_sysno_to_ext().

Referenced by zebra_register_check(), zebraExplain_open(), and zebraExplain_writeTarget().

Record rec_new ( Records  p)

creates new record (to be written to file storage)

Parameters
precords handle
Returns
record pointer (or NULL on error)

Definition at line 990 of file records.c.

References records_info::mutex, rec_new_int(), zebra_mutex_lock(), and zebra_mutex_unlock().

Referenced by createRecord(), zebra_extract_record_stream(), and zebraExplain_open().

static Record rec_new_int ( Records  p)
static
Records rec_open ( BFiles  bfs,
int  rw,
int  compression_method 
)
void rec_prstat ( Records  records,
int  verbose 
)
ZEBRA_RES rec_put ( Records  p,
Record recpp 
)
static ZEBRA_RES rec_release_blocks ( Records  p,
zint  sysno 
)
static
char* rec_strdup ( const char *  s,
size_t *  len 
)

Definition at line 1079 of file records.c.

Referenced by createRecord(), zebra_extract_record_stream(), and zebraExplain_open().

static zint rec_sysno_to_ext ( zint  sysno)
static

Definition at line 123 of file records.c.

References FAKE_OFFSET, and USUAL_RANGE.

Referenced by rec_get_next(), rec_get_root(), and rec_new_int().

zint rec_sysno_to_int ( zint  sysno)
static void rec_tmp_expand ( Records  p,
int  size 
)
static
static ZEBRA_RES rec_write_multiple ( Records  p,
int  saveCount 
)
static
static ZEBRA_RES rec_write_tmp_buf ( Records  p,
int  size,
zint sysnos 
)
static