Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Fast plain-text write-only DB driver.
[Database Abstraction Layer]


Files

file  flat_cmd.c
 Inmplementation of flatstore commands.
file  flat_cmd.h
 Inmplementation of flatstore commands.
file  flat_con.c
 Inmplementation of flatstore "connections".
file  flat_con.h
 Inmplementation of flatstore "connections".
file  flat_rpc.c
 Flatstore management interface.
file  flat_rpc.h
 Flatstore management interface.
file  flat_uri.c
 The implementation of parser parsing flatstore:..
file  flat_uri.h
 The functions parsing and interpreting flatstore: URIs.
file  flatstore_mod.c
 Flatstore module interface.
file  flatstore_mod.h
 Flatstore module interface.

Data Structures

struct  flat_cmd
 Extension structure of db_cmd adding flatstore specific data. More...
struct  flat_file
struct  flat_con
 A structure representing flatstore virtual connections. More...
struct  flat_uri
 Flatstore driver specific payload to attach to db_uri structures. More...

Enumerations

enum  flat_con_flags { FLAT_OPENED = (1 << 0) }
 Per-connection flags for flatstore connections. More...

Functions

void flat_cmd_free (db_cmd_t *cmd, struct flat_cmd *payload)
 Destroys a flat_cmd structure.
int flat_cmd (db_cmd_t *cmd)
 Creates a new flat_cmd data structure.
int flat_put (db_res_t *res, db_cmd_t *cmd)
 The main execution function in flat SER driver.
void flat_con_free (db_con_t *con, struct flat_con *payload)
 Free all memory allocated for a flat_con structure.
int flat_con (db_con_t *con)
 Create a new flat_con structure.
int flat_con_connect (db_con_t *con)
void flat_con_disconnect (db_con_t *con)
char * get_filename (str *dir, str *name)
int flat_open_table (int *idx, db_con_t *con, str *name)
void rotate (rpc_t *rpc, void *c)
 Register a new file rotation request.
void flat_uri_free (db_uri_t *uri, struct flat_uri *payload)
int flat_uri (db_uri_t *uri)
 Create a new flat_uri structure and convert the path in parameter.
MODULE_VERSION int child_init (int rank)
int mod_init (void)
void mod_destroy (void)

Variables

const char * flat_rotate_doc [2]
rpc_export_t flat_rpc []
rpc_export_t flat_rpc []
str flat_pid = STR_NULL
 PID to be used in file names.
int flat_flush = 1
 Enable/disable flushing after eaach write.
str flat_record_delimiter = STR_STATIC_INIT("\n")
 Row delimiter.
str flat_delimiter = STR_STATIC_INIT("|")
 Field delimiter.
str flat_escape = STR_STATIC_INIT("\\")
 Escape character.
str flat_suffix = STR_STATIC_INIT(".log")
 Filename suffix.
time_t * flat_rotate
 Timestamp of last file rotation request.
time_t flat_local_timestamp
 Timestamp of last file rotation.
cmd_export_t cmds []
param_export_t params []
module_exports exports
str flat_pid
 PID to be used in file names.
int flat_flush
 Enable/disable flushing after eaach write.
str flat_record_delimiter
 Row delimiter.
str flat_delimiter
 Field delimiter.
str flat_escape
 Escape character.
str flat_suffix
 Filename suffix.
time_t * flat_rotate
 Timestamp of last file rotation request.
time_t flat_local_timestamp
 Timestamp of last file rotation.

Enumeration Type Documentation

enum flat_con_flags
 

Per-connection flags for flatstore connections.

Enumeration values:
FLAT_OPENED  Handle opened successfully.

Definition at line 46 of file flat_con.h.


Function Documentation

int child_init int  rank  )  [static]
 

Definition at line 180 of file flatstore_mod.c.

References BUG, ERR, flat_pid, int2str(), _str::len, and _str::s.

int flat_cmd db_cmd_t cmd  ) 
 

Creates a new flat_cmd data structure.

This function allocates and initializes memory for a new flat_cmd data structure. The data structure is then attached to the generic db_cmd structure in cmd parameter.

Parameters:
cmd A generic db_cmd structure to which the newly created flat_cmd structure will be attached.

Definition at line 55 of file flat_cmd.c.

References cmd, db_ctx::con, db_cmd::ctx, db_cmd_t, db_con_t, db_drv_free(), db_drv_init(), DB_FLD_EMPTY, DB_SET_PAYLOAD, ERR, flat_cmd::file_index, flat_cmd(), flat_cmd_free(), flat_open_table(), flat_cmd::gen, pkg_free, pkg_malloc, db_cmd::table, and db_cmd::vals.

Referenced by flat_cmd().

void flat_cmd_free db_cmd_t cmd,
struct flat_cmd payload
[static]
 

Destroys a flat_cmd structure.

This function frees all memory used by flat_cmd structure.

Parameters:
cmd A pointer to generic db_cmd command being freed.
payload A pointer to flat_cmd structure to be freed.

Definition at line 48 of file flat_cmd.c.

References db_cmd_t, db_drv_free(), flat_cmd::gen, and pkg_free.

Referenced by flat_cmd().

int flat_con db_con_t con  ) 
 

Create a new flat_con structure.

This function creates a new flat_con structure and attachs the structure to the generic db_con structure in the parameter.

Parameters:
con A generic db_con structure to be extended with flatstore payload
Return values:
0 on success
A negative number on error

Definition at line 77 of file flat_con.c.

References db_uri::body, db_con::connect, db_con_t, db_pool_entry_free(), db_pool_entry_init(), db_pool_get(), db_pool_put(), DB_SET_PAYLOAD, DBG, db_con::disconnect, ERR, flat_con(), flat_con_free(), flat_con::gen, pkg_free, pkg_malloc, STR_FMT, and db_con::uri.

Referenced by flat_con().

int flat_con_connect db_con_t con  ) 
 

Definition at line 124 of file flat_con.c.

References db_uri::body, db_con_t, DB_GET_PAYLOAD, DBG, ERR, flat_file::f, flat_con::file, flat_file::filename, flat_con::flags, flat_con::n, STR_FMT, and db_con::uri.

Referenced by flat_put().

void flat_con_disconnect db_con_t con  ) 
 

Definition at line 162 of file flat_con.c.

References db_uri::body, db_con_t, DB_GET_PAYLOAD, DBG, flat_file::f, flat_con::file, flat_con::flags, flat_con::n, STR_FMT, and db_con::uri.

Referenced by flat_put().

void flat_con_free db_con_t con,
struct flat_con payload
[static]
 

Free all memory allocated for a flat_con structure.

This function function frees all memory that is in use by a flat_con structure.

Parameters:
con A generic db_con connection structure.
payload Flatstore specific payload to be freed.

Definition at line 53 of file flat_con.c.

References db_con_t, db_pool_entry_free(), db_pool_entry_t, db_pool_remove(), and pkg_free.

Referenced by flat_con().

int flat_open_table int idx,
db_con_t con,
str name
 

Definition at line 231 of file flat_con.c.

References db_con_t, DB_GET_PAYLOAD, DBG, ERR, flat_con::file, flat_file::filename, flat_con::flags, get_filename(), idx, _str::len, flat_con::n, flat_uri::path, pkg_free, pkg_malloc, pkg_realloc, _str::s, str, flat_file::table, and db_con::uri.

Referenced by flat_cmd().

int flat_put db_res_t res,
db_cmd_t cmd
 

The main execution function in flat SER driver.

This is the main execution function in this driver. It is executed whenever a SER module calls db_exec and the target database of the commands is flatstore.

Parameters:
res A pointer to (optional) result structure if the command returns a result.
Return values:
0 if executed successfully
A negative number if the database server failed to execute command
A positive number if there was an error on client side (SER)

Definition at line 95 of file flat_cmd.c.

References db_fld_val::bitmap, BUG, cmd, db_ctx::con, db_fld_val::cstr, db_cmd::ctx, DB_BITMAP, DB_BLOB, db_cmd_t, db_con_t, DB_CSTR, DB_DATETIME, DB_DOUBLE, DB_FLD_EMPTY, DB_FLD_LAST, DB_FLOAT, DB_GET_PAYLOAD, DB_INT, db_res_t, DB_STR, db_fld_val::dbl, ERR, flat_file::f, flat_con::file, flat_cmd::file_index, db_fld::flags, flat_con_connect(), flat_con_disconnect(), flat_delimiter, flat_escape, flat_flush, flat_local_timestamp, flat_record_delimiter, db_fld_val::flt, db_fld_val::int4, _str::len, len, db_fld_val::lstr, s, _str::s, db_fld_val::time, db_fld::v, and db_cmd::vals.

int flat_uri db_uri_t uri  ) 
 

Create a new flat_uri structure and convert the path in parameter.

This function builds a new flat_uri structure from the body of the generic URI given to it in parameter.

Parameters:
uri A generic db_uri structure.
Return values:
0 on success
A negative number on error.

Definition at line 50 of file flat_uri.c.

References db_uri::body, db_drv_free(), db_drv_init(), DB_SET_PAYLOAD, db_uri_t, ERR, flat_uri_free(), get_abs_pathname(), pkg_free, pkg_malloc, and STR_FMT.

void flat_uri_free db_uri_t uri,
struct flat_uri payload
[static]
 

Definition at line 41 of file flat_uri.c.

References db_drv_free(), db_uri_t, flat_uri::drv, flat_uri::path, pkg_free, and _str::s.

Referenced by flat_uri().

char* get_filename str dir,
str name
[static]
 

Definition at line 185 of file flat_con.c.

References buf, buf_len, ERR, flat_pid, flat_suffix, _str::len, pathmax(), pkg_malloc, _str::s, and str.

Referenced by flat_open_table().

void mod_destroy void   )  [static]
 

Definition at line 173 of file flatstore_mod.c.

References flat_pid, flat_rotate, and _str::s.

int mod_init void   )  [static]
 

Definition at line 141 of file flatstore_mod.c.

References ERR, flat_delimiter, flat_escape, flat_local_timestamp, flat_record_delimiter, flat_rotate, and _str::len.

void rotate rpc_t rpc,
void c
[static]
 

Register a new file rotation request.

This function can be called through the management interface in SER and it will register a new file rotation request. This function only registers the request, it will be carried out next time SER attempts to write new data into the file.

Definition at line 44 of file flat_rpc.c.

References flat_rotate, and rpc_t.


Variable Documentation

cmd_export_t cmds[] [static]
 

Initial value:

 {
        {"db_uri", (cmd_function)flat_uri, 0, 0, 0},
        {"db_con", (cmd_function)flat_con, 0, 0, 0},
        {"db_cmd", (cmd_function)flat_cmd, 0, 0, 0},
        {"db_put", (cmd_function)flat_put, 0, 0, 0},
        {0, 0, 0, 0, 0}
}

Definition at line 108 of file flatstore_mod.c.

struct module_exports exports
 

Initial value:

 {
        "flatstore",
        cmds,
        flat_rpc,    
        params,      
        mod_init,    
        0,           
        mod_destroy, 
        0,           
        child_init   
}

Definition at line 128 of file flatstore_mod.c.

str flat_delimiter
 

Field delimiter.

The character in this variable will be used to delimit fields.

Definition at line 77 of file flatstore_mod.c.

Referenced by flat_put(), and mod_init().

str flat_delimiter = STR_STATIC_INIT("|")
 

Field delimiter.

The character in this variable will be used to delimit fields.

Definition at line 77 of file flatstore_mod.c.

Referenced by flat_put(), and mod_init().

str flat_escape
 

Escape character.

The character in this variable will be used to escape specia characters, such as row and field delimiters, if they appear in the data being written in the files.

Definition at line 85 of file flatstore_mod.c.

Referenced by flat_put(), and mod_init().

str flat_escape = STR_STATIC_INIT("\\")
 

Escape character.

The character in this variable will be used to escape specia characters, such as row and field delimiters, if they appear in the data being written in the files.

Definition at line 85 of file flatstore_mod.c.

Referenced by flat_put(), and mod_init().

int flat_flush
 

Enable/disable flushing after eaach write.

Definition at line 65 of file flatstore_mod.c.

Referenced by flat_put().

int flat_flush = 1
 

Enable/disable flushing after eaach write.

Definition at line 65 of file flatstore_mod.c.

Referenced by flat_put().

time_t flat_local_timestamp
 

Timestamp of last file rotation.

This variable contains the time of the last rotation of files.

Definition at line 104 of file flatstore_mod.c.

Referenced by flat_put(), and mod_init().

time_t flat_local_timestamp
 

Timestamp of last file rotation.

This variable contains the time of the last rotation of files.

Definition at line 104 of file flatstore_mod.c.

Referenced by flat_put(), and mod_init().

str flat_pid
 

PID to be used in file names.

The flatstore module generates one file per SER process to ensure that every SER process has its own file and no locking/synchronization is necessary. This variable contains a unique id of the SER process which will be added to the file name.

Definition at line 61 of file flatstore_mod.c.

Referenced by child_init(), get_filename(), and mod_destroy().

str flat_pid = STR_NULL
 

PID to be used in file names.

The flatstore module generates one file per SER process to ensure that every SER process has its own file and no locking/synchronization is necessary. This variable contains a unique id of the SER process which will be added to the file name.

Definition at line 61 of file flatstore_mod.c.

Referenced by child_init(), get_filename(), and mod_destroy().

str flat_record_delimiter
 

Row delimiter.

The character in this variable will be used to delimit rows.

Definition at line 71 of file flatstore_mod.c.

Referenced by flat_put(), and mod_init().

str flat_record_delimiter = STR_STATIC_INIT("\n")
 

Row delimiter.

The character in this variable will be used to delimit rows.

Definition at line 71 of file flatstore_mod.c.

Referenced by flat_put(), and mod_init().

time_t* flat_rotate
 

Timestamp of last file rotation request.

This variable holds the timestamp of the last file rotation request received through the management interface.

Definition at line 98 of file flatstore_mod.c.

Referenced by mod_destroy(), mod_init(), and rotate().

time_t* flat_rotate
 

Timestamp of last file rotation request.

This variable holds the timestamp of the last file rotation request received through the management interface.

Definition at line 98 of file flatstore_mod.c.

Referenced by mod_destroy(), mod_init(), and rotate().

const char* flat_rotate_doc[2] [static]
 

Initial value:

 {
        "Close and reopen flatrotate files during log rotation.",
        0
}

Definition at line 50 of file flat_rpc.c.

rpc_export_t flat_rpc[]
 

Definition at line 56 of file flat_rpc.c.

rpc_export_t flat_rpc[]
 

Initial value:

 {
        {"flatstore.rotate", rotate, flat_rotate_doc, 0},
        {0, 0, 0, 0},
}

Definition at line 56 of file flat_rpc.c.

str flat_suffix
 

Filename suffix.

This is the suffix of newly created files.

Definition at line 91 of file flatstore_mod.c.

Referenced by get_filename().

str flat_suffix = STR_STATIC_INIT(".log")
 

Filename suffix.

This is the suffix of newly created files.

Definition at line 91 of file flatstore_mod.c.

Referenced by get_filename().

param_export_t params[] [static]
 

Initial value:

 {
        {"flush",            PARAM_INT, &flat_flush},
        {"field_delimiter",  PARAM_STR, &flat_delimiter},
        {"record_delimiter", PARAM_STR, &flat_record_delimiter},
        {"escape_char",      PARAM_STR, &flat_escape},
        {"file_suffix",      PARAM_STR, &flat_suffix},
        {0, 0, 0}
}

Definition at line 118 of file flatstore_mod.c.


Generated on Tue Sep 7 04:16:39 2010 for SIPExpressRouter by  doxygen 1.3.9.1