Skip to content

Commit 22ad4a1

Browse files
author
Vincent Wilms
committed
Merge commit '2b9f966ccfd3635fae443b7bb0c5e8be2d6ad766'
2 parents 9784f06 + 2b9f966 commit 22ad4a1

File tree

61 files changed

+276
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+276
-200
lines changed

.github/workflows/build-and-publish.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ jobs:
5353
sudo ln -s $(pwd)/HDF5-1.14.4.2-Linux/HDF_Group/HDF5/1.14.4.2/bin/h5dump /usr/bin/h5dump
5454
h5dump --version
5555
56+
- uses: actions/setup-dotnet@v5
57+
with:
58+
dotnet-version: '6.0.x'
59+
5660
- name: Build
5761
run: |
5862
dotnet build -c Release src/PureHDF/PureHDF.csproj
@@ -80,11 +84,12 @@ jobs:
8084
- name: Test (filters)
8185
run: dotnet test -c Release /p:BuildProjectReferences=false --filter "FullyQualifiedName~PureHDF.Tests.Filters"
8286

83-
- name: Test (HSDS)
84-
run: bash tests/PureHDF.Tests/Reading/PureHDF.VOL/run-hsds-tests.sh
87+
# Skip for now
88+
# - name: Test (HSDS)
89+
# run: bash tests/PureHDF.Tests/Reading/PureHDF.VOL/run-hsds-tests.sh
8590

8691
- name: Upload Artifacts
87-
uses: actions/upload-artifact@v3
92+
uses: actions/upload-artifact@v4
8893
with:
8994
name: artifacts
9095
path: |
@@ -119,7 +124,7 @@ jobs:
119124
steps:
120125

121126
- name: Download Artifacts
122-
uses: actions/download-artifact@v3
127+
uses: actions/download-artifact@v4
123128
with:
124129
name: artifacts
125130
path: artifacts
@@ -140,7 +145,7 @@ jobs:
140145
steps:
141146

142147
- name: Download Artifacts
143-
uses: actions/download-artifact@v3
148+
uses: actions/download-artifact@v4
144149
with:
145150
name: artifacts
146151
path: artifacts

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v2.1.2 - 2026-03-17
2+
3+
### Bugs fixed
4+
- The global heap collection was not read properly. (#153)
5+
16
## v2.1.1 - 2024-08-16
27

38
### Bugs fixed

src/PureHDF.SourceGenerator/PureHDF.SourceGenerator.sln

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/PureHDF/API.Writing/H5WriteOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace PureHDF;
88
/// <param name="DefaultStringLength">A value that indicates how strings are handled during serialization. A nonzero positve value means that strings are treated as fixed-length strings, otherwise they are variable-length strings. The default value is 0.</param>
99
/// <param name="MinimumGlobalHeapCollectionSize">A value that indicates the minimum size of a global heap collection in bytes. The default value is 4096 bytes which is the absolute minimum allowed size.</param>
1010
/// <param name="GlobalHeapFlushThreshold">A value that indicates the threshold after which global heap collections will be flushed. The default value is 4096 * 1024 = 4 MB.</param>
11+
/// <param name="UserBlockSize">Set the file user block size, in bytes. The default user block size is 0; it may be set to any power of 2 equal to 512 or greater (512, 1024, 2048, etc.).</param>
1112
/// <param name="PreferCompactDatasetLayout">A value that indicates whether the writer tries to use the compact layout for datasets if the total data size is &lt; 64 kB and it should not be chunked.</param>
1213
/// <param name="IncludeStructFields">A value that indicates whether struct fields are handled during serialization. The default value is <see langword="true"/>.</param>
1314
/// <param name="IncludeStructProperties">A value that indicates whether struct properties are handled during serialization. The default value is <see langword="false"/>.</param>
@@ -22,6 +23,7 @@ public record H5WriteOptions(
2223
int DefaultStringLength = default,
2324
int MinimumGlobalHeapCollectionSize = 4096,
2425
long GlobalHeapFlushThreshold = 4096 * 1024,
26+
ulong UserBlockSize = 0,
2527
bool PreferCompactDatasetLayout = true,
2628
bool IncludeStructFields = true,
2729
bool IncludeStructProperties = false,

src/PureHDF/Filters/ScaleOffsetGeneric.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ public static Memory<byte> Decompress(
6767
if (parameters.Sign == Sign.Unsigned)
6868
{
6969
if (parameters.Size == 1)
70-
PostdecompressByte(MemoryMarshal.Cast<byte, byte>(output), parameters, minbits, minval);
70+
PostdecompressByte(MemoryMarshal.Cast<byte, byte>(output.AsSpan()), parameters, minbits, minval);
7171

7272
else if (parameters.Size == 2)
73-
PostdecompressInteger(MemoryMarshal.Cast<byte, ushort>(output), parameters, minbits, minval);
73+
PostdecompressInteger(MemoryMarshal.Cast<byte, ushort>(output.AsSpan()), parameters, minbits, minval);
7474

7575
else if (parameters.Size == 4)
76-
PostdecompressInteger(MemoryMarshal.Cast<byte, uint>(output), parameters, minbits, minval);
76+
PostdecompressInteger(MemoryMarshal.Cast<byte, uint>(output.AsSpan()), parameters, minbits, minval);
7777

7878
else if (parameters.Size == 8)
79-
PostdecompressInteger(MemoryMarshal.Cast<byte, ulong>(output), parameters, minbits, minval);
79+
PostdecompressInteger(MemoryMarshal.Cast<byte, ulong>(output.AsSpan()), parameters, minbits, minval);
8080

8181
else
8282
throw new Exception("Unsupported data type.");
@@ -85,16 +85,16 @@ public static Memory<byte> Decompress(
8585
else
8686
{
8787
if (parameters.Size == 1)
88-
PostdecompressSByte(MemoryMarshal.Cast<byte, sbyte>(output), parameters, minbits, minval);
88+
PostdecompressSByte(MemoryMarshal.Cast<byte, sbyte>(output.AsSpan()), parameters, minbits, minval);
8989

9090
else if (parameters.Size == 2)
91-
PostdecompressInteger(MemoryMarshal.Cast<byte, short>(output), parameters, minbits, minval);
91+
PostdecompressInteger(MemoryMarshal.Cast<byte, short>(output.AsSpan()), parameters, minbits, minval);
9292

9393
else if (parameters.Size == 4)
94-
PostdecompressInteger(MemoryMarshal.Cast<byte, int>(output), parameters, minbits, minval);
94+
PostdecompressInteger(MemoryMarshal.Cast<byte, int>(output.AsSpan()), parameters, minbits, minval);
9595

9696
else if (parameters.Size == 8)
97-
PostdecompressInteger(MemoryMarshal.Cast<byte, long>(output), parameters, minbits, minval);
97+
PostdecompressInteger(MemoryMarshal.Cast<byte, long>(output.AsSpan()), parameters, minbits, minval);
9898

9999
else
100100
throw new Exception("Unsupported data type.");
@@ -106,10 +106,10 @@ public static Memory<byte> Decompress(
106106
if (parameters.ScaleType == ScaleType.FLOAT_DSCALE)
107107
{
108108
if (parameters.Size == 4)
109-
PostdecompressFloat32(MemoryMarshal.Cast<byte, float>(output), parameters, minbits, minval);
109+
PostdecompressFloat32(MemoryMarshal.Cast<byte, float>(output.AsSpan()), parameters, minbits, minval);
110110

111111
else if (parameters.Size == 8)
112-
PostdecompressFloat64(MemoryMarshal.Cast<byte, double>(output), parameters, minbits, minval);
112+
PostdecompressFloat64(MemoryMarshal.Cast<byte, double>(output.AsSpan()), parameters, minbits, minval);
113113

114114
else
115115
throw new Exception("Unsupported data type.");

src/PureHDF/VFD/H5DriverBase.Reading.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
internal abstract partial class H5DriverBase : IH5ReadStream
44
{
5-
private ulong _baseAddress;
6-
7-
public ulong BaseAddress { get => _baseAddress; }
5+
public ulong BaseAddress { get; private set; }
86

97
public abstract long Position { get; }
108
public abstract long Length { get; }
@@ -20,9 +18,14 @@ internal abstract partial class H5DriverBase : IH5ReadStream
2018
public abstract uint ReadUInt32();
2119
public abstract ulong ReadUInt64();
2220

21+
public void SeekRelativeToBaseAddress(long offset)
22+
{
23+
Seek((long)BaseAddress + offset, SeekOrigin.Begin);
24+
}
25+
2326
public void SetBaseAddress(ulong baseAddress)
2427
{
25-
_baseAddress = baseAddress;
28+
BaseAddress = baseAddress;
2629
}
2730

2831
#region IDisposable

src/PureHDF/VFD/H5FileHandleDriver.Reading.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public override void Seek(long offset, SeekOrigin seekOrigin)
2727
switch (seekOrigin)
2828
{
2929
case SeekOrigin.Begin:
30-
_position.Value = (long)BaseAddress + offset; break;
30+
_position.Value = offset; break;
3131

3232
case SeekOrigin.Current:
3333
_position.Value += offset; break;

src/PureHDF/VFD/H5MemoryMappedFileDriver.Reading.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public override void Seek(long offset, SeekOrigin seekOrigin)
2727
switch (seekOrigin)
2828
{
2929
case SeekOrigin.Begin:
30-
_position.Value = (long)BaseAddress + offset; break;
30+
_position.Value = offset; break;
3131

3232
case SeekOrigin.Current:
3333
_position.Value += offset; break;

src/PureHDF/VFD/H5StreamDriver.Reading.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public H5StreamDriver(Stream stream, bool leaveOpen)
2020
_leaveOpen = leaveOpen;
2121
}
2222

23-
public override long Position { get => _stream.Position - (long)BaseAddress; }
23+
public override long Position { get => _stream.Position; }
2424

2525
public override long Length => _stream.Length;
2626

@@ -29,7 +29,7 @@ public override void Seek(long offset, SeekOrigin seekOrigin)
2929
switch (seekOrigin)
3030
{
3131
case SeekOrigin.Begin:
32-
_stream.Seek((long)BaseAddress + offset, SeekOrigin.Begin);
32+
_stream.Seek(offset, SeekOrigin.Begin);
3333
break;
3434

3535
case SeekOrigin.Current:

src/PureHDF/VOL/Native/API.Reading/NativeFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ internal static NativeFile InternalOpen(
138138
throw new Exception($"The superblock of type '{superblock.GetType().Name}' is not supported.");
139139
}
140140

141-
driver.Seek((long)address, SeekOrigin.Begin);
141+
driver.SeekRelativeToBaseAddress((long)address);
142142

143143
var context = new NativeReadContext(
144144
driver,
@@ -174,7 +174,7 @@ public Selection Get(NativeRegionReference1 reference)
174174
if (reference.Equals(default))
175175
throw new Exception("The reference is invalid");
176176

177-
Context.Driver.Seek((long)reference.CollectionAddress, SeekOrigin.Begin);
177+
Context.Driver.SeekRelativeToBaseAddress((long)reference.CollectionAddress);
178178

179179
var globalHeapId = new ReadingGlobalHeapId(
180180
CollectionAddress: reference.CollectionAddress,

0 commit comments

Comments
 (0)