Skip to content

Commit 3727707

Browse files
DimitrisStaratzisgsvic
authored andcommitted
-Added methods to retrieves the non-empty domain range sizes from a fragment for a given name or dimension.
1 parent 8929d4f commit 3727707

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,48 @@ public FragmentInfo(Context ctx, String uri, EncryptionType encryptionType, Stri
5050
}
5151
}
5252

53+
/**
54+
* Retrieves the non-empty domain range sizes from a fragment for a given dimension index.
55+
* Applicable to var-sized dimensions.
56+
*
57+
* @param fragmentID The fragment ID
58+
* @param dimensionID The dimension name
59+
* @return The non-empty domain range sizes from a fragment for a given dimension index.
60+
* @throws TileDBError
61+
*/
62+
public Pair<Long, Long> getNonEmptyDomainVarSizeFromIndex(long fragmentID, long dimensionID)
63+
throws TileDBError {
64+
SWIGTYPE_p_unsigned_long_long startSize = tiledb.new_ullp();
65+
SWIGTYPE_p_unsigned_long_long endSize = tiledb.new_ullp();
66+
67+
ctx.handleError(
68+
tiledb.tiledb_fragment_info_get_non_empty_domain_var_size_from_index(
69+
ctx.getCtxp(), fragmentInfop, fragmentID, dimensionID, startSize, endSize));
70+
return new Pair(
71+
tiledb.ullp_value(startSize).longValue(), tiledb.ullp_value(endSize).longValue());
72+
}
73+
74+
/**
75+
* Retrieves the non-empty domain range sizes from a fragment for a given dimension name.
76+
* Applicable to var-sized dimensions.
77+
*
78+
* @param fragmentID The fragment ID
79+
* @param dimensionName The dimension name
80+
* @return The non-empty domain range sizes from a fragment for a given dimension name
81+
* @throws TileDBError
82+
*/
83+
public Pair<Long, Long> getNonEmptyDomainVarSizeFromName(long fragmentID, String dimensionName)
84+
throws TileDBError {
85+
SWIGTYPE_p_unsigned_long_long startSize = tiledb.new_ullp();
86+
SWIGTYPE_p_unsigned_long_long endSize = tiledb.new_ullp();
87+
88+
ctx.handleError(
89+
tiledb.tiledb_fragment_info_get_non_empty_domain_var_size_from_name(
90+
ctx.getCtxp(), fragmentInfop, fragmentID, dimensionName, startSize, endSize));
91+
return new Pair(
92+
tiledb.ullp_value(startSize).longValue(), tiledb.ullp_value(endSize).longValue());
93+
}
94+
5395
/**
5496
* Returns the number of fragments.
5597
*

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,48 @@ public void testNonEmptyDomainVar() throws Exception {
493493
}
494494
}
495495

496+
@Test
497+
public void testNonEmptyDomainVarSize() throws Exception {
498+
int testFragmentCount = 10;
499+
createSparseVarDimArray();
500+
501+
// Write three fragments
502+
for (int i = 0; i < testFragmentCount; ++i) {
503+
writeSparseVarDimArray();
504+
}
505+
506+
FragmentInfo info = new FragmentInfo(ctx, arrayURI);
507+
508+
long numFragments = info.getFragmentNum();
509+
510+
for (int i = 0; i < numFragments; ++i) {
511+
Array arr = new Array(ctx, arrayURI);
512+
Domain domain = arr.getSchema().getDomain();
513+
for (int dim = 0; dim < domain.getNDim(); ++dim) {
514+
Dimension dimension = domain.getDimension(dim);
515+
516+
// Test getNonEmptyDomainVarSizeFromIndex
517+
Pair p = info.getNonEmptyDomainVarSizeFromIndex(i, dim);
518+
519+
Assert.assertEquals(
520+
p.getFirst(), arr.getNonEmptyDomainVarSizeFromIndex(dim).getFirst().longValue());
521+
Assert.assertEquals(
522+
p.getSecond(), arr.getNonEmptyDomainVarSizeFromIndex(dim).getSecond().longValue());
523+
524+
// Test getNonEmptyDomainVarSizeFromName
525+
p = info.getNonEmptyDomainVarSizeFromName(i, dimension.getName());
526+
527+
// Test getNonEmptyDomainVarSizeFromName
528+
Assert.assertEquals(
529+
p.getFirst(),
530+
arr.getNonEmptyDomainVarSizeFromName(dimension.getName()).getFirst().longValue());
531+
Assert.assertEquals(
532+
p.getSecond(),
533+
arr.getNonEmptyDomainVarSizeFromName(dimension.getName()).getSecond().longValue());
534+
}
535+
}
536+
}
537+
496538
@Test
497539
public void testGetCellNumVar() throws Exception {
498540
int testFragmentCount = 10;

0 commit comments

Comments
 (0)