Skip to content

Commit 4090c28

Browse files
Fixing a bug where multiple "Dimension not found" messages where showing up in the output
1 parent 0493e4d commit 4090c28

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

src/main/java/io/tiledb/java/api/ArraySchema.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -464,19 +464,12 @@ public long getAttributeNum() throws TileDBError {
464464
* @throws TileDBError
465465
*/
466466
public boolean hasAttribute(String name) throws TileDBError {
467-
SWIGTYPE_p_p_tiledb_attribute_t attrpp = tiledb.new_tiledb_attribute_tpp();
468-
int rc;
469-
try {
470-
rc =
471-
tiledb.tiledb_array_schema_get_attribute_from_name(
472-
ctx.getCtxp(), getSchemap(), name, attrpp);
473-
if (rc == tiledb.TILEDB_OOM) {
474-
ctx.handleError(rc);
475-
}
476-
} finally {
477-
tiledb.delete_tiledb_attribute_tpp(attrpp);
478-
}
479-
return rc == tiledb.TILEDB_OK;
467+
SWIGTYPE_p_int hasAttribute = tiledb.new_intp();
468+
ctx.handleError(
469+
tiledb.tiledb_array_schema_has_attribute(ctx.getCtxp(), getSchemap(), name, hasAttribute));
470+
boolean result = tiledb.intp_value(hasAttribute) > 0;
471+
tiledb.delete_intp(hasAttribute);
472+
return result;
480473
}
481474

482475
/**

src/main/java/io/tiledb/java/api/Domain.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,12 @@ public List<Dimension> getDimensions() throws TileDBError {
196196
* @throws TileDBError
197197
*/
198198
public boolean hasDimension(String name) throws TileDBError {
199-
SWIGTYPE_p_p_tiledb_dimension_t dimpp = tiledb.new_tiledb_dimension_tpp();
200-
int rc;
201-
try {
202-
rc = tiledb.tiledb_domain_get_dimension_from_name(ctx.getCtxp(), getDomainp(), name, dimpp);
203-
if (rc == tiledb.TILEDB_OOM) {
204-
ctx.handleError(rc);
205-
}
206-
} finally {
207-
tiledb.delete_tiledb_dimension_tpp(dimpp);
208-
}
209-
return rc == tiledb.TILEDB_OK;
199+
SWIGTYPE_p_int hasDimension = tiledb.new_intp();
200+
ctx.handleError(
201+
tiledb.tiledb_domain_has_dimension(ctx.getCtxp(), getDomainp(), name, hasDimension));
202+
boolean result = tiledb.intp_value(hasDimension) > 0;
203+
tiledb.delete_intp(hasDimension);
204+
return result;
210205
}
211206

212207
/**

0 commit comments

Comments
 (0)