Hi,
I’m trying to create and write a simple dense array through the official tiledb java library (version 0.4.3) following the examples available here but I get this error:
[tiledb] [Process: 7832] [Thread: 20476] [error] [TileDB::Domain] Error: Dimension "a1" does not exist
Here below the code snippet:
public static final String ATTRIBUTE_NAME = "a1";
public static void createArray() throws TileDBError {
try (Context ctx = new Context();
Attribute a1 = new Attribute(ctx, ATTRIBUTE_NAME, Integer.class)) {
Dimension<Long> d1 = new Dimension<>(ctx, "d1", Long.class, new Pair<>(1L, 4L), 2L);
Dimension<Long> d2 = new Dimension<>(ctx, "d2", Long.class, new Pair<>(1L, 4L), 2L);
// Create getDomain
Domain domain = new Domain(ctx);
domain.addDimension(d1);
domain.addDimension(d2);
// Create array schema
ArraySchema schema = new ArraySchema(ctx, TILEDB_DENSE);
schema.setTileOrder(TILEDB_ROW_MAJOR);
schema.setCellOrder(TILEDB_ROW_MAJOR);
schema.setDomain(domain);
schema.addAttribute(a1);
// Check array schema
schema.check();
// Print array schema contents
schema.dump();
Array.create("my_dense_array", schema);
}
}
public static void writeArray() throws TileDBError {
try (Context ctx = new Context();
NativeArray a1Data = new NativeArray(ctx, new int[]{112, 113, 114, 115}, Integer.class);
Array myDenseArray = new Array(ctx, "my_dense_array", TILEDB_WRITE);
Query query = new Query(myDenseArray)) {
query.setLayout(TILEDB_GLOBAL_ORDER);
query.setSubarray(new NativeArray(ctx, new long[]{3, 4, 3, 4}, Long.class));
query.setBuffer(ATTRIBUTE_NAME, a1Data);
// Submit query
query.submit();
}
}
With the same code using a previous java library version like the 0.3.1 (and earlier) this error does not occur.
Could anyone help me to figure out what I am doing wrong?
Cheers,
Giordano