Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/main/java/io/tiledb/java/api/Array.java
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ public Pair<String, NativeArray> getMetadataFromIndex(BigInteger index) throws T
* timestamp.
* @throws TileDBError
*/
@Deprecated
public void deleteFragments(BigInteger timestampStart, BigInteger timestampEnd)
throws TileDBError {
Util.checkBigIntegerRange(timestampStart);
Expand All @@ -783,6 +784,25 @@ public void deleteFragments(BigInteger timestampStart, BigInteger timestampEnd)
ctx.getCtxp(), getArrayp(), uri, timestampStart, timestampEnd));
}

/**
* Deletes array fragments written between the input timestamps.
*
* @param ctx The Context
* @param uri The array URI
* @param timestampStart The epoch timestamp in milliseconds.
* @param timestampEnd The epoch timestamp in milliseconds. Use UINT64_MAX for the current
* timestamp.
* @throws TileDBError
*/
public static void deleteFragments(
Context ctx, String uri, BigInteger timestampStart, BigInteger timestampEnd)
throws TileDBError {
Util.checkBigIntegerRange(timestampStart);
Util.checkBigIntegerRange(timestampEnd);
ctx.handleError(
tiledb.tiledb_array_delete_fragments_v2(ctx.getCtxp(), uri, timestampStart, timestampEnd));
}

/**
* Returns a HashMap with all array metadata in a key-value manner.
*
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/io/tiledb/java/api/FragmentInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -778,17 +778,18 @@ public String getArraySchemaName(long fragmentID) throws TileDBError {
* @deprecated use getFragmentNameV2(long fragmentID) instead
* @throws TileDBError
*/
@Deprecated
public String getFragmentName(long fragmentID) throws TileDBError {
SWIGTYPE_p_p_char name = tiledb.new_charpp();
SWIGTYPE_p_p_tiledb_string_handle_t name = tiledb.new_tiledb_string_handle_tpp();
TileDBString ts = null;

try {
ctx.handleError(
tiledb.tiledb_fragment_info_get_fragment_name(
tiledb.tiledb_fragment_info_get_fragment_name_v2(
ctx.getCtxp(), fragmentInfop, fragmentID, name));
return tiledb.charpp_value(name);
ts = new TileDBString(ctx, name);
return ts.getView().getFirst();
} finally {
tiledb.delete_charpp(name);
if (ts != null) ts.close();
}
}

Expand All @@ -799,6 +800,7 @@ public String getFragmentName(long fragmentID) throws TileDBError {
* @return The fragment name.
* @throws TileDBError
*/
@Deprecated
public TileDBString getFragmentNameV2(long fragmentID) throws TileDBError {
SWIGTYPE_p_p_tiledb_string_handle_t name = tiledb.new_tiledb_string_handle_tpp();
TileDBString ts = null;
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/io/tiledb/java/api/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public long getMemberCount() throws TileDBError {
}
}

@Deprecated
/**
* Get the URI of a member of a group by index and details of group
*
Expand All @@ -195,6 +196,17 @@ public long getMemberCount() throws TileDBError {
* @throws TileDBError
*/
public String getMemberByIndexV2(BigInteger index) throws TileDBError {
return getMemberByIndex(index);
}

/**
* Get the URI of a member of a group by index and details of group
*
* @param index the index of the member.
* @return the corresponding member in the group.
* @throws TileDBError
*/
public String getMemberByIndex(BigInteger index) throws TileDBError {
Util.checkBigIntegerRange(index);
SWIGTYPE_p_tiledb_object_t objtypep = tiledb.new_tiledb_object_tp();
SWIGTYPE_p_p_tiledb_string_handle_t uripp = tiledb.new_tiledb_string_handle_tpp();
Expand All @@ -212,6 +224,7 @@ public String getMemberByIndexV2(BigInteger index) throws TileDBError {
}
}

@Deprecated
/**
* Get the URI of a member of a group by name
*
Expand All @@ -220,6 +233,17 @@ public String getMemberByIndexV2(BigInteger index) throws TileDBError {
* @throws TileDBError
*/
public String getMemberByNameV2(String name) throws TileDBError {
return getMemberByName(name);
}

/**
* Get the URI of a member of a group by name
*
* @param name the name of the member
* @return the URI of the member with the given name
* @throws TileDBError
*/
public String getMemberByName(String name) throws TileDBError {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can update the v2 methods to call the new ones to reduce duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are going to be removed very soon but yeah good catch. getFragmentNameV2() has a different return type which I can not create so I am leaving it as is.

SWIGTYPE_p_tiledb_object_t objtypep = tiledb.new_tiledb_object_tp();
SWIGTYPE_p_p_tiledb_string_handle_t uripp = tiledb.new_tiledb_string_handle_tpp();
TileDBString ts = null;
Expand Down
5 changes: 1 addition & 4 deletions src/test/java/io/tiledb/java/api/FragmentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ private void arrayRead() throws Exception {

@Test
public void testDeleteFragments() throws Exception {
Array array = new Array(ctx, arrayURI, TILEDB_MODIFY_EXCLUSIVE);

array.deleteFragments(BigInteger.valueOf(10L), BigInteger.valueOf(20L));
Array.deleteFragments(ctx, arrayURI, BigInteger.valueOf(10L), BigInteger.valueOf(20L));

File f = new File(arrayURI);
int nFiles = 0;
Expand All @@ -239,6 +237,5 @@ public void testDeleteFragments() throws Exception {
}
Assert.assertEquals(1, nFiles);
Assert.assertTrue(frag.getName().startsWith("__30_30_"));
array.close();
}
}
4 changes: 2 additions & 2 deletions src/test/java/io/tiledb/java/api/GroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ public void membersTest() throws Exception {
Assert.assertEquals(3, group.getMemberCount());

// test getters
String[] uri = group.getMemberByNameV2("array3Name").split("/");
String[] uri = group.getMemberByName("array3Name").split("/");
Assert.assertEquals("TileDB-Java/array3", uri[uri.length - 2] + "/" + uri[uri.length - 1]);

Assert.assertEquals("array2Name", group.getMemberByIndexV2(new BigInteger("1")));
Assert.assertEquals("array2Name", group.getMemberByIndex(new BigInteger("1")));

// remove a member
group.reopen(ctx, TILEDB_WRITE);
Expand Down