Skip to content

Commit 76d885f

Browse files
committed
Added setFillValueNullable support and fragment info
1 parent 2297da8 commit 76d885f

File tree

12 files changed

+1756
-35
lines changed

12 files changed

+1756
-35
lines changed

src/main/c/generated/tiledb_wrap.cxx

Lines changed: 950 additions & 28 deletions
Large diffs are not rendered by default.

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,20 @@ public ArraySchema getSchema() throws TileDBError {
996996
return _schema;
997997
}
998998

999+
/**
1000+
* Reopens a TileDB array (the array must be already open). This is useful when the array got
1001+
* updated after it got opened. To sync-up with the updates, the user must either close the array
1002+
* and open with `tiledb_array_open`, or just use `reopen` without closing. This function will be
1003+
* generally faster than the former alternative.
1004+
*
1005+
* <p>Note: reopening encrypted arrays does not require the encryption key.
1006+
*
1007+
* @throws TileDBError
1008+
*/
1009+
public void reopen() throws TileDBError {
1010+
ctx.handleError(tiledb.tiledb_array_reopen(ctx.getCtxp(), getArrayp()));
1011+
}
1012+
9991013
/** @return The TileDB QueryType enum value that the Array instance. */
10001014
public QueryType getQueryType() {
10011015
return query_type;

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

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,73 @@ public Pair<Object, Long> getFillValue() throws TileDBError {
290290
}
291291
}
292292

293-
public int setNullable(short nullable) throws TileDBError {
293+
/**
294+
* Sets the default fill value for the input, nullable attribute. This value will be used for the
295+
* input attribute whenever querying (1) an empty cell in a dense array, or (2) a non-empty cell
296+
* (in either dense or sparse array) when values on the input attribute are missing (e.g., if the
297+
* user writes a subset of the attributes in a write operation).
298+
*
299+
* @param value The fill value to set.
300+
* @param size The fill value size in bytes.
301+
* @param valid The validity fill value, zero for a null value and non-zero for a valid attribute.
302+
* @throws TileDBError
303+
*/
304+
public void setFillValueNullable(NativeArray value, BigInteger size, boolean valid)
305+
throws TileDBError {
306+
307+
try {
308+
ctx.handleError(
309+
tiledb.tiledb_attribute_set_fill_value_nullable(
310+
ctx.getCtxp(),
311+
attributep,
312+
value.toVoidPointer(),
313+
size,
314+
valid ? (short) 1 : (short) 0));
315+
} catch (TileDBError err) {
316+
throw err;
317+
}
318+
}
319+
320+
/**
321+
* Gets the default fill value for the input, nullable attribute. This value will be used for the
322+
* input attribute whenever querying (1) an empty cell in a dense array, or (2) a non-empty cell
323+
* (in either dense or sparse array) when values on the input attribute are missing (e.g., if the
324+
* user writes a subset of the attributes in a write operation).
325+
*
326+
* <p>Applicable to both fixed-sized and var-sized attributes.
327+
*
328+
* @return A pair which contains the fill value and a pair with its size and validity field i.e.
329+
* Pair(5, Pair(4, true))
330+
* @throws TileDBError
331+
*/
332+
public Pair<Object, Pair<Long, Boolean>> getFillValueNullable() throws TileDBError {
333+
334+
try (NativeArray value = new NativeArray(ctx, this.type.getNativeSize(), this.type)) {
335+
NativeArray validArr = new NativeArray(ctx, 1, Datatype.TILEDB_UINT8);
336+
SWIGTYPE_p_unsigned_long_long size = tiledb.new_ullp();
337+
SWIGTYPE_p_p_void v = tiledb.new_voidpArray(1);
338+
SWIGTYPE_p_unsigned_char valid = validArr.getUint8_tArray().cast();
339+
340+
ctx.handleError(
341+
tiledb.tiledb_attribute_get_fill_value_nullable(
342+
ctx.getCtxp(), attributep, v, size, valid));
343+
344+
Object fillValue;
345+
try (NativeArray fillValueArray = new NativeArray(ctx, getType(), v, 1)) {
346+
fillValue = fillValueArray.getItem(0);
347+
}
348+
349+
boolean validBoolean = validArr.getUint8_tArray().getitem(0) == 0 ? false : true;
350+
351+
return new Pair(fillValue, new Pair(tiledb.ullp_value(size), validBoolean));
352+
} catch (TileDBError err) {
353+
throw err;
354+
}
355+
}
356+
357+
public int setNullable(boolean isNullable) throws TileDBError {
358+
359+
short nullable = isNullable ? (short) 1 : (short) 0;
294360

295361
try {
296362
int res;

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,42 @@ public Query finalizeQuery() throws TileDBError {
16281628
return this;
16291629
}
16301630

1631+
/**
1632+
* Retrieves the number of written fragments. Applicable only to WRITE queries.
1633+
*
1634+
* @return The number of written fragments
1635+
* @throws TileDBError
1636+
*/
1637+
public long getFragmentNum() throws TileDBError {
1638+
SWIGTYPE_p_unsigned_int fragmentNum = tiledb.new_uintp();
1639+
ctx.handleError(tiledb.tiledb_query_get_fragment_num(ctx.getCtxp(), queryp, fragmentNum));
1640+
1641+
return tiledb.uintp_value(fragmentNum);
1642+
}
1643+
1644+
/**
1645+
* Retrieves the URI of the written fragment with the input index. Applicable only to WRITE
1646+
* queries.
1647+
*
1648+
* @return The URI
1649+
* @throws TileDBError
1650+
*/
1651+
public String getFragmentURI(BigInteger idx) throws TileDBError {
1652+
SWIGTYPE_p_p_char uri = tiledb.new_charpp();
1653+
ctx.handleError(tiledb.tiledb_query_get_fragment_uri(ctx.getCtxp(), queryp, idx, uri));
1654+
1655+
return tiledb.charpp_value(uri);
1656+
}
1657+
1658+
public Pair<Long, Long> getFragmentTimestampRange(BigInteger idx) throws TileDBError {
1659+
SWIGTYPE_p_unsigned_long_long t1 = tiledb.new_ullp();
1660+
SWIGTYPE_p_unsigned_long_long t2 = tiledb.new_ullp();
1661+
ctx.handleError(
1662+
tiledb.tiledb_query_get_fragment_timestamp_range(ctx.getCtxp(), queryp, idx, t1, t2));
1663+
1664+
return new Pair(tiledb.ullp_value(t1), tiledb.ullp_value(t2));
1665+
}
1666+
16311667
// Default noop async completion callback
16321668
private static class DefaultCallback implements Callback {
16331669
public DefaultCallback() {}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* ----------------------------------------------------------------------------
2+
* This file was automatically generated by SWIG (http://www.swig.org).
3+
* Version 4.0.1
4+
*
5+
* Do not make changes to this file unless you know what you are doing--modify
6+
* the SWIG interface file instead.
7+
* ----------------------------------------------------------------------------- */
8+
9+
package io.tiledb.libtiledb;
10+
11+
public class SWIGTYPE_p_p_tiledb_fragment_info_t {
12+
private transient long swigCPtr;
13+
14+
protected SWIGTYPE_p_p_tiledb_fragment_info_t(
15+
long cPtr, @SuppressWarnings("unused") boolean futureUse) {
16+
swigCPtr = cPtr;
17+
}
18+
19+
protected SWIGTYPE_p_p_tiledb_fragment_info_t() {
20+
swigCPtr = 0;
21+
}
22+
23+
protected static long getCPtr(SWIGTYPE_p_p_tiledb_fragment_info_t obj) {
24+
return (obj == null) ? 0 : obj.swigCPtr;
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* ----------------------------------------------------------------------------
2+
* This file was automatically generated by SWIG (http://www.swig.org).
3+
* Version 4.0.1
4+
*
5+
* Do not make changes to this file unless you know what you are doing--modify
6+
* the SWIG interface file instead.
7+
* ----------------------------------------------------------------------------- */
8+
9+
package io.tiledb.libtiledb;
10+
11+
public class SWIGTYPE_p_tiledb_fragment_info_t {
12+
private transient long swigCPtr;
13+
14+
protected SWIGTYPE_p_tiledb_fragment_info_t(
15+
long cPtr, @SuppressWarnings("unused") boolean futureUse) {
16+
swigCPtr = cPtr;
17+
}
18+
19+
protected SWIGTYPE_p_tiledb_fragment_info_t() {
20+
swigCPtr = 0;
21+
}
22+
23+
protected static long getCPtr(SWIGTYPE_p_tiledb_fragment_info_t obj) {
24+
return (obj == null) ? 0 : obj.swigCPtr;
25+
}
26+
}

0 commit comments

Comments
 (0)