Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
io.h File Reference
#include "groonga_in.h"
#include "error.h"
Include dependency graph for io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  grn_io_win
struct  grn_io_mapinfo
struct  _grn_io_header
struct  _grn_io
struct  _grn_io_ja_einfo
struct  _grn_io_ja_ehead
struct  _grn_io_array_spec
struct  _grn_io_array_info

Macros

#define GRN_IO_FILE_SIZE   1073741824UL
#define GRN_IO_COPY   grn_io_rdwr
#define GRN_IO_UPDATE   grn_io_rdwr
#define GRN_TABLE_ADD   (0x01<<6)
#define GRN_TABLE_ADDED   (0x01<<7)
#define GRN_IO_MAX_RETRY   (0x10000)
#define GRN_IO_MAX_REF   (0x80000000)
#define GRN_IO_EXPIRE_GTICK   (0x01)
#define GRN_IO_EXPIRE_SEGMENT   (0x02)
#define GRN_IO_TEMPORARY   (0x04)
#define GRN_IO_SEG_REF(io, segno, addr)
#define GRN_IO_SEG_UNREF(io, segno)
#define GRN_IO_ARRAY_AT(io, array, offset, flags, res)
#define GRN_IO_ARRAY_BIT_AT(io, array, offset, res)
#define GRN_IO_ARRAY_BIT_ON(io, array, offset)
#define GRN_IO_ARRAY_BIT_OFF(io, array, offset)
#define GRN_IO_ARRAY_BIT_FLIP(io, array, offset)
#define GRN_B_ENC(v, p)
#define GRN_B_ENC_SIZE(v)   ((v) < 0x8f ? 1 : ((v) < 0x408f ? 2 : ((v) < 0x20408f ? 3 : ((v) < 0x1020408f ? 4 : 5))))
#define GRN_B_DEC(v, p)
#define GRN_B_SKIP(p)
#define GRN_B_COPY(p2, p1)

Typedefs

typedef struct _grn_io grn_io
typedef struct _grn_io_array_info grn_io_array_info
typedef struct _grn_io_ja_einfo grn_io_ja_einfo
typedef struct _grn_io_ja_ehead grn_io_ja_ehead
typedef struct _grn_io_array_spec grn_io_array_spec

Enumerations

enum  grn_io_rw_mode { grn_io_rdonly, grn_io_wronly, grn_io_rdwr }
enum  grn_io_mode { grn_io_auto, grn_io_manual }

Functions

GRN_API grn_iogrn_io_create (grn_ctx *ctx, const char *path, uint32_t header_size, uint32_t segment_size, uint32_t max_segment, grn_io_mode mode, unsigned int flags)
grn_iogrn_io_open (grn_ctx *ctx, const char *path, grn_io_mode mode)
GRN_API grn_rc grn_io_close (grn_ctx *ctx, grn_io *io)
grn_rc grn_io_remove (grn_ctx *ctx, const char *path)
grn_rc grn_io_size (grn_ctx *ctx, grn_io *io, uint64_t *size)
grn_rc grn_io_rename (grn_ctx *ctx, const char *old_name, const char *new_name)
GRN_API void * grn_io_header (grn_io *io)
void * grn_io_win_map (grn_io *io, grn_ctx *ctx, grn_io_win *iw, uint32_t segment, uint32_t offset, uint32_t size, grn_io_rw_mode mode)
grn_rc grn_io_win_mapv (grn_io_win **list, grn_ctx *ctx, int nent)
grn_rc grn_io_win_unmap (grn_io_win *iw)
void * grn_io_win_map2 (grn_io *io, grn_ctx *ctx, grn_io_win *iw, uint32_t segment, uint32_t offset, uint32_t size, grn_io_rw_mode mode)
grn_rc grn_io_win_unmap2 (grn_io_win *iw)
grn_rc grn_io_read_ja (grn_io *io, grn_ctx *ctx, grn_io_ja_einfo *einfo, uint32_t epos, uint32_t key, uint32_t segment, uint32_t offset, void **value, uint32_t *value_len)
grn_rc grn_io_write_ja (grn_io *io, grn_ctx *ctx, uint32_t key, uint32_t segment, uint32_t offset, void *value, uint32_t value_len)
grn_rc grn_io_write_ja_ehead (grn_io *io, grn_ctx *ctx, uint32_t key, uint32_t segment, uint32_t offset, uint32_t value_len)
void grn_io_seg_map_ (grn_ctx *ctx, grn_io *io, uint32_t segno, grn_io_mapinfo *info)
uint32_t grn_io_base_seg (grn_io *io)
const char * grn_io_path (grn_io *io)
grn_iogrn_io_create_with_array (grn_ctx *ctx, const char *path, uint32_t header_size, uint32_t segment_size, grn_io_mode mode, int n_arrays, grn_io_array_spec *array_specs)
void * grn_io_array_at (grn_ctx *ctx, grn_io *io, uint32_t array, off_t offset, int *flags)
void grn_io_segment_alloc (grn_ctx *ctx, grn_io *io, grn_io_array_info *ai, uint32_t lseg, int *flags, void **p)
GRN_API grn_rc grn_io_lock (grn_ctx *ctx, grn_io *io, int timeout)
GRN_API void grn_io_unlock (grn_io *io)
void grn_io_clear_lock (grn_io *io)
uint32_t grn_io_is_locked (grn_io *io)
void * grn_io_anon_map (grn_ctx *ctx, grn_io_mapinfo *mi, size_t length)
void grn_io_anon_unmap (grn_ctx *ctx, grn_io_mapinfo *mi, size_t length)
uint32_t grn_io_detect_type (grn_ctx *ctx, const char *path)
grn_rc grn_io_set_type (grn_io *io, uint32_t type)
uint32_t grn_io_get_type (grn_io *io)
grn_rc grn_io_init (void)
grn_rc grn_io_fin (void)
uint32_t grn_io_expire (grn_ctx *ctx, grn_io *io, int count_thresh, uint32_t limit)
uint32_t grn_expire (grn_ctx *ctx, int count_thresh, uint32_t limit)

Macro Definition Documentation

#define GRN_B_COPY (   p2,
  p1 
)
Value:
do { \
uint32_t size = 0, _v = *p1++; \
*p2++ = _v; \
switch (_v >> 4) { \
case 0x08 : \
size = (_v == 0x8f) ? 4 : 0; \
break; \
case 0x09 : \
size = 3; \
break; \
case 0x0a : \
case 0x0b : \
size = 2; \
break; \
case 0x0c : \
case 0x0d : \
case 0x0e : \
case 0x0f : \
size = 1; \
break; \
} \
while (size--) { *p2++ = *p1++; } \
} while (0)

Definition at line 466 of file io.h.

#define GRN_B_DEC (   v,
 
)
Value:
do { \
uint8_t *_p = (uint8_t *)p; \
uint32_t _v = *_p++; \
switch (_v >> 4) { \
case 0x08 : \
if (_v == 0x8f) { \
memcpy(&_v, _p, sizeof(uint32_t));\
_p += sizeof(uint32_t); \
} \
break; \
case 0x09 : \
_v = (_v - 0x90) * 0x100 + *_p++; \
_v = _v * 0x100 + *_p++; \
_v = _v * 0x100 + *_p++ + 0x20408f; \
break; \
case 0x0a : \
case 0x0b : \
_v = (_v - 0xa0) * 0x100 + *_p++; \
_v = _v * 0x100 + *_p++ + 0x408f; \
break; \
case 0x0c : \
case 0x0d : \
case 0x0e : \
case 0x0f : \
_v = (_v - 0xc0) * 0x100 + *_p++ + 0x8f; \
break; \
} \
v = _v; \
p = _p; \
} while (0)

Definition at line 409 of file io.h.

#define GRN_B_ENC (   v,
 
)
Value:
do {\
uint8_t *_p = (uint8_t *)p; \
uint32_t _v = v; \
if (_v < 0x8f) { \
*_p++ = _v; \
} else if (_v < 0x408f) { \
_v -= 0x8f; \
*_p++ = 0xc0 + (_v >> 8); \
*_p++ = _v & 0xff; \
} else if (_v < 0x20408f) { \
_v -= 0x408f; \
*_p++ = 0xa0 + (_v >> 16); \
*_p++ = (_v >> 8) & 0xff; \
*_p++ = _v & 0xff; \
} else if (_v < 0x1020408f) { \
_v -= 0x20408f; \
*_p++ = 0x90 + (_v >> 24); \
*_p++ = (_v >> 16) & 0xff; \
*_p++ = (_v >> 8) & 0xff; \
*_p++ = _v & 0xff; \
} else { \
*_p++ = 0x8f; \
memcpy(_p, &_v, sizeof(uint32_t));\
_p += sizeof(uint32_t); \
} \
p = _p; \
} while (0)

Definition at line 378 of file io.h.

#define GRN_B_ENC_SIZE (   v)    ((v) < 0x8f ? 1 : ((v) < 0x408f ? 2 : ((v) < 0x20408f ? 3 : ((v) < 0x1020408f ? 4 : 5))))

Definition at line 406 of file io.h.

#define GRN_B_SKIP (   p)
Value:
do { \
uint8_t *_p = (uint8_t *)p; \
uint32_t _v = *_p++; \
switch (_v >> 4) { \
case 0x08 : \
if (_v == 0x8f) { \
_p += sizeof(uint32_t); \
} \
break; \
case 0x09 : \
_p += 3; \
break; \
case 0x0a : \
case 0x0b : \
_p += 2; \
break; \
case 0x0c : \
case 0x0d : \
case 0x0e : \
case 0x0f : \
_p += 1; \
break; \
} \
p = _p; \
} while (0)

Definition at line 440 of file io.h.

#define GRN_IO_ARRAY_AT (   io,
  array,
  offset,
  flags,
  res 
)
Value:
do {\
grn_io_array_info *ainfo = &(io)->ainfo[array];\
uint32_t lseg = (offset) >> ainfo->w_of_elm_in_a_segment;\
void **p_ = &ainfo->addrs[lseg];\
if (!*p_) {\
grn_io_segment_alloc(ctx, (io), ainfo, lseg, (flags), p_);\
if (!*p_) { (res) = NULL; break; }\
}\
*((byte **)(&(res))) = (((byte *)*p_) + \
(((offset) & ainfo->elm_mask_in_a_segment) * ainfo->element_size));\
} while (0)

Definition at line 324 of file io.h.

#define GRN_IO_ARRAY_BIT_AT (   io,
  array,
  offset,
  res 
)
Value:
do {\
uint8_t *ptr_;\
int flags_ = 0;\
GRN_IO_ARRAY_AT((io), (array), ((offset) >> 3) + 1, &flags_, ptr_);\
res = ptr_ ? ((*ptr_ >> ((offset) & 7)) & 1) : 0;\
} while (0)

Definition at line 336 of file io.h.

#define GRN_IO_ARRAY_BIT_FLIP (   io,
  array,
  offset 
)
Value:
do {\
uint8_t *ptr_;\
int flags_ = GRN_TABLE_ADD;\
GRN_IO_ARRAY_AT((io), (array), ((offset) >> 3) + 1, &flags_, ptr_);\
if (ptr_) { *ptr_ ^= (1 << ((offset) & 7)); }\
} while (0)

Definition at line 357 of file io.h.

#define GRN_IO_ARRAY_BIT_OFF (   io,
  array,
  offset 
)
Value:
do {\
uint8_t *ptr_;\
int flags_ = GRN_TABLE_ADD;\
GRN_IO_ARRAY_AT((io), (array), ((offset) >> 3) + 1, &flags_, ptr_);\
if (ptr_) { *ptr_ &= ~(1 << ((offset) & 7)); }\
} while (0)

Definition at line 350 of file io.h.

#define GRN_IO_ARRAY_BIT_ON (   io,
  array,
  offset 
)
Value:
do {\
uint8_t *ptr_;\
int flags_ = GRN_TABLE_ADD;\
GRN_IO_ARRAY_AT((io), (array), ((offset) >> 3) + 1, &flags_, ptr_);\
if (ptr_) { *ptr_ |= (1 << ((offset) & 7)); }\
} while (0)

Definition at line 343 of file io.h.

#define GRN_IO_COPY   grn_io_rdwr

Definition at line 42 of file io.h.

#define GRN_IO_EXPIRE_GTICK   (0x01)

Definition at line 173 of file io.h.

#define GRN_IO_EXPIRE_SEGMENT   (0x02)

Definition at line 174 of file io.h.

#define GRN_IO_FILE_SIZE   1073741824UL

Definition at line 41 of file io.h.

#define GRN_IO_MAX_REF   (0x80000000)

Definition at line 171 of file io.h.

#define GRN_IO_MAX_RETRY   (0x10000)

Definition at line 170 of file io.h.

#define GRN_IO_SEG_REF (   io,
  segno,
  addr 
)

Definition at line 184 of file io.h.

#define GRN_IO_SEG_UNREF (   io,
  segno 
)
Value:
do {\
uint32_t nref, *pnref = &(io)->maps[segno].nref;\
GRN_ATOMIC_ADD_EX(pnref, -1, nref);\
}\
} while (0)

Definition at line 283 of file io.h.

#define GRN_IO_TEMPORARY   (0x04)

Definition at line 175 of file io.h.

#define GRN_IO_UPDATE   grn_io_rdwr

Definition at line 43 of file io.h.

#define GRN_TABLE_ADD   (0x01<<6)

Definition at line 167 of file io.h.

#define GRN_TABLE_ADDED   (0x01<<7)

Definition at line 168 of file io.h.

Typedef Documentation

typedef struct _grn_io grn_io

Definition at line 59 of file io.h.

Definition at line 89 of file io.h.

Definition at line 294 of file io.h.

Definition at line 145 of file io.h.

Definition at line 144 of file io.h.

Enumeration Type Documentation

Enumerator:
grn_io_auto 
grn_io_manual 

Definition at line 52 of file io.h.

Enumerator:
grn_io_rdonly 
grn_io_wronly 
grn_io_rdwr 

Definition at line 46 of file io.h.

Function Documentation

uint32_t grn_expire ( grn_ctx ctx,
int  count_thresh,
uint32_t  limit 
)

Definition at line 1428 of file io.c.

void* grn_io_anon_map ( grn_ctx ctx,
grn_io_mapinfo mi,
size_t  length 
)

Definition at line 1451 of file io.c.

Here is the caller graph for this function:

void grn_io_anon_unmap ( grn_ctx ctx,
grn_io_mapinfo mi,
size_t  length 
)

Definition at line 1457 of file io.c.

Here is the caller graph for this function:

void* grn_io_array_at ( grn_ctx ctx,
grn_io io,
uint32_t  array,
off_t  offset,
int *  flags 
)

Definition at line 390 of file io.c.

uint32_t grn_io_base_seg ( grn_io io)

Definition at line 545 of file io.c.

void grn_io_clear_lock ( grn_io io)

Definition at line 1516 of file io.c.

Here is the caller graph for this function:

GRN_API grn_rc grn_io_close ( grn_ctx ctx,
grn_io io 
)

Definition at line 502 of file io.c.

Here is the caller graph for this function:

GRN_API grn_io* grn_io_create ( grn_ctx ctx,
const char *  path,
uint32_t  header_size,
uint32_t  segment_size,
uint32_t  max_segment,
grn_io_mode  mode,
unsigned int  flags 
)
grn_io* grn_io_create_with_array ( grn_ctx ctx,
const char *  path,
uint32_t  header_size,
uint32_t  segment_size,
grn_io_mode  mode,
int  n_arrays,
grn_io_array_spec array_specs 
)

Definition at line 304 of file io.c.

Here is the call graph for this function:

uint32_t grn_io_detect_type ( grn_ctx ctx,
const char *  path 
)

Definition at line 398 of file io.c.

Here is the caller graph for this function:

uint32_t grn_io_expire ( grn_ctx ctx,
grn_io io,
int  count_thresh,
uint32_t  limit 
)

Definition at line 1353 of file io.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_rc grn_io_fin ( void  )

Definition at line 103 of file io.c.

Here is the caller graph for this function:

uint32_t grn_io_get_type ( grn_io io)

Definition at line 573 of file io.c.

Here is the caller graph for this function:

GRN_API void* grn_io_header ( grn_io io)

Definition at line 557 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_init ( void  )

Definition at line 97 of file io.c.

Here is the caller graph for this function:

uint32_t grn_io_is_locked ( grn_io io)

Definition at line 1522 of file io.c.

Here is the caller graph for this function:

GRN_API grn_rc grn_io_lock ( grn_ctx ctx,
grn_io io,
int  timeout 
)

Definition at line 1467 of file io.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_io* grn_io_open ( grn_ctx ctx,
const char *  path,
grn_io_mode  mode 
)

Definition at line 426 of file io.c.

Here is the caller graph for this function:

const char* grn_io_path ( grn_io io)

Definition at line 551 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_read_ja ( grn_io io,
grn_ctx ctx,
grn_io_ja_einfo einfo,
uint32_t  epos,
uint32_t  key,
uint32_t  segment,
uint32_t  offset,
void **  value,
uint32_t *  value_len 
)

Definition at line 681 of file io.c.

grn_rc grn_io_remove ( grn_ctx ctx,
const char *  path 
)

Definition at line 623 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_rename ( grn_ctx ctx,
const char *  old_name,
const char *  new_name 
)

Definition at line 648 of file io.c.

void grn_io_seg_map_ ( grn_ctx ctx,
grn_io io,
uint32_t  segno,
grn_io_mapinfo info 
)

Definition at line 1304 of file io.c.

void grn_io_segment_alloc ( grn_ctx ctx,
grn_io io,
grn_io_array_info ai,
uint32_t  lseg,
int *  flags,
void **  p 
)

Definition at line 372 of file io.c.

grn_rc grn_io_set_type ( grn_io io,
uint32_t  type 
)

Definition at line 563 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_size ( grn_ctx ctx,
grn_io io,
uint64_t *  size 
)

Definition at line 594 of file io.c.

Here is the caller graph for this function:

GRN_API void grn_io_unlock ( grn_io io)

Definition at line 1507 of file io.c.

Here is the caller graph for this function:

void* grn_io_win_map ( grn_io io,
grn_ctx ctx,
grn_io_win iw,
uint32_t  segment,
uint32_t  offset,
uint32_t  size,
grn_io_rw_mode  mode 
)

Definition at line 856 of file io.c.

void* grn_io_win_map2 ( grn_io io,
grn_ctx ctx,
grn_io_win iw,
uint32_t  segment,
uint32_t  offset,
uint32_t  size,
grn_io_rw_mode  mode 
)

Definition at line 1175 of file io.c.

grn_rc grn_io_win_mapv ( grn_io_win **  list,
grn_ctx ctx,
int  nent 
)
grn_rc grn_io_win_unmap ( grn_io_win iw)

Definition at line 1098 of file io.c.

grn_rc grn_io_win_unmap2 ( grn_io_win iw)

Definition at line 1231 of file io.c.

Here is the caller graph for this function:

grn_rc grn_io_write_ja ( grn_io io,
grn_ctx ctx,
uint32_t  key,
uint32_t  segment,
uint32_t  offset,
void *  value,
uint32_t  value_len 
)

Definition at line 776 of file io.c.

grn_rc grn_io_write_ja_ehead ( grn_io io,
grn_ctx ctx,
uint32_t  key,
uint32_t  segment,
uint32_t  offset,
uint32_t  value_len 
)

Definition at line 831 of file io.c.