Learn R Programming

scidb (version 1.1-2)

iquery: Simple SciDB query tool

Description

Issue SciDB queries and optionally return output in a data frame.

Usage

iquery(query, `return` = FALSE, afl = TRUE, iterative = FALSE, n = 10000, excludecol, ...)

Arguments

query
A SciDB query string (character). Separate multiple queries with semicolons.
return
Set to TRUE to return output. Otherwise don't return query output. Only available when afl=TRUE
afl
TRUE indicates query is in AFL form, FALSE indicates AQL.
iterative
Set to TRUE to return a result iterator. FALSE returns entire result at once.
n
Maximum number of rows to return when iterating through results. Set to Inf to return everything.
excludecol
An optional numeric range of columns to exclude from iterative results (only applies when iterative=TRIE).
...
Options passed on to read.table used to parse results.

Value

  • If return=TRUE, return the query result in data frame form (similar to the command-line -olcsv+ output option).

    If return=FALSE, return the query ID number.

    SciDB errors encountered during query processing are propagated to R and can be handled with normal R error handling mechanisms.

    Set itreative=TRUE to return a result iterator. Use the iterator nextElem function to iteratively return results, a maximum of n results at a time. See help in the iterators package for examples and options.

Details

The iquery function is a simple analog of the command-line SciDB iquery program.

Examples

Run this code
iquery("list('instances')",return=TRUE)

# A simple example that iterates through results using foreach
# Build an array with 1 million numbers from zero to 1.
iquery("store(build(<x:double>[i=1:1000000,100000,0],i/1000000),X)")
# Apply a function and return result in an iterator:
i <- iquery("apply(X, y, sin(x))", return=TRUE, iterative=TRUE)

# Sum up x and y (and dimension i too)
library("foreach")
foreach(j=i, .combine=function(...)colSums(rbind(...)))
# Compare with the much faster equivalent inside SciDB:
iquery("aggregate(apply(X, y, sin(x)),sum(x),sum(y))", return=TRUE)

Run the code above in your browser using DataLab