From e9f18e8d4ccef4d7e1793feded36951a2a654f22 Mon Sep 17 00:00:00 2001 From: James Mudd Date: Sun, 21 Jul 2024 14:51:03 +0100 Subject: [PATCH 1/9] Update url to https --- jhdf/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhdf/build.gradle b/jhdf/build.gradle index a0ff99d3..4afe7219 100644 --- a/jhdf/build.gradle +++ b/jhdf/build.gradle @@ -142,7 +142,7 @@ publishing { pom { name = 'jhdf' description = 'A pure Java HDF5 library' - url = 'http://jhdf.io/' + url = 'https://jhdf.io/' licenses { license { name = 'MIT License' From cf13a7d0214a4771b79778388cac0d891995a719 Mon Sep 17 00:00:00 2001 From: James Mudd Date: Sun, 21 Jul 2024 14:51:28 +0100 Subject: [PATCH 2/9] Remove pom that was for dependabot --- .github/pom.xml | 53 ------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 .github/pom.xml diff --git a/.github/pom.xml b/.github/pom.xml deleted file mode 100644 index e5331694..00000000 --- a/.github/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - 4.0.0 - io.jhdf - jhdf - 0.6.2 - jhdf - A pure Java HDF5 library - http://jhdf.io/ - - - MIT License - https://opensource.org/licenses/MIT - - - - - jamesmudd - James Mudd - james.mudd@gmail.com - - - - scm:git:git://github.com/jamesmudd/jhdf.git - scm:git:git://github.com/jamesmudd/jhdf.git - https://github.com/jamesmudd/jhdf.git - - - - org.slf4j - slf4j-api - 1.7.30 - runtime - - - org.apache.commons - commons-lang3 - 3.12.0 - runtime - - - com.ning - compress-lzf - 1.1 - runtime - - - \ No newline at end of file From cf81b0a4b9c25629829446a1d363618887e2190d Mon Sep 17 00:00:00 2001 From: James Mudd Date: Sun, 21 Jul 2024 14:52:02 +0100 Subject: [PATCH 3/9] Update version number to v0.8.0 --- jhdf/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhdf/build.gradle b/jhdf/build.gradle index 4afe7219..b3a7712a 100644 --- a/jhdf/build.gradle +++ b/jhdf/build.gradle @@ -27,7 +27,7 @@ plugins { // Variables group = 'io.jhdf' -version = '0.7.0' +version = '0.8.0' compileJava { sourceCompatibility = "1.8" From e39807d71015e414931f657ecac8da2b52f7b97d Mon Sep 17 00:00:00 2001 From: James Mudd Date: Sun, 21 Jul 2024 14:59:41 +0100 Subject: [PATCH 4/9] Add writing attributes example --- .../io/jhdf/examples/WriteAttributes.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 jhdf/src/main/java/io/jhdf/examples/WriteAttributes.java diff --git a/jhdf/src/main/java/io/jhdf/examples/WriteAttributes.java b/jhdf/src/main/java/io/jhdf/examples/WriteAttributes.java new file mode 100644 index 00000000..5f4b868a --- /dev/null +++ b/jhdf/src/main/java/io/jhdf/examples/WriteAttributes.java @@ -0,0 +1,35 @@ +/* + * This file is part of jHDF. A pure Java library for accessing HDF5 files. + * + * http://jhdf.io + * + * Copyright (c) 2024 James Mudd + * + * MIT License see 'LICENSE' file + */ +package io.jhdf.examples; + +import io.jhdf.HdfFile; +import io.jhdf.WritableHdfFile; +import io.jhdf.api.WritableGroup; +import io.jhdf.api.WritiableDataset; + +import java.nio.file.Paths; + +/** + * Example application for writing attributes + * + * @author James Mudd + */ +public class WriteAttributes { + public static void main(String[] args) { + try (WritableHdfFile hdfFile = HdfFile.write(Paths.get("attributes.hdf5"))) { + // write scalar attribute on the root group + hdfFile.putAttribute("example_group_attribute", 55.543); + + // Write a dataset + WritiableDataset dataset = hdfFile.putDataset("ints", new int[]{1, 2, 3, 4}); + dataset.putAttribute("example_ints_attribute", new int[] {1, 2, 3, 4}); + } + } +} From 39fe85f7325027c2453ac9d3efc9bed9d27eca48 Mon Sep 17 00:00:00 2001 From: James Mudd Date: Sun, 21 Jul 2024 14:59:56 +0100 Subject: [PATCH 5/9] Add javadoc to the WritableNode interface --- .../main/java/io/jhdf/api/WritableNode.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/jhdf/src/main/java/io/jhdf/api/WritableNode.java b/jhdf/src/main/java/io/jhdf/api/WritableNode.java index 38ee59fe..883c494f 100644 --- a/jhdf/src/main/java/io/jhdf/api/WritableNode.java +++ b/jhdf/src/main/java/io/jhdf/api/WritableNode.java @@ -14,8 +14,31 @@ public interface WritableNode extends Node { + /** + * Writes this node to the file. Not for general use + * + * @param hdfFileChannel The file channel to write this node to + * @param position The position in the file to write this node + * @return bytes written + */ long write(HdfFileChannel hdfFileChannel, long position); + /** + * Adds an attribute to this node + * + * @since v0.8.0 + * @param name The attributes name + * @param data The attributes data + * @return The attribute + */ Attribute putAttribute(String name, Object data); + + /** + * Removes an attribute from this node + * + * @since v0.8.0 + * @param name The attribute to remove + * @return The removed attribute + */ Attribute removeAttribute(String name); } From 82564957f379ff49854b080272c03274743a6e21 Mon Sep 17 00:00:00 2001 From: James Mudd Date: Sun, 21 Jul 2024 15:06:33 +0100 Subject: [PATCH 6/9] Update CHANGES.md --- CHANGES.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 0d6ead61..216df223 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,15 @@ # jHDF Change Log +## v0.8.0 - July 2024 +- Major writing support improvements + - Attributes can now be written https://github.com/jamesmudd/jhdf/issues/552 + - Full support for `byte`, `short`, `int`, `long`, `float`, `double` and wrapper classes as datasets and attributes https://github.com/jamesmudd/jhdf/discussions/587 + - Support for scalar datasets and attributes + - Much more complete API on writable objects, allowing introspection of data type and data layout and data space etc. +- Many test improvements for writing support +- Build and dependency updates +- Note: This may be the last release supporting Java 8 + ## v0.7.0 - May 2024 - Release adding HDF5 writing support! https://github.com/jamesmudd/jhdf/issues/354. Special thanks to [@thadguidry](https://github.com/thadguidry) for sponsoring this work. See [WriteHdf5.java](jhdf/src/main/java/io/jhdf/examples/WriteHdf5.java) for example usage. Supports - Groups From 90a26bc38cf7184dbec74c6050af862ea7ce65d6 Mon Sep 17 00:00:00 2001 From: James Mudd Date: Sun, 21 Jul 2024 19:58:43 +0100 Subject: [PATCH 7/9] Add tests for the writing examples --- .../io/jhdf/examples/WriteAttributesTest.java | 19 ++++++++++++++++++ .../java/io/jhdf/examples/WriteHdf5Test.java | 20 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 jhdf/src/test/java/io/jhdf/examples/WriteAttributesTest.java create mode 100644 jhdf/src/test/java/io/jhdf/examples/WriteHdf5Test.java diff --git a/jhdf/src/test/java/io/jhdf/examples/WriteAttributesTest.java b/jhdf/src/test/java/io/jhdf/examples/WriteAttributesTest.java new file mode 100644 index 00000000..4b4b1c74 --- /dev/null +++ b/jhdf/src/test/java/io/jhdf/examples/WriteAttributesTest.java @@ -0,0 +1,19 @@ +package io.jhdf.examples; + +import org.junit.jupiter.api.Test; + +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class WriteAttributesTest { + @Test + void testWriteAttributes() { + assertDoesNotThrow(() -> + WriteAttributes.main(new String[]{})); + + assertTrue(Files.exists(Paths.get("attributes.hdf5"))); + } +} diff --git a/jhdf/src/test/java/io/jhdf/examples/WriteHdf5Test.java b/jhdf/src/test/java/io/jhdf/examples/WriteHdf5Test.java new file mode 100644 index 00000000..4e5ad82d --- /dev/null +++ b/jhdf/src/test/java/io/jhdf/examples/WriteHdf5Test.java @@ -0,0 +1,20 @@ +package io.jhdf.examples; + +import org.junit.jupiter.api.Test; + +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class WriteHdf5Test { + + @Test + void testWriteHdf5() { + assertDoesNotThrow(() -> + WriteHdf5.main(new String[]{})); + + assertTrue(Files.exists(Paths.get("jhdf.hdf5"))); + } +} From a478cbf7a858279dce4594caf1d498266247bbde Mon Sep 17 00:00:00 2001 From: James Mudd Date: Sun, 21 Jul 2024 22:24:34 +0100 Subject: [PATCH 8/9] Fix headers --- .../test/java/io/jhdf/examples/WriteAttributesTest.java | 9 +++++++++ jhdf/src/test/java/io/jhdf/examples/WriteHdf5Test.java | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/jhdf/src/test/java/io/jhdf/examples/WriteAttributesTest.java b/jhdf/src/test/java/io/jhdf/examples/WriteAttributesTest.java index 4b4b1c74..7d193d00 100644 --- a/jhdf/src/test/java/io/jhdf/examples/WriteAttributesTest.java +++ b/jhdf/src/test/java/io/jhdf/examples/WriteAttributesTest.java @@ -1,3 +1,12 @@ +/* + * This file is part of jHDF. A pure Java library for accessing HDF5 files. + * + * http://jhdf.io + * + * Copyright (c) 2024 James Mudd + * + * MIT License see 'LICENSE' file + */ package io.jhdf.examples; import org.junit.jupiter.api.Test; diff --git a/jhdf/src/test/java/io/jhdf/examples/WriteHdf5Test.java b/jhdf/src/test/java/io/jhdf/examples/WriteHdf5Test.java index 4e5ad82d..759142d8 100644 --- a/jhdf/src/test/java/io/jhdf/examples/WriteHdf5Test.java +++ b/jhdf/src/test/java/io/jhdf/examples/WriteHdf5Test.java @@ -1,3 +1,12 @@ +/* + * This file is part of jHDF. A pure Java library for accessing HDF5 files. + * + * http://jhdf.io + * + * Copyright (c) 2024 James Mudd + * + * MIT License see 'LICENSE' file + */ package io.jhdf.examples; import org.junit.jupiter.api.Test; From 58776a9f860323988466082008697aff2bcc7312 Mon Sep 17 00:00:00 2001 From: James Mudd Date: Sun, 21 Jul 2024 22:30:14 +0100 Subject: [PATCH 9/9] Cleanup import --- jhdf/src/main/java/io/jhdf/examples/WriteAttributes.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jhdf/src/main/java/io/jhdf/examples/WriteAttributes.java b/jhdf/src/main/java/io/jhdf/examples/WriteAttributes.java index 5f4b868a..28b8d1ee 100644 --- a/jhdf/src/main/java/io/jhdf/examples/WriteAttributes.java +++ b/jhdf/src/main/java/io/jhdf/examples/WriteAttributes.java @@ -11,7 +11,6 @@ import io.jhdf.HdfFile; import io.jhdf.WritableHdfFile; -import io.jhdf.api.WritableGroup; import io.jhdf.api.WritiableDataset; import java.nio.file.Paths;