IDZEBRA  2.2.7
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 <yaz/snprintf.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

◆ FAKE_OFFSET

#define FAKE_OFFSET   0

Definition at line 115 of file records.c.

◆ REC_BLOCK_TYPES

#define REC_BLOCK_TYPES   2

Definition at line 55 of file records.c.

◆ REC_HEAD_MAGIC

#define REC_HEAD_MAGIC   "recindex"

Definition at line 56 of file records.c.

◆ REC_VERSION

#define REC_VERSION   5

Definition at line 57 of file records.c.

◆ USUAL_RANGE

#define USUAL_RANGE   6000000000LL

Definition at line 116 of file records.c.

Enumeration Type Documentation

◆ recordCacheFlag

Enumerator
recordFlagNop 
recordFlagWrite 
recordFlagNew 
recordFlagDelete 

Definition at line 97 of file records.c.

Function Documentation

◆ rec_cache_flush()

static ZEBRA_RES rec_cache_flush ( Records  p,
int  saveCount 
)
static

◆ rec_cache_flush_block1()

static void rec_cache_flush_block1 ( Records  p,
Record  rec,
Record  last_rec,
char **  out_buf,
int *  out_size,
int *  out_offset 
)
static

◆ rec_cache_insert()

static ZEBRA_RES rec_cache_insert ( Records  p,
Record  rec,
enum recordCacheFlag  flag 
)
static

◆ rec_cache_lookup()

static Record* rec_cache_lookup ( Records  p,
zint  sysno,
enum recordCacheFlag  flag 
)
static

◆ rec_check_compression_method()

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 287 of file records.c.

References REC_COMPRESS_BZIP2, REC_COMPRESS_NONE, and REC_COMPRESS_ZLIB.

Referenced by zebra_register_open().

◆ rec_close()

ZEBRA_RES rec_close ( Records pp)

◆ rec_cp()

Record rec_cp ( Record  rec)

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

◆ rec_decode_unsigned()

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

Definition at line 416 of file records.c.

Referenced by rec_get_int().

◆ rec_decode_zint()

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

Definition at line 446 of file records.c.

Referenced by rec_get_int().

◆ rec_del()

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

◆ rec_delete_single()

static ZEBRA_RES rec_delete_single ( Records  p,
Record  rec 
)
static

◆ rec_encode_unsigned()

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

Definition at line 403 of file records.c.

Referenced by rec_cache_flush_block1().

◆ rec_encode_zint()

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

Definition at line 433 of file records.c.

Referenced by rec_cache_flush_block1().

◆ rec_flush_shared()

static ZEBRA_RES rec_flush_shared ( Records  p,
short  ref_count,
zint sysnos,
char *  out_buf,
int  out_offset 
)
static

◆ rec_free()

void rec_free ( Record recpp)

◆ rec_get()

Record rec_get ( Records  p,
zint  sysno 
)

◆ rec_get_int()

static Record rec_get_int ( Records  p,
zint  sysno 
)
static

◆ rec_get_next()

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

◆ rec_get_root()

Record rec_get_root ( Records  p)

gets root record

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

Definition at line 938 of file records.c.

References rec_get(), and rec_sysno_to_ext().

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

◆ rec_new()

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

◆ rec_new_int()

static Record rec_new_int ( Records  p)
static

◆ rec_open()

Records rec_open ( BFiles  bfs,
int  rw,
int  compression_method 
)

◆ rec_prstat()

void rec_prstat ( Records  records,
int  verbose 
)

◆ rec_put()

ZEBRA_RES rec_put ( Records  p,
Record recpp 
)

◆ rec_release_blocks()

static ZEBRA_RES rec_release_blocks ( Records  p,
zint  sysno 
)
static

◆ rec_strdup()

char* rec_strdup ( const char *  s,
size_t *  len 
)

Definition at line 1080 of file records.c.

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

◆ rec_sysno_to_ext()

static zint rec_sysno_to_ext ( zint  sysno)
static

Definition at line 124 of file records.c.

References FAKE_OFFSET, and USUAL_RANGE.

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

◆ rec_sysno_to_int()

zint rec_sysno_to_int ( zint  sysno)

◆ rec_tmp_expand()

static void rec_tmp_expand ( Records  p,
int  size 
)
static

◆ rec_write_multiple()

static ZEBRA_RES rec_write_multiple ( Records  p,
int  saveCount 
)
static

◆ rec_write_tmp_buf()

static ZEBRA_RES rec_write_tmp_buf ( Records  p,
int  size,
zint sysnos 
)
static