Class Array
- java.lang.Object
-
- io.tiledb.java.api.Array
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Array extends java.lang.Object implements java.lang.AutoCloseable
Class representing a TileDB array object.An Array object represents array data in TileDB at some persisted location, e.g. on disk, in an S3 bucket, etc. Once an array has been opened for reading or writing, interact with the data through
Query
objects.Example:
// Create an ArraySchema, add attributes, domain, etc. Context ctx = new Context(); ArraySchema schema = new ArraySchema(...); // Create empty array named "my_array" on persistent storage. Array.create("my_array", schema);
-
-
Constructor Summary
Constructors Constructor Description Array(Context ctx, java.lang.String uri)
Constructs an Array object opening the array for reading.Array(Context ctx, java.lang.String uri, QueryType query_type)
Constructs an Array object, opening the array for the given query type.Array(Context ctx, java.lang.String uri, QueryType query_type, EncryptionType encryption_type, byte[] key)
Constructs an Array object, opening the encrypted array for the given query type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Free's the native objects and closes the Array.static void
consolidate(Context ctx, java.lang.String uri)
Consolidates the fragments of an array into a single fragment.static void
consolidate(Context ctx, java.lang.String uri, Config config)
Consolidates the fragments of an array into a single fragment.static void
consolidate(Context ctx, java.lang.String uri, EncryptionType encryption_type, byte[] key)
Consolidates the fragments of an array into a single fragment.static void
consolidate(Context ctx, java.lang.String uri, EncryptionType encryption_type, byte[] key, Config config)
Consolidates the fragments of an array into a single fragment.static void
create(java.lang.String uri, ArraySchema schema)
Creates a persisted TileDB array given an inputArraySchema
static void
create(java.lang.String uri, ArraySchema schema, EncryptionType encryption_type, byte[] key)
Creates an encrypted persisted TileDBArray given inputArraySchema
and encryption keystatic boolean
exists(Context ctx, java.lang.String uri)
Checks if a given URI is an existing TileDB array objectprotected SWIGTYPE_p_tiledb_array_t
getArrayp()
Context
getCtx()
QueryType
getQueryType()
ArraySchema
getSchema()
java.lang.String
getUri()
java.util.HashMap<java.lang.String,Pair<java.lang.Long,java.lang.Long>>
maxBufferElements(NativeArray subarray)
Compute an upper bound on the buffer elements needed to read a subarray.java.util.HashMap<java.lang.String,Pair>
nonEmptyDomain()
Get the non-empty domain of an array, returning the bounding coordinates for each dimension.
-
-
-
Constructor Detail
-
Array
public Array(Context ctx, java.lang.String uri) throws TileDBError
Constructs an Array object opening the array for reading.Example:
Context ctx = new Context(); Array array new Array(ctx, "s3://bucket-name/array-name");
- Parameters:
ctx
- TileDB contexturi
- The array URI- Throws:
TileDBError
- A TileDB exception
-
Array
public Array(Context ctx, java.lang.String uri, QueryType query_type) throws TileDBError
Constructs an Array object, opening the array for the given query type.Example:
Context ctx = new Context(); Array array new Array(ctx, "s3://bucket-name/array-name", TILEDB_READ);
- Parameters:
ctx
- TileDB contexturi
- The array URIquery_type
- Query type to open the array for.- Throws:
TileDBError
- A TileDB exception
-
Array
public Array(Context ctx, java.lang.String uri, QueryType query_type, EncryptionType encryption_type, byte[] key) throws TileDBError
Constructs an Array object, opening the encrypted array for the given query type.Example:
Context ctx = new Context(); String key = "0123456789abcdeF0123456789abcdeF"; Array array new Array(ctx, "s3://bucket-name/array-name", TILEDB_READ, TILEDB_AES_256_GCM, key.getBytes(StandardCharsets.UTF_8));
- Parameters:
ctx
- TileDB contexturi
- The array URIquery_type
- Query type to open the array forencryption_type
- The encryption type to usekey
- The encryption key to use- Throws:
TileDBError
- A TileDB exception
-
-
Method Detail
-
consolidate
public static void consolidate(Context ctx, java.lang.String uri) throws TileDBError
Consolidates the fragments of an array into a single fragment.All queries to the array before consolidation must be finalized before consolidation can begin. Consolidation temporarily aquires an exclusive lock on the array when finalizing the resulting merged fragment.
Example:
Context ctx = new Context(); Array.consolidate(ctx, "s3://bucket-name/array-name");
- Parameters:
ctx
- TileDB context objecturi
- TileDB URI string- Throws:
TileDBError
- A TileDB exception
-
consolidate
public static void consolidate(Context ctx, java.lang.String uri, Config config) throws TileDBError
Consolidates the fragments of an array into a single fragment.All queries to the array before consolidation must be finalized before consolidation can begin. Consolidation temporarily aquires an exclusive lock on the array when finalizing the resulting merged fragment.
Example:
Context ctx = new Context(); Array.consolidate(ctx, "s3://bucket-name/array-name");
- Parameters:
ctx
- TileDB context objecturi
- TileDB URI stringconfig
- A TileDB config object with configuration parameters for the consolidation- Throws:
TileDBError
- A TileDB exception
-
consolidate
public static void consolidate(Context ctx, java.lang.String uri, EncryptionType encryption_type, byte[] key) throws TileDBError
Consolidates the fragments of an array into a single fragment.All queries to the array before consolidation must be finalized before consolidation can begin. Consolidation temporarily aquires an exclusive lock on the array when finalizing the resulting merged fragment.
Example:
Context ctx = new Context(); String key = "0123456789abcdeF0123456789abcdeF"; Array.consolidate(ctx, "s3://bucket-name/array-name", TILEDB_AES_256_GCM, key.getBytes(StandardCharsets.UTF_8));
- Parameters:
ctx
- A TileDB Contexturi
- URI string to TileDB arrayencryption_type
- Encryption type the array is encrypted withkey
- A byte array key to decrypt array- Throws:
TileDBError
-
consolidate
public static void consolidate(Context ctx, java.lang.String uri, EncryptionType encryption_type, byte[] key, Config config) throws TileDBError
Consolidates the fragments of an array into a single fragment.All queries to the array before consolidation must be finalized before consolidation can begin. Consolidation temporarily aquires an exclusive lock on the array when finalizing the resulting merged fragment.
Example:
Context ctx = new Context(); String key = "0123456789abcdeF0123456789abcdeF"; Array.consolidate(ctx, "s3://bucket-name/array-name", TILEDB_AES_256_GCM, key.getBytes(StandardCharsets.UTF_8));
- Parameters:
ctx
- A TileDB Contexturi
- URI string to TileDB arrayencryption_type
- Encryption type the array is encrypted withkey
- A byte array key to decrypt arrayconfig
- A TileDB config object with configuration parameters for the consolidation- Throws:
TileDBError
-
exists
public static boolean exists(Context ctx, java.lang.String uri) throws TileDBError
Checks if a given URI is an existing TileDB array object- Parameters:
ctx
- TileDB context objecturi
- TileDB URI array string- Returns:
- true if the uri is an array object, false otherwise
- Throws:
TileDBError
-
create
public static void create(java.lang.String uri, ArraySchema schema) throws TileDBError
Creates a persisted TileDB array given an inputArraySchema
Example:
Array.create("my_array", schema);
- Parameters:
uri
- The array URI stringschema
- The TileDB ArraySchema- Throws:
TileDBError
- A TileDB exception
-
create
public static void create(java.lang.String uri, ArraySchema schema, EncryptionType encryption_type, byte[] key) throws TileDBError
Creates an encrypted persisted TileDBArray given inputArraySchema
and encryption keyExample:
String key = "0123456789abcdeF0123456789abcdeF"; Array.create("my_array", schema, TILEDB_AES_256_GCM, key.getBytes(StandardCharsets.UTF_8));
- Parameters:
uri
- The array URI stringschema
- The TileDB ArraySchemaencryption_type
- The encryption type to usekey
- The encryption key to use- Throws:
TileDBError
- A TileDB exception
-
nonEmptyDomain
public java.util.HashMap<java.lang.String,Pair> nonEmptyDomain() throws TileDBError
Get the non-empty domain of an array, returning the bounding coordinates for each dimension.- Returns:
- A HashMap of dimension names and (lower, upper) inclusive bounding coordinate range pair. Empty HashMap if the array has no data.
- Throws:
TileDBError
- A TileDB exception
-
maxBufferElements
public java.util.HashMap<java.lang.String,Pair<java.lang.Long,java.lang.Long>> maxBufferElements(NativeArray subarray) throws TileDBError
Compute an upper bound on the buffer elements needed to read a subarray.- Parameters:
subarray
- Domain subarray- Returns:
- The maximum number of elements for each array attribute. If the Array is sparse, max number of coordinates are also returned. Note that two numbers are returned per attribute. The first is the maximum number of elements in the offset buffer (0 for fixed-sized attributes and coordinates), the second is the maximum number of elements of the value buffer.
- Throws:
TileDBError
- A TileDB exception
-
getCtx
public Context getCtx()
- Returns:
- The TileDB Context object associated with the Array instance.
-
getUri
public java.lang.String getUri()
- Returns:
- The URI string of the array
-
getSchema
public ArraySchema getSchema() throws TileDBError
- Returns:
- The TileDB ArraySchema of the Array instance.
- Throws:
TileDBError
-
getQueryType
public QueryType getQueryType()
- Returns:
- The TileDB QueryType enum value that the Array instance.
-
getArrayp
protected SWIGTYPE_p_tiledb_array_t getArrayp()
- Returns:
- SWIG tiledb_array_t pointer wrapper object.
-
close
public void close()
Free's the native objects and closes the Array.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
-