The R Project SVN R-packages

Rev

Rev 4590 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4590 Rev 4798
Line 129... Line 129...
129
 
129
 
130
/****************************************************************************
130
/****************************************************************************
131
 * SVEC FUNCTIONS
131
 * SVEC FUNCTIONS
132
 ****************************************************************************/
132
 ****************************************************************************/
133
SEXP sdf_get_variable(SEXP sdf, SEXP name) {
133
SEXP sdf_get_variable(SEXP sdf, SEXP name) {
134
    char *iname, *varname, *svec_type = NULL;
134
    const char *iname, *varname, *svec_type = NULL;
135
    const char *coltype;
135
    const char *coltype;
136
    int type = -1, res, nprotected = 0;
136
    int type = -1, res, nprotected = 0;
137
    SEXP ret, value;
137
    SEXP ret, value;
138
 
138
 
139
    if (!IS_CHARACTER(name)) {
139
    if (!IS_CHARACTER(name)) {
Line 192... Line 192...
192
 
192
 
193
}
193
}
194
 
194
 
195
 
195
 
196
SEXP sdf_get_variable_length(SEXP svec) {
196
SEXP sdf_get_variable_length(SEXP svec) {
197
    char *iname = SDF_INAME(svec);
197
    const char *iname = SDF_INAME(svec);
198
    if (!USE_SDF1(iname, TRUE, FALSE)) return R_NilValue;
198
    if (!USE_SDF1(iname, TRUE, FALSE)) return R_NilValue;
199
 
199
 
200
    return ScalarInteger(_get_row_count2(iname, 1));
200
    return ScalarInteger(_get_row_count2(iname, 1));
201
}
201
}
202
 
202
 
203
    
203
    
204
SEXP sdf_get_variable_index(SEXP svec, SEXP idx) {
204
SEXP sdf_get_variable_index(SEXP svec, SEXP idx) {
205
    SEXP ret = R_NilValue, tmp;
205
    SEXP ret = R_NilValue, tmp;
206
    char *iname = SDF_INAME(svec), *tblname = SVEC_TBLNAME(svec),
206
    const char *iname = SDF_INAME(svec), *tblname = SVEC_TBLNAME(svec),
207
         *varname = SVEC_VARNAME(svec);
207
               *varname = SVEC_VARNAME(svec);
208
    int *index, _idx, nrows, i, init=FALSE, retlen=0, res, coltype;
208
    int *index, _idx, nrows, i, init=FALSE, retlen=0, res, coltype;
209
    sqlite3_stmt *stmt;
209
    sqlite3_stmt *stmt;
210
 
210
 
211
    if (!USE_SDF1(iname, TRUE, FALSE)) return R_NilValue;
211
    if (!USE_SDF1(iname, TRUE, FALSE)) return R_NilValue;
Line 274... Line 274...
274
 
274
 
275
/* sqlite.vector.[<- */
275
/* sqlite.vector.[<- */
276
SEXP sdf_set_variable_index(SEXP svec, SEXP idx, SEXP value) {
276
SEXP sdf_set_variable_index(SEXP svec, SEXP idx, SEXP value) {
277
    int *index;
277
    int *index;
278
    int coltype, valtype, idx_len, val_len, svec_len, i, i2, res;
278
    int coltype, valtype, idx_len, val_len, svec_len, i, i2, res;
279
    char *iname = SDF_INAME(svec), *tblname = SVEC_TBLNAME(svec),
279
    const char *iname = SDF_INAME(svec), *tblname = SVEC_TBLNAME(svec),
280
         *varname = SVEC_VARNAME(svec);
280
               *varname = SVEC_VARNAME(svec);
281
    const char *decltype;
281
    const char *decltype;
282
    sqlite3_stmt *stmt;
282
    sqlite3_stmt *stmt;
283
 
283
 
284
 
284
 
Line 423... Line 423...
423
 
423
 
424
    return svec;
424
    return svec;
425
}
425
}
426
 
426
 
427
SEXP sdf_variable_summary(SEXP svec, SEXP maxsum) {
427
SEXP sdf_variable_summary(SEXP svec, SEXP maxsum) {
428
    char *iname, *tblname, *varname, *type;
428
    const char *iname, *tblname, *varname, *type;
429
    sqlite3_stmt *stmt;
429
    sqlite3_stmt *stmt;
430
    int nprotected = 0;
430
    int nprotected = 0;
431
    SEXP ret, names;
431
    SEXP ret, names;
432
 
432
 
433
    iname = SDF_INAME(svec);
433
    iname = SDF_INAME(svec);
Line 508... Line 508...
508
    g_accumulator = 0.0;   /* initialize accumulator */
508
    g_accumulator = 0.0;   /* initialize accumulator */
509
    g_start = 1;           /* flag that we are at start of accumulating */
509
    g_start = 1;           /* flag that we are at start of accumulating */
510
}
510
}
511
 
511
 
512
SEXP sdf_do_variable_math(SEXP func, SEXP vector, SEXP other_args) {
512
SEXP sdf_do_variable_math(SEXP func, SEXP vector, SEXP other_args) {
513
    char *iname, *iname_src, *varname_src, *funcname;
513
    const char *iname_src, *varname_src, *funcname;
-
 
514
    char *iname;
514
    int namelen, res;
515
    int namelen, res;
515
    sqlite3_stmt *stmt;
516
    sqlite3_stmt *stmt;
516
 
517
 
517
    /* get data from arguments (function name and sqlite.vector stuffs) */
518
    /* get data from arguments (function name and sqlite.vector stuffs) */
518
    funcname = CHAR_ELT(func, 0);
519
    funcname = CHAR_ELT(func, 0);
Line 568... Line 569...
568
 
569
 
569
    return _create_svector_sexp(iname, "sdf_data", "V1", "numeric");
570
    return _create_svector_sexp(iname, "sdf_data", "V1", "numeric");
570
}
571
}
571
 
572
 
572
SEXP sdf_do_variable_op(SEXP func, SEXP vector, SEXP op2, SEXP arg_reversed) {
573
SEXP sdf_do_variable_op(SEXP func, SEXP vector, SEXP op2, SEXP arg_reversed) {
573
    char *iname = NULL, *iname_src, *varname_src, *funcname;
574
    const char *iname_src, *varname_src, *funcname;
-
 
575
    char *iname = NULL; 
574
    int res, functype = -1, op2_len, svec_len, i, reversed;
576
    int res, functype = -1, op2_len, svec_len, i, reversed;
575
    sqlite3_stmt *stmt, *stmt2;
577
    sqlite3_stmt *stmt, *stmt2;
576
 
578
 
577
    /* get data from arguments (function name and sqlite.vector stuffs) */
579
    /* get data from arguments (function name and sqlite.vector stuffs) */
578
    funcname = CHAR_ELT(func, 0);
580
    funcname = CHAR_ELT(func, 0);
Line 943... Line 945...
943
        
945
        
944
        } else if (inherits(op2, "sqlite.vector")) { 
946
        } else if (inherits(op2, "sqlite.vector")) { 
945
            /* op2 is surely not a factor, as handled by the R wrapper */
947
            /* op2 is surely not a factor, as handled by the R wrapper */
946
            /* even though it is impossible for reversed to be FALSE, still use
948
            /* even though it is impossible for reversed to be FALSE, still use
947
             * sdf_idx and vec_idx so that code would be less confusing */
949
             * sdf_idx and vec_idx so that code would be less confusing */
948
            char *iname_op2, *varname_op2;
950
            const char *iname_op2, *varname_op2;
949
            sqlite3_stmt *stmt3;
951
            sqlite3_stmt *stmt3;
950
            iname_op2 = SDF_INAME(op2);
952
            iname_op2 = SDF_INAME(op2);
951
            varname_op2 = SVEC_VARNAME(op2);
953
            varname_op2 = SVEC_VARNAME(op2);
952
 
954
 
953
            if (!USE_SDF1(iname_op2, TRUE, TRUE)) {
955
            if (!USE_SDF1(iname_op2, TRUE, TRUE)) {
Line 1089... Line 1091...
1089
    return R_NilValue;
1091
    return R_NilValue;
1090
 
1092
 
1091
}
1093
}
1092
 
1094
 
1093
SEXP sdf_do_variable_summary(SEXP func, SEXP vector, SEXP na_rm) {
1095
SEXP sdf_do_variable_summary(SEXP func, SEXP vector, SEXP na_rm) {
1094
    char *iname_src, *varname_src, *funcname;
1096
    const char *iname_src, *varname_src, *funcname;
1095
    int res;
1097
    int res;
1096
    sqlite3_stmt *stmt;
1098
    sqlite3_stmt *stmt;
1097
    double _ret = NA_REAL, _ret2; SEXP ret;
1099
    double _ret = NA_REAL, _ret2; SEXP ret;
1098
 
1100
 
1099
    /* get data from arguments (function name and sqlite.vector stuffs) */
1101
    /* get data from arguments (function name and sqlite.vector stuffs) */
Line 1156... Line 1158...
1156
    return ret;
1158
    return ret;
1157
}
1159
}
1158
 
1160
 
1159
 
1161
 
1160
SEXP sdf_sort_variable(SEXP svec, SEXP decreasing) {
1162
SEXP sdf_sort_variable(SEXP svec, SEXP decreasing) {
1161
    char *iname, *tblname, *varname, *type, *sort_type;
1163
    const char *iname, *tblname, *varname, *type, *sort_type;
1162
    sqlite3_stmt *stmt;
1164
    sqlite3_stmt *stmt;
1163
    int res;
1165
    int res;
1164
 
1166
 
1165
    iname = SDF_INAME(svec);
1167
    iname = SDF_INAME(svec);
1166
    tblname = SVEC_TBLNAME(svec);
1168
    tblname = SVEC_TBLNAME(svec);