Skip to content

Commit a378a71

Browse files
committed
Generate updates for 0.1.4 version.
1 parent 3c3095b commit a378a71

8 files changed

Lines changed: 29 additions & 25 deletions

File tree

src/main/java/org/hdf5javalib/dataclass/HdfFixedPoint.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ public HdfFixedPoint(byte[] bytes, FixedPointDatatype datatype) {
5555
this.datatype = datatype;
5656
}
5757

58+
/**
59+
* Copy constructor
60+
* @param hdfFixedPoint hdfFixedPoint to copy
61+
*/
62+
public HdfFixedPoint(HdfFixedPoint hdfFixedPoint) {
63+
this.bytes = hdfFixedPoint.getBytes();
64+
this.datatype = hdfFixedPoint.getDatatype();
65+
}
66+
5867
/**
5968
* Constructs an HdfFixedPoint from a BigInteger value and a specified FixedPointDatatype.
6069
* <p>
@@ -355,9 +364,4 @@ public static byte[] truncateTo2048Boundary(byte[] bytes) {
355364
}
356365
return result;
357366
}
358-
359-
@Override
360-
public HdfFixedPoint clone() {
361-
return new HdfFixedPoint(bytes.clone(), datatype);
362-
}
363367
}

src/main/java/org/hdf5javalib/datatype/ArrayDatatype.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public ArrayDatatype(int classAndVersion, BitSet classBitField, int size, int di
105105
throw new IllegalArgumentException("Dimension sizes and permutation indices must match dimensionality");
106106
}
107107
// Validate size matches product of dimensions * base type size
108-
long expectedSize = (long) datatype.getSize() * Arrays.stream(dimensionSizes).asLongStream().reduce(1, (a, b) -> a * b);
108+
long expectedSize = datatype.getSize() * Arrays.stream(dimensionSizes).asLongStream().reduce(1, (a, b) -> a * b);
109109
if (expectedSize != size) {
110110
throw new IllegalArgumentException("Size (" + size + ") does not match base type size * dimensions (" + expectedSize + ")");
111111
}
@@ -219,7 +219,7 @@ public <T> T getInstance(Class<T> clazz, byte[] bytes) {
219219
*/
220220
@Override
221221
public boolean requiresGlobalHeap(boolean required) {
222-
return required | datatype.requiresGlobalHeap(required);
222+
return required || datatype.requiresGlobalHeap(required);
223223
}
224224

225225
/**

src/main/java/org/hdf5javalib/datatype/EnumDatatype.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public <T> T getInstance(Class<T> clazz, byte[] bytes) {
229229
*/
230230
@Override
231231
public boolean requiresGlobalHeap(boolean required) {
232-
return required | datatype.requiresGlobalHeap(required);
232+
return required || datatype.requiresGlobalHeap(required);
233233
}
234234

235235
/**

src/main/java/org/hdf5javalib/datatype/FixedPointDatatype.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public <T> T getInstance(Class<T> clazz, byte[] bytes) {
477477
*/
478478
@Override
479479
public boolean requiresGlobalHeap(boolean required) {
480-
return required | false;
480+
return required || false;
481481
}
482482

483483
/**

src/main/java/org/hdf5javalib/datatype/FloatingPointDatatype.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public <T> T getInstance(Class<T> clazz, byte[] bytes) {
225225
*/
226226
@Override
227227
public boolean requiresGlobalHeap(boolean required) {
228-
return required | false;
228+
return required || false;
229229
}
230230

231231
/**

src/main/java/org/hdf5javalib/datatype/StringDatatype.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public <T> T getInstance(Class<T> clazz, byte[] bytes) {
140140
*/
141141
@Override
142142
public boolean requiresGlobalHeap(boolean required) {
143-
return required | false;
143+
return required || false;
144144
}
145145

146146
/**

src/main/java/org/hdf5javalib/datatype/VariableLengthDatatype.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public <T> T getInstance(Class<T> clazz, byte[] bytes) {
159159
*/
160160
@Override
161161
public boolean requiresGlobalHeap(boolean required) {
162-
return required | true;
162+
return required || true;
163163
}
164164

165165
/**

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public HdfFixedPoint allocateNextSnodStorage() {
304304
}
305305
}
306306

307-
HdfFixedPoint offset = metadataNextAvailableOffset.clone();
307+
HdfFixedPoint offset = new HdfFixedPoint(metadataNextAvailableOffset);
308308
AllocationRecord record = new AllocationRecord(AllocationType.SNOD, "SNOD Block " + (snodRecords.size() + 1), offset, HDF_SNOD_STORAGE_SIZE, this);
309309
snodRecords.add(record);
310310
// allocationRecords.add(record);
@@ -332,7 +332,7 @@ public HdfFixedPoint allocateAndSetDataBlock(String datasetName, HdfFixedPoint d
332332
throw new IllegalStateException("Data block for '" + datasetName + "' already allocated");
333333
}
334334

335-
HdfFixedPoint dataOffset = dataNextAvailableOffset.clone();
335+
HdfFixedPoint dataOffset = new HdfFixedPoint(dataNextAvailableOffset);
336336
AllocationRecord record = new AllocationRecord(AllocationType.DATASET_DATA, "Data Block (" + datasetName + ")", dataOffset, dataSize, this);
337337
datasetRecordsByName.computeIfAbsent(datasetName, k -> new HashMap<>()).put(AllocationType.DATASET_DATA, record);
338338
// allocationRecords.add(record);
@@ -364,7 +364,7 @@ public HdfFixedPoint allocateAndSetContinuationBlock(String datasetName, HdfFixe
364364
moveDataNextAvailableOffset(new HdfFixedPoint(metadataNextAvailableOffset.add(continuationSize), metadataNextAvailableOffset.getDatatype()));
365365
}
366366

367-
HdfFixedPoint continuationOffset = metadataNextAvailableOffset.clone();
367+
HdfFixedPoint continuationOffset = new HdfFixedPoint(metadataNextAvailableOffset);
368368
AllocationRecord record = new AllocationRecord(AllocationType.DATASET_HEADER_CONTINUATION, "Continuation (" + datasetName + ")", continuationOffset, continuationSize, this);
369369
datasetRecordsByName.computeIfAbsent(datasetName, k -> new HashMap<>()).put(AllocationType.DATASET_HEADER_CONTINUATION, record);
370370
// allocationRecords.add(record);
@@ -384,8 +384,8 @@ public HdfFixedPoint allocateFirstGlobalHeapBlock() {
384384
throw new IllegalStateException("First global heap already allocated");
385385
}
386386

387-
HdfFixedPoint size = HDF_GLOBAL_HEAP_BLOCK_SIZE.clone();
388-
HdfFixedPoint offset = dataNextAvailableOffset.clone();
387+
HdfFixedPoint size = new HdfFixedPoint(HDF_GLOBAL_HEAP_BLOCK_SIZE);
388+
HdfFixedPoint offset = new HdfFixedPoint(dataNextAvailableOffset);
389389
AllocationRecord record = new AllocationRecord(AllocationType.GLOBAL_HEAP_1, "Global Heap Block 1", offset, size, this);
390390
globalHeapBlocks.put(AllocationType.GLOBAL_HEAP_1, record);
391391
// allocationRecords.add(record);
@@ -405,8 +405,8 @@ public HdfFixedPoint allocateNextGlobalHeapBlock() {
405405
throw new IllegalStateException("Only two global heap blocks allowed");
406406
}
407407

408-
HdfFixedPoint size = HDF_GLOBAL_HEAP_BLOCK_SIZE.clone();
409-
HdfFixedPoint offset = dataNextAvailableOffset.clone();
408+
HdfFixedPoint size = new HdfFixedPoint(HDF_GLOBAL_HEAP_BLOCK_SIZE);
409+
HdfFixedPoint offset = new HdfFixedPoint(dataNextAvailableOffset);
410410
AllocationRecord record = new AllocationRecord(AllocationType.GLOBAL_HEAP_2, "Global Heap Block 2", offset, size, this);
411411
globalHeapBlocks.put(AllocationType.GLOBAL_HEAP_2, record);
412412
// allocationRecords.add(record);
@@ -450,7 +450,7 @@ public HdfFixedPoint expandLocalHeapContents() {
450450
moveMetadataNextAvailableOffset(metadataNextAvailableOffset, newSize);
451451
}
452452

453-
HdfFixedPoint newOffset = metadataNextAvailableOffset.clone();
453+
HdfFixedPoint newOffset = new HdfFixedPoint(metadataNextAvailableOffset);
454454

455455
// Update existing LOCAL_HEAP record to indicate abandonment
456456
activeRecord.setType(AllocationType.LOCAL_HEAP_ABANDONED);
@@ -527,11 +527,11 @@ public HdfFixedPoint getGlobalHeapBlockSize(HdfFixedPoint offset) {
527527
* @param newOffset the new metadata offset
528528
*/
529529
private void updateMetadataOffset(HdfFixedPoint newOffset) {
530-
metadataNextAvailableOffset = newOffset.clone();
530+
metadataNextAvailableOffset = new HdfFixedPoint(newOffset);
531531
if (metadataNextAvailableOffset.compareTo(dataNextAvailableOffset) >= 0 &&
532532
!isDataBlocksAllocated() &&
533533
globalHeapBlocks.isEmpty()) {
534-
dataNextAvailableOffset = metadataNextAvailableOffset.clone();
534+
dataNextAvailableOffset = new HdfFixedPoint(metadataNextAvailableOffset);
535535
updateDataOffset(dataNextAvailableOffset);
536536
}
537537
}
@@ -542,10 +542,10 @@ private void updateMetadataOffset(HdfFixedPoint newOffset) {
542542
* @param newOffset the new data offset
543543
*/
544544
private void updateDataOffset(HdfFixedPoint newOffset) {
545-
dataNextAvailableOffset = newOffset.clone();
545+
dataNextAvailableOffset = new HdfFixedPoint(newOffset);
546546
if (metadataNextAvailableOffset.compareTo(HDF_MIN_DATA_OFFSET_THRESHOLD) >= 0 &&
547547
metadataNextAvailableOffset.compareTo(dataNextAvailableOffset) < 0) {
548-
metadataNextAvailableOffset = dataNextAvailableOffset.clone();
548+
metadataNextAvailableOffset = new HdfFixedPoint(dataNextAvailableOffset);
549549
}
550550
}
551551

@@ -576,7 +576,7 @@ private boolean checkForOverlap(HdfFixedPoint offset, HdfFixedPoint size) {
576576
*/
577577
private void moveMetadataNextAvailableOffset(HdfFixedPoint currentOffset, HdfFixedPoint size) {
578578
// long newOffset = Math.max(currentOffset, dataNextAvailableOffset);
579-
HdfFixedPoint newOffset = currentOffset.compareTo(dataNextAvailableOffset) > 0 ? currentOffset.clone() : dataNextAvailableOffset.clone();
579+
HdfFixedPoint newOffset = currentOffset.compareTo(dataNextAvailableOffset) > 0 ? new HdfFixedPoint(currentOffset) : new HdfFixedPoint(dataNextAvailableOffset);
580580
// newOffset.mutate(new); = ((newOffset + ALIGNMENT_BOUNDARY - 1) / ALIGNMENT_BOUNDARY) * ALIGNMENT_BOUNDARY; // Next 2048-byte boundary
581581
newOffset.mutate(HdfFixedPoint.truncateTo2048Boundary(HdfFixedPoint.minusOneBytes(newOffset.add(HDF_ALIGNMENT_BOUNDARY))));
582582
// / ALIGNMENT_BOUNDARY) * ALIGNMENT_BOUNDARY; // Next 2048-byte boundary

0 commit comments

Comments
 (0)