[TileDB::Domain] Error: Dimension "a1" does not exist

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

Hi @ggalanti,

Thank you for your message. We were able to run the code snippet you posted without facing any issues over version 0.4.3. We used the following code:

  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();
    }
  }

  public static void main(String[] args) throws Exception {
    createArray();
    writeArray();
  }

Could you please try to delete your array and try running the snippet above? If it fails, could you give us the following info?

  1. Which OS do you run?
  2. The exact command you use in order to run this example

Best,
Victor

Hi Victor,
First of all thank you for your prompt reply.
I already tried to delete my array before starting these tests.

Regarding the OS I’m on a Microsoft Windows 10 Enterprise (10.0.19041 N/A Build 19041).

Moreover I have created a new from-scratch maven project using your code snippet and I have repeated the test but I got the same error.
I can’t upload the zipped maven project using this form so I uploaded the file here (it expires in one week).
Please let me know if you have problems to download it or if I have to upload this file in another way.

To run the tests I simply executed the following command:

.\mvnw.cmd clean install; java -jar target\testTileDb-1.0-SNAPSHOT.jar

I also tried to run the same test inside a windows docker container following the steps below:

  1. unzip project file and cd the extracted directory,
  2. run the following command using powershell:
    docker run -v ${pwd}:c:/test -w c:/test openjdk:11.0.10-jdk-windowsservercore-1809 powershell -Command ".\mvnw.cmd clean install; java -jar target\testTileDb-1.0-SNAPSHOT.jar"

Thank you for your help.

Regards,
Giordano

Hi @ggalanti
Thank you for your message.
After some investigation we were able to reproduce the bug which appears to be Windows-specific. We are currently working on a fix. These error messages do not affect the functionality of TileDB, they are just wrongly displayed. We will release a new version of TileDB-Java very soon to address the issue.

Best,
Dimitris

Hi @ggalanti ,
We just released version 0.4.4 to fix the issue. Thank you again for your message.

Hi Dimitris,
thank you so much for your help and for the prompt fix.

Regards,
Giordano

Hi Dimitris,
We have tried version 0.4.5 (downloaded from maven central) and we can confirm we don’t receive the “[[TileDB::Domain] Error: Dimension “a1” does not exist” error anymore

Unfortunately, we are not able to retrieve data after we have inserted in a simple dense array.

For your convenience we posted below the source code.
The environment where we have run the test is the same mentioned above.

Could you please check what is missing here?
Thanks.

Regards,
Giordano

package tiledb;

import io.tiledb.java.api.*;

import java.util.Arrays;

public class Test {

    public static void createArray() throws TileDBError {
        try (Context ctx = new Context();
             Attribute a1 = new Attribute(ctx, "a1", Long.class);
             ArraySchema schema = new ArraySchema(ctx, ArrayType.TILEDB_DENSE)) {
            Dimension<Long> d1 = new Dimension<>(ctx, "d1", Long.class, new Pair<>(1L, 4L), 1L);
            Dimension<Long> d2 = new Dimension<>(ctx, "d2", Long.class, new Pair<>(1L, 4L), 1L);

            // Create getDomain
            Domain domain = new Domain(ctx);
            domain.addDimension(d1);
            domain.addDimension(d2);

            // Create array schema
            schema.setTileOrder(Layout.TILEDB_ROW_MAJOR);
            schema.setCellOrder(Layout.TILEDB_ROW_MAJOR);
            schema.setDomain(domain);
            schema.addAttribute(a1);

            // Check array schema
            schema.check();

            // Prlong 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 long[]{1, 2, 3, 4}, Long.class);
             Array myDenseArray = new Array(ctx, "my_dense_array", QueryType.TILEDB_WRITE);
             Query query = new Query(myDenseArray)) {

            query.setLayout(Layout.TILEDB_GLOBAL_ORDER);
            query.setSubarray(new NativeArray(ctx, new long[]{1, 1, 1, 4}, Long.class));
            query.setBuffer("a1", a1Data);

            query.submit();
        }
    }

    public static void readArray() throws TileDBError {
        try (Context ctx = new Context();
             Array array = new Array(ctx, "my_dense_array", QueryType.TILEDB_READ);
             Query query = new Query(array, QueryType.TILEDB_READ)) {

            query.setBuffer("d1", new NativeArray(ctx, 4, Long.class));
            query.setBuffer("d2", new NativeArray(ctx, 4, Long.class));
            query.setBuffer("a1", new NativeArray(ctx, 4, Long.class));

            query.setSubarray(new NativeArray(ctx, new long[]{1, 1, 1, 4}, Long.class))
                    .setLayout(Layout.TILEDB_GLOBAL_ORDER);
            query.submit();

            long[] a1 = (long[]) query.getBuffer("a1"); 
            Arrays.stream(a1).forEach(System.out::print); //-9223372036854775808-9223372036854775808-9223372036854775808-9223372036854775808
        }
    }

    public static void main(String[] args) throws Exception {
        createArray();
        writeArray();
        readArray();
    }
}

Hi @ggalanti ,

The problem is in the writeArray() method. Writing in TILEDB_GLOBAL_ORDER needs a bit more care. You can find more details here.
Instead, use TILEDB_ROW_MAJOR and you should be able to read the expected values.
Hope that helps!

Best,
Dimitris

Hi Dimitris,
Fast and helpful!
Sorry to have wasted your time I should have notice that in documentation.

Regards,
Giordano

1 Like