Skip to content

Commit 7ebcaac

Browse files
fix wrong option datatypes for the scale float filter
1 parent 603928e commit 7ebcaac

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

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

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,30 @@ public FloatScalingFilter(Context ctx) throws TileDBError {
2626
* @param byteWidth The byteWidth param
2727
* @throws TileDBError
2828
*/
29-
public FloatScalingFilter(Context ctx, int offset, int factor, int byteWidth) throws TileDBError {
29+
public FloatScalingFilter(Context ctx, double offset, double factor, long byteWidth)
30+
throws TileDBError {
3031
super(ctx, tiledb_filter_type_t.TILEDB_FILTER_SCALE_FLOAT);
3132
try (NativeArray offsetArray =
3233
new NativeArray(
3334
ctx,
34-
new int[] {
35+
new double[] {
3536
offset,
3637
},
37-
Integer.class);
38+
Double.class);
3839
NativeArray factorArray =
3940
new NativeArray(
4041
ctx,
41-
new int[] {
42+
new double[] {
4243
factor,
4344
},
44-
Integer.class);
45+
Double.class);
4546
NativeArray byteWidthArray =
4647
new NativeArray(
4748
ctx,
48-
new int[] {
49+
new long[] {
4950
byteWidth,
5051
},
51-
Integer.class); ) {
52+
Long.class); ) {
5253
ctx.handleError(
5354
tiledb.tiledb_filter_set_option(
5455
ctx.getCtxp(),
@@ -80,14 +81,14 @@ public FloatScalingFilter(Context ctx, int offset, int factor, int byteWidth) th
8081
* @param offset The offset input.
8182
* @throws TileDBError
8283
*/
83-
public void setOffset(Context ctx, int offset) throws TileDBError {
84+
public void setOffset(Context ctx, double offset) throws TileDBError {
8485
try (NativeArray offsetArray =
8586
new NativeArray(
8687
ctx,
87-
new int[] {
88+
new double[] {
8889
offset,
8990
},
90-
Integer.class)) {
91+
Double.class)) {
9192
ctx.handleError(
9293
tiledb.tiledb_filter_set_option(
9394
ctx.getCtxp(),
@@ -107,14 +108,14 @@ public void setOffset(Context ctx, int offset) throws TileDBError {
107108
* @param factor The factor input
108109
* @throws TileDBError
109110
*/
110-
public void setFactor(Context ctx, int factor) throws TileDBError {
111+
public void setFactor(Context ctx, double factor) throws TileDBError {
111112
try (NativeArray offsetArray =
112113
new NativeArray(
113114
ctx,
114-
new int[] {
115+
new double[] {
115116
factor,
116117
},
117-
Integer.class)) {
118+
Double.class)) {
118119
ctx.handleError(
119120
tiledb.tiledb_filter_set_option(
120121
ctx.getCtxp(),
@@ -134,14 +135,14 @@ public void setFactor(Context ctx, int factor) throws TileDBError {
134135
* @param byteWidth The byteWidth param
135136
* @throws TileDBError
136137
*/
137-
public void setByteWidth(Context ctx, int byteWidth) throws TileDBError {
138+
public void setByteWidth(Context ctx, long byteWidth) throws TileDBError {
138139
try (NativeArray offsetArray =
139140
new NativeArray(
140141
ctx,
141-
new int[] {
142+
new long[] {
142143
byteWidth,
143144
},
144-
Integer.class)) {
145+
Long.class)) {
145146
ctx.handleError(
146147
tiledb.tiledb_filter_set_option(
147148
ctx.getCtxp(),
@@ -168,17 +169,17 @@ protected FloatScalingFilter(Context ctx, SWIGTYPE_p_p_tiledb_filter_t filterpp)
168169
* @return The ByteWidth param
169170
* @throws TileDBError
170171
*/
171-
public int getByteWidth() throws TileDBError {
172+
public long getByteWidth() throws TileDBError {
172173
Context ctx = getCtx();
173-
int window;
174-
try (NativeArray byteWidthArray = new NativeArray(ctx, 1, Integer.class)) {
174+
long window;
175+
try (NativeArray byteWidthArray = new NativeArray(ctx, 1, Long.class)) {
175176
ctx.handleError(
176177
tiledb.tiledb_filter_get_option(
177178
ctx.getCtxp(),
178179
getFilterp(),
179180
tiledb_filter_option_t.TILEDB_SCALE_FLOAT_BYTEWIDTH,
180181
byteWidthArray.toVoidPointer()));
181-
window = (int) byteWidthArray.getItem(0);
182+
window = (long) byteWidthArray.getItem(0);
182183
}
183184
return window;
184185
}
@@ -187,17 +188,17 @@ public int getByteWidth() throws TileDBError {
187188
* @return The factor param
188189
* @throws TileDBError
189190
*/
190-
public int getFactor() throws TileDBError {
191+
public double getFactor() throws TileDBError {
191192
Context ctx = getCtx();
192-
int window;
193-
try (NativeArray factorArray = new NativeArray(ctx, 1, Integer.class)) {
193+
double window;
194+
try (NativeArray factorArray = new NativeArray(ctx, 1, Double.class)) {
194195
ctx.handleError(
195196
tiledb.tiledb_filter_get_option(
196197
ctx.getCtxp(),
197198
getFilterp(),
198199
tiledb_filter_option_t.TILEDB_SCALE_FLOAT_FACTOR,
199200
factorArray.toVoidPointer()));
200-
window = (int) factorArray.getItem(0);
201+
window = (double) factorArray.getItem(0);
201202
}
202203
return window;
203204
}
@@ -206,17 +207,17 @@ public int getFactor() throws TileDBError {
206207
* @return The offset param
207208
* @throws TileDBError
208209
*/
209-
public int getOffset() throws TileDBError {
210+
public double getOffset() throws TileDBError {
210211
Context ctx = getCtx();
211-
int window;
212-
try (NativeArray offsetArray = new NativeArray(ctx, 1, Integer.class)) {
212+
double window;
213+
try (NativeArray offsetArray = new NativeArray(ctx, 1, Double.class)) {
213214
ctx.handleError(
214215
tiledb.tiledb_filter_get_option(
215216
ctx.getCtxp(),
216217
getFilterp(),
217218
tiledb_filter_option_t.TILEDB_SCALE_FLOAT_OFFSET,
218219
offsetArray.toVoidPointer()));
219-
window = (int) offsetArray.getItem(0);
220+
window = (double) offsetArray.getItem(0);
220221
}
221222
return window;
222223
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ public void testLZ4Filter() throws Exception {
7878
@Test
7979
public void testFloatScalingFilter() throws Exception {
8080
try (Context ctx = new Context()) {
81-
try (FloatScalingFilter filter = new FloatScalingFilter(ctx, 10, 10, 10)) {
82-
Assert.assertEquals(filter.getFactor(), 10);
83-
Assert.assertEquals(filter.getOffset(), 10);
84-
Assert.assertEquals(filter.getByteWidth(), 10);
81+
try (FloatScalingFilter filter = new FloatScalingFilter(ctx, 10.0, 10.0, 10L)) {
82+
Assert.assertEquals(filter.getFactor(), 10.0, 0);
83+
Assert.assertEquals(filter.getOffset(), 10.0, 0);
84+
Assert.assertEquals(filter.getByteWidth(), 10L, 0);
8585
}
8686
try (FloatScalingFilter filter = new FloatScalingFilter(ctx)) {
87-
Assert.assertEquals(filter.getFactor(), 0);
88-
Assert.assertEquals(filter.getOffset(), 0);
89-
Assert.assertEquals(filter.getByteWidth(), 8);
87+
Assert.assertEquals(filter.getFactor(), 1.0, 0);
88+
Assert.assertEquals(filter.getOffset(), 0.0, 0);
89+
Assert.assertEquals(filter.getByteWidth(), 8L, 0);
9090
}
9191
}
9292
}

0 commit comments

Comments
 (0)