Modules | Typedefs | Functions
FastBit C API.

Modules

 Column-access functiones.
 This set of functions provide column-wise accesses to query results.
 
 Row-wise access functiones.
 This set of functions provide row-wise accesses to query results.
 

Typedefs

typedef struct FastBitQuery * FastBitQueryHandle
 A handle to be used by C clients. More...
 

Functions

int fastbit_add_values (const char *colname, const char *coltype, void *vals, uint32_t nelem, uint32_t start)
 Add nelem values of the specified column (colname) to the in-memory buffer. More...
 
int fastbit_build_index (const char *indexLocation, const char *cname, const char *indexOptions)
 Build an index for the named attribute. More...
 
int fastbit_build_indexes (const char *indexLocation, const char *indexOptions)
 Build indexes for all columns in the named directory. More...
 
FastBitQueryHandle fastbit_build_query (const char *selectClause, const char *indexLocation, const char *queryConditions)
 Build a new FastBit query. More...
 
void fastbit_cleanup (void)
 Clean up resources hold by FastBit file manager. More...
 
int fastbit_columns_in_partition (const char *dir)
 Return the number of columns in the data partition. More...
 
int fastbit_destroy_query (FastBitQueryHandle query)
 Free all resource associated with the handle. More...
 
int fastbit_flush_buffer (const char *dir)
 Flush the in-memory data to the named directory. More...
 
const char * fastbit_get_from_clause (FastBitQueryHandle query)
 Return the table name. More...
 
const char * fastbit_get_logfile ()
 Find out the name of the current log file. More...
 
FILE * fastbit_get_logfilepointer ()
 Return the file pointer to the log file. More...
 
int fastbit_get_result_columns (FastBitQueryHandle query)
 Count the number of columns selected in the select clause of the query. More...
 
int fastbit_get_result_row_ids (FastBitQueryHandle, uint32_t *)
 Retrieve the row number of those satisfying the query conditions. More...
 
int fastbit_get_result_rows (FastBitQueryHandle query)
 Retrieve the number of hits in the query. More...
 
const char * fastbit_get_select_clause (FastBitQueryHandle query)
 Return the string form of the select clause. More...
 
int fastbit_get_verbose_level (void)
 Return the current verboseness level. More...
 
int fastbit_get_version_number ()
 Return the software version as an integer. More...
 
const char * fastbit_get_version_string ()
 Return the software version as a string. More...
 
const char * fastbit_get_where_clause (FastBitQueryHandle query)
 Return the where clause of the query. More...
 
void fastbit_init (const char *rcfile)
 Initialization function. More...
 
int fastbit_purge_index (const char *indexLocation, const char *cname)
 Purge the index of the named attribute. More...
 
int fastbit_purge_indexes (const char *indexLocation)
 Purge all index files. More...
 
double fastbit_read_clock ()
 Read the system's wallclock timer. More...
 
int fastbit_reorder_partition (const char *dir)
 Reorder all the columns in the partition. More...
 
int fastbit_rows_in_partition (const char *dir)
 Return the number of rows in the data partition. More...
 
int fastbit_set_logfile (const char *filename)
 Change the name of the log file. More...
 
int fastbit_set_verbose_level (int v)
 Change the verboseness of FastBit functions. More...
 

Detailed Description

Typedef Documentation

typedef struct FastBitQuery* FastBitQueryHandle

A handle to be used by C clients.

Function Documentation

int fastbit_add_values ( const char *  colname,
const char *  coltype,
void *  vals,
uint32_t  nelem,
uint32_t  start 
)

Add nelem values of the specified column (colname) to the in-memory buffer.

Add nelem values of the specified column (colname) to the in-memory buffer.

  • colname Name of the column. Must start with an alphabet and followed by a combination of alphanumerical characters. Following the SQL standard, the column name is not case sensitive.
  • coltype The type of the values for the column. The support types are: "category", "text", "double", "float", "long", "int", "short", "byte", "ulong", "uint", "ushort", and "ubyte". Only the first non-space character is checked for the first eight types, and only the first two characters are checked for the remaining types. This string is not case sensitive.
  • vals The array containing the values. It is expected to contain no less than nelem values, though only the first nelem values are used by this function.
  • nelem The number of elements of the array vals to be added to the in-memory buffer.
  • start The position (row number) of the first element of the array. Normally, this argument is zero (0) if all values are valid. One may use this argument to skip some rows and indicate to FastBit that the skipped rows contain NULL values.

References ibis::tablex::addColumn(), ibis::tablex::append(), ibis::CATEGORY, ibis::DOUBLE, ibis::FLOAT, ibis::INT, ibis::LONG, ibis::SHORT, ibis::TEXT, ibis::UBYTE, ibis::UINT, ibis::ULONG, ibis::UNKNOWN_TYPE, and ibis::USHORT.

int fastbit_build_index ( const char *  indexLocation,
const char *  cname,
const char *  indexOptions 
)
int fastbit_build_indexes ( const char *  indexLocation,
const char *  indexOptions 
)

Build indexes for all columns in the named directory.

References ibis::part::buildIndexes(), ibis::part::nColumns(), and ibis::part::nRows().

FastBitQueryHandle fastbit_build_query ( const char *  select,
const char *  datadir,
const char *  where 
)

Build a new FastBit query.

Build a new FastBit query.

" A blank selectClause is equivalent to "count(*)". The dataLocation is the directory containing the data and indexes. This is a required field. If the where clause is missing, the query is assumed to match all rows following the convention used by SQL.

Note
Must call fastbit_destroy_query on the handle returned to free the resources.

References fastbit_destroy_query().

void fastbit_cleanup ( void  )

Clean up resources hold by FastBit file manager.

Clean up resources hold by FastBit file manager.

It is expected to be te last function to be called by the user. Since there is no centralized list of query objects, the user is responsible for freeing the resources held by each query object.

References ibis::fileManager::clear(), ibis::util::closeLogFile(), and ibis::fileManager::instance().

int fastbit_columns_in_partition ( const char *  dir)

Return the number of columns in the data partition.

References ibis::part::nColumns(), and ibis::part::releaseAccess().

int fastbit_destroy_query ( FastBitQueryHandle  query)

Free all resource associated with the handle.

Note
The handle becomes invalid.

References ibis::DOUBLE, ibis::FLOAT, ibis::INT, ibis::LONG, ibis::OID, ibis::SHORT, ibis::TEXT, ibis::UBYTE, ibis::UINT, ibis::ULONG, and ibis::USHORT.

Referenced by fastbit_build_query().

int fastbit_flush_buffer ( const char *  dir)

Flush the in-memory data to the named directory.

Flush the in-memory data to the named directory.

In addition, if the new records contain columns that are not already in the directory, then the new columns are automatically added with existing records assumed to contain NULL values. This set of functions are intended for a user to append some number of rows in one operation. It is clear that writing one row as a time is slow because of the overhead involved in writing the files. On the other hand, since the new rows are stored in memory, it can not store too many rows.

References ibis::part::releaseAccess(), ibis::part::updateData(), and ibis::tablex::write().

const char* fastbit_get_from_clause ( FastBitQueryHandle  query)

Return the table name.

References ibis::part::name().

const char* fastbit_get_logfile ( )

Find out the name of the current log file.

Returns
Return the current log file name. A blank string or a null pointer indicates the standard output.

References ibis::util::getLogFileName().

FILE* fastbit_get_logfilepointer ( )

Return the file pointer to the log file.

References ibis::util::getLogFile().

int fastbit_get_result_columns ( FastBitQueryHandle  query)

Count the number of columns selected in the select clause of the query.

int fastbit_get_result_row_ids ( FastBitQueryHandle  qhandle,
uint32_t *  ids 
)

Retrieve the row number of those satisfying the query conditions.

Retrieve the row number of those satisfying the query conditions.

The row ids are limited to be uint32_t so that no more than 4 billion rows could be stored in a single data partition.

The caller must have allocated enough space.

References ibis::query::FULL_EVALUATE, and ibis::bitvector::indexSet::nIndices().

int fastbit_get_result_rows ( FastBitQueryHandle  query)

Retrieve the number of hits in the query.

It is also the number of rows in the result set. The arrays returned by fastbit_get_qualified_floats shall have this many elements.

References ibis::query::FULL_EVALUATE.

const char* fastbit_get_select_clause ( FastBitQueryHandle  query)

Return the string form of the select clause.

int fastbit_get_verbose_level ( void  )

Return the current verboseness level.

int fastbit_get_version_number ( )

Return the software version as an integer.

References ibis::util::getVersionNumber().

const char* fastbit_get_version_string ( )

Return the software version as a string.

References ibis::util::getVersionString().

const char* fastbit_get_where_clause ( FastBitQueryHandle  query)

Return the where clause of the query.

void fastbit_init ( const char *  rcfile)

Initialization function.

Initialization function.

May pass in a nil pointer as rcfile if one is expected to use use the default configuartion files listed in the documentation of ibis::resources::read. One may call this function multiple times to read multiple configuration files to modify the parameters.

References ibis::gParameters(), and ibis::resource::read().

int fastbit_purge_index ( const char *  indexLocation,
const char *  cname 
)
int fastbit_purge_indexes ( const char *  indexLocation)

Purge all index files.

References ibis::part::purgeIndexFiles(), and ibis::part::releaseAccess().

double fastbit_read_clock ( )

Read the system's wallclock timer.

It tries to use clock_gettime if it is available, otherwise it falls back to gettimeofday and clock.

int fastbit_reorder_partition ( const char *  dir)

Reorder all the columns in the partition.

Reordering the rows can lead to better index compression and query performance.

Returns
It returns zero (0) on success and a negative on failure.
Warning
When this function fails for whatever reason, the data is left in an undetermined state. Make sure you have a copy of the original data before attempting to reorder the rows.

References ibis::part::releaseAccess(), and ibis::part::reorder().

int fastbit_rows_in_partition ( const char *  dir)

Return the number of rows in the data partition.

References ibis::part::nRows(), and ibis::part::releaseAccess().

int fastbit_set_logfile ( const char *  filename)

Change the name of the log file.

Returns
Return 0 to indicate success, a negative value to indicate error.

References ibis::util::setLogFileName().

int fastbit_set_verbose_level ( int  v)

Change the verboseness of FastBit functions.

Returns
Returns the old verboseness level.
Note
This function is not thread-safe. It is possible for multiple threads to assign different values at the same time, however, we anticipate that getting the log message wrong by a few notches will not be of great harm.

Make It A Bit Faster
Contact us
Disclaimers
FastBit source code
FastBit mailing list archive