24 lines
1.0 KiB
Go
24 lines
1.0 KiB
Go
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package io
|
|
|
|
import "testing"
|
|
|
|
// TestHDF5SetEstimateCapsTinyChunkTargets pins the node estimate's
|
|
// cap: the estimate is a starting buffer the write grows past by
|
|
// append, so a pathological chunk target of a couple of bytes must
|
|
// charge the dataset a bounded guess rather than a B-tree node, and
|
|
// its kilobyte of image, to every single data byte.
|
|
func TestHDF5SetEstimateCapsTinyChunkTargets(t *testing.T) {
|
|
s := &hdf5OutSet{path: "d", shape: []int{1 << 20}, class: 1, width: 8, nbytes: 8 << 20}
|
|
honest := hdf5SetEstimate(s, HDF5WriteOptions{ChunkBytes: 4096, Shuffle: true})
|
|
if honest <= int64(s.nbytes) || honest > 100<<20 {
|
|
t.Fatalf("the honest estimate is %d bytes for a %d-byte payload, want a bounded cover", honest, s.nbytes)
|
|
}
|
|
tiny := hdf5SetEstimate(s, HDF5WriteOptions{ChunkBytes: 2, Shuffle: true})
|
|
if tiny > 50<<20 {
|
|
t.Fatalf("a two-byte chunk target estimated %d bytes for a %d-byte payload", tiny, s.nbytes)
|
|
}
|
|
}
|