Skip to content

Pvt/main #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 110 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
7f86053
Refactor and cleanup
karlnicholas Mar 28, 2025
8936177
Refactor and cleanup
karlnicholas Mar 28, 2025
247ceb4
Refactor and cleanup
karlnicholas Mar 29, 2025
9af6734
Refactor and cleanup
karlnicholas Mar 29, 2025
a1973d9
All support multiple datasets and all types.
karlnicholas Mar 29, 2025
2f76e20
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
59c1d46
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
b2b7336
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
627da0a
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
3fbcec8
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
dfa50e6
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
97e1227
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
f0d4b8f
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
3ebf21f
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
5e3e197
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
ff64989
All support multiple datasets and all types.
karlnicholas Mar 30, 2025
9734c61
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
8a70131
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
2eb27d4
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
350e7c3
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
a09974e
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
26eb8e5
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
a313ed6
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
cc4b105
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
7aceb4f
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
0e9b296
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
d80bc33
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
fb81ce5
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
ecf57ba
All support multiple datasets and all types.
karlnicholas Mar 31, 2025
6cf3237
All support multiple datasets and all types.
karlnicholas Apr 1, 2025
7532300
All support multiple datasets and all types.
karlnicholas Apr 1, 2025
68b3a1a
All support multiple datasets and all types.
karlnicholas Apr 1, 2025
fb07a78
All support multiple datasets and all types.
karlnicholas Apr 2, 2025
bb75726
All support multiple datasets and all types.
karlnicholas Apr 2, 2025
6a682e7
All support multiple datasets and all types.
karlnicholas Apr 2, 2025
a68d82d
All support multiple datasets and all types.
karlnicholas Apr 2, 2025
280b0c3
All support multiple datasets and all types.
karlnicholas Apr 3, 2025
2327394
All support multiple datasets and all types.
karlnicholas Apr 3, 2025
5e9c349
All support multiple datasets and all types.
karlnicholas Apr 3, 2025
6d3edfd
All support multiple datasets and all types.
karlnicholas Apr 5, 2025
895ecbc
All support multiple datasets and all types.
karlnicholas Apr 5, 2025
c2c89bd
All support multiple datasets and all types.
karlnicholas Apr 5, 2025
69534d4
All support multiple datasets and all types.
karlnicholas Apr 5, 2025
8cfc0fe
All support multiple datasets and all types.
karlnicholas Apr 6, 2025
5b80eda
All support multiple datasets and all types.
karlnicholas Apr 6, 2025
3ab397d
All support multiple datasets and all types.
karlnicholas Apr 6, 2025
6c6d842
All support multiple datasets and all types.
karlnicholas Apr 7, 2025
cfa44f5
All support multiple datasets and all types.
karlnicholas Apr 7, 2025
25a7a2e
All support multiple datasets and all types.
karlnicholas Apr 8, 2025
d92a52a
All support multiple datasets and all types.
karlnicholas Apr 8, 2025
5fa5e6d
All support multiple datasets and all types.
karlnicholas Apr 8, 2025
0a9eb52
All support multiple datasets and all types.
karlnicholas Apr 8, 2025
05a6015
All support multiple datasets and all types.
karlnicholas Apr 8, 2025
ed7ff57
All support multiple datasets and all types.
karlnicholas Apr 9, 2025
eca9e1b
All support multiple datasets and all types.
karlnicholas Apr 9, 2025
4c320df
All support multiple datasets and all types.
karlnicholas Apr 9, 2025
05bb68c
All support multiple datasets and all types.
karlnicholas Apr 9, 2025
8f888e8
All support multiple datasets and all types.
karlnicholas Apr 9, 2025
6085363
All support multiple datasets and all types.
karlnicholas Apr 9, 2025
ba03158
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
6a94890
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
545054a
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
1151bab
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
fa6d131
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
dc257b0
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
5a89d08
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
07523e0
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
b7536cf
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
26781aa
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
333cf64
All support multiple datasets and all types.
karlnicholas Apr 10, 2025
595b6a3
All support multiple datasets and all types.
karlnicholas Apr 11, 2025
661bc74
All support multiple datasets and all types.
karlnicholas Apr 11, 2025
5807810
All support multiple datasets and all types.
karlnicholas Apr 11, 2025
3374343
All support multiple datasets and all types.
karlnicholas Apr 11, 2025
1bfe7d8
All support multiple datasets and all types.
karlnicholas Apr 11, 2025
a5d789c
All support multiple datasets and all types.
karlnicholas Apr 11, 2025
9e1258e
All support multiple datasets and all types.
karlnicholas Apr 11, 2025
7b8823d
Updates test cases
karlnicholas Apr 11, 2025
df2e8ca
Updates test cases
karlnicholas Apr 11, 2025
9f0de09
Updates test cases
karlnicholas Apr 12, 2025
eff247e
Write compound
karlnicholas Apr 12, 2025
802a833
Write compound
karlnicholas Apr 14, 2025
6801d88
Write compound
karlnicholas Apr 14, 2025
2699822
Write compound
karlnicholas Apr 15, 2025
57d0b71
Write compound
karlnicholas Apr 15, 2025
15c7fbb
Write compound
karlnicholas Apr 15, 2025
0954ea5
Write compound
karlnicholas Apr 15, 2025
6df483b
Write compound
karlnicholas Apr 15, 2025
1f1ffcf
Write compound
karlnicholas Apr 16, 2025
e8c04f3
Write compound
karlnicholas Apr 16, 2025
519591c
Write compound
karlnicholas Apr 16, 2025
182ded0
Write compound
karlnicholas Apr 16, 2025
7e1eaa8
Write compound
karlnicholas Apr 16, 2025
a038e54
Write compound
karlnicholas Apr 16, 2025
11a64ed
Write compound
karlnicholas Apr 17, 2025
d0fd82f
Write compound
karlnicholas Apr 17, 2025
fa8044a
Write compound
karlnicholas Apr 17, 2025
bc104b8
Write compound
karlnicholas Apr 17, 2025
15e3f5f
Write compound
karlnicholas Apr 17, 2025
1e245eb
Write compound
karlnicholas Apr 17, 2025
b6365a8
Write mutliple datasets
karlnicholas Apr 18, 2025
921fadb
Write mutliple datasets
karlnicholas Apr 18, 2025
66aab13
Write mutliple datasets
karlnicholas Apr 18, 2025
5528c69
Write mutliple datasets
karlnicholas Apr 18, 2025
9b99dd6
Write mutliple datasets
karlnicholas Apr 18, 2025
4dec16a
Write mutliple datasets
karlnicholas Apr 18, 2025
f39e1c8
Confirm commit works
karlnicholas Apr 20, 2025
ead0f1d
messing around with git
karlnicholas Apr 20, 2025
d3320a6
messing around with git
karlnicholas Apr 20, 2025
84e6095
working on Btree insertion
karlnicholas Apr 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ build/
/src/main/resources/*.h5
/src/main/resources/*.csv

*.h5
*.exe

/*.h5
hdf5/*/*.h5
Binary file added 3d_tictactoe.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions hdf5/alltypesexample/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "MINGW64",
"intelliSenseMode": "gcc-x64",
"compilerPath": "C:/msys64/mingw64/bin/g++.exe",
"includePath": [
"C:/msys64/mingw64/include/**",
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"_CONSOLE"
],
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
27 changes: 27 additions & 0 deletions hdf5/alltypesexample/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Active File",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "Build Active File"
}
]
}

59 changes: 59 additions & 0 deletions hdf5/alltypesexample/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"format": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"text_encoding": "cpp",
"typeinfo": "cpp",
"variant": "cpp"
}
}
29 changes: 29 additions & 0 deletions hdf5/alltypesexample/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Active File",
"type": "shell",
"command": "C:/msys64/mingw64/bin/g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.exe",
"-IC:/msys64/mingw64/include",
"-IC:/msys64/mingw64/include/hdf5",
"-LC:/msys64/mingw64/lib",
"-lhdf5_cpp",
"-lhdf5",
"-lz"
],
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Builds currently open file with HDF5 support"
}
]
}

102 changes: 102 additions & 0 deletions hdf5/alltypesexample/alltypesgpt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#include "hdf5.h"
#include <iostream>
#include <string>
#include <vector>
#include <cstring>

const char* FILENAME = "example.h5";
const char* DATASET = "/compound_example";

int main() {
// Define the struct that matches our compound type
struct Record {
int32_t fixed_point;
float floating_point;
int64_t time;
char str[16];
uint8_t bitfield;
uint8_t opaque;
int32_t nested_fixed;
hobj_ref_t reference;
uint8_t enum_val;
hvl_t var_len;
int array[3];
};

// Fill in one example record
Record record = {
42, // Fixed-Point
3.14f, // Floating-Point
1234567890LL, // Time
"Hello HDF5", // String (fixed-length)
0b10101010, // Bit field
0xFF, // Opaque
7, // Compound (nested)
{}, // Reference (set later)
1, // Enum
{}, // Variable-Length (set later)
{1, 2, 3} // Array
};

// Create file and dataspace
hid_t file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
hid_t space = H5Screate(H5S_SCALAR); // One record

// === Build compound datatype ===
hid_t str_type = H5Tcopy(H5T_C_S1);
H5Tset_size(str_type, 16);

hid_t bitfield_type = H5Tcopy(H5T_STD_B8LE);
hid_t opaque_type = H5Tcreate(H5T_OPAQUE, 1);
H5Tset_tag(opaque_type, "byte");

hid_t nested_type = H5Tcreate(H5T_COMPOUND, sizeof(int32_t));
H5Tinsert(nested_type, "nested_fixed", 0, H5T_NATIVE_INT32);

hid_t ref_type = H5T_STD_REF_OBJ;

hid_t enum_type = H5Tcreate(H5T_ENUM, sizeof(uint8_t));
uint8_t enum_val0 = 0, enum_val1 = 1;
H5Tenum_insert(enum_type, "ZERO", &enum_val0);
H5Tenum_insert(enum_type, "ONE", &enum_val1);

hid_t vlen_type = H5Tvlen_create(H5T_NATIVE_INT);
int vl_data[] = {10, 20, 30};
record.var_len.len = 3;
record.var_len.p = vl_data;

hid_t array_type = H5Tarray_create(H5T_NATIVE_INT, 1, (hsize_t[]){3});

hid_t compound_type = H5Tcreate(H5T_COMPOUND, sizeof(Record));
H5Tinsert(compound_type, "fixed_point", HOFFSET(Record, fixed_point), H5T_NATIVE_INT32);
H5Tinsert(compound_type, "floating_point", HOFFSET(Record, floating_point), H5T_NATIVE_FLOAT);
H5Tinsert(compound_type, "time", HOFFSET(Record, time), H5T_NATIVE_INT64);
H5Tinsert(compound_type, "string", HOFFSET(Record, str), str_type);
H5Tinsert(compound_type, "bitfield", HOFFSET(Record, bitfield), bitfield_type);
H5Tinsert(compound_type, "opaque", HOFFSET(Record, opaque), opaque_type);
H5Tinsert(compound_type, "compound", HOFFSET(Record, nested_fixed), nested_type);
H5Tinsert(compound_type, "reference", HOFFSET(Record, reference), ref_type);
H5Tinsert(compound_type, "enum", HOFFSET(Record, enum_val), enum_type);
H5Tinsert(compound_type, "vlen", HOFFSET(Record, var_len), vlen_type);
H5Tinsert(compound_type, "array", HOFFSET(Record, array), array_type);

// Write dummy object to reference
hid_t ref_space = H5Screate(H5S_SCALAR);
hid_t ref_dset = H5Dcreate(file, "/dummy", H5T_NATIVE_INT, ref_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Rcreate(&record.reference, file, "/dummy", H5R_OBJECT, -1);
H5Sclose(ref_space);
H5Dclose(ref_dset);

// Write the compound data
hid_t dset = H5Dcreate(file, DATASET, compound_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Dwrite(dset, compound_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, &record);

// Cleanup
H5Dclose(dset);
H5Sclose(space);
H5Tclose(compound_type);
H5Fclose(file);

std::cout << "Done. Wrote " << FILENAME << std::endl;
return 0;
}
108 changes: 108 additions & 0 deletions hdf5/alltypesexample/alltypesgrok.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#include <H5Cpp.h>
#include <H5Tpublic.h>
#include <cstring>
#include <iostream>

using namespace H5;
using namespace std;

struct Record {
int32_t fixed_point; // 4 bytes, offset 0
float floating_point; // 4 bytes, offset 4
int64_t time; // 8 bytes, offset 8
char string[16]; // 16 bytes, offset 16
uint8_t bit_field; // 1 byte, offset 32
uint8_t opaque[4]; // 4 bytes, offset 33
struct {
int16_t nested_int; // 2 bytes, offset 0 (relative)
double nested_double; // 8 bytes, offset 8 (padded)
} compound; // 16 bytes total, offset 40
hobj_ref_t reference; // 8 bytes, offset 56
int enumerated; // 4 bytes, offset 64
int array[3]; // 12 bytes, offset 68
hvl_t variable_length; // 16 bytes, offset 80
};

int main() {
cout << "sizeof(Record): " << sizeof(Record) << endl;
cout << "Offsets: " << HOFFSET(Record, fixed_point) << ", " << HOFFSET(Record, floating_point) << ", "
<< HOFFSET(Record, time) << ", " << HOFFSET(Record, string) << ", " << HOFFSET(Record, bit_field) << ", "
<< HOFFSET(Record, opaque) << ", " << HOFFSET(Record, compound) << ", " << HOFFSET(Record, compound.nested_int) << ", "
<< HOFFSET(Record, compound.nested_double) << ", " << HOFFSET(Record, reference) << ", " << HOFFSET(Record, enumerated) << ", "
<< HOFFSET(Record, array) << ", " << HOFFSET(Record, variable_length) << endl;

try {
H5File file("compound_example.h5", H5F_ACC_TRUNC);

// Create a simple dataset in the root group (like /dummy in example.h5)
hsize_t dims[1] = {1};
DataSpace scalar_space(1, dims);
DataSet dummy_dataset = file.createDataSet("/dummy", PredType::NATIVE_INT, scalar_space);
int dummy_value = 0;
dummy_dataset.write(&dummy_value, PredType::NATIVE_INT);

// Define the compound datatype
CompType compound_type(sizeof(Record));

compound_type.insertMember("fixed_point", HOFFSET(Record, fixed_point), PredType::NATIVE_INT32);
compound_type.insertMember("floating_point", HOFFSET(Record, floating_point), PredType::NATIVE_FLOAT);
compound_type.insertMember("time", HOFFSET(Record, time), PredType::NATIVE_INT64);
StrType str_type(PredType::C_S1, 16);
compound_type.insertMember("string", HOFFSET(Record, string), str_type);
IntType bitfield_type(H5Tcopy(H5T_STD_B8LE));
compound_type.insertMember("bit_field", HOFFSET(Record, bit_field), bitfield_type);
DataType opaque_type(H5T_OPAQUE, 4);
H5Tset_tag(opaque_type.getId(), "4-byte opaque data");
compound_type.insertMember("opaque", HOFFSET(Record, opaque), opaque_type);
CompType nested_type(static_cast<size_t>(16));
nested_type.insertMember("nested_int", 0, PredType::NATIVE_INT16);
nested_type.insertMember("nested_double", 8, PredType::NATIVE_DOUBLE);
compound_type.insertMember("compound", HOFFSET(Record, compound), nested_type);
compound_type.insertMember("reference", HOFFSET(Record, reference), PredType::STD_REF_OBJ);
EnumType enum_type(PredType::NATIVE_INT);
int val1 = 0, val2 = 1, val3 = 2;
enum_type.insert("LOW", &val1);
enum_type.insert("MEDIUM", &val2);
enum_type.insert("HIGH", &val3);
compound_type.insertMember("enumerated", HOFFSET(Record, enumerated), enum_type);
hsize_t array_dims[1] = {3};
ArrayType array_type(PredType::NATIVE_INT, 1, array_dims);
compound_type.insertMember("array", HOFFSET(Record, array), array_type);
VarLenType vlen_type(PredType::NATIVE_INT);
compound_type.insertMember("variable_length", HOFFSET(Record, variable_length), vlen_type);

// Create the dataset with the compound type
DataSpace dataspace(1, dims);
DataSet dataset = file.createDataSet("/myDataset", compound_type, dataspace);

// Prepare one record of data
Record data{};
data.fixed_point = 42;
data.floating_point = 3.14f;
data.time = 1698765432;
strcpy(data.string, "Hello HDF5!");
data.bit_field = 0b10101010; // 170, stored as a bitfield
memcpy(data.opaque, "ABCD", 4);
data.compound.nested_int = 123;
data.compound.nested_double = 2.718;
hid_t file_id = file.getId();
H5Rcreate(&data.reference, file_id, "/dummy", H5R_OBJECT, -1); // Point to /dummy dataset
data.enumerated = 1;
int vlen_data[3] = {10, 20, 30};
data.variable_length.p = vlen_data;
data.variable_length.len = 3;
data.array[0] = 1;
data.array[1] = 2;
data.array[2] = 3;

dataset.write(&data, compound_type);

cout << "HDF5 file created successfully with one compound record!" << endl;
}
catch (Exception& e) {
cerr << "Error: " << e.getDetailMsg() << endl;
return 1;
}

return 0;
}
Loading