Skip to content

Commit 8f36bbb

Browse files
committed
Moved NIO functions to tiledb_custom.cxx bindings
1 parent 0e8cc06 commit 8f36bbb

File tree

8 files changed

+143
-136
lines changed

8 files changed

+143
-136
lines changed

src/main/c/custom/tiledb_custom.cxx

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,86 @@ extern "C" {
11321132
return jresult;
11331133
}
11341134

1135+
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1set_1subarray_1nio(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jobject jarg3) {
1136+
void* buffer = (void *)jenv->GetDirectBufferAddress(jarg3);
1137+
1138+
jint jresult = 0 ;
1139+
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
1140+
tiledb_query_t *arg2 = (tiledb_query_t *) 0 ;
1141+
void *arg3 = (void *) 0 ;
1142+
int32_t result;
1143+
1144+
(void)jenv;
1145+
(void)jcls;
1146+
arg1 = *(tiledb_ctx_t **)&jarg1;
1147+
arg2 = *(tiledb_query_t **)&jarg2;
1148+
arg3 = *(void **)&jarg3;
1149+
result = (int32_t)tiledb_query_set_subarray(arg1,arg2,buffer);
1150+
jresult = (jint)result;
1151+
return jresult;
1152+
}
1153+
1154+
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1set_1buffer_1nio(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jobject jarg4, jlong jarg5) {
1155+
void* buffer = (void *)jenv->GetDirectBufferAddress(jarg4);
1156+
1157+
jint jresult = 0 ;
1158+
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
1159+
tiledb_query_t *arg2 = (tiledb_query_t *) 0 ;
1160+
char *arg3 = (char *) 0 ;
1161+
void *arg4 = (void *) 0 ;
1162+
uint64_t *arg5 = (uint64_t *) 0 ;
1163+
int32_t result;
1164+
1165+
(void)jenv;
1166+
(void)jcls;
1167+
arg1 = *(tiledb_ctx_t **)&jarg1;
1168+
arg2 = *(tiledb_query_t **)&jarg2;
1169+
arg3 = 0;
1170+
if (jarg3) {
1171+
arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
1172+
if (!arg3) return 0;
1173+
}
1174+
arg4 = *(void **)&jarg4;
1175+
arg5 = *(uint64_t **)&jarg5;
1176+
result = (int32_t)tiledb_query_set_buffer(arg1,arg2,(char const *)arg3, buffer,arg5);
1177+
jresult = (jint)result;
1178+
if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
1179+
return jresult;
1180+
}
1181+
1182+
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1set_1buffer_1var_1nio(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jobject jarg4, jlong jarg5, jobject jarg6, jlong jarg7) {
1183+
void* offsets = (void *)jenv->GetDirectBufferAddress(jarg4);
1184+
void* buffer = (void *)jenv->GetDirectBufferAddress(jarg6);
1185+
1186+
jint jresult = 0 ;
1187+
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
1188+
tiledb_query_t *arg2 = (tiledb_query_t *) 0 ;
1189+
char *arg3 = (char *) 0 ;
1190+
uint64_t *arg4 = (uint64_t *) 0 ;
1191+
uint64_t *arg5 = (uint64_t *) 0 ;
1192+
void *arg6 = (void *) 0 ;
1193+
uint64_t *arg7 = (uint64_t *) 0 ;
1194+
int32_t result;
1195+
1196+
(void)jenv;
1197+
(void)jcls;
1198+
arg1 = *(tiledb_ctx_t **)&jarg1;
1199+
arg2 = *(tiledb_query_t **)&jarg2;
1200+
arg3 = 0;
1201+
if (jarg3) {
1202+
arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
1203+
if (!arg3) return 0;
1204+
}
1205+
arg4 = *(uint64_t **)&jarg4;
1206+
arg5 = *(uint64_t **)&jarg5;
1207+
arg6 = *(void **)&jarg6;
1208+
arg7 = *(uint64_t **)&jarg7;
1209+
result = (int32_t)tiledb_query_set_buffer_var(arg1,arg2,(char const *)arg3,(uint64_t *)offsets,arg5,buffer,arg7);
1210+
jresult = (jint)result;
1211+
if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
1212+
return jresult;
1213+
}
1214+
11351215

11361216
#ifdef __cplusplus
11371217
}

src/main/c/generated/tiledb_wrap.cxx

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -7108,24 +7108,6 @@ SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1set_1s
71087108
return jresult;
71097109
}
71107110

7111-
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1set_1subarray_1nio(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jobject jarg3) {
7112-
void* buffer = (void *)jenv->GetDirectBufferAddress(jarg3);
7113-
7114-
jint jresult = 0 ;
7115-
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
7116-
tiledb_query_t *arg2 = (tiledb_query_t *) 0 ;
7117-
void *arg3 = (void *) 0 ;
7118-
int32_t result;
7119-
7120-
(void)jenv;
7121-
(void)jcls;
7122-
arg1 = *(tiledb_ctx_t **)&jarg1;
7123-
arg2 = *(tiledb_query_t **)&jarg2;
7124-
arg3 = *(void **)&jarg3;
7125-
result = (int32_t)tiledb_query_set_subarray(arg1,arg2,buffer);
7126-
jresult = (jint)result;
7127-
return jresult;
7128-
}
71297111

71307112
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1set_1buffer(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jlong jarg4, jlong jarg5) {
71317113
jint jresult = 0 ;
@@ -7184,33 +7166,6 @@ SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1set_1b
71847166
return jresult;
71857167
}
71867168

7187-
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1set_1buffer_1nio(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jobject jarg4, jlong jarg5) {
7188-
void* buffer = (void *)jenv->GetDirectBufferAddress(jarg4);
7189-
7190-
jint jresult = 0 ;
7191-
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
7192-
tiledb_query_t *arg2 = (tiledb_query_t *) 0 ;
7193-
char *arg3 = (char *) 0 ;
7194-
void *arg4 = (void *) 0 ;
7195-
uint64_t *arg5 = (uint64_t *) 0 ;
7196-
int32_t result;
7197-
7198-
(void)jenv;
7199-
(void)jcls;
7200-
arg1 = *(tiledb_ctx_t **)&jarg1;
7201-
arg2 = *(tiledb_query_t **)&jarg2;
7202-
arg3 = 0;
7203-
if (jarg3) {
7204-
arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
7205-
if (!arg3) return 0;
7206-
}
7207-
arg4 = *(void **)&jarg4;
7208-
arg5 = *(uint64_t **)&jarg5;
7209-
result = (int32_t)tiledb_query_set_buffer(arg1,arg2,(char const *)arg3, buffer,arg5);
7210-
jresult = (jint)result;
7211-
if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
7212-
return jresult;
7213-
}
72147169

72157170
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1set_1buffer_1nullable(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jlong jarg4, jlong jarg5, jlong jarg6, jlong jarg7) {
72167171
jint jresult = 0 ;
@@ -7304,38 +7259,6 @@ SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1get_1b
73047259
return jresult;
73057260
}
73067261

7307-
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1set_1buffer_1var_1nio(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jobject jarg4, jlong jarg5, jobject jarg6, jlong jarg7) {
7308-
void* offsets = (void *)jenv->GetDirectBufferAddress(jarg4);
7309-
void* buffer = (void *)jenv->GetDirectBufferAddress(jarg6);
7310-
7311-
jint jresult = 0 ;
7312-
tiledb_ctx_t *arg1 = (tiledb_ctx_t *) 0 ;
7313-
tiledb_query_t *arg2 = (tiledb_query_t *) 0 ;
7314-
char *arg3 = (char *) 0 ;
7315-
uint64_t *arg4 = (uint64_t *) 0 ;
7316-
uint64_t *arg5 = (uint64_t *) 0 ;
7317-
void *arg6 = (void *) 0 ;
7318-
uint64_t *arg7 = (uint64_t *) 0 ;
7319-
int32_t result;
7320-
7321-
(void)jenv;
7322-
(void)jcls;
7323-
arg1 = *(tiledb_ctx_t **)&jarg1;
7324-
arg2 = *(tiledb_query_t **)&jarg2;
7325-
arg3 = 0;
7326-
if (jarg3) {
7327-
arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
7328-
if (!arg3) return 0;
7329-
}
7330-
arg4 = *(uint64_t **)&jarg4;
7331-
arg5 = *(uint64_t **)&jarg5;
7332-
arg6 = *(void **)&jarg6;
7333-
arg7 = *(uint64_t **)&jarg7;
7334-
result = (int32_t)tiledb_query_set_buffer_var(arg1,arg2,(char const *)arg3,(uint64_t *)offsets,arg5,buffer,arg7);
7335-
jresult = (jint)result;
7336-
if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
7337-
return jresult;
7338-
}
73397262

73407263
SWIGEXPORT jint JNICALL Java_io_tiledb_libtiledb_tiledbJNI_tiledb_1query_1get_1buffer_1var(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jlong jarg4, jlong jarg5, jlong jarg6, jlong jarg7) {
73417264
jint jresult = 0 ;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public synchronized Query setSubarray(NativeArray subarray) throws TileDBError {
198198
* @exception TileDBError A TileDB exception
199199
*/
200200
public synchronized Query setSubarray(ByteBuffer subarray) throws TileDBError {
201-
ctx.handleError(tiledb.tiledb_query_set_subarray_nio(ctx.getCtxp(), queryp, subarray));
201+
ctx.handleError(Utils.tiledb_query_set_subarray_nio(ctx.getCtxp(), queryp, subarray));
202202
return this;
203203
}
204204

@@ -740,7 +740,7 @@ public synchronized Query setBuffer(String attr, ByteBuffer buffer) throws TileD
740740
buffer_sizes_.put(attr, new Pair<>(offsets_array_size, values_array_size));
741741

742742
ctx.handleError(
743-
tiledb.tiledb_query_set_buffer_nio(
743+
Utils.tiledb_query_set_buffer_nio(
744744
ctx.getCtxp(), queryp, attr, buffer, values_array_size.cast()));
745745

746746
return this;
@@ -863,7 +863,7 @@ public synchronized Query setBuffer(String attr, ByteBuffer offsets, ByteBuffer
863863
this.byteBuffers_.put(attr, new Pair(offsets, buffer));
864864

865865
ctx.handleError(
866-
tiledb.tiledb_query_set_buffer_var_nio(
866+
Utils.tiledb_query_set_buffer_var_nio(
867867
ctx.getCtxp(),
868868
queryp,
869869
attr,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ private static Path extractLibraryFile(
317317
*/
318318
private static Path findNativeLibrary(String libraryName, boolean mapLibraryName) {
319319
String mappedLibraryName = mapLibraryName ? System.mapLibraryName(libraryName) : libraryName;
320-
String libDir = LIB_RESOURCE_DIR;
320+
String libDir = LIB_RESOURCE_DIR + "/" + getOSClassifier();
321321
String libPath = libDir + "/" + mappedLibraryName;
322322

323323
boolean hasNativeLib = hasResource(libPath);

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.tiledb.libtiledb;
22

3+
import java.nio.ByteBuffer;
4+
35
public class Utils {
46

57
public static int32_tArray newInt32_tArray(int[] array) {
@@ -180,6 +182,44 @@ public static int tiledb_query_submit_async(
180182
callback);
181183
}
182184

185+
public static int tiledb_query_set_subarray_nio(
186+
SWIGTYPE_p_tiledb_ctx_t ctx, SWIGTYPE_p_tiledb_query_t query, ByteBuffer subarray) {
187+
return tiledbJNI.tiledb_query_set_subarray_nio(
188+
SWIGTYPE_p_tiledb_ctx_t.getCPtr(ctx), SWIGTYPE_p_tiledb_query_t.getCPtr(query), subarray);
189+
}
190+
191+
public static int tiledb_query_set_buffer_nio(
192+
SWIGTYPE_p_tiledb_ctx_t ctx,
193+
SWIGTYPE_p_tiledb_query_t query,
194+
String name,
195+
ByteBuffer buffer,
196+
SWIGTYPE_p_unsigned_long_long buffer_size) {
197+
return tiledbJNI.tiledb_query_set_buffer_nio(
198+
SWIGTYPE_p_tiledb_ctx_t.getCPtr(ctx),
199+
SWIGTYPE_p_tiledb_query_t.getCPtr(query),
200+
name,
201+
buffer,
202+
SWIGTYPE_p_unsigned_long_long.getCPtr(buffer_size));
203+
}
204+
205+
public static int tiledb_query_set_buffer_var_nio(
206+
SWIGTYPE_p_tiledb_ctx_t ctx,
207+
SWIGTYPE_p_tiledb_query_t query,
208+
String name,
209+
ByteBuffer buffer_off,
210+
SWIGTYPE_p_unsigned_long_long buffer_off_size,
211+
ByteBuffer buffer_val,
212+
SWIGTYPE_p_unsigned_long_long buffer_val_size) {
213+
return tiledbJNI.tiledb_query_set_buffer_var_nio(
214+
SWIGTYPE_p_tiledb_ctx_t.getCPtr(ctx),
215+
SWIGTYPE_p_tiledb_query_t.getCPtr(query),
216+
name,
217+
buffer_off,
218+
SWIGTYPE_p_unsigned_long_long.getCPtr(buffer_off_size),
219+
buffer_val,
220+
SWIGTYPE_p_unsigned_long_long.getCPtr(buffer_val_size));
221+
}
222+
183223
public static int tiledb_object_ls(
184224
SWIGTYPE_p_tiledb_ctx_t ctx, String path, PathCallback callback) {
185225
return tiledbJNI.tiledb_object_ls_java(

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

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
package io.tiledb.libtiledb;
1010

11-
import java.nio.ByteBuffer;
12-
1311
public class tiledb implements tiledbConstants {
1412
public static SWIGTYPE_p_p_char new_charpArray(int nelements) {
1513
long cPtr = tiledbJNI.new_charpArray(nelements);
@@ -2171,12 +2169,6 @@ public static int tiledb_query_set_subarray(
21712169
SWIGTYPE_p_void.getCPtr(subarray));
21722170
}
21732171

2174-
public static int tiledb_query_set_subarray_nio(
2175-
SWIGTYPE_p_tiledb_ctx_t ctx, SWIGTYPE_p_tiledb_query_t query, ByteBuffer subarray) {
2176-
return tiledbJNI.tiledb_query_set_subarray_nio(
2177-
SWIGTYPE_p_tiledb_ctx_t.getCPtr(ctx), SWIGTYPE_p_tiledb_query_t.getCPtr(query), subarray);
2178-
}
2179-
21802172
public static int tiledb_query_set_buffer(
21812173
SWIGTYPE_p_tiledb_ctx_t ctx,
21822174
SWIGTYPE_p_tiledb_query_t query,
@@ -2191,20 +2183,6 @@ public static int tiledb_query_set_buffer(
21912183
SWIGTYPE_p_unsigned_long_long.getCPtr(buffer_size));
21922184
}
21932185

2194-
public static int tiledb_query_set_buffer_nio(
2195-
SWIGTYPE_p_tiledb_ctx_t ctx,
2196-
SWIGTYPE_p_tiledb_query_t query,
2197-
String name,
2198-
ByteBuffer buffer,
2199-
SWIGTYPE_p_unsigned_long_long buffer_size) {
2200-
return tiledbJNI.tiledb_query_set_buffer_nio(
2201-
SWIGTYPE_p_tiledb_ctx_t.getCPtr(ctx),
2202-
SWIGTYPE_p_tiledb_query_t.getCPtr(query),
2203-
name,
2204-
buffer,
2205-
SWIGTYPE_p_unsigned_long_long.getCPtr(buffer_size));
2206-
}
2207-
22082186
public static int tiledb_query_set_buffer_var(
22092187
SWIGTYPE_p_tiledb_ctx_t ctx,
22102188
SWIGTYPE_p_tiledb_query_t query,
@@ -2223,24 +2201,6 @@ public static int tiledb_query_set_buffer_var(
22232201
SWIGTYPE_p_unsigned_long_long.getCPtr(buffer_val_size));
22242202
}
22252203

2226-
public static int tiledb_query_set_buffer_var_nio(
2227-
SWIGTYPE_p_tiledb_ctx_t ctx,
2228-
SWIGTYPE_p_tiledb_query_t query,
2229-
String name,
2230-
ByteBuffer buffer_off,
2231-
SWIGTYPE_p_unsigned_long_long buffer_off_size,
2232-
ByteBuffer buffer_val,
2233-
SWIGTYPE_p_unsigned_long_long buffer_val_size) {
2234-
return tiledbJNI.tiledb_query_set_buffer_var_nio(
2235-
SWIGTYPE_p_tiledb_ctx_t.getCPtr(ctx),
2236-
SWIGTYPE_p_tiledb_query_t.getCPtr(query),
2237-
name,
2238-
buffer_off,
2239-
SWIGTYPE_p_unsigned_long_long.getCPtr(buffer_off_size),
2240-
buffer_val,
2241-
SWIGTYPE_p_unsigned_long_long.getCPtr(buffer_val_size));
2242-
}
2243-
22442204
public static int tiledb_query_set_buffer_nullable(
22452205
SWIGTYPE_p_tiledb_ctx_t ctx,
22462206
SWIGTYPE_p_tiledb_query_t query,

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ public class tiledbJNI {
2424
}
2525
}
2626

27+
public static final native int tiledb_query_set_subarray_nio(
28+
long jarg1, long jarg2, ByteBuffer jarg3);
29+
30+
public static final native int tiledb_query_set_buffer_nio(
31+
long jarg1, long jarg2, String jarg3, ByteBuffer jarg4, long jarg5);
32+
33+
public static final native int tiledb_query_set_buffer_var_nio(
34+
long jarg1,
35+
long jarg2,
36+
String jarg3,
37+
ByteBuffer jarg4,
38+
long jarg5,
39+
ByteBuffer jarg6,
40+
long jarg7);
41+
2742
public static final native int tiledb_query_submit_async_java(
2843
long jarg1,
2944
SWIGTYPE_p_tiledb_ctx_t jarg1_,
@@ -931,27 +946,12 @@ public static final native int tiledb_array_schema_has_attribute(
931946

932947
public static final native int tiledb_query_set_subarray(long jarg1, long jarg2, long jarg3);
933948

934-
public static final native int tiledb_query_set_subarray_nio(
935-
long jarg1, long jarg2, ByteBuffer jarg3);
936-
937949
public static final native int tiledb_query_set_buffer(
938950
long jarg1, long jarg2, String jarg3, long jarg4, long jarg5);
939951

940-
public static final native int tiledb_query_set_buffer_nio(
941-
long jarg1, long jarg2, String jarg3, ByteBuffer jarg4, long jarg5);
942-
943952
public static final native int tiledb_query_set_buffer_var(
944953
long jarg1, long jarg2, String jarg3, long jarg4, long jarg5, long jarg6, long jarg7);
945954

946-
public static final native int tiledb_query_set_buffer_var_nio(
947-
long jarg1,
948-
long jarg2,
949-
String jarg3,
950-
ByteBuffer jarg4,
951-
long jarg5,
952-
ByteBuffer jarg6,
953-
long jarg7);
954-
955955
public static final native int tiledb_query_set_buffer_nullable(
956956
long jarg1, long jarg2, String jarg3, long jarg4, long jarg5, long jarg6, long jarg7);
957957

0 commit comments

Comments
 (0)