osl logo

The lightweight storage library


[README] [Download] [INSTALL] [Quick Start] [API] [License] [Contact] [man page]
osl.h
Go to the documentation of this file.
1 #ifndef _OSL_H
2 #define _OSL_H
3 /*
4  * Copyright (C) 2007-2009 Andre Noll <maan@tuebingen.mpg.de>
5  *
6  * Licensed under the GPL v2. For licencing details see COPYING.
7  */
8 
11 #include <sys/mman.h>
12 #include <inttypes.h>
13 
15 #pragma GCC visibility push(default)
16 
18 struct osl_object {
20  void *data;
22  size_t size;
23 };
24 
29 };
30 
50 };
51 
71 };
72 
74 struct osl_table;
76 struct osl_row;
77 
85 typedef int osl_compare_func(const struct osl_object *obj1,
86  const struct osl_object *obj2);
87 
94 typedef int osl_rbtree_loop_func(struct osl_row *row, void *data);
95 
101  uint16_t storage_type;
103  uint16_t storage_flags;
109  char *name;
124  uint32_t data_size;
125 };
126 
140  const char *dir;
146  const char *name;
148  uint16_t num_columns;
150  uint8_t flags;
153 };
154 
170 };
171 
179 int osl_create_table(const struct osl_table_description *desc);
180 
194 int osl_open_table(const struct osl_table_description *desc,
195  struct osl_table **result);
196 
211 int osl_close_table(struct osl_table *t, enum osl_close_flags flags);
212 
229 int osl_get_row(const struct osl_table *t, unsigned col_num,
230  const struct osl_object *obj, struct osl_row **result);
231 
248 int osl_get_object(const struct osl_table *t, const struct osl_row *row,
249  unsigned col_num, struct osl_object *object);
250 
267 int osl_open_disk_object(const struct osl_table *t,
268  const struct osl_row *r, unsigned col_num, struct osl_object *obj);
269 
279 int osl_close_disk_object(struct osl_object *obj);
280 
304 int osl_add_and_get_row(struct osl_table *t, struct osl_object *objects,
305  struct osl_row **row);
306 
317 int osl_add_row(struct osl_table *t, struct osl_object *objects);
318 
332 int osl_del_row(struct osl_table *t, struct osl_row *row);
333 
357 int osl_rbtree_loop(const struct osl_table *t, unsigned col_num,
358  void *private_data, osl_rbtree_loop_func *func);
359 
375 int osl_rbtree_loop_reverse(const struct osl_table *t, unsigned col_num,
376  void *private_data, osl_rbtree_loop_func *func);
377 
397 int osl_update_object(struct osl_table *t, const struct osl_row *r,
398  unsigned col_num, struct osl_object *obj);
399 
410 int osl_get_num_rows(const struct osl_table *t, unsigned *num_rows);
411 
428 int osl_rbtree_first_row(const struct osl_table *t, unsigned col_num,
429  struct osl_row **result);
430 
446 int osl_rbtree_last_row(const struct osl_table *t, unsigned col_num,
447  struct osl_row **result);
448 
468 int osl_get_nth_row(const struct osl_table *t, unsigned col_num,
469  unsigned n, struct osl_row **result);
470 
487 int osl_get_rank(const struct osl_table *t, struct osl_row *r,
488  unsigned col_num, unsigned *rank);
489 
500 const char *osl_strerror(int num);
501 
502 #pragma GCC visibility pop
503 
504 enum osl_errors { E_OSL_BAD_DB_DIR=1,
505  E_OSL_NO_COLUMN_DESC,
506  E_OSL_BAD_NAME,
507  E_OSL_BAD_STORAGE_TYPE,
508  E_OSL_BAD_STORAGE_FLAGS,
509  E_OSL_NO_COLUMN_NAME,
510  E_OSL_NO_COLUMNS,
511  E_OSL_BAD_COLUMN_NAME,
512  E_OSL_NO_UNIQUE_RBTREE_COLUMN,
513  E_OSL_NO_RBTREE_COL,
514  E_OSL_DUPLICATE_COL_NAME,
515  E_OSL_BAD_STORAGE_SIZE,
516  E_OSL_NO_COMPARE_FUNC,
517  E_OSL_BAD_DATA_SIZE,
518  E_OSL_NOT_MAPPED,
519  E_OSL_ALREADY_MAPPED,
520  E_OSL_BAD_SIZE,
521  E_OSL_BAD_TABLE,
522  E_OSL_BAD_TABLE_DESC,
523  E_OSL_RB_KEY_EXISTS,
524  E_OSL_RB_KEY_NOT_FOUND,
525  E_OSL_BAD_ROW_NUM,
526  E_OSL_INDEX_CORRUPTION,
527  E_OSL_LSEEK,
528  E_OSL_BUSY,
529  E_OSL_SHORT_TABLE,
530  E_OSL_NO_MAGIC,
531  E_OSL_VERSION_MISMATCH,
532  E_OSL_BAD_COLUMN_NUM,
533  E_OSL_BAD_TABLE_FLAGS,
534  E_OSL_BAD_ROW,
535  E_OSL_EMPTY,
536  E_OSL_MMAP,
537  E_OSL_LOOP,
538  E_OSL_NOMEM,
539  E_OSL_NOTDIR,
540  E_OSL_STAT,
541  E_OSL_UNLINK,
542  E_OSL_WRITE,
543  E_OSL_OPEN,
544  E_OSL_TRUNCATE,
545  E_OSL_MKDIR,
546  E_OSL_RENAME,
547  E_OSL_MUNMAP,
548  E_OSL_FSTAT,
549  E_OSL_DIR_EXISTS,
550  E_OSL_NOENT};
551 #endif /* _OSL_H */
osl_storage_type
Definition: osl.h:32
struct osl_column_description * column_descriptions
Definition: osl.h:152
int osl_rbtree_loop_reverse(const struct osl_table *t, unsigned col_num, void *private_data, osl_rbtree_loop_func *func)
int osl_open_disk_object(const struct osl_table *t, const struct osl_row *r, unsigned col_num, struct osl_object *obj)
int osl_close_disk_object(struct osl_object *obj)
osl_close_flags
Definition: osl.h:156
osl_table_flags
Definition: osl.h:26
Definition: osl.h:68
int osl_update_object(struct osl_table *t, const struct osl_row *r, unsigned col_num, struct osl_object *obj)
Definition: osl.h:64
int osl_add_row(struct osl_table *t, struct osl_object *objects)
int osl_del_row(struct osl_table *t, struct osl_row *row)
int osl_get_nth_row(const struct osl_table *t, unsigned col_num, unsigned n, struct osl_row **result)
int osl_rbtree_first_row(const struct osl_table *t, unsigned col_num, struct osl_row **result)
int osl_rbtree_loop(const struct osl_table *t, unsigned col_num, void *private_data, osl_rbtree_loop_func *func)
size_t size
Definition: osl.h:22
int osl_compare_func(const struct osl_object *obj1, const struct osl_object *obj2)
Definition: osl.h:85
int osl_close_table(struct osl_table *t, enum osl_close_flags flags)
uint16_t num_columns
Definition: osl.h:148
int osl_get_object(const struct osl_table *t, const struct osl_row *row, unsigned col_num, struct osl_object *object)
void * data
Definition: osl.h:20
const char * name
Definition: osl.h:146
const char * osl_strerror(int num)
uint32_t data_size
Definition: osl.h:124
int osl_rbtree_loop_func(struct osl_row *row, void *data)
Definition: osl.h:94
uint16_t storage_type
Definition: osl.h:101
int osl_get_num_rows(const struct osl_table *t, unsigned *num_rows)
int osl_get_rank(const struct osl_table *t, struct osl_row *r, unsigned col_num, unsigned *rank)
int osl_open_table(const struct osl_table_description *desc, struct osl_table **result)
osl_storage_flags
Definition: osl.h:55
int osl_get_row(const struct osl_table *t, unsigned col_num, const struct osl_object *obj, struct osl_row **result)
osl_errors
Definition: osl.h:504
int osl_rbtree_last_row(const struct osl_table *t, unsigned col_num, struct osl_row **result)
uint16_t storage_flags
Definition: osl.h:103
uint8_t flags
Definition: osl.h:150
int osl_create_table(const struct osl_table_description *desc)
int osl_add_and_get_row(struct osl_table *t, struct osl_object *objects, struct osl_row **row)
osl_compare_func * compare_function
Definition: osl.h:118
Definition: osl.h:18
const char * dir
Definition: osl.h:140