Skip to content

Commit d6f9755

Browse files
committed
Add N5Writer.deleteBlocks method with trivial default implementation
This should be handled by a dedicated DatasetAccess method
1 parent e6e390d commit d6f9755

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/main/java/org/janelia/saalfeldlab/n5/N5Writer.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,24 @@ boolean deleteBlock(
327327
final String datasetPath,
328328
final long... gridPosition) throws N5Exception;
329329

330+
/**
331+
* Deletes the blocks at the given {@code gridPositions}.
332+
*
333+
* @param datasetPath dataset path
334+
* @param gridPositions a list of grid positions
335+
* @return {@code true} if any of the specified blocks existed and was deleted
336+
* @throws N5Exception if any of the block exists but could not be deleted
337+
*/
338+
default boolean deleteBlocks(
339+
final String datasetPath,
340+
final List<long[]> gridPositions) throws N5Exception {
341+
boolean deleted = false;
342+
for (long[] pos : gridPositions) {
343+
deleted |= deleteBlock(datasetPath, pos);
344+
}
345+
return deleted;
346+
}
347+
330348
/**
331349
* Save a {@link Serializable} as an N5 {@link DataBlock} at a given offset.
332350
* The

src/main/java/org/janelia/saalfeldlab/n5/shard/DatasetAccess.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public interface DatasetAccess<T> {
3434

3535
void writeBlocks(PositionValueAccess kva, List<DataBlock<T>> blocks) throws N5IOException;
3636

37+
// TODO:
38+
// boolean deleteBlocks(PositionValueAccess kva, List<long[]> positions) throws N5IOException;
39+
3740

3841
/**
3942
*

0 commit comments

Comments
 (0)