hamsterdb API Documentation
hamsterdb_int.h File Reference
Internal hamsterdb functions. More...
#include <ham/hamsterdb.h>
Go to the source code of this file.
Detailed Description
Internal hamsterdb functions.Copyright (C) 2005-2008 Christoph Rupp (chris@crupp.de).
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
See files COPYING.* for License information.
Definition in file hamsterdb_int.h.
Typedef Documentation
| typedef ham_status_t(* ham_file_filter_after_read_cb_t)(ham_env_t *env, ham_file_filter_t *filter, ham_u8_t *file_data, ham_size_t file_size) |
A callback function for a file-level filter; called immediately after the data is read from disk
Definition at line 85 of file hamsterdb_int.h.
| typedef ham_status_t(* ham_file_filter_before_write_cb_t)(ham_env_t *env, ham_file_filter_t *filter, ham_u8_t *file_data, ham_size_t file_size) |
A callback function for a file-level filter; called before the data is written to disk
Definition at line 78 of file hamsterdb_int.h.
| typedef void(* ham_file_filter_close_cb_t)(ham_env_t *env, ham_file_filter_t *filter) |
A callback function for a file-level filter; called immediately before the Environment is closed. Can be used to avoid memory leaks.
Definition at line 92 of file hamsterdb_int.h.
| typedef struct ham_file_filter_t ham_file_filter_t |
Definition at line 72 of file hamsterdb_int.h.
| typedef ham_status_t(* ham_record_filter_after_read_cb_t)(ham_db_t *db, ham_record_filter_t *filter, ham_record_t *record) |
A callback function for a record-level filter; called immediately after the record is read from disk, and before it is returned to the user.
Definition at line 176 of file hamsterdb_int.h.
| typedef ham_status_t(* ham_record_filter_before_insert_cb_t)(ham_db_t *db, ham_record_filter_t *filter, ham_record_t *record) |
A callback function for a record-level filter; called before the record is inserted
Definition at line 169 of file hamsterdb_int.h.
| typedef void(* ham_record_filter_close_cb_t)(ham_db_t *db, ham_record_filter_t *filter) |
A callback function for a record-level filter; called immediately before the Database is closed. Can be used to avoid memory leaks.
Definition at line 183 of file hamsterdb_int.h.
| typedef struct ham_record_filter_t ham_record_filter_t |
Definition at line 163 of file hamsterdb_int.h.
Function Documentation
| HAM_EXPORT ham_status_t HAM_CALLCONV ham_add_record_filter | ( | ham_db_t * | db, | |
| ham_record_filter_t * | filter | |||
| ) |
A function to install a record-level filter.
Record-level filters are usually installed immediately after the Database is created with ham_create[_ex] or opened with ham_open[_ex].
- Parameters:
-
db A valid Database handle filter A pointer to a ham_record_filter_t structure
- Returns:
- HAM_SUCCESS upon success
HAM_INV_PARAMETER if db or filter is NULL
| HAM_EXPORT ham_status_t HAM_CALLCONV ham_check_integrity | ( | ham_db_t * | db, | |
| ham_txn_t * | txn | |||
| ) |
Verifies the whole Database
This function is only interesting if you want to debug hamsterdb.
Returns HAM_NOT_IMPLEMENTED unless hamsterdb was built with HAM_ENABLE_INTERNAL (run ./configure --enable-internal).
- Parameters:
-
db A valid Database handle txn A Transaction handle, or NULL
- Returns:
- HAM_SUCCESS upon success
HAM_INTEGRITY_VIOLATED if the Database is broken
| HAM_EXPORT ham_db_t* HAM_CALLCONV ham_cursor_get_database | ( | ham_cursor_t * | cursor | ) |
Retrieves the Database handle of a Cursor
- Parameters:
-
cursor A valid Cursor handle
- Returns:
- The Database handle of cursor
| HAM_EXPORT ham_status_t HAM_CALLCONV ham_env_add_file_filter | ( | ham_env_t * | env, | |
| ham_file_filter_t * | filter | |||
| ) |
A function to install a file-level filter.
File-level filters are usually installed immediately after the Environment is created with ham_env_create[_ex] or opened with ham_env_open[_ex].
- Parameters:
-
env A valid Environment handle filter A pointer to a ham_file_filter_t structure
- Returns:
- HAM_SUCCESS upon success
HAM_INV_PARAMETER if env or filter is NULL
| HAM_EXPORT ham_status_t HAM_CALLCONV ham_env_remove_file_filter | ( | ham_env_t * | env, | |
| ham_file_filter_t * | filter | |||
| ) |
A function to remove a file-level filter.
This function is usually not necessary - the lifetime of a file-filter usually starts before the first Database operation, and ends when the Environment is closed. It is not recommended to use this function.
- Parameters:
-
env A valid Environment handle filter A pointer to a ham_file_filter_t structure
- Returns:
- HAM_SUCCESS upon success
HAM_INV_PARAMETER if env or filter is NULL
| HAM_EXPORT ham_status_t HAM_CALLCONV ham_env_set_device | ( | ham_env_t * | env, | |
| void * | device | |||
| ) |
Install a custom device object
Custom device objects can be used to overwrite the functions which open, create, read, write etc. to/from the file.
The device structure is defined in src/device.h. The default device objects (for file-based access and for in-memory access) are implemented in src/device.c.
This function has to be called after the Environment handle has been allocated (with ham_env_new) and before the Environment is created or opened (with ham_env_create[_ex] or ham_env_open[_ex]).
- Parameters:
-
env A valid Environment handle device A pointer to a ham_device_t structure
- Returns:
- HAM_SUCCESS upon success
HAM_INV_PARAMETER if db or device is NULL
HAM_ALREADY_INITIALIZED if this function was already called for this Environment
| HAM_EXPORT void* HAM_CALLCONV ham_get_context_data | ( | ham_db_t * | db | ) |
Retrieves a user-provided context pointer
This function retrieves a user-provided context pointer. This can be any arbitrary pointer which was previously stored with ham_set_context_data.
- Parameters:
-
db A valid Database handle
- Returns:
- The pointer to the context data
| HAM_EXPORT ham_status_t HAM_CALLCONV ham_remove_record_filter | ( | ham_db_t * | db, | |
| ham_record_filter_t * | filter | |||
| ) |
A function to remove a record-level filter.
This function is usually not necessary - the lifetime of a record-filter usually starts before the first Database operation, and ends when the Database is closed. It is not recommended to use this function.
- Parameters:
-
db A valid Database handle filter A pointer to a ham_record_filter_t structure
- Returns:
- HAM_SUCCESS upon success
HAM_INV_PARAMETER if db or filter is NULL
| HAM_EXPORT void HAM_CALLCONV ham_set_context_data | ( | ham_db_t * | db, | |
| void * | data | |||
| ) |
Set a user-provided context pointer
This function sets a user-provided context pointer. This can be any arbitrary pointer; it is stored in the Database handle and can be retrieved with ham_get_context_data. It is mainly used by Wrappers and language bindings.
- Parameters:
-
db A valid Database handle data The pointer to the context data