Skip to content

Commit 24ff964

Browse files
committed
sonarqube cleanup.
1 parent 54de3f7 commit 24ff964

17 files changed

Lines changed: 16 additions & 196 deletions

src/main/java/org/hdf5javalib/examples/FileByteComparator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static void main(String[] args) {
8686
}
8787

8888
} catch (IOException e) {
89-
log.error("Error reading files: " + e.getMessage());
89+
log.error("Error reading files: ", e);
9090
System.exit(1);
9191
}
9292
}

src/main/java/org/hdf5javalib/examples/read/FixedPointRead.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void tryMatrixSpliterator(SeekableByteChannel fileChannel, HdfDataFile hdfDataFi
166166
for (int c = 0; c < shape[1]; c++) {
167167
row.append(FlattenedArrayUtils.getElement(flattenedData, shape, r, c).setScale(2, RoundingMode.HALF_UP)).append(" ");
168168
}
169-
log.info("{}", row.toString().trim());
169+
log.info("{}", row);
170170
}
171171

172172
log.info("FlattenedData Streamed = ");
@@ -176,7 +176,7 @@ void tryMatrixSpliterator(SeekableByteChannel fileChannel, HdfDataFile hdfDataFi
176176
for (int c = 0; c < shape[1]; c++) {
177177
row.append(bdMatrix[r][c].setScale(2, RoundingMode.HALF_UP)).append(" ");
178178
}
179-
log.info("{}", row.toString().trim());
179+
log.info("{}", row);
180180
}
181181

182182
BigDecimal[] bdReduced = (BigDecimal[]) FlattenedArrayUtils.reduceAlongAxis(dataSource.streamFlattened(), shape, 0, BigDecimal::max, BigDecimal.class);

src/main/java/org/hdf5javalib/hdffile/dataobjects/messages/DataLayoutMessage.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.hdf5javalib.hdfjava.HdfDataFile;
1010
import org.hdf5javalib.utils.HdfDisplayUtils;
1111
import org.hdf5javalib.utils.HdfReadUtils;
12-
import org.hdf5javalib.utils.HdfWriteUtils;
1312

1413
import java.io.IOException;
1514
import java.lang.reflect.InvocationTargetException;
@@ -269,8 +268,7 @@ private static HdfBTreeV1 readFromSeekableByteChannelRecursive(SeekableByteChann
269268

270269
List<HdfBTreeEntryBase> entries = new ArrayList<>(entriesUsed);
271270

272-
HdfBTreeV1 currentNode = new HdfBTreeV1(nodeType, nodeLevel, entriesUsed, leftSiblingAddress, rightSiblingAddress, null, entries, hdfDataFile,
273-
HdfWriteUtils.hdfFixedPointFromValue(nodeAddress, hdfOffset));
271+
HdfBTreeV1 currentNode = new HdfBTreeV1(nodeType, nodeLevel, entriesUsed, leftSiblingAddress, rightSiblingAddress, null, entries, hdfDataFile);
274272
visitedNodes.put(nodeAddress, currentNode);
275273

276274
// (4 + 4 + 8*dimensions + 1*length + 1*length) * entriesUsed
@@ -315,18 +313,6 @@ public DataLayoutStorage getDataLayoutStorage() throws IOException {
315313
return dataLayoutStorage;
316314
}
317315

318-
// public void setDataAddress(HdfFixedPoint dataAddress) {
319-
// this.dataAddress = dataAddress;
320-
// }
321-
//
322-
// public HdfFixedPoint getDataAddress() {
323-
// return dataLayoutStorage.getDataAddress();
324-
// }
325-
//
326-
// public HdfFixedPoint[] getDimensionSizes() {
327-
// return d;
328-
// }
329-
330316
public static abstract class DataLayoutStorage {
331317
protected final HdfDataFile hdfDataFile;
332318
public DataLayoutStorage(HdfDataFile hdfDataFile) {

src/main/java/org/hdf5javalib/hdffile/dataobjects/messages/LinkMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public LinkMessage(
6060
int messageFlags,
6161
int sizeMessageData
6262
) {
63-
super(MessageType.LINK_MESSAGE, sizeMessageData, flags);
63+
super(MessageType.LINK_MESSAGE, sizeMessageData, messageFlags);
6464
this.version = version;
6565
this.flags = flags;
6666
this.linkType = linkType;

src/main/java/org/hdf5javalib/hdffile/infrastructure/HdfBTreeV1.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ public HdfBTreeV1(
7575
HdfFixedPoint rightSiblingAddress,
7676
HdfFixedPoint keyZero,
7777
List<HdfBTreeEntryBase> entries,
78-
HdfDataFile hdfDataFile,
79-
HdfFixedPoint offset
78+
HdfDataFile hdfDataFile
8079
) {
8180
this.nodeType = nodeType;
8281
this.nodeLevel = nodeLevel;
@@ -124,7 +123,7 @@ public HdfBTreeV1(
124123
public String toString() {
125124
StringBuilder sb = new StringBuilder();
126125
sb.append("HdfBTree{");
127-
sb.append("signature='").append(new String("TREE")).append('\'');
126+
sb.append("signature='").append("TREE").append('\'');
128127
sb.append(", nodeType=").append(nodeType);
129128
sb.append(", nodeLevel=").append(nodeLevel);
130129
sb.append(", entriesUsed=").append(entriesUsed);

src/main/java/org/hdf5javalib/hdffile/infrastructure/HdfChunkBTreeEntry.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,4 @@ public long getSizeOfChunk() {
6969
public long getFilterMask() {
7070
return filterMask;
7171
}
72-
// public HdfGroupSymbolTableNode getSymbolTableNode() {
73-
// return symbolTableNode;
74-
// }
75-
//
76-
// public HdfBTree getChildBTree() {
77-
// return childBTree;
78-
// }
7972
}

src/main/java/org/hdf5javalib/hdffile/infrastructure/HdfGlobalHeap.java

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public byte[] getDataBytes(HdfFixedPoint heapOffset, int objectId) throws IOExce
101101
throw new IllegalStateException("Heap not loaded for offset: " + heapOffset + " and no initializer provided.");
102102
}
103103
}
104-
// LinkedHashMap<Integer, GlobalHeapObject> specificHeapObjects = heapCollections.get(heapOffset);
105104
return block.getDataBytes(heapOffset, objectId);
106105
}
107106

@@ -175,22 +174,11 @@ public void initializeFromSeekableByteChannel(SeekableByteChannel fileChannel, H
175174

176175
HdfGlobalHeapBlock heapBlock = new HdfGlobalHeapBlock(
177176
localObjects,
178-
localCollectionSize,
179177
localNextObjectId,
180178
hdfDataFile,
181179
hdfStartOffset
182180
);
183181
globalHeaps.put(hdfStartOffset, heapBlock);
184-
// this.heapCollections.put(hdfStartOffset, localObjects);
185-
// this.collectionSizes.put(hdfStartOffset, localCollectionSize);
186-
// this.nextObjectIds.put(hdfStartOffset, localNextObjectId);
187-
188-
// this.setType(heapCollections.size() > 1 ? AllocationType.GLOBAL_HEAP_2 : AllocationType.GLOBAL_HEAP_1);
189-
// this.setName(heapCollections.size() > 1 ? "Global Heap 1" : "Global Heap 2");
190-
// this.setOffset(hdfStartOffset);
191-
// this.setSize(localCollectionSize);
192-
// this.hdfDataFile.getFileAllocation().addAllocationBlock(this);
193-
194182
}
195183

196184
/**
@@ -202,52 +190,6 @@ public void initializeFromSeekableByteChannel(SeekableByteChannel fileChannel, H
202190
* @throws IllegalStateException if the heap block is not allocated or full
203191
*/
204192
public byte[] addToHeap(byte[] bytes) {
205-
// if (bytes == null) {
206-
// throw new IllegalArgumentException("Input byte array cannot be null.");
207-
// }
208-
//
209-
// HdfFileAllocation fileAllocation = hdfDataFile.getFileAllocation();
210-
//
211-
// if (currentWriteHeapOffset == null) {
212-
// this.currentWriteHeapOffset = fileAllocation.getGlobalHeapOffset();
213-
// }
214-
// final HdfFixedPoint currentHeapOffset = this.currentWriteHeapOffset;
215-
//
216-
// HdfGlobalHeapBlock heapBlock = globalHeaps.computeIfAbsent(currentHeapOffset, k -> {
217-
// return new HdfGlobalHeapBlock(
218-
// new LinkedHashMap<>(),
219-
// HdfWriteUtils.hdfFixedPointFromValue(0, hdfDataFile.getSuperblock().getFixedPointDatatypeForLength()),
220-
// 1,
221-
// hdfDataFile,
222-
// globalHeaps.size() > 1 ? AllocationType.GLOBAL_HEAP_2 : AllocationType.GLOBAL_HEAP_1,
223-
// globalHeaps.size() > 1 ? "Global Heap 2" : "Global Heap 2",
224-
// currentHeapOffset);
225-
//// globalHeaps.put(currentHeapOffset, heapBlock);
226-
//// return heapBlock;
227-
//
228-
// });
229-
// boolean attempt = heapBlock.attemptAddBytes(bytes);
230-
// if (!attempt) {
231-
//// currentUsedSize + newObjectRequiredSize + GLOBAL_HEAP_OBJECT_SIZE > blockSize.getInstance(Long.class);
232-
// HdfFixedPoint newHeapOffset;
233-
// if (currentHeapOffset == fileAllocation.getGlobalHeapOffset()) {
234-
// newHeapOffset = fileAllocation.allocateNextGlobalHeapBlock();
235-
// } else {
236-
// newHeapOffset = fileAllocation.expandGlobalHeapBlock();
237-
// }
238-
// HdfGlobalHeapBlock globalHeapBlock = new HdfGlobalHeapBlock(
239-
// new LinkedHashMap<>(),
240-
// HdfWriteUtils.hdfFixedPointFromValue(0, hdfDataFile.getSuperblock().getFixedPointDatatypeForLength()),
241-
// 1,
242-
// hdfDataFile,
243-
// globalHeaps.size() > 1 ? AllocationType.GLOBAL_HEAP_2 : AllocationType.GLOBAL_HEAP_1,
244-
// globalHeaps.size() > 1 ? "Global Heap 1" : "Global Heap 1",
245-
// currentHeapOffset);
246-
// globalHeaps.put(newHeapOffset, globalHeapBlock);
247-
// currentWriteHeapOffset = newHeapOffset;
248-
// }
249-
//
250-
// return heapBlock.addToHeap(bytes);
251193
return null;
252194
}
253195

src/main/java/org/hdf5javalib/hdffile/infrastructure/HdfGlobalHeapBlock.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class HdfGlobalHeapBlock {
2424
*/
2525
public HdfGlobalHeapBlock(
2626
LinkedHashMap<Integer, GlobalHeapObject> globalHeapObjects,
27-
HdfFixedPoint collectionSize,
2827
Integer nextObjectId,
2928
HdfDataFile hdfDataFile,
3029
HdfFixedPoint offset

src/main/java/org/hdf5javalib/hdffile/infrastructure/HdfLocalHeap.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ public HdfFixedPoint getFreeListOffset() {
5353
* @param version the version of the local heap format
5454
* @param hdfDataFile the HDF5 data file containing the local heap
5555
* @param heapData the raw byte array containing the heap's data
56-
* @param heapOffset
5756
*/
58-
public HdfLocalHeap(int version, HdfDataFile hdfDataFile, HdfLocalHeapData heapData,
59-
long heapOffset) {
57+
public HdfLocalHeap(int version, HdfDataFile hdfDataFile, HdfLocalHeapData heapData) {
6058
this.version = version;
6159
this.hdfDataFile = hdfDataFile;
6260
this.heapData = heapData;

src/main/java/org/hdf5javalib/hdffile/infrastructure/HdfLocalHeapData.java

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -65,42 +65,12 @@ public HdfLocalHeapData(HdfFixedPoint offset, HdfFixedPoint size, HdfDataFile hd
6565
* @param objectName the string to add to the heap
6666
* @return the offset in the heap where the string is stored
6767
*/
68-
// public int addToHeap(HdfString objectName) {
68+
6969
public HdfFixedPoint addToHeap(String objectName, HdfDataFile hdfDataFile) {
70-
// HdfFileAllocation fileAllocation = hdfDataFile.getFileAllocation();
71-
// byte[] objectNameBytes = objectName.getBytes(StandardCharsets.US_ASCII);
72-
// // Calculate string size and alignment
73-
// int stringSize = objectNameBytes.length + 1; // Include null terminator
74-
// int alignedStringSize = (stringSize + 7) & ~7; // Pad to 8-byte boundary
75-
//
76-
// // Determine current heap offset
77-
// HdfFixedPoint currentOffset = freeListOffset.getInstance(Long.class) == 1 ? heapContentsSize.clone() : freeListOffset.clone();
78-
//
79-
// // Calculate initial required space (string only)
80-
// byte[] requiredSpace = HdfWriteUtils.toFixedPointBytes(alignedStringSize, currentOffset.getDatatype(), Integer.class);
81-
//
82-
//
83-
// // Check if there's enough space for the string
84-
// if (HdfFixedPoint.compareToBytes(HdfFixedPoint.addBytes(currentOffset.getBytes(), requiredSpace), heapContentsSize.getBytes()) > 0) {
85-
// // Resize heap
86-
// this.heapContentsSize = fileAllocation.expandLocalHeapContents();
87-
// this.heapContentsOffset = fileAllocation.getCurrentLocalHeapContentsOffset();
88-
// }
89-
//
90-
// data.put(currentOffset, new HdfLocalHeapDataValue(objectName, currentOffset));
91-
//
92-
// return currentOffset;
9370
return null;
9471
}
9572

9673
public void writeToByteChannel(SeekableByteChannel seekableByteChannel, HdfDataFile hdfDataFile) throws IOException {
97-
98-
// buffer = ByteBuffer.wrap(heapData);
99-
// seekableByteChannel.position(hdfDataFile.getFileAllocation().getCurrentLocalHeapContentsOffset());
100-
// while (buffer.hasRemaining()) {
101-
// seekableByteChannel.write(buffer);
102-
// }
103-
10474
}
10575

10676
@Override

0 commit comments

Comments
 (0)