| 3255 |
mrmanese |
1 |
#include "R.h"
|
|
|
2 |
#include "Rdefines.h"
|
|
|
3 |
#include "Rinternals.h"
|
|
|
4 |
#include "sqlite3.h"
|
|
|
5 |
|
|
|
6 |
#ifndef __SQLITE_DATAFRAME__
|
|
|
7 |
#define __SQLITE_DATAFRAME__
|
|
|
8 |
|
|
|
9 |
#define WORKSPACE_COLUMNS 3
|
|
|
10 |
|
| 3307 |
mrmanese |
11 |
/* utilities for checking characteristics of arg */
|
| 3255 |
mrmanese |
12 |
int _is_r_sym(char *sym);
|
|
|
13 |
int _file_exists(char *filename);
|
| 3307 |
mrmanese |
14 |
int _sdf_exists2(char *iname);
|
|
|
15 |
|
|
|
16 |
/* sdf utilities */
|
|
|
17 |
SEXP _create_sdf_sexp(const char *iname); /* create a SEXP for an SDF */
|
|
|
18 |
int _add_sdf1(char *filename, char *internal_name); /* add SDF to workspace */
|
| 3255 |
mrmanese |
19 |
int _get_factor_levels1(const char *iname, const char *varname, SEXP var);
|
| 3281 |
mrmanese |
20 |
int _get_row_count2(const char *table);
|
| 3307 |
mrmanese |
21 |
SEXP _get_rownames(const char *sdf_iname);
|
|
|
22 |
char *_get_full_pathname2(char *relpath); /* get full path given relpath, used in workspace mgmt */
|
| 3255 |
mrmanese |
23 |
|
| 3307 |
mrmanese |
24 |
/* utilities for creating SDF's */
|
|
|
25 |
char *_create_sdf_skeleton2(SEXP name, int *o_namelen);
|
|
|
26 |
|
|
|
27 |
/* R utilities */
|
|
|
28 |
SEXP _getListElement(SEXP list, char *varname);
|
|
|
29 |
SEXP _shrink_vector(SEXP vec, int len); /* shrink vector size */
|
|
|
30 |
|
|
|
31 |
/* sqlite utilities */
|
|
|
32 |
int _empty_callback(void *data, int ncols, char **row, char **cols);
|
|
|
33 |
int _sqlite_error(int res);
|
|
|
34 |
const char *_get_column_type(const char *class, int type); /* get sqlite type corresponding to R class & type */
|
|
|
35 |
|
|
|
36 |
/* global buffer (g_sql_buf) utilities */
|
|
|
37 |
int _expand_buf(int i, int size); /* expand ith buf if size > buf[i].size */
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
/* sqlite.vector utilities */
|
| 3281 |
mrmanese |
41 |
SEXP sdf_get_variable(SEXP sdf, SEXP name);
|
|
|
42 |
|
| 3307 |
mrmanese |
43 |
/* misc utilities */
|
|
|
44 |
char *_r2iname(char *internal_name, char *filename);
|
|
|
45 |
char *_fixname(char *rname);
|
|
|
46 |
|
|
|
47 |
/* register functions to sqlite */
|
|
|
48 |
void __register_vector_math();
|
|
|
49 |
|
| 3255 |
mrmanese |
50 |
#define _sqlite_exec(sql) sqlite3_exec(g_workspace, sql, _empty_callback, NULL, NULL)
|
| 3281 |
mrmanese |
51 |
#ifndef SET_ROWNAMES
|
|
|
52 |
#define SET_ROWNAMES(x,n) setAttrib(x, R_RowNamesSymbol, n)
|
|
|
53 |
#endif
|
| 3255 |
mrmanese |
54 |
|
|
|
55 |
/* R object accessors shortcuts */
|
|
|
56 |
#define CHAR_ELT(str, i) CHAR(STRING_ELT(str,i))
|
|
|
57 |
|
|
|
58 |
/* SDF object accessors shortcuts */
|
|
|
59 |
#define SDF_INAME(sdf) CHAR(STRING_ELT(_getListElement(sdf, "iname"),0))
|
|
|
60 |
#define SVEC_VARNAME(sdf) CHAR(STRING_ELT(_getListElement(sdf, "varname"),0))
|
|
|
61 |
|
|
|
62 |
/* # of sql buffers */
|
|
|
63 |
#define NBUFS 4
|
|
|
64 |
|
|
|
65 |
/* possible var types when stored in sqlite as integer */
|
|
|
66 |
#define VAR_INTEGER 0
|
|
|
67 |
#define VAR_FACTOR 1
|
|
|
68 |
#define VAR_ORDERED 2
|
|
|
69 |
|
| 3307 |
mrmanese |
70 |
/* detail constants (see _get_sdf_detail2 in sqlite_workspace.c) */
|
|
|
71 |
#define SDF_DETAIL_EXISTS 0
|
|
|
72 |
#define SDF_DETAIL_FULLFILENAME 1
|
| 3255 |
mrmanese |
73 |
|
|
|
74 |
#ifndef __SQLITE_WORKSPACE__
|
|
|
75 |
extern sqlite3 *g_workspace;
|
|
|
76 |
extern char *g_sql_buf[NBUFS];
|
|
|
77 |
extern int g_sql_buf_sz[NBUFS];
|
|
|
78 |
#endif
|
|
|
79 |
|
|
|
80 |
#endif
|