@@ -295,16 +295,18 @@ public void setFillValue(NativeArray value, BigInteger size) throws TileDBError
295295 * @throws TileDBError
296296 */
297297 public void setFillValue (Object value ) throws TileDBError {
298- NativeArray array = new NativeArray (ctx , this .type .getNativeSize (), this .type .javaClass ());
298+ int size ;
299+
300+ if (value instanceof String ) size = ((String ) value ).length ();
301+ else size = this .type .getNativeSize ();
302+
303+ NativeArray array = new NativeArray (ctx , size , this .type .javaClass ());
299304 array .setItem (0 , value );
300305
301306 try {
302307 ctx .handleError (
303308 tiledb .tiledb_attribute_set_fill_value (
304- ctx .getCtxp (),
305- attributep ,
306- array .toVoidPointer (),
307- BigInteger .valueOf (this .type .getNativeSize ())));
309+ ctx .getCtxp (), attributep , array .toVoidPointer (), BigInteger .valueOf ((long ) size )));
308310 } catch (TileDBError err ) {
309311 throw err ;
310312 }
@@ -328,10 +330,12 @@ public Pair<Object, Long> getFillValue() throws TileDBError {
328330 SWIGTYPE_p_p_void v = tiledb .new_voidpArray (1 );
329331
330332 ctx .handleError (tiledb .tiledb_attribute_get_fill_value (ctx .getCtxp (), attributep , v , size ));
333+ int extractedSize = tiledb .ullp_value (size ).intValue ();
331334
332335 Object fillValue ;
333- try (NativeArray fillValueArray = new NativeArray (ctx , getType (), v , 1 )) {
334- fillValue = fillValueArray .getItem (0 );
336+ try (NativeArray fillValueArray = new NativeArray (ctx , getType (), v , extractedSize )) {
337+ if (this .isVar ()) fillValue = fillValueArray .toJavaArray (extractedSize );
338+ else fillValue = fillValueArray .getItem (0 );
335339 }
336340
337341 return new Pair (fillValue , tiledb .ullp_value (size ));
@@ -378,8 +382,12 @@ public void setFillValueNullable(NativeArray value, BigInteger size, boolean val
378382 * @throws TileDBError
379383 */
380384 public void setFillValueNullable (Object value , boolean valid ) throws TileDBError {
385+ int size ;
386+
387+ if (value instanceof String ) size = ((String ) value ).length ();
388+ else size = this .type .getNativeSize ();
381389
382- NativeArray valueArray = new NativeArray (ctx , this . type . getNativeSize () , this .type .javaClass ());
390+ NativeArray valueArray = new NativeArray (ctx , size , this .type .javaClass ());
383391 valueArray .setItem (0 , value );
384392
385393 try {
@@ -388,7 +396,7 @@ public void setFillValueNullable(Object value, boolean valid) throws TileDBError
388396 ctx .getCtxp (),
389397 attributep ,
390398 valueArray .toVoidPointer (),
391- BigInteger .valueOf (this . type . getNativeSize () ),
399+ BigInteger .valueOf (size ),
392400 valid ? (short ) 1 : (short ) 0 ));
393401 } catch (TileDBError err ) {
394402 throw err ;
@@ -419,9 +427,12 @@ public Pair<Object, Pair<Long, Boolean>> getFillValueNullable() throws TileDBErr
419427 tiledb .tiledb_attribute_get_fill_value_nullable (
420428 ctx .getCtxp (), attributep , v , size , valid ));
421429
430+ int extractedSize = tiledb .ullp_value (size ).intValue ();
431+
422432 Object fillValue ;
423- try (NativeArray fillValueArray = new NativeArray (ctx , getType (), v , 1 )) {
424- fillValue = fillValueArray .getItem (0 );
433+ try (NativeArray fillValueArray = new NativeArray (ctx , getType (), v , extractedSize )) {
434+ if (this .isVar ()) fillValue = fillValueArray .toJavaArray (extractedSize );
435+ else fillValue = fillValueArray .getItem (0 );
425436 }
426437
427438 boolean validBoolean = validArr .getUint8_tArray ().getitem (0 ) == 0 ? false : true ;
0 commit comments