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