From a830950aea363c260bdd3c68a81d6bee13eeceb3 Mon Sep 17 00:00:00 2001 From: James Mudd Date: Fri, 10 Jan 2025 22:24:17 +0000 Subject: [PATCH] Add test file for implicit index --- .../chunked/indexing/ImplicitChunkIndex.java | 1 - .../hdf5/implicit_index_datasets.hdf5 | Bin 0 -> 2128 bytes .../scripts/implicit_index_datasets.py | 28 ++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 jhdf/src/test/resources/hdf5/implicit_index_datasets.hdf5 create mode 100644 jhdf/src/test/resources/scripts/implicit_index_datasets.py diff --git a/jhdf/src/main/java/io/jhdf/dataset/chunked/indexing/ImplicitChunkIndex.java b/jhdf/src/main/java/io/jhdf/dataset/chunked/indexing/ImplicitChunkIndex.java index 3ee47884..ad945d66 100644 --- a/jhdf/src/main/java/io/jhdf/dataset/chunked/indexing/ImplicitChunkIndex.java +++ b/jhdf/src/main/java/io/jhdf/dataset/chunked/indexing/ImplicitChunkIndex.java @@ -26,7 +26,6 @@ public class ImplicitChunkIndex implements ChunkIndex { private final long baseAddress; public ImplicitChunkIndex(long baseAddress, DatasetInfo datasetInfo) { - this.baseAddress = baseAddress; this.chunkSize = datasetInfo.getChunkSizeInBytes(); this.datasetDimensions = datasetInfo.getDatasetDimensions(); diff --git a/jhdf/src/test/resources/hdf5/implicit_index_datasets.hdf5 b/jhdf/src/test/resources/hdf5/implicit_index_datasets.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..9f250fab5c52cedd70a91f6be378ecea6d190eb9 GIT binary patch literal 2128 zcmeD5aB<`1lHy|K;9!7(|4NBfY=O-j3NvSOpIU( zY&MV!2FyGRi~>Nfv4D9B46Hy`GIMeWFfg((0X47!Nmy9yf@&F(RP6RQUPIF1qmCX8 zfzc2c4S~@Rpic+@>u3fhAZ7+)P^HKU#B4y!4#c3EkQ0cxfS4PId4QM~i1~n+ABY8j NSP+Oo^}jF>0{}PVI_3ZX literal 0 HcmV?d00001 diff --git a/jhdf/src/test/resources/scripts/implicit_index_datasets.py b/jhdf/src/test/resources/scripts/implicit_index_datasets.py new file mode 100644 index 00000000..463d9178 --- /dev/null +++ b/jhdf/src/test/resources/scripts/implicit_index_datasets.py @@ -0,0 +1,28 @@ +import h5py +import numpy + + +f = h5py.File("implicit_index_datasets.hdf5", "w", libver='latest') + +data = numpy.arange(20) + +dataspace = h5py.h5s.create_simple(data.shape) # Create simple dataspace +datatype = h5py.h5t.NATIVE_INT32 + +# Dataset creation property list +dcpl = h5py.h5p.create(h5py.h5p.DATASET_CREATE) +dcpl.set_alloc_time(h5py.h5d.ALLOC_TIME_EARLY) +# Set chunk dimensions (e.g., chunks of size 5) +chunk_dims = (5,) # Ensure chunks are compatible with dataspace shape +dcpl.set_chunk(chunk_dims) + +# Create the dataset +dataset_name = "implicit_index".encode('utf-8') # Dataset name must be bytes +dataset = h5py.h5d.create(f.id, dataset_name, datatype, dataspace, dcpl) + +# 5. Write data to the dataset +dataset.write(h5py.h5s.ALL, h5py.h5s.ALL, data) +dataset.close() + + +f.close()