Skip to content

Commit 4987be1

Browse files
committed
Fill Value
1 parent fc581d0 commit 4987be1

File tree

6 files changed

+248
-2
lines changed

6 files changed

+248
-2
lines changed

src/main/c/generated/tiledb_wrap.cxx

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6068,6 +6068,71 @@ SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1attribute_1du
60686068
}
60696069

60706070

6071+
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1attribute_1set_1fill_1value(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3, jobject jarg4) {
6072+
jint jresult = 0 ;
6073+
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
6074+
tiledb_attribute_t *arg2 = (tiledb_attribute_t *) 0 ;
6075+
void *arg3 = (void *) 0 ;
6076+
uint64_t arg4 ;
6077+
int32_t result;
6078+
6079+
(void)jenv;
6080+
(void)jcls;
6081+
arg1 = *(tiledb_ctx_t **)&jarg1;
6082+
arg2 = *(tiledb_attribute_t **)&jarg2;
6083+
arg3 = *(void **)&jarg3;
6084+
{
6085+
jclass clazz;
6086+
jmethodID mid;
6087+
jbyteArray ba;
6088+
jbyte* bae;
6089+
jsize sz;
6090+
int i;
6091+
6092+
if (!jarg4) {
6093+
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
6094+
return 0;
6095+
}
6096+
clazz = jenv->GetObjectClass(jarg4);
6097+
mid = jenv->GetMethodID(clazz, "toByteArray", "()[B");
6098+
ba = (jbyteArray)jenv->CallObjectMethod(jarg4, mid);
6099+
bae = jenv->GetByteArrayElements(ba, 0);
6100+
sz = jenv->GetArrayLength(ba);
6101+
arg4 = 0;
6102+
if (sz > 0) {
6103+
arg4 = (uint64_t)(signed char)bae[0];
6104+
for(i=1; i<sz; i++) {
6105+
arg4 = (arg4 << 8) | (uint64_t)(unsigned char)bae[i];
6106+
}
6107+
}
6108+
jenv->ReleaseByteArrayElements(ba, bae, 0);
6109+
}
6110+
result = (int32_t)tiledb_attribute_set_fill_value(arg1,arg2,(void const *)arg3,arg4);
6111+
jresult = (jint)result;
6112+
return jresult;
6113+
}
6114+
6115+
6116+
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1attribute_1get_1fill_1value(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3, jlong jarg4) {
6117+
jint jresult = 0 ;
6118+
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
6119+
tiledb_attribute_t *arg2 = (tiledb_attribute_t *) 0 ;
6120+
void **arg3 = (void **) 0 ;
6121+
uint64_t *arg4 = (uint64_t *) 0 ;
6122+
int32_t result;
6123+
6124+
(void)jenv;
6125+
(void)jcls;
6126+
arg1 = *(tiledb_ctx_t **)&jarg1;
6127+
arg2 = *(tiledb_attribute_t **)&jarg2;
6128+
arg3 = *(void ***)&jarg3;
6129+
arg4 = *(uint64_t **)&jarg4;
6130+
result = (int32_t)tiledb_attribute_get_fill_value(arg1,arg2,(void const **)arg3,arg4);
6131+
jresult = (jint)result;
6132+
return jresult;
6133+
}
6134+
6135+
60716136
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1domain_1alloc(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
60726137
jint jresult = 0 ;
60736138
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
@@ -7338,6 +7403,24 @@ SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1get_1l
73387403
}
73397404

73407405

7406+
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1get_1array(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
7407+
jint jresult = 0 ;
7408+
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
7409+
tiledb_query_t *arg2 = (tiledb_query_t *) 0 ;
7410+
tiledb_array_t **arg3 = (tiledb_array_t **) 0 ;
7411+
int32_t result;
7412+
7413+
(void)jenv;
7414+
(void)jcls;
7415+
arg1 = *(tiledb_ctx_t **)&jarg1;
7416+
arg2 = *(tiledb_query_t **)&jarg2;
7417+
arg3 = *(tiledb_array_t ***)&jarg3;
7418+
result = (int32_t)tiledb_query_get_array(arg1,arg2,arg3);
7419+
jresult = (jint)result;
7420+
return jresult;
7421+
}
7422+
7423+
73417424
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1add_1range(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3, jlong jarg4, jlong jarg5, jlong jarg6) {
73427425
jint jresult = 0 ;
73437426
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
@@ -9235,6 +9318,36 @@ SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1vfs_1move_1di
92359318
}
92369319

92379320

9321+
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1vfs_1copy_1file(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jstring jarg4) {
9322+
jint jresult = 0 ;
9323+
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
9324+
tiledb_vfs_t *arg2 = (tiledb_vfs_t *) 0 ;
9325+
char *arg3 = (char *) 0 ;
9326+
char *arg4 = (char *) 0 ;
9327+
int32_t result;
9328+
9329+
(void)jenv;
9330+
(void)jcls;
9331+
arg1 = *(tiledb_ctx_t **)&jarg1;
9332+
arg2 = *(tiledb_vfs_t **)&jarg2;
9333+
arg3 = 0;
9334+
if (jarg3) {
9335+
arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
9336+
if (!arg3) return 0;
9337+
}
9338+
arg4 = 0;
9339+
if (jarg4) {
9340+
arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0);
9341+
if (!arg4) return 0;
9342+
}
9343+
result = (int32_t)tiledb_vfs_copy_file(arg1,arg2,(char const *)arg3,(char const *)arg4);
9344+
jresult = (jint)result;
9345+
if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
9346+
if (arg4) jenv->ReleaseStringUTFChars(jarg4, (const char *)arg4);
9347+
return jresult;
9348+
}
9349+
9350+
92389351
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1vfs_1open(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jint jarg4, jlong jarg5) {
92399352
jint jresult = 0 ;
92409353
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import static io.tiledb.java.api.Constants.TILEDB_VAR_NUM;
2828

2929
import io.tiledb.libtiledb.*;
30+
import java.math.BigInteger;
3031

3132
/**
3233
* Describes an Attribute of an Array cell.
@@ -260,6 +261,35 @@ public FilterList getFilterList() throws TileDBError {
260261
return filterlist;
261262
}
262263

264+
public void setFillValue(NativeArray value, BigInteger size) throws TileDBError {
265+
try {
266+
ctx.handleError(
267+
tiledb.tiledb_attribute_set_fill_value(
268+
ctx.getCtxp(), attributep, value.toVoidPointer(), size));
269+
} catch (TileDBError err) {
270+
throw err;
271+
}
272+
}
273+
274+
public Pair<Object, Long> getFillValue() throws TileDBError {
275+
276+
try (NativeArray value = new NativeArray(ctx, this.type.getNativeSize(), this.type)) {
277+
SWIGTYPE_p_unsigned_long_long size = tiledb.new_ullp();
278+
SWIGTYPE_p_p_void v = tiledb.new_voidpArray(1);
279+
280+
ctx.handleError(tiledb.tiledb_attribute_get_fill_value(ctx.getCtxp(), attributep, v, size));
281+
282+
Object fillValue;
283+
try (NativeArray fillValueArray = new NativeArray(ctx, getType(), v, 1)) {
284+
fillValue = fillValueArray.getItem(0);
285+
}
286+
287+
return new Pair(fillValue, tiledb.ullp_value(size));
288+
} catch (TileDBError err) {
289+
throw err;
290+
}
291+
}
292+
263293
/** @return A String representation for the Attribute. */
264294
@Override
265295
public String toString() {

src/main/java/io/tiledb/libtiledb/tiledb.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,30 @@ public static int tiledb_attribute_dump(
16521652
SWIGTYPE_p_FILE.getCPtr(out));
16531653
}
16541654

1655+
public static int tiledb_attribute_set_fill_value(
1656+
SWIGTYPE_p_tiledb_ctx_t ctx,
1657+
SWIGTYPE_p_tiledb_attribute_t attr,
1658+
SWIGTYPE_p_void value,
1659+
java.math.BigInteger size) {
1660+
return tiledbJNI.tiledb_attribute_set_fill_value(
1661+
SWIGTYPE_p_tiledb_ctx_t.getCPtr(ctx),
1662+
SWIGTYPE_p_tiledb_attribute_t.getCPtr(attr),
1663+
SWIGTYPE_p_void.getCPtr(value),
1664+
size);
1665+
}
1666+
1667+
public static int tiledb_attribute_get_fill_value(
1668+
SWIGTYPE_p_tiledb_ctx_t ctx,
1669+
SWIGTYPE_p_tiledb_attribute_t attr,
1670+
SWIGTYPE_p_p_void value,
1671+
SWIGTYPE_p_unsigned_long_long size) {
1672+
return tiledbJNI.tiledb_attribute_get_fill_value(
1673+
SWIGTYPE_p_tiledb_ctx_t.getCPtr(ctx),
1674+
SWIGTYPE_p_tiledb_attribute_t.getCPtr(attr),
1675+
SWIGTYPE_p_p_void.getCPtr(value),
1676+
SWIGTYPE_p_unsigned_long_long.getCPtr(size));
1677+
}
1678+
16551679
public static int tiledb_domain_alloc(
16561680
SWIGTYPE_p_tiledb_ctx_t ctx, SWIGTYPE_p_p_tiledb_domain_t domain) {
16571681
return tiledbJNI.tiledb_domain_alloc(
@@ -2295,6 +2319,16 @@ public static int tiledb_query_get_layout(
22952319
SWIGTYPE_p_tiledb_layout_t.getCPtr(query_layout));
22962320
}
22972321

2322+
public static int tiledb_query_get_array(
2323+
SWIGTYPE_p_tiledb_ctx_t ctx,
2324+
SWIGTYPE_p_tiledb_query_t query,
2325+
SWIGTYPE_p_p_tiledb_array_t array) {
2326+
return tiledbJNI.tiledb_query_get_array(
2327+
SWIGTYPE_p_tiledb_ctx_t.getCPtr(ctx),
2328+
SWIGTYPE_p_tiledb_query_t.getCPtr(query),
2329+
SWIGTYPE_p_p_tiledb_array_t.getCPtr(array));
2330+
}
2331+
22982332
public static int tiledb_query_add_range(
22992333
SWIGTYPE_p_tiledb_ctx_t ctx,
23002334
SWIGTYPE_p_tiledb_query_t query,
@@ -3081,6 +3115,15 @@ public static int tiledb_vfs_move_dir(
30813115
new_uri);
30823116
}
30833117

3118+
public static int tiledb_vfs_copy_file(
3119+
SWIGTYPE_p_tiledb_ctx_t ctx, SWIGTYPE_p_tiledb_vfs_t vfs, String old_uri, String new_uri) {
3120+
return tiledbJNI.tiledb_vfs_copy_file(
3121+
SWIGTYPE_p_tiledb_ctx_t.getCPtr(ctx),
3122+
SWIGTYPE_p_tiledb_vfs_t.getCPtr(vfs),
3123+
old_uri,
3124+
new_uri);
3125+
}
3126+
30843127
public static int tiledb_vfs_open(
30853128
SWIGTYPE_p_tiledb_ctx_t ctx,
30863129
SWIGTYPE_p_tiledb_vfs_t vfs,

src/main/java/io/tiledb/libtiledb/tiledbConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public interface tiledbConstants {
1313
public static final int TILEDB_OK = 0;
1414
public static final int TILEDB_OOM = (-2);
1515
public static final int TILEDB_VERSION_MAJOR = 2;
16-
public static final int TILEDB_VERSION_MINOR = 0;
17-
public static final int TILEDB_VERSION_PATCH = 5;
16+
public static final int TILEDB_VERSION_MINOR = 1;
17+
public static final int TILEDB_VERSION_PATCH = 2;
1818
}

src/main/java/io/tiledb/libtiledb/tiledbJNI.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,12 @@ public static final native int tiledb_attribute_get_cell_val_num(
795795

796796
public static final native int tiledb_attribute_dump(long jarg1, long jarg2, long jarg3);
797797

798+
public static final native int tiledb_attribute_set_fill_value(
799+
long jarg1, long jarg2, long jarg3, java.math.BigInteger jarg4);
800+
801+
public static final native int tiledb_attribute_get_fill_value(
802+
long jarg1, long jarg2, long jarg3, long jarg4);
803+
798804
public static final native int tiledb_domain_alloc(long jarg1, long jarg2);
799805

800806
public static final native void tiledb_domain_free(long jarg1);
@@ -965,6 +971,8 @@ public static final native int tiledb_query_submit_async(
965971

966972
public static final native int tiledb_query_get_layout(long jarg1, long jarg2, long jarg3);
967973

974+
public static final native int tiledb_query_get_array(long jarg1, long jarg2, long jarg3);
975+
968976
public static final native int tiledb_query_add_range(
969977
long jarg1, long jarg2, long jarg3, long jarg4, long jarg5, long jarg6);
970978

@@ -1170,6 +1178,9 @@ public static final native int tiledb_vfs_move_file(
11701178
public static final native int tiledb_vfs_move_dir(
11711179
long jarg1, long jarg2, String jarg3, String jarg4);
11721180

1181+
public static final native int tiledb_vfs_copy_file(
1182+
long jarg1, long jarg2, String jarg3, String jarg4);
1183+
11731184
public static final native int tiledb_vfs_open(
11741185
long jarg1, long jarg2, String jarg3, int jarg4, long jarg5);
11751186

src/test/java/io/tiledb/java/api/AttributeTest.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import static io.tiledb.java.api.Constants.TILEDB_VAR_NUM;
2828

29+
import java.math.BigInteger;
2930
import org.junit.Assert;
3031
import org.junit.Test;
3132

@@ -59,4 +60,52 @@ public void testAttributeDatatype() throws Exception {
5960
Assert.assertEquals(Datatype.TILEDB_FLOAT32, a.getType());
6061
}
6162
}
63+
64+
@Test
65+
public void testAttributeSetFillValue() throws Exception {
66+
try (Context ctx = new Context();
67+
Attribute a = new Attribute(ctx, "a2", Datatype.TILEDB_INT32)) {
68+
69+
NativeArray arr = new NativeArray(ctx, 1, Datatype.TILEDB_INT32);
70+
71+
arr.setItem(0, 5);
72+
73+
a.setFillValue(arr, BigInteger.valueOf(arr.getNativeTypeSize() * arr.getSize()));
74+
75+
Assert.assertEquals(5, a.getFillValue().getFirst());
76+
Assert.assertEquals(
77+
BigInteger.valueOf(arr.getNativeTypeSize() * arr.getSize()),
78+
a.getFillValue().getSecond());
79+
}
80+
81+
try (Context ctx = new Context();
82+
Attribute a = new Attribute(ctx, "a2", Datatype.TILEDB_INT64)) {
83+
84+
NativeArray arr = new NativeArray(ctx, 1, Datatype.TILEDB_INT64);
85+
86+
arr.setItem(0, 5L);
87+
88+
a.setFillValue(arr, BigInteger.valueOf(arr.getNativeTypeSize() * arr.getSize()));
89+
90+
Assert.assertEquals(5L, a.getFillValue().getFirst());
91+
Assert.assertEquals(
92+
BigInteger.valueOf(arr.getNativeTypeSize() * arr.getSize()),
93+
a.getFillValue().getSecond());
94+
}
95+
96+
try (Context ctx = new Context();
97+
Attribute a = new Attribute(ctx, "a2", Datatype.TILEDB_CHAR)) {
98+
99+
NativeArray arr = new NativeArray(ctx, 1, Datatype.TILEDB_CHAR);
100+
101+
arr.setItem(0, "c");
102+
103+
a.setFillValue(arr, BigInteger.valueOf(arr.getNativeTypeSize() * arr.getSize()));
104+
105+
Assert.assertEquals((byte) 'c', a.getFillValue().getFirst());
106+
Assert.assertEquals(
107+
BigInteger.valueOf(arr.getNativeTypeSize() * arr.getSize()),
108+
a.getFillValue().getSecond());
109+
}
110+
}
62111
}

0 commit comments

Comments
 (0)