One of the things which has always irritated me is that there is no way to directly type an array in a query. You must always either load one from a file, or use a convoluted build() command. Being able to do this would enormously useful. So I created my own.
You can create simple one dimensional arrays, or more complicated arrays by optionally including a schema.
A simple array:
$ iquery AFL% a('[45,16,73]'); X,a 0,45 1,16 2,73
A simple array with two attributes:
AFL% a('[(45,1),(16,4),(73,12)]'); X,a,b 0,45,1 1,16,4 2,73,12
Note that for implicit schemas, the first attribute is ‘a’, the second ‘b’, and so forth. The dimension name is ‘X’, and it runs from 0 to infinity (or the 64bit equivalent) with a chunk size of 10,000 (because why not).
You can use it for lookup():
AFL% store(build(<val:double>[i=10:19,10,0],sqrt(i)*3),values); i,val 10,9.48683 11,9.94987 12,10.3923 13,10.8167 14,11.225 15,11.619 16,12 17,12.3693 18,12.7279 19,13.0767 AFL% lookup(a('[12,16,19]'),values); X,val 0,10.3923 1,12 2,13.0767
A custom schema:
AFL% a('[[text,is,possible][resistence,is,futile][dont,be,square]]',<sval:string>[rows=0:2,3,0,cols=0:2,3,0]); rows,cols,sval 0,0,'text' 0,1,'is' 0,2,'possible' 1,0,'resistence' 1,1,'is' 1,2,'futile' 2,0,'dont' 2,1,'be' 2,2,'square''
The SciDB text format is no longer in the current documentation, however, you may still find it in documentation for the 11.12 version: http://www.scidb.org/forum/download/file.php?id=25 Hopefully this will be restored to the documentation soon.
I might get around to adding this to a github repository, but until then, I have attached the source tarball. The code it entirely in the public domain, so feel free to use it however you wish, especially if you work at Paradigm4.
text_array.tgz (2.97 KB)