@@ -456,46 +456,37 @@ public static void create(
456
456
*/
457
457
public HashMap <String , Pair > nonEmptyDomain () throws TileDBError {
458
458
checkIsOpen ();
459
- HashMap <String , Pair > ret = new HashMap <String , Pair >();
460
- try (Domain domain = schema .getDomain ();
461
- NativeArray domainArray =
462
- new NativeArray (ctx , 2 * (int ) domain .getRank (), domain .getType ())) {
463
- SWIGTYPE_p_int emptyp = tiledb .new_intp ();
464
- try {
465
- ctx .handleError (
466
- tiledb .tiledb_array_get_non_empty_domain (
467
- ctx .getCtxp (), arrayp , domainArray .toVoidPointer (), emptyp ));
468
- if (tiledb .intp_value (emptyp ) == 1 ) {
469
- return ret ;
470
- }
471
- } finally {
472
- tiledb .delete_intp (emptyp );
473
- }
474
- for (int i = 0 ; i < domain .getRank (); i ++) {
475
- try (Dimension d = domain .getDimension (i )) {
476
- ret .put (
477
- d .getName (),
478
- new Pair (domainArray .getItem ((2 * i ) + 0 ), domainArray .getItem ((2 * i ) + 1 )));
479
- }
459
+ HashMap <String , Pair > ret = new HashMap <>();
460
+ try {
461
+ Domain domain = schema .getDomain ();
462
+ long numDims = domain .getNDim ();
463
+ for (long dimIdx = 0 ; dimIdx < numDims ; ++dimIdx ) {
464
+ Dimension dimension = domain .getDimension (dimIdx );
465
+ Pair p = getNonEmptyDomainFromIndex (dimIdx );
466
+ ret .put (dimension .getName (), p );
480
467
}
468
+ } catch (TileDBError error ) {
469
+ throw error ;
481
470
}
482
471
return ret ;
483
472
}
484
473
485
474
/**
486
- * Given a dimension's index, return the bounding coordinates for that dimension.
475
+ * Given a dimension's index, return the bounding coordinates for that dimension. The method
476
+ * checks if the dimension is var-sized or not, and it works for both cases.
487
477
*
488
478
* @param index THe dimension's index
489
479
* @return A Pair that contains the dimension's bounds
490
480
* @exception TileDBError A TileDB exception
491
481
*/
492
482
public Pair getNonEmptyDomainFromIndex (long index ) throws TileDBError {
493
483
checkIsOpen ();
494
- Pair p ;
495
484
try (Domain domain = schema .getDomain ();
496
485
NativeArray domainArray =
497
486
new NativeArray (ctx , 2 * (int ) domain .getRank (), domain .getType ())) {
498
487
488
+ if (domain .getDimension (index ).isVar ()) return getNonEmptyDomainVarFromIndex (index );
489
+
499
490
SWIGTYPE_p_int emptyp = tiledb .new_intp ();
500
491
try {
501
492
ctx .handleError (
@@ -514,7 +505,8 @@ public Pair getNonEmptyDomainFromIndex(long index) throws TileDBError {
514
505
}
515
506
516
507
/**
517
- * Given a dimension's name, return the bounding coordinates for that dimension.
508
+ * Given a dimension's name, return the bounding coordinates for that dimension. The method checks
509
+ * if the dimension is var-sized or not, and it works for both cases.
518
510
*
519
511
* @param name THe dimension's name
520
512
* @return A Pair that contains the dimension's bounds
@@ -525,6 +517,9 @@ public Pair getNonEmptyDomainFromName(String name) throws TileDBError {
525
517
try (Domain domain = schema .getDomain ();
526
518
NativeArray domainArray =
527
519
new NativeArray (ctx , 2 * (int ) domain .getRank (), domain .getType ())) {
520
+
521
+ if (domain .getDimension (name ).isVar ()) return this .getNonEmptyDomainVarFromName (name );
522
+
528
523
SWIGTYPE_p_int emptyp = tiledb .new_intp ();
529
524
try {
530
525
ctx .handleError (
@@ -540,6 +535,111 @@ public Pair getNonEmptyDomainFromName(String name) throws TileDBError {
540
535
}
541
536
}
542
537
538
+ /**
539
+ * Retrieves the non-empty domain range sizes from an array for a given dimension index. This is
540
+ * the union of the non-empty domains of the array fragments on the given dimension. Applicable
541
+ * only to var-sized dimensions.
542
+ *
543
+ * @param index The dimension index
544
+ * @return The non-empty domain range sizes
545
+ * @throws TileDBError A TileDB exception
546
+ */
547
+ public Pair <BigInteger , BigInteger > getNonEmptyDomainVarSizeFromIndex (long index )
548
+ throws TileDBError {
549
+ SWIGTYPE_p_int emptyp = tiledb .new_intp ();
550
+ SWIGTYPE_p_unsigned_long_long startSize = tiledb .new_ullp ();
551
+ SWIGTYPE_p_unsigned_long_long endSize = tiledb .new_ullp ();
552
+
553
+ ctx .handleError (
554
+ tiledb .tiledb_array_get_non_empty_domain_var_size_from_index (
555
+ ctx .getCtxp (), arrayp , index , startSize , endSize , emptyp ));
556
+
557
+ return new Pair (tiledb .ullp_value (startSize ), tiledb .ullp_value (endSize ));
558
+ }
559
+
560
+ /**
561
+ * Retrieves the non-empty domain range sizes from an array for a given dimension name. This is
562
+ * the union of the non-empty domains of the array fragments on the given dimension. Applicable
563
+ * only to var-sized dimensions.
564
+ *
565
+ * @param name The dimension name
566
+ * @return The non-empty domain range sizes
567
+ * @throws TileDBError A TileDB exception
568
+ */
569
+ public Pair <BigInteger , BigInteger > getNonEmptyDomainVarSizeFromName (String name )
570
+ throws TileDBError {
571
+ SWIGTYPE_p_int emptyp = tiledb .new_intp ();
572
+ SWIGTYPE_p_unsigned_long_long startSize = tiledb .new_ullp ();
573
+ SWIGTYPE_p_unsigned_long_long endSize = tiledb .new_ullp ();
574
+
575
+ ctx .handleError (
576
+ tiledb .tiledb_array_get_non_empty_domain_var_size_from_name (
577
+ ctx .getCtxp (), arrayp , name , startSize , endSize , emptyp ));
578
+
579
+ return new Pair (tiledb .ullp_value (startSize ), tiledb .ullp_value (endSize ));
580
+ }
581
+
582
+ /**
583
+ * Retrieves the non-empty domain from an array for a given dimension index. This is the union of
584
+ * the non-empty domains of the array fragments on the given dimension. Applicable only to
585
+ * var-sized dimensions.
586
+ *
587
+ * @param index The dimension index
588
+ * @return The non-empty domain
589
+ * @throws TileDBError A TileDB exception
590
+ */
591
+ public Pair <String , String > getNonEmptyDomainVarFromIndex (long index ) throws TileDBError {
592
+ SWIGTYPE_p_int emptyp = tiledb .new_intp ();
593
+
594
+ Dimension dim = this .schema .getDomain ().getDimension (index );
595
+ Pair <BigInteger , BigInteger > size = this .getNonEmptyDomainVarSizeFromIndex (index );
596
+
597
+ Datatype dimType = dim .getType ();
598
+ int startSize = size .getFirst ().intValue ();
599
+ int endSize = size .getSecond ().intValue ();
600
+
601
+ NativeArray start = new NativeArray (ctx , startSize , dimType );
602
+ NativeArray end = new NativeArray (ctx , endSize , dimType );
603
+
604
+ ctx .handleError (
605
+ tiledb .tiledb_array_get_non_empty_domain_var_from_index (
606
+ ctx .getCtxp (), arrayp , index , start .toVoidPointer (), end .toVoidPointer (), emptyp ));
607
+
608
+ return new Pair (
609
+ new String ((byte []) start .toJavaArray ()), new String ((byte []) end .toJavaArray ()));
610
+ }
611
+
612
+ /**
613
+ * Retrieves the non-empty domain from an array for a given dimension name. This is the union of
614
+ * the non-empty domains of the array fragments on the given dimension. Applicable only to
615
+ * var-sized dimensions.
616
+ *
617
+ * @param name The dimension name
618
+ * @return The non-empty domain
619
+ * @throws TileDBError A TileDB exception
620
+ */
621
+ public Pair <String , String > getNonEmptyDomainVarFromName (String name ) throws TileDBError {
622
+ SWIGTYPE_p_int emptyp = tiledb .new_intp ();
623
+
624
+ Dimension dim = this .schema .getDomain ().getDimension (name );
625
+
626
+ Pair <BigInteger , BigInteger > size = this .getNonEmptyDomainVarSizeFromName (name );
627
+
628
+ Datatype dimType = dim .getType ();
629
+ int startSize = size .getFirst ().intValue ();
630
+ int endSize = size .getSecond ().intValue ();
631
+
632
+ NativeArray start = new NativeArray (ctx , startSize , dimType );
633
+ NativeArray end = new NativeArray (ctx , endSize , dimType );
634
+
635
+ ctx .handleError (
636
+ tiledb .tiledb_array_get_non_empty_domain_var_from_name (
637
+ ctx .getCtxp (), arrayp , name , start .toVoidPointer (), end .toVoidPointer (), emptyp ));
638
+
639
+ return new Pair (
640
+ new String ((byte []) start .toJavaArray ()), new String ((byte []) end .toJavaArray ()));
641
+ }
642
+
543
643
/**
544
644
* Compute an upper bound on the buffer elements needed to read a subarray.
545
645
*
0 commit comments