Skip to content

Commit

Permalink
Merge pull request #626 from marcobitplane/master
Browse files Browse the repository at this point in the history
Get decompressed chunks
  • Loading branch information
jamesmudd authored Sep 24, 2024
2 parents 5ffd065 + faf0d3a commit ac7b13f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions jhdf/src/main/java/io/jhdf/api/dataset/ChunkedDataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ public interface ChunkedDataset extends Dataset {
*/
ByteBuffer getRawChunkBuffer(int[] chunkOffset);

/**
* Gets the decompressed byte array for the specified chunk.
*
* @param chunkOffset the offset of the required chunk
* @return the decompressed byte array for this chunk
* @throws HdfException If the chunk offset is not valid for this dataset
*/
byte[] getDecompressedChunk(int[] chunkOffset);

}
10 changes: 10 additions & 0 deletions jhdf/src/main/java/io/jhdf/dataset/chunked/ChunkedDatasetBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ public ByteBuffer getRawChunkBuffer(int[] chunkOffset) {
return getDataBuffer(chunk);
}

@Override
public byte[] getDecompressedChunk(int[] chunkOffset) {
final Chunk chunk = getChunk(new ChunkOffset(chunkOffset));
if (chunk == null) {
throw new HdfException("No chunk with offset " + Arrays.toString(chunkOffset) +
" in dataset: " + getPath());
}
return decompressChunk(chunk);
}

private Collection<Chunk> getAllChunks() {
return getChunkLookup().values();
}
Expand Down

0 comments on commit ac7b13f

Please sign in to comment.