Skip to content

Commit f46db19

Browse files
committed
refactor v2 code
1 parent 8f2dd3e commit f46db19

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/main/java/org/hdf5javalib/dataclass/reference/HdfObjectReference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private ObjectReferenceData parseObject2Type3(byte[] bytes, ReferenceDatatype dt
112112
heapBytes.get(datasetReferenceBytes);
113113
HdfFixedPoint datasetReferenced = new HdfFixedPoint(datasetReferenceBytes, offsetSpec);
114114

115-
/* long length = */ Integer.toUnsignedLong(heapBytes.getInt()); // Length is read but not used
115+
/* long length = */ heapBytes.getInt(); // Length is read but not used
116116
/* int selectionType = */ heapBytes.getInt(); // selectionType is read but not used
117117

118118
HdfDataspaceSelectionInstance selectionInstance = HdfDataspaceSelectionInstance.parseSelectionInfo(heapBytes);
@@ -139,7 +139,7 @@ private ObjectReferenceData parseObject2Type4(byte[] bytes, ReferenceDatatype dt
139139
heapBytes.get(datasetReferenceBytes);
140140
HdfFixedPoint datasetReferenced = new HdfFixedPoint(datasetReferenceBytes, offsetSpec);
141141

142-
/* long length = */ Integer.toUnsignedLong(heapBytes.getInt()); // Length is read but not used
142+
/* long length = */ heapBytes.getInt(); // Length is read but not used
143143
int nameLength = heapBytes.getInt();
144144

145145
// Parse attribute name

src/main/java/org/hdf5javalib/hdfjava/HdfDataset.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
import java.nio.ByteBuffer;
1414
import java.nio.ByteOrder;
1515
import java.nio.channels.SeekableByteChannel;
16-
import java.util.ArrayList;
17-
import java.util.List;
18-
import java.util.Optional;
16+
import java.util.*;
1917

2018
/**
2119
* Represents a leaf node (HdfDataset) in the B-Tree.
@@ -163,7 +161,31 @@ private record ChunkedReadContext(
163161
long endElement,
164162
Optional<FilterPipelineMessage> filterPipeline,
165163
FillValueMessage fillValueMessage
166-
) {}
164+
) {
165+
@Override
166+
public boolean equals(Object o) {
167+
if (o == null || getClass() != o.getClass()) return false;
168+
ChunkedReadContext that = (ChunkedReadContext) o;
169+
return dimensions == that.dimensions && endElement == that.endElement && elementSize == that.elementSize && startElement == that.startElement && Objects.deepEquals(chunkDims, that.chunkDims) && Objects.deepEquals(datasetDims, that.datasetDims);
170+
}
171+
172+
@Override
173+
public int hashCode() {
174+
return Objects.hash(dimensions, Arrays.hashCode(datasetDims), Arrays.hashCode(chunkDims), elementSize, startElement, endElement);
175+
}
176+
177+
@Override
178+
public String toString() {
179+
return "ChunkedReadContext{" +
180+
"dimensions=" + dimensions +
181+
", datasetDims=" + Arrays.toString(datasetDims) +
182+
", chunkDims=" + Arrays.toString(chunkDims) +
183+
", elementSize=" + elementSize +
184+
", startElement=" + startElement +
185+
", endElement=" + endElement +
186+
'}';
187+
}
188+
}
167189

168190
// In the method:
169191
public synchronized ByteBuffer getDatasetData(SeekableByteChannel channel, long offset, long size) throws IOException, InvocationTargetException, InstantiationException, IllegalAccessException {

0 commit comments

Comments
 (0)