Index
SciDB Quick Reference Guide
Operators         Aggregates
adddim
allversions
 

adddim

adddim(array, new_dimension_name)

Create an array that adds a new integer dimension of length 1 to an existing array.

store(build(<x:double>[i=1:10,10,0],i), A); adddim(A, k);

allversions

allversions(array)

Create an array that contains all the versions of an existing array, organized along a new dimension called "VersionNo."

store(build(<x:double>[i=1:10,10,0],i), A); store(build(<x:double>[i=1:10,10,0],2*i), A); store(build(<x:double>[i=1:10,10,0],3*i), A); allversions(A);

analyze

analyze(array[,attribute1, attribute2, ...])

Create an array that characterize the contents of an existing array. Each cell in the result array includes the following attributes:


store(build_sparse(<x:double>[i=1:10,10,0],2*i,i<5), A); analyze(x);

apply

apply(source_array,new_attribute1,function1[,new_attribute2,function2]...)

Create an array with new attributes defined by scalar functions of existing attributes and/or constants.

store(build(<x:double>[i=1:10,10,0],i), A); apply(A, y, sqrt(x) + 1);

ApproxDC

ApproxDC(array[,attribute[,dimension_1,dimension_2,...])

Create an array that contains an estimate the number of distinct values of an array attribute, optionally grouped along one or more dimensions.

store(build(<x:double>[i=1:10,10,0],i/2), A); ApproxDC(A,x);

attribute_rename

attribute_rename(array,old_attribute1,new_attribute1[, old_attribute2,new_attribute2,...])

Create a duplicate array with renamed attributes.

store(build(<x:double>[i=1:10,10,0],i/2), A); attribute_rename(A,x,z);

attributes

attributes(array)

Create an array describing attributes of an existing named array.

store(apply(build(<x:double>[i=1:10,10,0],i/2),y,5), A); attributes(A);

avg_rank

avg_rank(array[, attribute[, dimension1[, dimension2, ...]]])

Create an array with an attribute that ranks an existing array attribute along one or more dimensions, averaging ties. The rank attribute name is the original attribute name plus "_rank." The original array attribute is also returned in the output array.

store(build(<x:double>[i=1:4,4,0,j=1:4,4,0],10*double(random())/2147483647 + 1),A); avg_rank(A,x,i);

between

between(array, low_coord1[, low_coord2, ...], high_coord1[, high_coord2, ...])

Create a new sparse array of the same shape as the input array with empty cells outside the specified rectangular coordinate range and copies of the input array cells elsewhere.

store(build(<x:double>[i=1:10,10,0],i), A); between(A, 3, 7);

build

build(array | schema, expression)

Create a single-attribute array or schema definition with values defined by the expression. The array dimensions must be bounded.

build(<x:double>[i=1:10,10,0],sqrt(i)); create_array(A,<x:double>[i=1:10,10,0]); build(A,sqrt(i));

build_sparse

build_sparse(array | schema, expression, boolean_expression)

Create a single-attribute sparse array or schema definition with values defined by the expression in coordinate locations that satisfy the boolean expression. Array dimensions must be bounded.

build_sparse(<x:double>[i=1:10,10,0], i, double(i)/2 = i/2); create_array(A,<x:double>[i=1:10,10,0]); build_sparse(A, i, double(i)/2 = i/2);

cancel

cancel(query_id)

Cancel a query. Nothing is returned.

cast

cast(array, array | schema)

Duplicate an existing array, changing its schema. The example converts a string dimension to an integer dimension. Cast can also change dimension and attribute names.

create_array(A,<i:int64>[x(string)=10,10,0]); redimension_store(build(<x:string>[i=1:10,10,0],'x'+string(i)), A); cast(A,<i:int64>[x=0:9,10,0]);

concat

concat(array1, array2)

Create a new array that contains the concatenation of two arrays along their left-most dimensions, which must have the same starting index, chunk size and overlap. All other dimensions and attributes must match exactly.

store(build(<x:double>[i=0:3,4,0,j=0:2,1,0],1),array1); store(build(<x:double>[i=0:1,4,0,j=0:2,1,0],2),array2); concat(array1,array2);

cross

cross(array1, array2)

Create the cross product of two arrays.

store(build(<x:double>[i=1:10,5,0,j=0:2,1,0],1), A); cross(A, build(<y:double>[k=1:5,5,0],2));

cross_join

cross_join(array1, array2[, dimension1, dimension2[, dimension3, dimension4, ...]])

Create the cross-product array of two arrays with equality predicates applied to pairs of dimensions. The arrays must have int64 dimension types.

store(build(<x:double>[i=1:10,5,0,j=0:2,1,0],1), A); cross_join(A, build(<y:double>[i=1:10,5,0],2) as B, A.i, B.i);

deldim

deldim(array)

Create an array that omits the leftmost dimension of the specified array. The leftmost dimension must have length 1. This is the inverse of adddim.

store(build(<x:double>[i=1:10,5,0,j=0:2,1,0],1), A); store(adddim(A,k),B); deldim(B);

dimensions

dimensions(array)

Create an array that describes the dimensions of the specified array.

store(build(<x:double>[i=1:10,5,0,j=0:2,1,0],1), A); dimensions(A);

filter

filter(array, boolean_expression)

Create an array of the same shape as the specified array that copies cells that meet the Boolean expression and marks cells that don't meet the condition EMPTY. The expression may use attributes and/or dimensions.

store(build(<x:double>[i=1:10,5,0,j=0:2,1,0],5), A); filter(A, x + i < 10);

help

help(operator_name)

Create an array that describes how to use the specified operator name (specified as a string value).

help('build_sparse')

insert

insert(input, array)

Create an array that inserts specified input values into an existing named array. This operator has the side effect of also updating the original named array with the inserted values. The arrays must be conformable with int64 dimension types.

store(build_sparse(<x:double>[i=1:10,5,0], sqrt(i), double(i)/2 = i/2),A); insert(build(<x:double>[i=1:10,5,0],i),A);

join

join(array1, array2)

Create an array that joins attributes from non-empty cells of two arrays at matching dimension values. The arrays must have the same dimension starting coordinates, chunk sizes and chunk overlaps.

store(build(<x:double>[i=1:10,5,0], sqrt(i)),A); join(build(<y:double>[i=1:50,5,0], i*i),A);

list

list(element)

Create an array that lists the requested elements in SciDB. 'element' is a string value that may be one of:

Leaving element unspecified implies list('arrays').
list('arrays')

lookup

lookup(indices, array)

Create an array of the same shape as the "indices" array that contains values in the specified array by coordinates specified in the attributes of the "indices" array. The "indices" array must have the same number of attributes as dimensions in the specified array.

The example resamples rows from a two dimensional array "A" with replacement. The array "I" contains the row resampling vector. (Note: the odd expression "double(random())/2147483647" generates numbers sampled from a uniform pseudo-random distribution between zero and 1.)

store(build(<x:double>[i=1:10,5,0,j=1:10,5,0],i*10+j),A); store(build(<i:int64>[k=1:10,10,0],10*double(random())/2147483647 + 1),I); lookup(cross(I,build(<j:int64>[h=1:10,10,0],h)),A);

max

max(array[, attribute[, dimension1[, dimension2, ...]]])

Create an array that returns the maximum value of all attributes in an entire array, or of a specified attribute, optionally grouped along one or more dimensions.

max(build(<x:double>[i=1:10,5,0], sin(i))); max(build(<x:double>[i=1:10,5,0,j=1:10,5,0], sin(i-j)), x, i);

merge

merge(array1, array2)

Create an array that merges the contents of two arrays. The arrays must have the same number of attributes, attribute types, starting dimension values, chunk sizes and chunk overlaps. Non-empty cells from "array1" appear in the output, as do non-empty cells from "array2" that correspond to empty cells in "array1." Both arrays must have int64 dimension types.

store(build_sparse(<x:double>[i=1:10,5,0], sqrt(i), double(i)/2 = i/2), A); merge(A, build(<x:double>[i=1:10,5,0], i));

min

min(array[, attribute[, dimension1[, dimension2, ...]]])

Create an array that returns the minimum value of all attributes in an array, or of a specified attribute, optionally grouped along one or more dimensions.

min(build(<x:double>[i=1:10,5,0], sin(i)));

multiply

multiply(array1, array2[, option])

Create the matrix product array from conformable, two-dimensional input arrays. The input arrays must each have a single attribute and bounded dimensions. The optinal parameter is a string value indicating either 'sparse' 'dense' or 'auto' code paths. The array attributes value types must have scalar multiplication defined.

store(build(<val:double>[i=0:2,3,0,j=0:1,2,0],sin(i+j)),A); store(build(<val:double>[i=0:1,2,0,j=0:1,2,0],cos(i+j)),B); multiply(A,B);

normalize

normalize(array)

Create a new array from the one-dimensional input array with a single, numeric-valued attribute, by dividing by the square root of the sum of the squares of the attribute values in the input array.

store(build(<val:double>[i=0:10,10,0],cos(i/3)), A); normalize(A);

project

project(array, attribute[, attribute[,...]])

Create a duplicate of the specified array restricted to the listed attributes.

store(apply(build(<val:double>[i=0:10,10,0],cos(i/3)), y, sin(i/3)), A); project(A, y);

quantile

quantile(array[,attribute1] [,dimension1, dimension2, ...], n)

Create an array that divides the specified attribute values from the input array into n quantiles along the specified dimensions. If no attribute is indicated, quantile uses the left-most array attribute. The output array contains two attributes, "percentage" and "*_quantile," where "*" indicates the attribute name. The "percentage" attribute is double-valued and indicates XXX

store(build(<x:double>[i=1:10,10,0,j=1:10,10,0],10*double(random())/2147483647 + 1),A); quantile(A, 4, x, i);

rank

rank(array[, attribute[, dimension1[, dimension2, ...]]])

Create an array that assigns rank order to elements of specified array.

store(build(<x:double>[i=1:10,10,0], random()%7/1.0), A); rank(A, x);

redimension_store

redimension_store(source, array[, aggregate (source_attribute) [as result_attribute]]...)

Create an array that omits attributes or dimensions, promotes attributes from "source" as dimensions, or demotes dimensions from "source" to attributes, optionally applying aggregates as it goes. This operator has the side effect of storing data to the specified "array." Redimension_store also returns the array as output. Redimension_store is a workhorse SciDB operator.

The first example converts an integer dimension in the build array into an integer attribute in the array "A" and converts a string attribute in the build array into a string dimension into the array "A." The "j" dimension of the output array is not explicitly specified and the first dimension value is used by default.

create_array(A,<i:int64>[x(string)=10,10,0,j=1:10,10,0]); redimension_store(build(<x:string>[i=1:10,10,0],'x'+string(i)), A);

The next example is almost the same as the first, but there are collisions in the string dimension. They are resolved by implicitly using the unspecified "j" dimension as required, referred to as a "synthetic dimension" in this context.

create_array(A,<i:int64>[x(string)=10,10,0,j=1:2,10,0]); redimension_store(build(<x:string>[i=1:10,10,0],'x'+string(i/2)), A);

regrid

regrid(array, grid_1[, grid2[, ...]], aggregate1[, aggregate2[, ...]])

Create an array that partitions the cells in the input array into blocks, and for each block, apply an aggregate operation over the values in the block. Each grid argument must be integer-valued (of type int64).

The example produces a 5x5 array that averages values and computes the maximum value over 2x2 blocks from the input array.

store(build(<x:double>[i=1:10,10,0,j=1:10,10,0],10*double(random())/2147483647 + 1),A); regrid(A, 2, 2, sum(x) as sum, max(x) as max);

remove

remove(array)

Remove an array.

store(build(<x:double>[i=1:10,10,0,j=1:10,10,0],i+j),A); remove(A);

rename

rename(array, new_name)

Rename an array. The new name is specified without quoting. This operator returns nothing, and is only used for its side effect.

store(build(<x:double>[i=1:10,10,0,j=1:10,10,0],i+j),A); rename(A, A1);

repart

repart(array1, array2 | schema)

Duplicate the contents of array1, applying the schema defined in array2 or schema. The schema must match attribute and dimension names and types from array1, but is free to define chunk size, chunk overlap, and dimension upper bounds. The operator returns the duplicated array and, if an output array is specified as array2, also stores its output there.

store(build(<x:double>[i=1:10,10,0,j=1:10,10,0],i+j),A); repart(A, <x:double>[i=1:10,5,1,j=1:10,2,0]);

reshape

reshape(array1, array2 | schema)

Duplicate the contents of array1 into the schema defined by the specified output array2 or schema. The schema must match the attributes of the source array1, and its dimensions must define an array with the same number of cells as array1. The reshape operator does not work on arrays with nonzero chunk overlap.

store(build(<x:double>[i=1:10,10,0,j=1:10,10,1],i+j),A); reshape(A, <x:double>[i=1:100,10,0]); reshape(A, <x:double>[i=1:5,5,0,j=1:5,5,0,k=1:4,4,0]);

reverse

reverse(array)

Create a copy of the input array with cells reversed in each array dimension.

store(build(<x:double>[i=1:10,10,0,j=1:10,10,1],i+j),A); reverse(A);

save

save(array, path[, instance[, format]])

Save an array to the indicated path, returning the array to the caller. The instance indicates on which SciDB instance filesystem to save the file (see list('instances')— 0 means the coordinator instance). Format is a string that indicates the saved file format. Here are some possible options (see the SciDB reference guide for more):

Format stringDescription
'lcsv+'Dimension and attribute values separated by commas
'dcsv'Dimension values in braces separated by commans, then attribute values separated by commas
'(type1[, type2[, ...]])'Attribute values in binary save format (see below).

store(build(<x:double>[i=1:3,3,0,j=1:3,3,0],i+j),A); save(A, '/tmp/A.csv', 0, 'lcsv+'); save(A, '/tmp/A.bin', 0, '(double)');

Examples of reading the output files produced by the example using GNU command-line utilities follow:

cat /tmp/A.csv # ASCII comma-separated value format od -tf8 /tmp/A.bin # Binary output format

scan

scan(array)

Identity function—return the array.

store(build(<x:double>[i=1:3,3,0,j=1:3,3,0],i+j),A); scan(A);

show

show(array | schema)

Create an array containing the schema of the specified stored array or schema.

store(build(<x:double>[i=1:3,3,0,j=1:3,3,0],i+j),A); show(A);

slice

slice(array, dimension1, value1[, dimension2, value2[, ...]])


Create a new array that subsets the input array along specified dimension values. The output array has lower dimension than the input array.

store(build(<x:double>[i=1:3,3,0,j=1:3,3,0],i+j),A); slice(A, i, 2);

sort

sort(array, attribute [asc | desc][, attribute [asc | desc][, ...]][, chunk_size])

Create an array containing a sorted representation of the input array by attribute values, optionally specifying ascending or descending order and output chunk size. The output array is one-dimensional with integer dimension "n" (don't use sort on an input array attribute named "n").

store(build(<x:double>[i=1:10,10,0],10*double(random())/2147483647 + 1),A); store(apply(A, s, 'x' + string(x)), B); sort(B, x, s);

stdev

stdev(array, attribute[, dimension1[, dimension2[, ...]]])

Create an array with the standard deviation of the indicated input array attribute values along the indicated dimensions. If no dimension is specified, compute the standard deviation of all indicated attribute values in the array.

store(build(<x:double>[i=1:10,10,0,j=1:10,10,0],10*double(random())/2147483647 + 1),A); stdev(A, x); stdev(A, x, j);

store

store(result, array)

Store the output result of a SciDB operator to the array name specified, returning the output array for use by the caller.

sum(store(build(<x:double>[i=1:10,10,0],i), A)); store(build(<x:double>[i=1:10,10,0],i), A); sum(A);

subarray

subarray(array, coordinate1, ...)

Create an array containing a clipped, rectilinear subset of the input array. The coordinates specified must, in order, indicate the low boundaries in each array dimension, followed by the high boundaries in each array dimension.

store(build(<x:double>[i=1:10,10,0,j=1:10,10,0],10*double(random())/2147483647 + 1),A); subarray(A, 2, 2, 5, 5);

substitute

substitute(array1, array2[, attribute1[, attribute2[, ...]]])

Create an array that substitutes null values in the indicated attributes in array1 with non-null values from the single-attribute array2. If no attributes are specified, null values in all attributes will be substituted. The single substitute value will be taken from the attribute value of array2 at dimension coordinate zero. Both array dimension start indices must be zero. The indicated output array attributes will be set to non-nullable.

The example creates an array with two attributes x and y with identical values that are null below coordinate i=5, then substitutes 0 for the null values in the y attribute.

store ( apply ( build(<x:double null>[i=0:9,10,0],iif(i<5,null,i)), y, x ), A ); substitute(A, build(<u:double>[j=0:0,1,0],0), y);

sum

sum(array[, attribute[, dimension1[, dimension2, ...]]])

Create an array that returns the sum of all attributes in the array, or just the sum of values in a specified attribute, optionally grouped along one or more dimensions.

sum(build(<x:double>[i=1:10,5,0,j=1:10,10,0], sin((double(i*j)/100))),x,i);

thin

thin(array, start1, step1, start2, step2, ...)

Create an array that selects data from an array at fixed intervals along each dimension. A dimension chunk size must be evenly divisible by its step size and must evenly divide the corresponding array dimension upper bound (in the case of an explicitly bounded dimension).

store(build(<x:double>[i=1:10,10,0,j=1:10,10,0], i+j),A); thin(A, 2, 5, 1, 2);

unpack

unpack(array, dimension_name[, chunk_size])

Create a 1-D array version of any array, converting input array dimension values to attributes in the output array. (The output array resembles the SciDB "lcsv+" formatted output.)

store(build(<x:double>[i=1:10,10,0,j=1:10,10,0], i+j),A); unpack(A, k);

var

var(array[, attribute[, dimension1[, dimension2, ...]]])

Create an array that returns the variance of all attributes in the array, or just the variance of values in a specified attribute, optionally grouped along one or more dimensions.

var(build(<x:double>[i=1:10,5,0,j=1:10,10,0], sin((double(i*j)/100))),x,i);

versions

versions(array)

Create an array that contains version information for the specified array, which must be stored in SciDB. The version information includes a sequential ID and date/time of update.

store(build_sparse([i=1:10,5,0], sqrt(i), double(i)/2 = i/2),A); versions(A); insert(build([i=1:10,5,0],i),A); versions(A);

xgrid

xgrid(array, scale1[, scale2[, ...]])

Create an array that prolongs each dimension of the specified input array by a scale factor. Input array cells are replicated to fill the new array. The number of supplied scale arguments must match the number of dimensions of the array. Each scale argument must be integer-valued (type int32).

store(build_sparse([i=1:4,5,0], i, double(i)/2 = i/2),A); xgrid(A, 2);

The xgrid operator in some cases can be the inverse of the regrid operator:

store(build_sparse([i=1:4,4,0,j=1:4,4,0], i + j, double(j)/2 = j/2 or double(i)/2 = i/2),A); xgrid(A, 2, 2); regrid(xgrid(A,2,2), 2, 2, max(x) as x);