capi.h
1 /* File: $Id$
2  Author: John Wu <John.Wu at acm.org>
3  Lawrence Berkeley National Laboratory
4  Copyright (c) 2006-2016 the Regents of the University of California
5 */
6 #ifndef IBIS_CAPI_H
7 #define IBIS_CAPI_H
8 
24 #if _MSC_VER >= 1000
25 #pragma once
26 #endif /* _MSC_VER >= 1000 */
27 
28 #if !defined(WITHOUT_FASTBIT_CONFIG_H) && !defined(__MINGW32__) && !defined(_MSC_VER)
29 #include "fastbit-config.h"
30 #endif
31 #if defined(HAVE_SYS_TYPES_H) || defined(__PGI)
32 # include <sys/types.h> /* required by PGI compilers (bug 775993) */
33 #endif
34 #if defined(HAVE_INTTYPES_H) || defined(__sun) || defined(__MINGW32__) || defined(__FreeBSD__)
35 # include <inttypes.h>
36 #elif defined(HAVE_STDINT_H) || defined(__unix__) || defined(__APPLE__)
37 # include <stdint.h>
38 #elif defined(_WIN32) && defined(_MSC_VER)
39 /* MS windows has its own exact-width types, use them */
40 # ifndef int16_t
41 # define int16_t __int16
42 # endif
43 # ifndef uint16_t
44 # define uint16_t unsigned __int16
45 # endif
46 # ifndef int32_t
47 # define int32_t __int32
48 # endif
49 # ifndef uint32_t
50 # define uint32_t unsigned __int32
51 # endif
52 # ifndef int64_t
53 # define int64_t __int64
54 # endif
55 # ifndef uint64_t
56 # define uint64_t unsigned __int64
57 # endif
58 #else
59 #error Do NOT know how to find the exact width data types!
60 #endif
61 
62 #if defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__))
63 # if defined(_USRDLL) || defined(CXX_USE_DLL)
64 # if defined(DLL_EXPORT)
65 # define FASTBIT_DLLSPEC __declspec(dllexport)
66 # else
67 # define FASTBIT_DLLSPEC __declspec(dllimport)
68 # endif
69 # else
70 # define FASTBIT_DLLSPEC
71 # endif
72 #else
73 # define FASTBIT_DLLSPEC
74 #endif
75 
76 #include <stdio.h> /* FILE* */
77 
82 #ifdef __cplusplus
83 extern "C" {
84 #endif
85 
86  FASTBIT_DLLSPEC int
87  fastbit_build_indexes(const char *indexLocation,
88  const char *indexOptions);
90  FASTBIT_DLLSPEC int fastbit_purge_indexes(const char *indexLocation);
92  FASTBIT_DLLSPEC int
93  fastbit_build_index(const char *indexLocation, const char* cname,
94  const char *indexOptions);
96  FASTBIT_DLLSPEC int
97  fastbit_purge_index(const char *indexLocation, const char* cname);
98  FASTBIT_DLLSPEC int fastbit_reorder_partition(const char *dir);
99 
101  struct FastBitQuery;
103  typedef struct FastBitQuery* FastBitQueryHandle;
104 
106  FASTBIT_DLLSPEC FastBitQueryHandle
107  fastbit_build_query(const char *selectClause, const char *indexLocation,
108  const char *queryConditions);
111  FASTBIT_DLLSPEC int fastbit_destroy_query(FastBitQueryHandle query);
112 
115  FASTBIT_DLLSPEC int fastbit_get_result_columns(FastBitQueryHandle query);
119  FASTBIT_DLLSPEC int fastbit_get_result_rows(FastBitQueryHandle query);
121  FASTBIT_DLLSPEC int fastbit_get_result_row_ids
122  (FastBitQueryHandle, uint32_t *);
123 
125  FASTBIT_DLLSPEC const char*
126  fastbit_get_select_clause(FastBitQueryHandle query);
128  FASTBIT_DLLSPEC const char*
129  fastbit_get_from_clause(FastBitQueryHandle query);
131  FASTBIT_DLLSPEC const char*
132  fastbit_get_where_clause(FastBitQueryHandle query);
133 
144  FASTBIT_DLLSPEC const float*
145  fastbit_get_qualified_floats(FastBitQueryHandle query,
146  const char* cname);
147  FASTBIT_DLLSPEC const double*
148  fastbit_get_qualified_doubles(FastBitQueryHandle query,
149  const char* cname);
150  FASTBIT_DLLSPEC const signed char*
151  fastbit_get_qualified_bytes(FastBitQueryHandle query,
152  const char* cname);
153  FASTBIT_DLLSPEC const int16_t*
154  fastbit_get_qualified_shorts(FastBitQueryHandle query,
155  const char* cname);
156  FASTBIT_DLLSPEC const int32_t*
157  fastbit_get_qualified_ints(FastBitQueryHandle query,
158  const char* cname);
159  FASTBIT_DLLSPEC const int64_t*
160  fastbit_get_qualified_longs(FastBitQueryHandle query,
161  const char* cname);
162  FASTBIT_DLLSPEC const unsigned char*
163  fastbit_get_qualified_ubytes(FastBitQueryHandle query,
164  const char* cname);
165  FASTBIT_DLLSPEC const uint16_t*
166  fastbit_get_qualified_ushorts(FastBitQueryHandle query,
167  const char* cname);
168  FASTBIT_DLLSPEC const uint32_t*
169  fastbit_get_qualified_uints(FastBitQueryHandle query,
170  const char* cname);
171  FASTBIT_DLLSPEC const uint64_t*
172  fastbit_get_qualified_ulongs(FastBitQueryHandle query,
173  const char* cname);
174  FASTBIT_DLLSPEC const char**
175  fastbit_get_qualified_strings(FastBitQueryHandle query,
176  const char* cname);
183  struct FastBitResultSet;
185  typedef struct FastBitResultSet* FastBitResultSetHandle;
186 
188  FASTBIT_DLLSPEC FastBitResultSetHandle
189  fastbit_build_result_set(FastBitQueryHandle query);
191  FASTBIT_DLLSPEC int
192  fastbit_destroy_result_set(FastBitResultSetHandle rset);
193 
195  FASTBIT_DLLSPEC int fastbit_result_set_next(FastBitResultSetHandle);
197  FASTBIT_DLLSPEC int fastbit_result_set_next_bundle(FastBitResultSetHandle);
199  FASTBIT_DLLSPEC int
200  fastbit_result_set_get_int(FastBitResultSetHandle rset, const char *cname);
202  FASTBIT_DLLSPEC unsigned
203  fastbit_result_set_get_unsigned(FastBitResultSetHandle rset,
204  const char *cname);
206  FASTBIT_DLLSPEC int64_t
207  fastbit_result_set_get_long(FastBitResultSetHandle rset,
208  const char *cname);
211  FASTBIT_DLLSPEC float
212  fastbit_result_set_get_float(FastBitResultSetHandle rset,
213  const char *cname);
216  FASTBIT_DLLSPEC double
217  fastbit_result_set_get_double(FastBitResultSetHandle rset,
218  const char *cname);
220  FASTBIT_DLLSPEC const char*
221  fastbit_result_set_get_string(FastBitResultSetHandle rset,
222  const char *cname);
227  FASTBIT_DLLSPEC int32_t
228  fastbit_result_set_getInt(FastBitResultSetHandle rset,
229  unsigned position);
231  FASTBIT_DLLSPEC uint32_t
232  fastbit_result_set_getUnsigned(FastBitResultSetHandle rset,
233  unsigned position);
235  FASTBIT_DLLSPEC int64_t
236  fastbit_result_set_getLong(FastBitResultSetHandle rset,
237  unsigned position);
240  FASTBIT_DLLSPEC float
241  fastbit_result_set_getFloat(FastBitResultSetHandle rset,
242  unsigned position);
245  FASTBIT_DLLSPEC double
246  fastbit_result_set_getDouble(FastBitResultSetHandle rset,
247  unsigned position);
249  FASTBIT_DLLSPEC const char*
250  fastbit_result_set_getString(FastBitResultSetHandle rset,
251  unsigned position);
255  FASTBIT_DLLSPEC int fastbit_flush_buffer(const char *dir);
258  FASTBIT_DLLSPEC int
259  fastbit_add_values(const char *colname, const char *coltype,
260  void *vals, uint32_t nelem, uint32_t start);
262  FASTBIT_DLLSPEC int fastbit_rows_in_partition(const char *dir);
264  FASTBIT_DLLSPEC int fastbit_columns_in_partition(const char *dir);
265 
267  FASTBIT_DLLSPEC void fastbit_init(const char *rcfile);
269  FASTBIT_DLLSPEC void fastbit_cleanup(void);
271  FASTBIT_DLLSPEC int fastbit_set_verbose_level(int v);
273  FASTBIT_DLLSPEC int fastbit_get_verbose_level(void);
275  FASTBIT_DLLSPEC int fastbit_set_logfile(const char* filename);
277  FASTBIT_DLLSPEC const char* fastbit_get_logfile();
279  FASTBIT_DLLSPEC FILE* fastbit_get_logfilepointer();
280  FASTBIT_DLLSPEC double fastbit_read_clock();
281 
283  FASTBIT_DLLSPEC const char* fastbit_get_version_string();
285  FASTBIT_DLLSPEC int fastbit_get_version_number();
286 #ifdef __cplusplus
287 }
288 #endif
289 
290 #endif /* ifndef IBIS_CAPI_H */
FILE * fastbit_get_logfilepointer()
Return the file pointer to the log file.
Definition: capi.cpp:1953
int fastbit_result_set_next_bundle(FastBitResultSetHandle)
Returns 0 if there are more bundles, otherwise returns -1.
Definition: capi.cpp:2086
uint32_t fastbit_result_set_getUnsigned(FastBitResultSetHandle rset, unsigned position)
Get the value of the named column as an unsigned integer.
Definition: capi.cpp:2327
double fastbit_result_set_getDouble(FastBitResultSetHandle rset, unsigned position)
Get the value of the named column as a double-precision floating-point number.
Definition: capi.cpp:2417
int fastbit_get_version_number()
Return the software version as an integer.
Definition: capi.cpp:226
int fastbit_set_verbose_level(int v)
Change the verboseness of FastBit functions.
Definition: capi.cpp:1911
int fastbit_get_result_columns(FastBitQueryHandle query)
Count the number of columns selected in the select clause of the query.
Definition: capi.cpp:762
const char * fastbit_get_logfile()
Find out the name of the current log file.
Definition: capi.cpp:1949
int64_t fastbit_result_set_get_long(FastBitResultSetHandle rset, const char *cname)
Get the value of the named column as a long.
Definition: capi.cpp:2175
int fastbit_result_set_next(FastBitResultSetHandle)
Returns 0 if there are more results, otherwise returns -1.
Definition: capi.cpp:2055
int fastbit_purge_index(const char *indexLocation, const char *cname)
Purge the index of the named attribute.
Definition: capi.cpp:364
const char * fastbit_result_set_get_string(FastBitResultSetHandle rset, const char *cname)
Get the value of the named column as a string.
Definition: capi.cpp:2262
void fastbit_cleanup(void)
Clean up resources hold by FastBit file manager.
Definition: capi.cpp:1877
double fastbit_read_clock()
Read the system's wallclock timer.
Definition: capi.cpp:1959
double fastbit_result_set_get_double(FastBitResultSetHandle rset, const char *cname)
Get the value of the named column as a double-precision floating-point number.
Definition: capi.cpp:2233
int32_t fastbit_result_set_getInt(FastBitResultSetHandle rset, unsigned position)
Get the value of the named column as an integer.
Definition: capi.cpp:2297
int fastbit_get_verbose_level(void)
Return the current verboseness level.
Definition: capi.cpp:1917
int fastbit_destroy_query(FastBitQueryHandle query)
Free all resource associated with the handle.
Definition: capi.cpp:547
int fastbit_get_result_row_ids(FastBitQueryHandle, uint32_t *)
Retrieve the row number of those satisfying the query conditions.
Definition: capi.cpp:670
struct FastBitQuery * FastBitQueryHandle
A handle to be used by C clients.
Definition: capi.h:103
unsigned fastbit_result_set_get_unsigned(FastBitResultSetHandle rset, const char *cname)
Get the value of the named column as an unsigned integer.
Definition: capi.cpp:2146
int fastbit_reorder_partition(const char *dir)
Reorder all the columns in the partition.
Definition: capi.cpp:419
FastBitResultSetHandle fastbit_build_result_set(FastBitQueryHandle query)
Build a new result set from a query object.
Definition: capi.cpp:2002
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.
Definition: capi.cpp:2567
void fastbit_init(const char *rcfile)
Initialization function.
Definition: capi.cpp:1852
const char * fastbit_get_version_string()
Return the software version as a string.
Definition: capi.cpp:230
int fastbit_rows_in_partition(const char *dir)
Return the number of rows in the data partition.
Definition: capi.cpp:2665
int fastbit_result_set_get_int(FastBitResultSetHandle rset, const char *cname)
Get the value of the named column as an integer.
Definition: capi.cpp:2117
int64_t fastbit_result_set_getLong(FastBitResultSetHandle rset, unsigned position)
Get the value of the named column as a long.
Definition: capi.cpp:2357
int fastbit_columns_in_partition(const char *dir)
Return the number of columns in the data partition.
Definition: capi.cpp:2679
const char * fastbit_result_set_getString(FastBitResultSetHandle rset, unsigned position)
Get the value of the named column as a string.
Definition: capi.cpp:2447
int fastbit_flush_buffer(const char *dir)
Flush the in-memory data to the named directory.
Definition: capi.cpp:2488
const char * fastbit_get_where_clause(FastBitQueryHandle query)
Return the where clause of the query.
Definition: capi.cpp:789
float fastbit_result_set_getFloat(FastBitResultSetHandle rset, unsigned position)
Get the value of the named column as a single-precision floating-point number.
Definition: capi.cpp:2387
float fastbit_result_set_get_float(FastBitResultSetHandle rset, const char *cname)
Get the value of the named column as a single-precision floating-point number.
Definition: capi.cpp:2204
int fastbit_purge_indexes(const char *indexLocation)
Purge all index files.
Definition: capi.cpp:273
FastBitQueryHandle fastbit_build_query(const char *selectClause, const char *indexLocation, const char *queryConditions)
Build a new FastBit query.
Definition: capi.cpp:468
int fastbit_get_result_rows(FastBitQueryHandle query)
Retrieve the number of hits in the query.
Definition: capi.cpp:726
int fastbit_set_logfile(const char *filename)
Change the name of the log file.
Definition: capi.cpp:1923
int fastbit_build_indexes(const char *indexLocation, const char *indexOptions)
Build indexes for all columns in the named directory.
Definition: capi.cpp:234
const char * fastbit_get_from_clause(FastBitQueryHandle query)
Return the table name.
Definition: capi.cpp:780
int fastbit_build_index(const char *indexLocation, const char *cname, const char *indexOptions)
Build an index for the named attribute.
Definition: capi.cpp:308
struct FastBitResultSet * FastBitResultSetHandle
A handle to identify a set of query results.
Definition: capi.h:185
const char * fastbit_get_select_clause(FastBitQueryHandle query)
Return the string form of the select clause.
Definition: capi.cpp:771
int fastbit_destroy_result_set(FastBitResultSetHandle rset)
Destroy a result set.
Definition: capi.cpp:2048

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