Skip to content

Commit a8b6e5c

Browse files
replace Class with tiledb.Datatype in Query Condition constructor
1 parent 0302ba1 commit a8b6e5c

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group 'io.tiledb'
12-
version '0.17.6-SNAPSHOT'
12+
version '0.17.8-SNAPSHOT'
1313

1414
repositories {
1515
jcenter()

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,24 @@ public QueryCondition(
4343
Context ctx,
4444
String attributeName,
4545
Object value,
46-
Class conditionType,
46+
Datatype type,
4747
tiledb_query_condition_op_t OP)
4848
throws TileDBError {
4949
try {
50-
if (conditionType != null) {
51-
this.type = Types.getNativeType(conditionType);
52-
}
5350
conditionpp = tiledb.new_tiledb_query_condition_tpp();
5451
ctx.handleError(tiledb.tiledb_query_condition_alloc(ctx.getCtxp(), conditionpp));
5552
NativeArray array = null;
5653
if (value.getClass().isArray()) {
57-
array = new NativeArray(ctx, value, this.type.javaClass());
54+
array = new NativeArray(ctx, value, type.javaClass());
5855
} else {
59-
if (this.type != null) {
60-
int byteSize = this.type.getNativeSize();
61-
array = new NativeArray(ctx, byteSize, this.type.javaClass());
56+
if (type != null) {
57+
int byteSize = type.getNativeSize();
58+
array = new NativeArray(ctx, byteSize, type);
6259
array.setItem(0, value);
6360
}
6461
}
6562
conditionp = tiledb.tiledb_query_condition_tpp_value(conditionpp);
66-
if (this.type == null) {
63+
if (type == null) {
6764
ctx.handleError(
6865
tiledb.tiledb_query_condition_init(
6966
ctx.getCtxp(), conditionp, attributeName, null, BigInteger.valueOf(0), OP));

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
package io.tiledb.java.api;
2626

2727
import static io.tiledb.java.api.ArrayType.*;
28+
import static io.tiledb.java.api.Datatype.TILEDB_FLOAT32;
29+
import static io.tiledb.java.api.Datatype.TILEDB_INT32;
2830
import static io.tiledb.java.api.Datatype.TILEDB_UINT8;
2931
import static io.tiledb.java.api.Layout.*;
3032
import static io.tiledb.java.api.QueryType.*;
@@ -114,9 +116,9 @@ public void arrayCreate() throws Exception {
114116
domain.addDimension(d2);
115117

116118
// Create and add getAttributes
117-
Attribute a1 = new Attribute(ctx, "a1", Integer.class);
119+
Attribute a1 = new Attribute(ctx, "a1", TILEDB_INT32);
118120
a1.setNullable(true);
119-
Attribute a2 = new Attribute(ctx, "a2", Float.class);
121+
Attribute a2 = new Attribute(ctx, "a2", TILEDB_FLOAT32);
120122

121123
ArraySchema schema = new ArraySchema(ctx, TILEDB_DENSE);
122124
schema.setTileOrder(TILEDB_ROW_MAJOR);
@@ -136,13 +138,13 @@ public void arrayWrite() throws Exception {
136138

137139
// Prepare cell buffers
138140
NativeArray a1_data =
139-
new NativeArray(ctx, new int[] {8, 9, 10, 11, 12, 13, 14, 15, 16}, Integer.class);
141+
new NativeArray(ctx, new int[] {8, 9, 10, 11, 12, 13, 14, 15, 16}, TILEDB_INT32);
140142

141143
NativeArray buffer_a2 =
142144
new NativeArray(
143145
ctx,
144146
new float[] {13.2f, 14.1f, 14.2f, 15.1f, 15.2f, 15.3f, 16.1f, 18.3f, 19.1f},
145-
Float.class);
147+
TILEDB_FLOAT32);
146148

147149
// Create query
148150
NativeArray a1Bytemap =
@@ -176,15 +178,15 @@ private void arrayRead() throws Exception {
176178
max_sizes.put("a2", new Pair<>(0L, query.getEstResultSize(ctx, "a2")));
177179
query.setBufferNullable(
178180
"a1",
179-
new NativeArray(ctx, max_sizes.get("a1").getSecond().intValue(), Integer.class),
181+
new NativeArray(ctx, max_sizes.get("a1").getSecond().intValue(), TILEDB_INT32),
180182
new NativeArray(ctx, 16, TILEDB_UINT8));
181183
query.setBuffer(
182184
"a2", new NativeArray(ctx, max_sizes.get("a2").getSecond().intValue(), Float.class));
183185
// null + normal + combined condition test
184-
QueryCondition con1 = new QueryCondition(ctx, "a2", 15.0f, Float.class, TILEDB_GT);
186+
QueryCondition con1 = new QueryCondition(ctx, "a2", 15.0f, TILEDB_FLOAT32, TILEDB_GT);
185187
QueryCondition con2 = new QueryCondition(ctx, "a1", 0, null, TILEDB_EQ);
186188
QueryCondition con3 = con1.combine(con2, TILEDB_AND);
187-
QueryCondition con4 = new QueryCondition(ctx, "a1", 9, Integer.class, TILEDB_EQ);
189+
QueryCondition con4 = new QueryCondition(ctx, "a1", 9, TILEDB_INT32, TILEDB_EQ);
188190
QueryCondition con5 = con4.combine(con3, TILEDB_OR);
189191
query.setCondition(con5);
190192

@@ -237,7 +239,7 @@ public void testDataDeletion() throws TileDBError {
237239
// delete data with appropriate QC
238240
Array array = new Array(ctx, arrayURISparse, TILEDB_DELETE);
239241
Query query = new Query(array, TILEDB_DELETE);
240-
QueryCondition deleteQc = new QueryCondition(ctx, "a1", 3, Integer.class, TILEDB_GT);
242+
QueryCondition deleteQc = new QueryCondition(ctx, "a1", 3, TILEDB_INT32, TILEDB_GT);
241243
query.setCondition(deleteQc);
242244
query.submit();
243245
// close resources

0 commit comments

Comments
 (0)