Swarm-NG  1.1
log2db.cpp File Reference

Implements a utility to that converts binary log files to databases and create indexes on top of them. More...

#include <boost/program_options.hpp>
#include <boost/program_options/positional_options.hpp>
#include <limits>
#include <iostream>
#include <signal.h>
#include <db_cxx.h>
#include "swarm/swarm.h"
#include "swarm/query.hpp"
#include "binary_reader.hpp"

Go to the source code of this file.

Functions

template<typename T >
void put_in_dbt (const T &t, Dbt *data)
 Helper function to put any constant size type into a Dbt struct. More...
 
int lr_extract_sysid (Db *secondary, const Dbt *key, const Dbt *data, Dbt *result)
 Extract the system ID from a log record. More...
 
int compare_logdb_primary_key (DB *db, const DBT *k1, const DBT *k2)
 The primary key is a struct we just convert the key into the struct and perform lexicographical compare in order of time , system_id and event_id.
 
void sigTERM_handler (int signum)
 When a signal of TERM or INT is received. More...
 
int main (int argc, char *argv[])
 main program
 

Detailed Description

Implements a utility to that converts binary log files to databases and create indexes on top of them.

Definition in file log2db.cpp.

Function Documentation

int lr_extract_sysid ( Db *  secondary,
const Dbt *  key,
const Dbt *  data,
Dbt *  result 
)

Extract the system ID from a log record.

Parameters
secondary,:The secondary parameter is the database handle for the secondary.
key: The key parameter is a Dbt referencing the primary key.
data: The data parameter is a Dbt referencing the primary data item.
result: The result parameter is a zeroed Dbt in which the callback function should fill in data and size fields that describe the secondary key or keys.

Definition at line 166 of file log2db.cpp.

References put_in_dbt().

Referenced by main().

template<typename T >
void put_in_dbt ( const T &  t,
Dbt *  data 
)

Helper function to put any constant size type into a Dbt struct.

the flag DB_DBT_APPMALLOC hints berkeley db that the data is allocated by the application

Definition at line 132 of file log2db.cpp.

Referenced by lr_extract_sysid().

void sigTERM_handler ( int  signum)

When a signal of TERM or INT is received.

Save the last position that was processed successfully and close all the databases before exiting.

Definition at line 273 of file log2db.cpp.

Referenced by main().