Getting started with SciDB-R


#1

Okay so I am getting started with SciDB - R and the documentations are completely confusing me.
So I have a csv file consisting of 10 rows and 5 columns of some random integers.
I am able to create an array and load this file into it via the AQL AFL queries
How to do this in R?

https://paradigm4.github.io/SciDBR/

using the above links as reference.

@apoliakov


#2

@apoliakov Can you help? Thanks !


#3

Sure, so, first note you can use the iquery function inside R to execute any AFL statement you like:

> system("cat /tmp/foo.tsv")
1	2	3
4	5	6
7	8	9
> iquery("aio_input('/tmp/foo.tsv', 'num_attributes=3')", return =TRUE)
  tuple_no dst_instance_id src_instance_id a0 a1 a2 error
1        0               0               0  1  2  3  <NA>
2        1               0               0  4  5  6  <NA>
3        2               0               0  7  8  9  <NA>
> iquery("store(aio_input('/tmp/foo.tsv', 'num_attributes=3'), foo)", return =TRUE)
  tuple_no dst_instance_id src_instance_id a0 a1 a2 error
1        0               0               0  1  2  3  <NA>
2        1               0               0  4  5  6  <NA>
3        2               0               0  7  8  9  <NA>

Also you can use as.scidb to load directly from an data.frame. Here, gc=0 means decouple the array from R’s garbage collector and a name for the target array is given:

> foo_df = read.table('/tmp/foo.tsv', sep='\t')
> foo_df
  V1 V2 V3
1  1  2  3
2  4  5  6
3  7  8  9
> bar = as.scidb(foo_df, name="bar", gc=0)
> bar
SciDB expression  bar
SciDB schema  <V1:int32,V2:int32,V3:int32> [tuple_no=0:*,100000,0,dst_instance_id=0:15,1,0,src_instance_id=0:15,1,0] 
         variable dimension  type nullable start end  chunk
1        tuple_no      TRUE int64    FALSE     0   * 100000
2 dst_instance_id      TRUE int64    FALSE     0  15      1
3 src_instance_id      TRUE int64    FALSE     0  15      1
4              V1     FALSE int32     TRUE                 
5              V2     FALSE int32     TRUE                 
6              V3     FALSE int32     TRUE                 
> bar[]
  tuple_no dst_instance_id src_instance_id V1 V2 V3
1        0               0               0  1  2  3
2        1               0               0  4  5  6
3        2               0               0  7  8  9