Using Arrays with Namespaces

When using the Enterprise Edition in namespaces mode, arrays are contained within namespaces. You access these arrays by using either unqualified names and the set_namespace operator, or with fully qualified array names.

Your user account must have sufficient privileges to access the namespaces used by your queries, whether the working namespace or a namespace qualifier in a fully qualifed array name.

Unqualified Array Names

Unqualified array names take the form: arrayName. The namespace that the array resides in must be selected as the working namespace using set_namespace(namespace_name) first. Think of set_namespace as being similar to the cd command in Linux where the cd command changes the working directory. You can use the array name in any operator that accepts array names.  This example shows accessing array samples1 while the working namespace is sensor_data. 

set_namespace('sensor_data');  scan(samples1);

Using unqualified array names only allows access to arrays that are in the current working namespace.  When you first connect to SciDB, the current namespace is set to public .

Fully Qualified Array Names

Fully qualified array names take the form: namespaceName.arrayName.  The namespace containing the array not need be the working namespace.  This example shows accessing array ns1_array2 from within namespace NS1 while the working namespace is public.   Using a fully qualified array name has no effect on the working namespace.

set_namespace('public');  scan(NS1.ns1_array2);

 

Using the set_namespace Operator

Assume a namespace called NS1 containing arrays named A1 and A2 and a namespace called NS2 containing arrays named A1 and A3. You can use the scan operator to show the contents of these arrays. Use the set_namespace operator to accomplish this as follows:

 

iquery --auth-file <authentication_filename> "set_namespace('NS1');  scan('A1');"
iquery --auth-file <authentication_filename> "set_namespace('NS1');  scan('A2');"
iquery --auth-file <authentication_filename> "set_namespace('NS2');  scan('A1');"
iquery --auth-file <authentication_filename> "set_namespace('NS2');  scan('A3');"

Each iquery command makes a separate connection to SciDB, so the default namespace is set to public at the start of each connection.   To see the unqualified arrays in NS1 and NS2, a set_namespace operation is required each time.