The R Project SVN R-packages

Rev

Rev 3855 | Rev 4590 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3855 Rev 4160
Line 46... Line 46...
46
    UNPROTECT(nprotected);
46
    UNPROTECT(nprotected);
47
 
47
 
48
    return ret;
48
    return ret;
49
}
49
}
50
 
50
 
51
/* if ret == NULL, 3rd arg is the length of the vector created. otherwise
51
/* if ret == NULL, 3rd arg is the length of the vector to be created. otherwise
52
 * it is the index in the vector ret where we will put the result extracted
52
 * it is the index in the vector ret where we will put the result extracted
53
 * from ret */
53
 * from ret */
54
int _get_vector_index_typed_result(sqlite3_stmt *stmt, SEXP *ret, int idx_or_len) {
54
int _get_vector_index_typed_result(sqlite3_stmt *stmt, SEXP *ret, int colidx,
-
 
55
        int idx_or_len, int *coltype) {
55
    int added = 1;
56
    int added = 1, ctype;
56
    if (*ret == NULL || *ret == R_NilValue) {
57
    if (*ret == NULL || *ret == R_NilValue) {
57
        const char *coltype = sqlite3_column_decltype(stmt, 0);
-
 
58
        if (sqlite3_column_type(stmt, 0) == SQLITE_NULL) {
58
        if ((ctype = sqlite3_column_type(stmt, colidx)) == SQLITE_NULL) {
59
            added = 0;
59
            added = 0;
60
        }
60
        }
61
        
61
        
62
        if (strcmp(coltype, "text") == 0) {
62
        if (ctype == SQLITE_TEXT) {
63
            PROTECT(*ret = NEW_CHARACTER(idx_or_len));
63
            PROTECT(*ret = NEW_CHARACTER(idx_or_len));
64
            if (added) 
64
            if (added) 
65
                SET_STRING_ELT(*ret, 0, mkChar((char *)sqlite3_column_text(stmt, 0)));
65
                SET_STRING_ELT(*ret, 0, mkChar((char *)sqlite3_column_text(stmt, colidx)));
66
        } else if (strcmp(coltype, "double") == 0) {
66
        } else if (ctype == SQLITE_FLOAT) {
67
            PROTECT(*ret = NEW_NUMERIC(idx_or_len));
67
            PROTECT(*ret = NEW_NUMERIC(idx_or_len));
68
            if (added) REAL(*ret)[0] = sqlite3_column_double(stmt, 0);
68
            if (added) REAL(*ret)[0] = sqlite3_column_double(stmt, colidx);
69
        } else if (strcmp(coltype, "bit") == 0) {
69
        } else if (ctype == SQLITE_INTEGER) {
70
            PROTECT(*ret = NEW_LOGICAL(idx_or_len));
70
            /* sqlite does not differentiate b/w ints & bits, so we have to
71
            if (added) INTEGER(*ret)[0] = sqlite3_column_int(stmt, 0);
71
             * do it ourselves since R distinguishes b/w ints & logicals */
72
        } else if (strcmp(coltype, "integer") == 0 || 
72
            if (strcmp(sqlite3_column_decltype(stmt, colidx), "bit") == 0) {
73
                   strcmp(coltype, "int") == 0) {
73
                ctype = SQLITEDF_BIT; 
-
 
74
                PROTECT(*ret = NEW_LOGICAL(idx_or_len));
74
            /* caller should just copy off the vars level attr for factors */
75
                if (added) LOGICAL(*ret)[0] = sqlite3_column_int(stmt, colidx);
-
 
76
            } else {
75
            PROTECT(*ret = NEW_INTEGER(idx_or_len));
77
                PROTECT(*ret = NEW_INTEGER(idx_or_len));
76
            if (added) INTEGER(*ret)[0] = sqlite3_column_int(stmt, 0);
78
                if (added) INTEGER(*ret)[0] = sqlite3_column_int(stmt, colidx);
-
 
79
            }
77
        } else added = 0;
80
        } else added = 0;
78
 
81
 
79
        UNPROTECT(1);
82
        if (added) UNPROTECT(1);
-
 
83
        *coltype = ctype;
80
    } else if (stmt != NULL) {
84
    } else if (stmt != NULL) {
-
 
85
        int ctype = *coltype;
-
 
86
 
-
 
87
        /* first row must have been NULL so that *coltype was not set */
-
 
88
        if (ctype == SQLITE_NULL) {
81
        const char *coltype = sqlite3_column_decltype(stmt, 0);
89
            ctype = *coltype = sqlite3_column_type(stmt, colidx);
-
 
90
            /* distinguish int or logical */
-
 
91
            if (ctype == SQLITE_INTEGER) 
-
 
92
                ctype = (strcmp(sqlite3_column_decltype(stmt, colidx), "bit") == 0) ?
-
 
93
                    SQLITEDF_BIT : SQLITE_INTEGER;
-
 
94
        }
-
 
95
 
82
        if (sqlite3_column_type(stmt, 0) == SQLITE_NULL) {
96
        if (sqlite3_column_type(stmt, colidx) == SQLITE_NULL) {
83
            added = 0;
97
            added = 0;
84
        } else if (strcmp(coltype, "text") == 0) {
98
        } else if (ctype == SQLITE_TEXT) {
85
            SET_STRING_ELT(*ret, idx_or_len, 
99
            SET_STRING_ELT(*ret, idx_or_len, 
86
                    mkChar((char *)sqlite3_column_text(stmt, 0)));
100
                    mkChar((char *)sqlite3_column_text(stmt, colidx)));
87
        } else if (strcmp(coltype, "double") == 0) {
101
        } else if (ctype == SQLITE_FLOAT) {
88
            REAL(*ret)[idx_or_len] = sqlite3_column_double(stmt, 0);
102
            REAL(*ret)[idx_or_len] = sqlite3_column_double(stmt, colidx);
89
        } else if (strcmp(coltype, "bit") == 0) {
103
        } else if (ctype == SQLITE_INTEGER) {
90
            INTEGER(*ret)[idx_or_len] = sqlite3_column_int(stmt, 0);
104
            INTEGER(*ret)[idx_or_len] = sqlite3_column_int(stmt, colidx);
91
        } else if (strcmp(coltype, "integer") == 0 ||
105
        } else if (ctype == SQLITEDF_BIT) {
92
                   strcmp(coltype, "int") == 0) {
-
 
93
            /* caller should just copy off the vars level attr for factors */
-
 
94
            INTEGER(*ret)[idx_or_len] = sqlite3_column_int(stmt, 0);
106
            LOGICAL(*ret)[idx_or_len] = sqlite3_column_int(stmt, colidx);
95
        } else added = 0;
107
        } else added = 0;
96
    } else if (stmt == NULL) {
108
    } else if (stmt == NULL) {
97
        const char *coltype = sqlite3_column_decltype(stmt, 0);
109
        /* used when there is no row returned (sqlite3_step(stmt)!= QLITE_ROW),
-
 
110
         * and we just insert NAs in the result */
-
 
111
        ctype = *coltype;
98
        if (sqlite3_column_type(stmt, 0) == SQLITE_NULL) {
112
        if (ctype == SQLITE_NULL) { 
-
 
113
            /* since stmt == NULL, we can't check its column type */
99
            added = 0;
114
            added = 0;
100
        } else if (strcmp(coltype, "text") == 0) {
115
        } else if (ctype == SQLITE_TEXT) {
101
            SET_STRING_ELT(*ret, idx_or_len, NA_STRING);
116
            SET_STRING_ELT(*ret, idx_or_len, NA_STRING);
102
        } else if (strcmp(coltype, "double") == 0) {
117
        } else if (ctype == SQLITE_FLOAT) {
103
            REAL(*ret)[idx_or_len] = NA_REAL;
118
            REAL(*ret)[idx_or_len] = NA_REAL;
104
        } else if (strcmp(coltype, "bit") == 0 || strcmp(coltype, "integer") == 0 ||
-
 
105
                   strcmp(coltype, "int") == 0) {
119
        } else if (ctype == SQLITE_INTEGER) {
106
            INTEGER(*ret)[idx_or_len] = NA_INTEGER;
120
            INTEGER(*ret)[idx_or_len] = NA_INTEGER;
-
 
121
        } else if (ctype == SQLITEDF_BIT) {
-
 
122
            LOGICAL(*ret)[idx_or_len] = NA_LOGICAL;
107
        } else added = 0;
123
        } else added = 0;
108
    }
124
    }
109
        
125
        
110
    return added;
126
    return added;
111
}
127
}
Line 157... Line 173...
157
    if (strcmp(coltype, "text") == 0) svec_type = "character";
173
    if (strcmp(coltype, "text") == 0) svec_type = "character";
158
    else if (strcmp(coltype, "double") == 0) svec_type = "numeric";
174
    else if (strcmp(coltype, "double") == 0) svec_type = "numeric";
159
    else if (strcmp(coltype, "bit") == 0) svec_type = "logical";
175
    else if (strcmp(coltype, "bit") == 0) svec_type = "logical";
160
    else if (strcmp(coltype, "integer") == 0 || strcmp(coltype, "int") == 0) {
176
    else if (strcmp(coltype, "integer") == 0 || strcmp(coltype, "int") == 0) {
161
        /* determine if int, factor or ordered */
177
        /* determine if int, factor or ordered */
162
        type = _get_factor_levels1(iname, varname, ret);
178
        type = _get_factor_levels1(iname, varname, ret, FALSE);
163
        switch(type) {
179
        switch(type) {
164
            case VAR_INTEGER: svec_type = "integer"; break;
180
            case VAR_INTEGER: svec_type = "integer"; break;
165
            case VAR_FACTOR: svec_type = "factor"; break;
181
            case VAR_FACTOR: svec_type = "factor"; break;
166
            case VAR_ORDERED: svec_type = "ordered";
182
            case VAR_ORDERED: svec_type = "ordered";
167
        }
183
        }
168
 
-
 
169
    }
184
    }
170
 
185
 
171
    SET_CLASS(ret, mkString("sqlite.vector"));
186
    SET_CLASS(ret, mkString("sqlite.vector"));
172
    SET_SDFVECTORTYPE(ret, mkString(svec_type));
187
    SET_SDFVECTORTYPE(ret, mkString(svec_type));
173
 
188
 
Line 187... Line 202...
187
    
202
    
188
SEXP sdf_get_variable_index(SEXP svec, SEXP idx) {
203
SEXP sdf_get_variable_index(SEXP svec, SEXP idx) {
189
    SEXP ret = R_NilValue, tmp;
204
    SEXP ret = R_NilValue, tmp;
190
    char *iname = SDF_INAME(svec), *tblname = SVEC_TBLNAME(svec),
205
    char *iname = SDF_INAME(svec), *tblname = SVEC_TBLNAME(svec),
191
         *varname = SVEC_VARNAME(svec);
206
         *varname = SVEC_VARNAME(svec);
192
    int index, idxlen, i, retlen=0, res;
207
    int index, idxlen, i, retlen=0, res, coltype;
193
    sqlite3_stmt *stmt;
208
    sqlite3_stmt *stmt;
194
 
209
 
195
    if (!USE_SDF1(iname, TRUE, FALSE)) return R_NilValue;
210
    if (!USE_SDF1(iname, TRUE, FALSE)) return R_NilValue;
196
 
211
 
197
    idxlen = LENGTH(idx);
212
    idxlen = LENGTH(idx);
198
    if (idxlen < 1) return ret;
213
    if (idxlen < 1) return ret;
199
 
214
 
200
    sprintf(g_sql_buf[0], "select [%s] from [%s].[%s] limit ?,1",
215
    sprintf(g_sql_buf[0], "select [%s] from [%s].[%s] where rowid=?",
201
            varname, iname, tblname);
216
            varname, iname, tblname);
202
    res = sqlite3_prepare(g_workspace, g_sql_buf[0], -1, &stmt, 0);
217
    res = sqlite3_prepare(g_workspace, g_sql_buf[0], -1, &stmt, 0);
203
    if (_sqlite_error(res)) error("cannot complete request");
218
    if (_sqlite_error(res)) error("cannot complete request");
204
 
219
 
205
    /* get data based on index */
220
    /* get data based on index */
206
    if (IS_NUMERIC(idx)) {
221
    if (IS_NUMERIC(idx)) {
-
 
222
        /* special handling of 1st index, bec this is where we create the
-
 
223
         * SEXP to be used to hold the result */
207
        index = ((int) REAL(idx)[0]) - 1;
224
        index = (int) REAL(idx)[0];
208
        if (index < 0 && idxlen == 1) return ret;
225
        if (index < 1 && idxlen == 1) return ret;
209
 
226
 
210
        if (index >= 0) {
227
        if (index >= 1) {
211
            sqlite3_bind_int(stmt, 1, index);
228
            sqlite3_bind_int(stmt, 1, index);
212
            res = sqlite3_step(stmt);
229
            res = sqlite3_step(stmt);
213
            if (res == SQLITE_ROW) { 
230
            if (res == SQLITE_ROW) { 
214
                retlen = _get_vector_index_typed_result(stmt, &ret, idxlen);
231
                retlen = _get_vector_index_typed_result(stmt, &ret, 0, idxlen, &coltype);
215
            } 
232
            } 
216
        } 
233
        } 
217
        
234
        
218
        if (index < 0 || res != SQLITE_ROW) {
235
        if (index < 1 || res != SQLITE_ROW) {
219
            /* something wrong w/ 1st idx, and it is quietly ignored. we make 
236
            /* something wrong w/ 1st idx, and it is quietly ignored. we make 
220
             * a "dummy" call to setup the SEXP */
237
             * a "dummy" call to setup the SEXP */
221
            sqlite3_reset(stmt);
238
            sqlite3_reset(stmt);
222
            sqlite3_bind_int(stmt, 1, 0);
239
            sqlite3_bind_int(stmt, 1, 0);
223
            res = sqlite3_step(stmt);
240
            res = sqlite3_step(stmt);
224
            if (res == SQLITE_ROW) {
241
            if (res == SQLITE_ROW) {
-
 
242
                /* populate with 1st row. this should be overwritten by 
-
 
243
                 * succeeding calls. if there are no valid result, then 
-
 
244
                 * everything will be removed by _shrink_vector().
-
 
245
                 */
225
                _get_vector_index_typed_result(stmt, &ret, idxlen - 1);
246
                _get_vector_index_typed_result(stmt, &ret, 0, idxlen - 1, &coltype);
226
            }
247
            }
227
            retlen = 0;
248
            retlen = 0;
228
        }
249
        }
229
 
250
 
230
 
251
 
231
        if (idxlen > 1) {
252
        if (idxlen > 1) {
232
            for (i = 1; i < idxlen; i++) {
253
            for (i = 1; i < idxlen; i++) {
233
                index = ((int) REAL(idx)[i]) - 1;
254
                index = (int) REAL(idx)[i];
234
                if (index < 0) continue;
255
                if (index < 1) continue;
235
                sqlite3_reset(stmt);
256
                sqlite3_reset(stmt);
236
                sqlite3_bind_int(stmt, 1, index);
257
                sqlite3_bind_int(stmt, 1, index);
237
                res = sqlite3_step(stmt);
258
                res = sqlite3_step(stmt);
238
                if (res == SQLITE_ROW) {
259
                if (res == SQLITE_ROW) {
239
                    retlen += _get_vector_index_typed_result(stmt, &ret, retlen); 
260
                    retlen += _get_vector_index_typed_result(stmt, &ret, 0, retlen, &coltype); 
240
                } else {
261
                } else {
241
                    retlen += _get_vector_index_typed_result(NULL, &ret, retlen); 
262
                    retlen += _get_vector_index_typed_result(NULL, &ret, 0, retlen, &coltype); 
242
                }
263
                }
243
            }
264
            }
244
        }
265
        }
245
    } else if (IS_INTEGER(idx)) {
266
    } else if (IS_INTEGER(idx)) {
246
        /* similar to REAL (IS_NUMERIC) above, except that we don't have
267
        /* similar to REAL (IS_NUMERIC) above, except that we don't have
247
         * to cast idx to int. can't refactor this out, sucks. */
268
         * to cast idx to int. can't refactor this out, sucks. */
248
        index = INTEGER(idx)[0] - 1;
269
        index = INTEGER(idx)[0];
249
        if (index < 0 && idxlen == 1) return ret;
270
        if (index < 1 && idxlen == 1) return ret;
250
 
271
 
251
        if (index >= 0) {
272
        if (index >= 1) {
252
            sqlite3_bind_int(stmt, 1, index);
273
            sqlite3_bind_int(stmt, 1, index);
253
            res = sqlite3_step(stmt);
274
            res = sqlite3_step(stmt);
254
            if (res == SQLITE_ROW) { 
275
            if (res == SQLITE_ROW) { 
255
                retlen = _get_vector_index_typed_result(stmt, &ret, idxlen);
276
                retlen = _get_vector_index_typed_result(stmt, &ret, 0, idxlen, &coltype);
256
            } 
277
            } 
257
        } 
278
        } 
258
        
279
        
259
        if (index < 0 || res != SQLITE_ROW) {
280
        if (index < 1 || res != SQLITE_ROW) {
260
            /* something wrong w/ 1st idx, and it is quietly ignored. we make 
281
            /* something wrong w/ 1st idx, and it is quietly ignored. we make 
261
             * a "dummy" call to setup the SEXP */
282
             * a "dummy" call to setup the SEXP */
262
            sqlite3_reset(stmt);
283
            sqlite3_reset(stmt);
263
            sqlite3_bind_int(stmt, 1, 0);
284
            sqlite3_bind_int(stmt, 1, 0);
264
            res = sqlite3_step(stmt);
285
            res = sqlite3_step(stmt);
265
            if (res == SQLITE_ROW) {
286
            if (res == SQLITE_ROW) {
266
                _get_vector_index_typed_result(stmt, &ret, idxlen - 1);
287
                _get_vector_index_typed_result(stmt, &ret, 0, idxlen - 1, &coltype);
267
            }
288
            }
268
            retlen = 0;
289
            retlen = 0;
269
        }
290
        }
270
 
291
 
271
        if (idxlen > 1) {
292
        if (idxlen > 1) {
272
            for (i = 1; i < idxlen; i++) {
293
            for (i = 1; i < idxlen; i++) {
273
                index = INTEGER(idx)[i] - 1;
294
                index = INTEGER(idx)[i];
274
                if (index < 0) continue;
295
                if (index < 1) continue;
275
                sqlite3_reset(stmt);
296
                sqlite3_reset(stmt);
276
                sqlite3_bind_int(stmt, 1, index);
297
                sqlite3_bind_int(stmt, 1, index);
277
                res = sqlite3_step(stmt);
298
                res = sqlite3_step(stmt);
278
                if (res == SQLITE_ROW) {
299
                if (res == SQLITE_ROW) {
279
                    retlen += _get_vector_index_typed_result(stmt, &ret, retlen); 
300
                    retlen += _get_vector_index_typed_result(stmt, &ret, 0, retlen, &coltype); 
280
                } else {
301
                } else {
281
                    retlen += _get_vector_index_typed_result(NULL, &ret, retlen);
302
                    retlen += _get_vector_index_typed_result(NULL, &ret, 0, retlen, &coltype);
282
                }
303
                }
283
            }
304
            }
284
        }
305
        }
285
 
306
 
286
    } else if (IS_LOGICAL(idx)) {
307
    } else if (IS_LOGICAL(idx)) {
287
        /* have to deal with recycling */
308
        /* have to deal with recycling */
288
        int veclen = _get_row_count2(iname, 1);
309
        int veclen = _get_row_count2(iname, 1);
289
 
310
 
-
 
311
        /* in this indexing, idx[i] == TRUE is equiv to vector[i]. therefore
-
 
312
         * idxlen <= veclen. if idxlen < veclen, then idx is recycled. */
-
 
313
 
290
        /* find if there is any TRUE element in the vector */
314
        /* find if there is any TRUE element in the vector */
291
        for (i = 0; i < idxlen && i < veclen; i++) {
315
        for (i = 1; i < idxlen && i < veclen; i++) {
292
            if (LOGICAL(idx)[i]) {
316
            if (LOGICAL(idx)[i]) {
293
                sqlite3_bind_int(stmt, 1, i);
317
                sqlite3_bind_int(stmt, 1, i+1);
294
                sqlite3_step(stmt);
318
                sqlite3_step(stmt);
295
                /* there are at least (idxlen-i) TRUE per cycle of the LOGICAL
319
                /* there are at least (idxlen-i) TRUE per cycle of the LOGICAL
296
                 * index. there are at least (veclen/idxlen) cycles (int div).
320
                 * index. there are at least (veclen/idxlen) cycles (int div).
297
                 * at the last cycle, if (veclen%idxlen > 0), there will be
321
                 * at the last cycle, if (veclen%idxlen > 0), there will be
298
                 * at least (veclen%idxlen - i) if veclen%idxlen > i */
322
                 * at least (veclen%idxlen - i) if veclen%idxlen > i */
299
                retlen = (idxlen-i) * (veclen/idxlen);
323
                retlen = (idxlen-i) * (veclen/idxlen);
300
                if (veclen%idxlen > i) retlen += (veclen%idxlen - i);
324
                if (veclen%idxlen > i) retlen += (veclen%idxlen - i);
301
 
325
 
302
                /* create the vector */
326
                /* create the vector */
303
                retlen = _get_vector_index_typed_result(stmt, &ret, retlen);
327
                retlen = _get_vector_index_typed_result(stmt, &ret, 0, retlen, &coltype);
304
                break;
328
                break;
305
            }
329
            }
306
        }
330
        }
307
 
331
 
308
        if (i < idxlen && i < veclen) {
332
        if (i < idxlen && i < veclen) {
309
            for (i++; i < veclen; i++) {
333
            for (i++; i < veclen; i++) {
310
                if (LOGICAL(idx)[i%idxlen]) {
334
                if (LOGICAL(idx)[i%idxlen]) {
311
                    sqlite3_reset(stmt);
335
                    sqlite3_reset(stmt);
312
                    sqlite3_bind_int(stmt, 1, i);
336
                    sqlite3_bind_int(stmt, 1, i+1);
313
                    res = sqlite3_step(stmt);
337
                    res = sqlite3_step(stmt);
314
                    if (res == SQLITE_ROW) {
338
                    if (res == SQLITE_ROW) {
315
                        retlen += _get_vector_index_typed_result(stmt, &ret, retlen);
339
                        retlen += _get_vector_index_typed_result(stmt, &ret, 0, retlen, &coltype);
316
                    } else {
340
                    } else {
317
                        retlen += _get_vector_index_typed_result(NULL, &ret, retlen);
341
                        retlen += _get_vector_index_typed_result(NULL, &ret, 0, retlen, &coltype);
318
                    }
342
                    }
319
                }
343
                }
320
            }
344
            }
321
        }
345
        }
322
    }
346
    }
Line 342... Line 366...
342
    return ret;
366
    return ret;
343
}
367
}
344
 
368
 
345
/* sqlite.vector.[<- */
369
/* sqlite.vector.[<- */
346
SEXP sdf_set_variable_index(SEXP svec, SEXP idx, SEXP value) {
370
SEXP sdf_set_variable_index(SEXP svec, SEXP idx, SEXP value) {
347
    int idx_len, val_len;
371
    int idx_len, val_len, svec_len, i, res;
-
 
372
    char *iname = SDF_INAME(svec), *tblname = SVEC_TBLNAME(svec),
-
 
373
         *varname = SVEC_VARNAME(svec);
-
 
374
    sqlite3_stmt *stmt;
348
 
375
 
349
    /* match levels if factor or ordered */
376
    /* match levels if factor or ordered */
350
    if (inherits(value, "ordered")) {
377
    if (inherits(value, "ordered")) {
351
    } else if (inherits(value, "factor")) {
378
    } else if (inherits(value, "factor")) {
352
    }
379
    }
353
 
380
 
354
    idx_len = LENGTH(idx);
381
    idx_len = LENGTH(idx);
355
    val_len = LENGTH(value);
382
    val_len = LENGTH(value);
-
 
383
    svec_len = _get_row_count2(iname, TRUE);
-
 
384
 
-
 
385
    if (idx_len % val_len != 0) 
-
 
386
        warning("number of items to replace is not a multiple of replacement length");
-
 
387
 
-
 
388
    sprintf(g_sql_buf[0], "update [%s].[%s] set [%s]=? where rowid=?",
-
 
389
            iname, tblname, varname);
-
 
390
    _sqlite_begin;
-
 
391
    res = sqlite3_prepare(g_workspace, g_sql_buf[0], -1, &stmt, 0);
-
 
392
    if (_sqlite_error(res)) {
-
 
393
        error("cannot complete request");
-
 
394
        _sqlite_commit;
-
 
395
    }
356
 
396
 
357
    if (IS_NUMERIC(idx)) {
397
    if (IS_NUMERIC(idx)) {
-
 
398
        for (i = 0; i < idx_len; i++) {
-
 
399
            /* determine type of svec, cast value to type of it */
-
 
400
            /* value can only be of a single type, because it is a vector! */
-
 
401
            /* if svec is a factor, value is a string, must check with
-
 
402
             * factor levels */
-
 
403
        }
358
    } else if (IS_INTEGER(idx)) {
404
    } else if (IS_INTEGER(idx)) {
359
    } else if (IS_LOGICAL(idx)) {
405
    } else if (IS_LOGICAL(idx)) {
360
    }
406
    }
361
 
407
 
-
 
408
    _sqlite_commit;
362
    return R_NilValue;
409
    return R_NilValue;
363
}
410
}
364
 
411
 
365
SEXP sdf_variable_summary(SEXP svec, SEXP maxsum) {
412
SEXP sdf_variable_summary(SEXP svec, SEXP maxsum) {
366
    char *iname, *tblname, *varname, *type;
413
    char *iname, *tblname, *varname, *type;
Line 1094... Line 1141...
1094
    return ret;
1141
    return ret;
1095
}
1142
}
1096
 
1143
 
1097
 
1144
 
1098
SEXP sdf_sort_variable(SEXP svec, SEXP decreasing) {
1145
SEXP sdf_sort_variable(SEXP svec, SEXP decreasing) {
1099
    char *iname, *tblname, *varname, *type, *sort_type, *iname2;
1146
    char *iname, *tblname, *varname, *type, *sort_type;
1100
    sqlite3_stmt *stmt;
1147
    sqlite3_stmt *stmt;
1101
    int res;
1148
    int res;
1102
 
1149
 
1103
    iname = SDF_INAME(svec);
1150
    iname = SDF_INAME(svec);
1104
    tblname = SVEC_TBLNAME(svec);
1151
    tblname = SVEC_TBLNAME(svec);