From 32e5813b627a6652dd49df08f446df27c9d0f6dd Mon Sep 17 00:00:00 2001 From: gsvic Date: Fri, 1 May 2020 14:33:47 +0300 Subject: [PATCH] Support Dimension Val Num [ch1881] --- gradle.properties | 2 +- .../java/io/tiledb/java/api/Dimension.java | 32 +++++++++++++++++++ .../io/tiledb/java/api/DimensionTest.java | 20 ++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 44eb70dc..97b89700 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ TILEDB_GIT_REPOSITORY=https://github.com/TileDB-Inc/TileDB -TILEDB_GIT_TAG=2.0.0-rc5 +TILEDB_GIT_TAG=2.0.0 TILEDB_VERBOSE=OFF TILEDB_S3=OFF TILEDB_HDFS=OFF diff --git a/src/main/java/io/tiledb/java/api/Dimension.java b/src/main/java/io/tiledb/java/api/Dimension.java index 22752bcb..8e3863b7 100644 --- a/src/main/java/io/tiledb/java/api/Dimension.java +++ b/src/main/java/io/tiledb/java/api/Dimension.java @@ -248,6 +248,38 @@ public Dimension setFilterList(FilterList filters) throws TileDBError { return this; } + /** + * Sets the number of values per cell for the dimension. + * + * @param cellValNum The number of values per cell + * @throws TileDBError + */ + public void setCellValNum(long cellValNum) throws TileDBError { + try { + ctx.handleError( + tiledb.tiledb_dimension_set_cell_val_num(ctx.getCtxp(), dimensionp, cellValNum)); + } catch (TileDBError error) { + throw error; + } + } + + /** + * Retrieves the number of values per cell for the dimension. + * + * @return The number of values per cell + * @throws TileDBError + */ + public long getCellValNum() throws TileDBError { + SWIGTYPE_p_unsigned_int uint = tiledb.new_uintp(); + try { + ctx.handleError(tiledb.tiledb_dimension_get_cell_val_num(ctx.getCtxp(), dimensionp, uint)); + + return tiledb.uintp_value(uint); + } catch (TileDBError error) { + throw error; + } + } + /** * @return A string representation of the extent. * @throws TileDBError A TileDB exception diff --git a/src/test/java/io/tiledb/java/api/DimensionTest.java b/src/test/java/io/tiledb/java/api/DimensionTest.java index fb4f1a4b..ca97f169 100644 --- a/src/test/java/io/tiledb/java/api/DimensionTest.java +++ b/src/test/java/io/tiledb/java/api/DimensionTest.java @@ -55,4 +55,24 @@ public void testInvalidDimensionDatatype() throws Exception { Assert.assertEquals("d1", dim.getName()); } } + + @Test + public void testSetCellValNum() throws Exception { + try (Context ctx = new Context(); + Dimension dim = + new Dimension<>(ctx, "d1", Datatype.TILEDB_INT32, new Pair<>(1, 10), 10)) { + + dim.setCellValNum(1); + } + } + + @Test + public void testGetCellValNum() throws Exception { + try (Context ctx = new Context(); + Dimension dim = + new Dimension<>(ctx, "d1", Datatype.TILEDB_INT32, new Pair<>(1, 10), 10)) { + + Assert.assertEquals(1, dim.getCellValNum()); + } + } }