Develop clang format java (#1653)
This commit is contained in:
@@ -1,7 +1,20 @@
|
||||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
AlignConsecutiveAssignments: true
|
||||
BraceWrapping:
|
||||
AfterFunction: true
|
||||
#llvm10-11: AfterControlStatement: false - Never
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
#llvm11: BeforeLambdaBody: false
|
||||
#llvm11: BeforeWhile: false
|
||||
BreakBeforeBraces: Stroustrup
|
||||
BreakAfterJavaFieldAnnotations: true
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 110 # Update $max_trace_macro_line_len in bin/trace also
|
||||
IndentWidth: 4
|
||||
---
|
||||
Language: Cpp
|
||||
#llvm11: AlignConsecutiveBitFields: false
|
||||
AlignConsecutiveDeclarations: true
|
||||
AlignConsecutiveMacros: true
|
||||
@@ -22,17 +35,6 @@ AlwaysBreakAfterReturnType: AllDefinitions
|
||||
# - H5_ATTR_CONST
|
||||
# - H5_ATTR_PURE
|
||||
# - H5_ATTR_FALLTHROUGH
|
||||
BraceWrapping:
|
||||
AfterFunction: true
|
||||
#llvm10-11: AfterControlStatement: false - Never
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
#llvm11: BeforeLambdaBody: false
|
||||
#llvm11: BeforeWhile: false
|
||||
BreakBeforeBraces: Stroustrup
|
||||
BreakAfterJavaFieldAnnotations: true
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 110 # Update $max_trace_macro_line_len in bin/trace also
|
||||
ForEachMacros: ['ALL_MEMBERS', 'UNIQUE_MEMBERS']
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
@@ -55,7 +57,6 @@ IndentCaseLabels: true
|
||||
#llvm11: IndentCaseBlocks: false
|
||||
IndentGotoLabels: false
|
||||
#llvm11: IndentExternBlock: AfterExternBlock
|
||||
IndentWidth: 4
|
||||
#llvm11: InsertTrailingCommas: None
|
||||
MacroBlockBegin: "^BEGIN_FUNC"
|
||||
MacroBlockEnd: "^END_FUNC"
|
||||
@@ -92,5 +93,8 @@ StatementMacros:
|
||||
#llvm11: WhitespaceSensitiveMacros:
|
||||
#llvm11: - STRINGIZE
|
||||
#llvm11: - PP_STRINGIZE
|
||||
---
|
||||
Language: Java
|
||||
BreakAfterJavaFieldAnnotations: true
|
||||
JavaImportGroups: ['java', 'hdf', 'hdf.hdf5lib', 'org']
|
||||
...
|
||||
|
||||
|
||||
4
.github/workflows/clang-format-check.yml
vendored
4
.github/workflows/clang-format-check.yml
vendored
@@ -8,11 +8,11 @@ jobs:
|
||||
if: "!contains(github.event.head_commit.message, 'skip-ci')"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run clang-format style check for C programs.
|
||||
- name: Run clang-format style check for C and java programs.
|
||||
uses: DoozyX/clang-format-lint-action@v0.11
|
||||
with:
|
||||
source: '.'
|
||||
extensions: 'c,h,cpp,hpp'
|
||||
extensions: 'c,h,cpp,hpp,java'
|
||||
clangFormatVersion: 10
|
||||
style: file
|
||||
exclude: './config ./hl/src/H5LTanalyze.c ./hl/src/H5LTparse.c ./hl/src/H5LTparse.h ./src/H5Epubgen.h ./src/H5Einit.h ./src/H5Eterm.h ./src/H5Edefin.h ./src/H5version.h ./src/H5overflow.h'
|
||||
|
||||
4
.github/workflows/clang-format-fix.yml
vendored
4
.github/workflows/clang-format-fix.yml
vendored
@@ -9,11 +9,11 @@ jobs:
|
||||
if: "!contains(github.event.head_commit.message, 'skip-ci')"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run clang-format style check for C programs.
|
||||
- name: Run clang-format style check for C and Java programs.
|
||||
uses: DoozyX/clang-format-lint-action@v0.11
|
||||
with:
|
||||
source: '.'
|
||||
extensions: 'c,h,cpp,hpp'
|
||||
extensions: 'c,h,cpp,hpp,java'
|
||||
clangFormatVersion: 10
|
||||
inplace: True
|
||||
style: file
|
||||
|
||||
@@ -20,7 +20,7 @@ find . \( -type d -path ./config -prune -and -not -path ./config \) \
|
||||
-or -name H5version.h \
|
||||
-or -name H5overflow.h \
|
||||
\) \) \
|
||||
-and \( -iname *.h -or -iname *.c -or -iname *.cpp -or -iname *.hpp \) \) \
|
||||
-and \( -iname *.h -or -iname *.c -or -iname *.cpp -or -iname *.hpp -or -iname *.java \) \) \
|
||||
| xargs clang-format -style=file -i -fallback-style=none
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -20,7 +20,7 @@ find . \( -type d -path ./config -prune -and -not -path ./config \) \
|
||||
-or -name H5version.h \
|
||||
-or -name H5overflow.h \
|
||||
\) \) \
|
||||
-and \( -iname *.h -or -iname *.c -or -iname *.cpp -or -iname *.hpp \) \) \
|
||||
-and \( -iname *.h -or -iname *.c -or -iname *.cpp -or -iname *.hpp -or -iname *.java \) \) \
|
||||
| xargs clang-format -style=file -i -fallback-style=none
|
||||
|
||||
git diff > clang_format.patch
|
||||
|
||||
@@ -62,6 +62,13 @@ foreach (example ${HDF_JAVA_EXAMPLES})
|
||||
# install_jar (${example} ${HJAVA_INSTALL_DATA_DIR}/examples examples)
|
||||
get_target_property (${example}_CLASSPATH ${example} CLASSDIR)
|
||||
add_dependencies (${example} ${HDF5_JAVA_HDF5_LIB_TARGET})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target to clang-format
|
||||
#-----------------------------------------------------------------------------
|
||||
if (HDF5_ENABLE_FORMATTERS)
|
||||
clang_format (HDF5_JAVA_${example}_SRC_FORMAT ${example}.java)
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
set (CMAKE_JAVA_INCLUDE_PATH "${HDF5_JAVA_JARS};${HDF5_JAVA_LOGGING_JAR};${HDF5_JAVA_LOGGING_NOP_JAR}")
|
||||
|
||||
@@ -29,49 +29,47 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Alloc {
|
||||
private static String FILENAME = "H5Ex_D_Alloc.h5";
|
||||
private static String FILENAME = "H5Ex_D_Alloc.h5";
|
||||
private static String DATASETNAME1 = "DS1";
|
||||
private static String DATASETNAME2 = "DS2";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int FILLVAL = 99;
|
||||
private static final int RANK = 2;
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int FILLVAL = 99;
|
||||
private static final int RANK = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5D_space_status {
|
||||
H5D_SPACE_STATUS_ERROR(-1), H5D_SPACE_STATUS_NOT_ALLOCATED(0), H5D_SPACE_STATUS_PART_ALLOCATED(1), H5D_SPACE_STATUS_ALLOCATED(
|
||||
2);
|
||||
H5D_SPACE_STATUS_ERROR(-1),
|
||||
H5D_SPACE_STATUS_NOT_ALLOCATED(0),
|
||||
H5D_SPACE_STATUS_PART_ALLOCATED(1),
|
||||
H5D_SPACE_STATUS_ALLOCATED(2);
|
||||
private static final Map<Integer, H5D_space_status> lookup = new HashMap<Integer, H5D_space_status>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5D_space_status s : EnumSet.allOf(H5D_space_status.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5D_space_status(int space_status) {
|
||||
this.code = space_status;
|
||||
}
|
||||
H5D_space_status(int space_status) { this.code = space_status; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5D_space_status get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5D_space_status get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static void allocation() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void allocation()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id1 = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id2 = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long dataset_id1 = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id2 = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
int space_status = 0;
|
||||
int space_status = 0;
|
||||
long storage_size = 0;
|
||||
|
||||
// Initialize the dataset.
|
||||
@@ -82,7 +80,7 @@ public class H5Ex_D_Alloc {
|
||||
// Create a file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -125,7 +123,8 @@ public class H5Ex_D_Alloc {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0))
|
||||
dataset_id1 = H5.H5Dcreate(file_id, DATASETNAME1, HDF5Constants.H5T_NATIVE_INT, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -135,7 +134,7 @@ public class H5Ex_D_Alloc {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id2 = H5.H5Dcreate(file_id, DATASETNAME2, HDF5Constants.H5T_NATIVE_INT, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -190,16 +189,16 @@ public class H5Ex_D_Alloc {
|
||||
// Write the data to the datasets.
|
||||
try {
|
||||
if (dataset_id1 >= 0)
|
||||
H5.H5Dwrite(dataset_id1, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data[0]);
|
||||
H5.H5Dwrite(dataset_id1, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data[0]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (dataset_id2 >= 0)
|
||||
H5.H5Dwrite(dataset_id2, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data[0]);
|
||||
H5.H5Dwrite(dataset_id2, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data[0]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -291,8 +290,5 @@ public class H5Ex_D_Alloc {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5Ex_D_Alloc.allocation();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5Ex_D_Alloc.allocation(); }
|
||||
}
|
||||
|
||||
@@ -30,42 +30,46 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Checksum {
|
||||
private static String FILENAME = "H5Ex_D_Checksum.h5";
|
||||
private static String FILENAME = "H5Ex_D_Checksum.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5Z_filter {
|
||||
H5Z_FILTER_ERROR(-1), H5Z_FILTER_NONE(0), H5Z_FILTER_DEFLATE(1), H5Z_FILTER_SHUFFLE(2), H5Z_FILTER_FLETCHER32(3), H5Z_FILTER_SZIP(
|
||||
4), H5Z_FILTER_NBIT(5), H5Z_FILTER_SCALEOFFSET(6), H5Z_FILTER_RESERVED(256), H5Z_FILTER_MAX(65535);
|
||||
H5Z_FILTER_ERROR(-1),
|
||||
H5Z_FILTER_NONE(0),
|
||||
H5Z_FILTER_DEFLATE(1),
|
||||
H5Z_FILTER_SHUFFLE(2),
|
||||
H5Z_FILTER_FLETCHER32(3),
|
||||
H5Z_FILTER_SZIP(4),
|
||||
H5Z_FILTER_NBIT(5),
|
||||
H5Z_FILTER_SCALEOFFSET(6),
|
||||
H5Z_FILTER_RESERVED(256),
|
||||
H5Z_FILTER_MAX(65535);
|
||||
private static final Map<Integer, H5Z_filter> lookup = new HashMap<Integer, H5Z_filter>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5Z_filter s : EnumSet.allOf(H5Z_filter.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5Z_filter(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5Z_filter(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5Z_filter get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5Z_filter get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static boolean checkFletcher32Filter() {
|
||||
private static boolean checkFletcher32Filter()
|
||||
{
|
||||
try {
|
||||
int available = H5.H5Zfilter_avail(H5Z_filter.H5Z_FILTER_FLETCHER32.getCode());
|
||||
if (available == 0) {
|
||||
@@ -79,8 +83,8 @@ public class H5Ex_D_Checksum {
|
||||
|
||||
try {
|
||||
int filter_info = H5.H5Zget_filter_info(HDF5Constants.H5Z_FILTER_FLETCHER32);
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0)
|
||||
|| ((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) ||
|
||||
((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
System.out.println("N-Bit filter not available for encoding and decoding.");
|
||||
return false;
|
||||
}
|
||||
@@ -91,13 +95,14 @@ public class H5Ex_D_Checksum {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void writeChecksum() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeChecksum()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data.
|
||||
@@ -108,7 +113,7 @@ public class H5Ex_D_Checksum {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -140,7 +145,7 @@ public class H5Ex_D_Checksum {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -149,8 +154,8 @@ public class H5Ex_D_Checksum {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -191,10 +196,11 @@ public class H5Ex_D_Checksum {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readChecksum() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readChecksum()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open an existing file.
|
||||
@@ -228,14 +234,14 @@ public class H5Ex_D_Checksum {
|
||||
try {
|
||||
if (dcpl_id >= 0) {
|
||||
// Java lib requires a valid filter_name object and cd_values
|
||||
int[] flags = { 0 };
|
||||
long[] cd_nelmts = { 1 };
|
||||
int[] cd_values = { 0 };
|
||||
String[] filter_name = { "" };
|
||||
int[] filter_config = { 0 };
|
||||
int filter_type = -1;
|
||||
filter_type = H5
|
||||
.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name, filter_config);
|
||||
int[] flags = {0};
|
||||
long[] cd_nelmts = {1};
|
||||
int[] cd_values = {0};
|
||||
String[] filter_name = {""};
|
||||
int[] filter_config = {0};
|
||||
int filter_type = -1;
|
||||
filter_type = H5.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name,
|
||||
filter_config);
|
||||
System.out.print("Filter type is: ");
|
||||
switch (H5Z_filter.get(filter_type)) {
|
||||
case H5Z_FILTER_DEFLATE:
|
||||
@@ -264,7 +270,7 @@ public class H5Ex_D_Checksum {
|
||||
try {
|
||||
if (dataset_id >= 0) {
|
||||
int status = H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
// Check if the read was successful. Normally we do not perform
|
||||
// error checking in these examples for the sake of clarity, but in
|
||||
// this case we will make an exception because this is how the
|
||||
@@ -328,7 +334,8 @@ public class H5Ex_D_Checksum {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Check if the Fletcher32 filter is available and can be used for
|
||||
// both encoding and decoding. Normally we do not perform error
|
||||
// checking in these examples for the sake of clarity, but in this
|
||||
@@ -340,5 +347,4 @@ public class H5Ex_D_Checksum {
|
||||
H5Ex_D_Checksum.readChecksum();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,47 +30,48 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Chunk {
|
||||
private static String FILENAME = "H5Ex_D_Chunk.h5";
|
||||
private static String FILENAME = "H5Ex_D_Chunk.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 6;
|
||||
private static final int DIM_Y = 8;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 4;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 6;
|
||||
private static final int DIM_Y = 8;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 4;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5D_layout {
|
||||
H5D_LAYOUT_ERROR(-1), H5D_COMPACT(0), H5D_CONTIGUOUS(1), H5D_CHUNKED(2), H5D_VIRTUAL(3), H5D_NLAYOUTS(4);
|
||||
H5D_LAYOUT_ERROR(-1),
|
||||
H5D_COMPACT(0),
|
||||
H5D_CONTIGUOUS(1),
|
||||
H5D_CHUNKED(2),
|
||||
H5D_VIRTUAL(3),
|
||||
H5D_NLAYOUTS(4);
|
||||
private static final Map<Integer, H5D_layout> lookup = new HashMap<Integer, H5D_layout>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5D_layout s : EnumSet.allOf(H5D_layout.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5D_layout(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5D_layout(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5D_layout get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5D_layout get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static void writeChunk() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeChunk()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data to "1", to make it easier to see the selections.
|
||||
@@ -91,7 +92,7 @@ public class H5Ex_D_Chunk {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -127,20 +128,21 @@ public class H5Ex_D_Chunk {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Define and select the first part of the hyperslab selection.
|
||||
long[] start = { 0, 0 };
|
||||
long[] stride = { 3, 3 };
|
||||
long[] count = { 2, 3 };
|
||||
long[] block = { 2, 2 };
|
||||
long[] start = {0, 0};
|
||||
long[] stride = {3, 3};
|
||||
long[] count = {2, 3};
|
||||
long[] block = {2, 2};
|
||||
try {
|
||||
if ((filespace_id >= 0))
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_SET, start, stride, count, block);
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_SET, start, stride, count,
|
||||
block);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -152,12 +154,13 @@ public class H5Ex_D_Chunk {
|
||||
block[1] = 1;
|
||||
try {
|
||||
if ((filespace_id >= 0)) {
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_NOTB, start, stride, count, block);
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_NOTB, start, stride, count,
|
||||
block);
|
||||
|
||||
// Write the data to the dataset.
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -199,11 +202,12 @@ public class H5Ex_D_Chunk {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readChunk() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readChunk()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open an existing file.
|
||||
@@ -267,8 +271,8 @@ public class H5Ex_D_Chunk {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -294,18 +298,19 @@ public class H5Ex_D_Chunk {
|
||||
if (dataset_id >= 0) {
|
||||
filespace_id = H5.H5Dget_space(dataset_id);
|
||||
|
||||
long[] start = { 0, 1 };
|
||||
long[] stride = { 4, 4 };
|
||||
long[] count = { 2, 2 };
|
||||
long[] block = { 2, 3 };
|
||||
long[] start = {0, 1};
|
||||
long[] stride = {4, 4};
|
||||
long[] count = {2, 2};
|
||||
long[] block = {2, 3};
|
||||
|
||||
if (filespace_id >= 0) {
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_SET, start, stride, count, block);
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_SET, start, stride, count,
|
||||
block);
|
||||
|
||||
// Read the data using the previously defined hyperslab.
|
||||
if ((dataset_id >= 0) && (filespace_id >= 0))
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
filespace_id, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,9 +363,9 @@ public class H5Ex_D_Chunk {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_D_Chunk.writeChunk();
|
||||
H5Ex_D_Chunk.readChunk();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,43 +27,44 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Compact {
|
||||
private static String FILENAME = "H5Ex_D_Compact.h5";
|
||||
private static String FILENAME = "H5Ex_D_Compact.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int RANK = 2;
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int RANK = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5D_layout {
|
||||
H5D_LAYOUT_ERROR(-1), H5D_COMPACT(0), H5D_CONTIGUOUS(1), H5D_CHUNKED(2), H5D_VIRTUAL(3), H5D_NLAYOUTS(4);
|
||||
H5D_LAYOUT_ERROR(-1),
|
||||
H5D_COMPACT(0),
|
||||
H5D_CONTIGUOUS(1),
|
||||
H5D_CHUNKED(2),
|
||||
H5D_VIRTUAL(3),
|
||||
H5D_NLAYOUTS(4);
|
||||
private static final Map<Integer, H5D_layout> lookup = new HashMap<Integer, H5D_layout>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5D_layout s : EnumSet.allOf(H5D_layout.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5D_layout(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5D_layout(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5D_layout get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5D_layout get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static void writeCompact() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeCompact()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data.
|
||||
@@ -74,7 +75,7 @@ public class H5Ex_D_Compact {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -110,7 +111,7 @@ public class H5Ex_D_Compact {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -119,8 +120,8 @@ public class H5Ex_D_Compact {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -161,11 +162,12 @@ public class H5Ex_D_Compact {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readCompact() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readCompact()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open file and dataset using the default properties.
|
||||
@@ -229,8 +231,8 @@ public class H5Ex_D_Compact {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -281,9 +283,9 @@ public class H5Ex_D_Compact {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_D_Compact.writeCompact();
|
||||
H5Ex_D_Compact.readCompact();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,20 +24,21 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_External {
|
||||
private static String FILENAME = "H5Ex_D_External.h5";
|
||||
private static String EXTERNALNAME = "H5Ex_D_External.data";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int RANK = 2;
|
||||
private static String FILENAME = "H5Ex_D_External.h5";
|
||||
private static String EXTERNALNAME = "H5Ex_D_External.data";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int RANK = 2;
|
||||
private static final int NAME_BUF_SIZE = 32;
|
||||
|
||||
private static void writeExternal() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeExternal()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize the dataset.
|
||||
@@ -48,7 +49,7 @@ public class H5Ex_D_External {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -84,7 +85,7 @@ public class H5Ex_D_External {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -92,8 +93,8 @@ public class H5Ex_D_External {
|
||||
|
||||
// Write the dataset.
|
||||
try {
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -133,15 +134,15 @@ public class H5Ex_D_External {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void readExternal() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readExternal()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
String[] Xname = new String[1];
|
||||
String[] Xname = new String[1];
|
||||
|
||||
// Open file using the default properties.
|
||||
try {
|
||||
@@ -183,8 +184,8 @@ public class H5Ex_D_External {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -227,9 +228,9 @@ public class H5Ex_D_External {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_D_External.writeExternal();
|
||||
H5Ex_D_External.readExternal();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,29 +26,30 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_FillValue {
|
||||
private static String FILENAME = "H5Ex_D_FillValue.h5";
|
||||
private static String FILENAME = "H5Ex_D_FillValue.h5";
|
||||
private static String DATASETNAME = "ExtendibleArray";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int EDIM_X = 6;
|
||||
private static final int EDIM_Y = 10;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 4;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int FILLVAL = 99;
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int EDIM_X = 6;
|
||||
private static final int EDIM_Y = 10;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 4;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int FILLVAL = 99;
|
||||
|
||||
private static void fillValue() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] extdims = { EDIM_X, EDIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long[] maxdims = { HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED };
|
||||
int[][] write_dset_data = new int[DIM_X][DIM_Y];
|
||||
int[][] read_dset_data = new int[DIM_X][DIM_Y];
|
||||
private static void fillValue()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] extdims = {EDIM_X, EDIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
long[] maxdims = {HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED};
|
||||
int[][] write_dset_data = new int[DIM_X][DIM_Y];
|
||||
int[][] read_dset_data = new int[DIM_X][DIM_Y];
|
||||
int[][] extend_dset_data = new int[EDIM_X][EDIM_Y];
|
||||
|
||||
// Initialize the dataset.
|
||||
@@ -59,7 +60,7 @@ public class H5Ex_D_FillValue {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -92,7 +93,7 @@ public class H5Ex_D_FillValue {
|
||||
|
||||
// Set the fill value for the dataset
|
||||
try {
|
||||
int[] fill_value = { FILLVAL };
|
||||
int[] fill_value = {FILLVAL};
|
||||
if (dcpl_id >= 0)
|
||||
H5.H5Pset_fill_value(dcpl_id, HDF5Constants.H5T_NATIVE_INT, fill_value);
|
||||
}
|
||||
@@ -115,7 +116,7 @@ public class H5Ex_D_FillValue {
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -124,8 +125,8 @@ public class H5Ex_D_FillValue {
|
||||
// Read values from the dataset, which has not been written to yet.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, read_dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, read_dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -144,8 +145,8 @@ public class H5Ex_D_FillValue {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, write_dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, write_dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -154,8 +155,8 @@ public class H5Ex_D_FillValue {
|
||||
// Read the data back.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, read_dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, read_dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -183,8 +184,8 @@ public class H5Ex_D_FillValue {
|
||||
// Read from the extended dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, extend_dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, extend_dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -233,11 +234,7 @@ public class H5Ex_D_FillValue {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5Ex_D_FillValue.fillValue();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5Ex_D_FillValue.fillValue(); }
|
||||
}
|
||||
|
||||
@@ -29,45 +29,46 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Gzip {
|
||||
private static String FILENAME = "H5Ex_D_Gzip.h5";
|
||||
private static String FILENAME = "H5Ex_D_Gzip.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5Z_filter {
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR), H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE), H5Z_FILTER_DEFLATE(
|
||||
HDF5Constants.H5Z_FILTER_DEFLATE), H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE), H5Z_FILTER_FLETCHER32(
|
||||
HDF5Constants.H5Z_FILTER_FLETCHER32), H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP), H5Z_FILTER_NBIT(
|
||||
HDF5Constants.H5Z_FILTER_NBIT), H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET), H5Z_FILTER_RESERVED(
|
||||
HDF5Constants.H5Z_FILTER_RESERVED), H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR),
|
||||
H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE),
|
||||
H5Z_FILTER_DEFLATE(HDF5Constants.H5Z_FILTER_DEFLATE),
|
||||
H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE),
|
||||
H5Z_FILTER_FLETCHER32(HDF5Constants.H5Z_FILTER_FLETCHER32),
|
||||
H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP),
|
||||
H5Z_FILTER_NBIT(HDF5Constants.H5Z_FILTER_NBIT),
|
||||
H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET),
|
||||
H5Z_FILTER_RESERVED(HDF5Constants.H5Z_FILTER_RESERVED),
|
||||
H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
private static final Map<Integer, H5Z_filter> lookup = new HashMap<Integer, H5Z_filter>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5Z_filter s : EnumSet.allOf(H5Z_filter.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5Z_filter(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5Z_filter(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5Z_filter get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5Z_filter get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static boolean checkGzipFilter() {
|
||||
private static boolean checkGzipFilter()
|
||||
{
|
||||
try {
|
||||
int available = H5.H5Zfilter_avail(HDF5Constants.H5Z_FILTER_DEFLATE);
|
||||
if (available == 0) {
|
||||
@@ -81,8 +82,8 @@ public class H5Ex_D_Gzip {
|
||||
|
||||
try {
|
||||
int filter_info = H5.H5Zget_filter_info(HDF5Constants.H5Z_FILTER_DEFLATE);
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0)
|
||||
|| ((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) ||
|
||||
((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
System.out.println("gzip filter not available for encoding and decoding.");
|
||||
return false;
|
||||
}
|
||||
@@ -93,13 +94,14 @@ public class H5Ex_D_Gzip {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void writeGzip() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeGzip()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data.
|
||||
@@ -110,7 +112,7 @@ public class H5Ex_D_Gzip {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -143,7 +145,7 @@ public class H5Ex_D_Gzip {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -152,8 +154,8 @@ public class H5Ex_D_Gzip {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -194,10 +196,11 @@ public class H5Ex_D_Gzip {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readGzip() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readGzip()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open an existing file.
|
||||
@@ -231,14 +234,14 @@ public class H5Ex_D_Gzip {
|
||||
try {
|
||||
if (dcpl_id >= 0) {
|
||||
// Java lib requires a valid filter_name object and cd_values
|
||||
int[] flags = { 0 };
|
||||
long[] cd_nelmts = { 1 };
|
||||
int[] cd_values = { 0 };
|
||||
String[] filter_name = { "" };
|
||||
int[] filter_config = { 0 };
|
||||
int filter_type = -1;
|
||||
filter_type = H5
|
||||
.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name, filter_config);
|
||||
int[] flags = {0};
|
||||
long[] cd_nelmts = {1};
|
||||
int[] cd_values = {0};
|
||||
String[] filter_name = {""};
|
||||
int[] filter_config = {0};
|
||||
int filter_type = -1;
|
||||
filter_type = H5.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name,
|
||||
filter_config);
|
||||
System.out.print("Filter type is: ");
|
||||
switch (H5Z_filter.get(filter_type)) {
|
||||
case H5Z_FILTER_DEFLATE:
|
||||
@@ -272,8 +275,8 @@ public class H5Ex_D_Gzip {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0) {
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -318,7 +321,8 @@ public class H5Ex_D_Gzip {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Check if gzip compression is available and can be used for both
|
||||
// compression and decompression. Normally we do not perform error
|
||||
// checking in these examples for the sake of clarity, but in this
|
||||
@@ -329,5 +333,4 @@ public class H5Ex_D_Gzip {
|
||||
H5Ex_D_Gzip.readGzip();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,17 +26,18 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Hyperslab {
|
||||
private static String FILENAME = "H5Ex_D_Hyperslab.h5";
|
||||
private static String FILENAME = "H5Ex_D_Hyperslab.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 6;
|
||||
private static final int DIM_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int DIM_X = 6;
|
||||
private static final int DIM_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
|
||||
private static void writeHyperslab() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeHyperslab()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data to "1", to make it easier to see the selections.
|
||||
@@ -57,7 +58,7 @@ public class H5Ex_D_Hyperslab {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -76,20 +77,22 @@ public class H5Ex_D_Hyperslab {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Define and select the first part of the hyperslab selection.
|
||||
long[] start = { 0, 0 };
|
||||
long[] stride = { 3, 3 };
|
||||
long[] count = { 2, 3 };
|
||||
long[] block = { 2, 2 };
|
||||
long[] start = {0, 0};
|
||||
long[] stride = {3, 3};
|
||||
long[] count = {2, 3};
|
||||
long[] block = {2, 2};
|
||||
try {
|
||||
if ((filespace_id >= 0))
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_SET, start, stride, count, block);
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_SET, start, stride, count,
|
||||
block);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -101,12 +104,13 @@ public class H5Ex_D_Hyperslab {
|
||||
block[1] = 1;
|
||||
try {
|
||||
if ((filespace_id >= 0)) {
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_NOTB, start, stride, count, block);
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_NOTB, start, stride, count,
|
||||
block);
|
||||
|
||||
// Write the data to the dataset.
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -140,11 +144,12 @@ public class H5Ex_D_Hyperslab {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readHyperslab() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readHyperslab()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open an existing file.
|
||||
@@ -167,8 +172,8 @@ public class H5Ex_D_Hyperslab {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -194,18 +199,19 @@ public class H5Ex_D_Hyperslab {
|
||||
if (dataset_id >= 0) {
|
||||
filespace_id = H5.H5Dget_space(dataset_id);
|
||||
|
||||
long[] start = { 0, 1 };
|
||||
long[] stride = { 4, 4 };
|
||||
long[] count = { 2, 2 };
|
||||
long[] block = { 2, 3 };
|
||||
long[] start = {0, 1};
|
||||
long[] stride = {4, 4};
|
||||
long[] count = {2, 2};
|
||||
long[] block = {2, 3};
|
||||
|
||||
if (filespace_id >= 0) {
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_SET, start, stride, count, block);
|
||||
H5.H5Sselect_hyperslab(filespace_id, HDF5Constants.H5S_SELECT_SET, start, stride, count,
|
||||
block);
|
||||
|
||||
// Read the data using the previously defined hyperslab.
|
||||
if ((dataset_id >= 0) && (filespace_id >= 0))
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
filespace_id, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,9 +264,9 @@ public class H5Ex_D_Hyperslab {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_D_Hyperslab.writeHyperslab();
|
||||
H5Ex_D_Hyperslab.readHyperslab();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,45 +29,46 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Nbit {
|
||||
private static String FILENAME = "H5Ex_D_Nbit.h5";
|
||||
private static String FILENAME = "H5Ex_D_Nbit.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5Z_filter {
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR), H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE), H5Z_FILTER_DEFLATE(
|
||||
HDF5Constants.H5Z_FILTER_DEFLATE), H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE), H5Z_FILTER_FLETCHER32(
|
||||
HDF5Constants.H5Z_FILTER_FLETCHER32), H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP), H5Z_FILTER_NBIT(
|
||||
HDF5Constants.H5Z_FILTER_NBIT), H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET), H5Z_FILTER_RESERVED(
|
||||
HDF5Constants.H5Z_FILTER_RESERVED), H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR),
|
||||
H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE),
|
||||
H5Z_FILTER_DEFLATE(HDF5Constants.H5Z_FILTER_DEFLATE),
|
||||
H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE),
|
||||
H5Z_FILTER_FLETCHER32(HDF5Constants.H5Z_FILTER_FLETCHER32),
|
||||
H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP),
|
||||
H5Z_FILTER_NBIT(HDF5Constants.H5Z_FILTER_NBIT),
|
||||
H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET),
|
||||
H5Z_FILTER_RESERVED(HDF5Constants.H5Z_FILTER_RESERVED),
|
||||
H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
private static final Map<Integer, H5Z_filter> lookup = new HashMap<Integer, H5Z_filter>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5Z_filter s : EnumSet.allOf(H5Z_filter.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5Z_filter(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5Z_filter(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5Z_filter get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5Z_filter get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static boolean checkNbitFilter() {
|
||||
private static boolean checkNbitFilter()
|
||||
{
|
||||
try {
|
||||
// Check if N-Bit compression is available and can be used for both compression and decompression.
|
||||
int available = H5.H5Zfilter_avail(HDF5Constants.H5Z_FILTER_NBIT);
|
||||
@@ -82,8 +83,8 @@ public class H5Ex_D_Nbit {
|
||||
|
||||
try {
|
||||
int filter_info = H5.H5Zget_filter_info(HDF5Constants.H5Z_FILTER_NBIT);
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0)
|
||||
|| ((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) ||
|
||||
((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
System.out.println("N-Bit filter not available for encoding and decoding.");
|
||||
return false;
|
||||
}
|
||||
@@ -94,14 +95,15 @@ public class H5Ex_D_Nbit {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void writeData() throws Exception {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeData() throws Exception
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data.
|
||||
@@ -112,7 +114,7 @@ public class H5Ex_D_Nbit {
|
||||
try {
|
||||
// Create a new file using the default properties.
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
|
||||
// Create dataspace. Setting maximum size to NULL sets the maximum
|
||||
// size to be the current size.
|
||||
@@ -130,12 +132,12 @@ public class H5Ex_D_Nbit {
|
||||
H5.H5Pset_chunk(dcpl_id, NDIMS, chunk_dims);
|
||||
|
||||
// Create the dataset.
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, dtype_id, filespace_id, HDF5Constants.H5P_DEFAULT, dcpl_id,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, dtype_id, filespace_id, HDF5Constants.H5P_DEFAULT,
|
||||
dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
|
||||
// Write the data to the dataset.
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -155,10 +157,11 @@ public class H5Ex_D_Nbit {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readData() throws Exception {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readData() throws Exception
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open an existing file.
|
||||
@@ -192,14 +195,14 @@ public class H5Ex_D_Nbit {
|
||||
try {
|
||||
if (dcpl_id >= 0) {
|
||||
// Java lib requires a valid filter_name object and cd_values
|
||||
int[] flags = { 0 };
|
||||
long[] cd_nelmts = { 1 };
|
||||
int[] cd_values = { 0 };
|
||||
String[] filter_name = { "" };
|
||||
int[] filter_config = { 0 };
|
||||
int filter_type = -1;
|
||||
filter_type = H5
|
||||
.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name, filter_config);
|
||||
int[] flags = {0};
|
||||
long[] cd_nelmts = {1};
|
||||
int[] cd_values = {0};
|
||||
String[] filter_name = {""};
|
||||
int[] filter_config = {0};
|
||||
int filter_type = -1;
|
||||
filter_type = H5.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name,
|
||||
filter_config);
|
||||
System.out.print("Filter type is: ");
|
||||
switch (H5Z_filter.get(filter_type)) {
|
||||
case H5Z_FILTER_DEFLATE:
|
||||
@@ -234,7 +237,7 @@ public class H5Ex_D_Nbit {
|
||||
try {
|
||||
if (dataset_id >= 0) {
|
||||
int status = H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
// Check if the read was successful.
|
||||
if (status < 0)
|
||||
System.out.print("Dataset read failed!");
|
||||
@@ -280,14 +283,14 @@ public class H5Ex_D_Nbit {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
/*
|
||||
* Check if N-Bit compression is available and can be used for both compression and decompression. Normally we
|
||||
* do not perform error checking in these examples for the sake of clarity, but in this case we will make an
|
||||
* exception because this filter is an optional part of the hdf5 library.
|
||||
* Check if N-Bit compression is available and can be used for both compression and decompression.
|
||||
* Normally we do not perform error checking in these examples for the sake of clarity, but in this
|
||||
* case we will make an exception because this filter is an optional part of the hdf5 library.
|
||||
*/
|
||||
try {
|
||||
if (H5Ex_D_Nbit.checkNbitFilter()) {
|
||||
|
||||
@@ -24,17 +24,18 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_ReadWrite {
|
||||
private static String FILENAME = "H5Ex_D_ReadWrite.h5";
|
||||
private static String FILENAME = "H5Ex_D_ReadWrite.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int RANK = 2;
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int RANK = 2;
|
||||
|
||||
private static void WriteDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void WriteDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data.
|
||||
@@ -45,7 +46,7 @@ public class H5Ex_D_ReadWrite {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -64,7 +65,8 @@ public class H5Ex_D_ReadWrite {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -73,8 +75,8 @@ public class H5Ex_D_ReadWrite {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -107,9 +109,10 @@ public class H5Ex_D_ReadWrite {
|
||||
}
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open file using the default properties.
|
||||
@@ -132,8 +135,8 @@ public class H5Ex_D_ReadWrite {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -168,9 +171,9 @@ public class H5Ex_D_ReadWrite {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_D_ReadWrite.WriteDataset();
|
||||
H5Ex_D_ReadWrite.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,45 +30,46 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Shuffle {
|
||||
private static String FILENAME = "H5Ex_D_Shuffle.h5";
|
||||
private static String FILENAME = "H5Ex_D_Shuffle.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5Z_filter {
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR), H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE), H5Z_FILTER_DEFLATE(
|
||||
HDF5Constants.H5Z_FILTER_DEFLATE), H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE), H5Z_FILTER_FLETCHER32(
|
||||
HDF5Constants.H5Z_FILTER_FLETCHER32), H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP), H5Z_FILTER_NBIT(
|
||||
HDF5Constants.H5Z_FILTER_NBIT), H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET), H5Z_FILTER_RESERVED(
|
||||
HDF5Constants.H5Z_FILTER_RESERVED), H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR),
|
||||
H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE),
|
||||
H5Z_FILTER_DEFLATE(HDF5Constants.H5Z_FILTER_DEFLATE),
|
||||
H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE),
|
||||
H5Z_FILTER_FLETCHER32(HDF5Constants.H5Z_FILTER_FLETCHER32),
|
||||
H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP),
|
||||
H5Z_FILTER_NBIT(HDF5Constants.H5Z_FILTER_NBIT),
|
||||
H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET),
|
||||
H5Z_FILTER_RESERVED(HDF5Constants.H5Z_FILTER_RESERVED),
|
||||
H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
private static final Map<Integer, H5Z_filter> lookup = new HashMap<Integer, H5Z_filter>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5Z_filter s : EnumSet.allOf(H5Z_filter.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5Z_filter(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5Z_filter(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5Z_filter get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5Z_filter get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static boolean checkGzipFilter() {
|
||||
private static boolean checkGzipFilter()
|
||||
{
|
||||
try {
|
||||
int available = H5.H5Zfilter_avail(HDF5Constants.H5Z_FILTER_DEFLATE);
|
||||
if (available == 0) {
|
||||
@@ -82,8 +83,8 @@ public class H5Ex_D_Shuffle {
|
||||
|
||||
try {
|
||||
int filter_info = H5.H5Zget_filter_info(HDF5Constants.H5Z_FILTER_DEFLATE);
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0)
|
||||
|| ((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) ||
|
||||
((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
System.out.println("gzip filter not available for encoding and decoding.");
|
||||
return false;
|
||||
}
|
||||
@@ -94,7 +95,8 @@ public class H5Ex_D_Shuffle {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean checkShuffleFilter() {
|
||||
private static boolean checkShuffleFilter()
|
||||
{
|
||||
try {
|
||||
int available = H5.H5Zfilter_avail(HDF5Constants.H5Z_FILTER_SHUFFLE);
|
||||
if (available == 0) {
|
||||
@@ -108,8 +110,8 @@ public class H5Ex_D_Shuffle {
|
||||
|
||||
try {
|
||||
int filter_info = H5.H5Zget_filter_info(HDF5Constants.H5Z_FILTER_SHUFFLE);
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0)
|
||||
|| ((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) ||
|
||||
((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
System.out.println("Shuffle filter not available for encoding and decoding.");
|
||||
return false;
|
||||
}
|
||||
@@ -120,13 +122,14 @@ public class H5Ex_D_Shuffle {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void writeShuffle() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeShuffle()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data.
|
||||
@@ -137,7 +140,7 @@ public class H5Ex_D_Shuffle {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -176,7 +179,7 @@ public class H5Ex_D_Shuffle {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -185,8 +188,8 @@ public class H5Ex_D_Shuffle {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -227,10 +230,11 @@ public class H5Ex_D_Shuffle {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readShuffle() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readShuffle()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open an existing file.
|
||||
@@ -266,14 +270,14 @@ public class H5Ex_D_Shuffle {
|
||||
int nfilters = H5.H5Pget_nfilters(dcpl_id);
|
||||
for (int indx = 0; indx < nfilters; indx++) {
|
||||
// Java lib requires a valid filter_name object and cd_values
|
||||
int[] flags = { 0 };
|
||||
long[] cd_nelmts = { 1 };
|
||||
int[] cd_values = { 0 };
|
||||
String[] filter_name = { "" };
|
||||
int[] filter_config = { 0 };
|
||||
int filter_type = -1;
|
||||
filter_type = H5.H5Pget_filter(dcpl_id, indx, flags, cd_nelmts, cd_values, 120, filter_name,
|
||||
filter_config);
|
||||
int[] flags = {0};
|
||||
long[] cd_nelmts = {1};
|
||||
int[] cd_values = {0};
|
||||
String[] filter_name = {""};
|
||||
int[] filter_config = {0};
|
||||
int filter_type = -1;
|
||||
filter_type = H5.H5Pget_filter(dcpl_id, indx, flags, cd_nelmts, cd_values, 120,
|
||||
filter_name, filter_config);
|
||||
System.out.print("Filter " + indx + ": Type is: ");
|
||||
switch (H5Z_filter.get(filter_type)) {
|
||||
case H5Z_FILTER_DEFLATE:
|
||||
@@ -308,8 +312,8 @@ public class H5Ex_D_Shuffle {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0) {
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -354,7 +358,8 @@ public class H5Ex_D_Shuffle {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Check if gzip compression is available and can be used for both
|
||||
// compression and decompression. Normally we do not perform error
|
||||
// checking in these examples for the sake of clarity, but in this
|
||||
@@ -366,5 +371,4 @@ public class H5Ex_D_Shuffle {
|
||||
H5Ex_D_Shuffle.readShuffle();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ package examples.datasets;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Locale;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
@@ -33,45 +33,46 @@ import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Sofloat {
|
||||
|
||||
private static String FILENAME = "H5Ex_D_Sofloat.h5";
|
||||
private static String FILENAME = "H5Ex_D_Sofloat.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5Z_filter {
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR), H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE), H5Z_FILTER_DEFLATE(
|
||||
HDF5Constants.H5Z_FILTER_DEFLATE), H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE), H5Z_FILTER_FLETCHER32(
|
||||
HDF5Constants.H5Z_FILTER_FLETCHER32), H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP), H5Z_FILTER_NBIT(
|
||||
HDF5Constants.H5Z_FILTER_NBIT), H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET), H5Z_FILTER_RESERVED(
|
||||
HDF5Constants.H5Z_FILTER_RESERVED), H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR),
|
||||
H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE),
|
||||
H5Z_FILTER_DEFLATE(HDF5Constants.H5Z_FILTER_DEFLATE),
|
||||
H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE),
|
||||
H5Z_FILTER_FLETCHER32(HDF5Constants.H5Z_FILTER_FLETCHER32),
|
||||
H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP),
|
||||
H5Z_FILTER_NBIT(HDF5Constants.H5Z_FILTER_NBIT),
|
||||
H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET),
|
||||
H5Z_FILTER_RESERVED(HDF5Constants.H5Z_FILTER_RESERVED),
|
||||
H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
private static final Map<Integer, H5Z_filter> lookup = new HashMap<Integer, H5Z_filter>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5Z_filter s : EnumSet.allOf(H5Z_filter.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5Z_filter(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5Z_filter(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5Z_filter get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5Z_filter get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static boolean checkScaleoffsetFilter() {
|
||||
private static boolean checkScaleoffsetFilter()
|
||||
{
|
||||
try {
|
||||
int available = H5.H5Zfilter_avail(HDF5Constants.H5Z_FILTER_SCALEOFFSET);
|
||||
if (available == 0) {
|
||||
@@ -85,8 +86,8 @@ public class H5Ex_D_Sofloat {
|
||||
|
||||
try {
|
||||
int filter_info = H5.H5Zget_filter_info(HDF5Constants.H5Z_FILTER_SCALEOFFSET);
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0)
|
||||
|| ((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) ||
|
||||
((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
System.out.println("Scale-Offset filter not available for encoding and decoding.");
|
||||
return false;
|
||||
}
|
||||
@@ -97,20 +98,21 @@ public class H5Ex_D_Sofloat {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void writeData() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
private static void writeData()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
double[][] dset_data = new double[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data.
|
||||
for (int indx = 0; indx < DIM_X; indx++)
|
||||
for (int jndx = 0; jndx < DIM_Y; jndx++) {
|
||||
double x = indx;
|
||||
double y = jndx;
|
||||
double x = indx;
|
||||
double y = jndx;
|
||||
dset_data[indx][jndx] = (x + 1) / (y + 0.3) + y;
|
||||
}
|
||||
|
||||
@@ -133,7 +135,7 @@ public class H5Ex_D_Sofloat {
|
||||
// Create a new file using the default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -164,7 +166,7 @@ public class H5Ex_D_Sofloat {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_IEEE_F64LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -173,8 +175,8 @@ public class H5Ex_D_Sofloat {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -215,10 +217,11 @@ public class H5Ex_D_Sofloat {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readData() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readData()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
double[][] dset_data = new double[DIM_X][DIM_Y];
|
||||
|
||||
// Open file using the default properties.
|
||||
@@ -251,15 +254,15 @@ public class H5Ex_D_Sofloat {
|
||||
try {
|
||||
if (dcpl_id >= 0) {
|
||||
// Java lib requires a valid filter_name object and cd_values
|
||||
int[] flags = { 0 };
|
||||
long[] cd_nelmts = { 1 };
|
||||
int[] cd_values = { 0 };
|
||||
String[] filter_name = { "" };
|
||||
int[] filter_config = { 0 };
|
||||
int filter_type = -1;
|
||||
int[] flags = {0};
|
||||
long[] cd_nelmts = {1};
|
||||
int[] cd_values = {0};
|
||||
String[] filter_name = {""};
|
||||
int[] filter_config = {0};
|
||||
int filter_type = -1;
|
||||
|
||||
filter_type = H5
|
||||
.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name, filter_config);
|
||||
filter_type = H5.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name,
|
||||
filter_config);
|
||||
System.out.print("Filter type is: ");
|
||||
switch (H5Z_filter.get(filter_type)) {
|
||||
case H5Z_FILTER_DEFLATE:
|
||||
@@ -293,8 +296,8 @@ public class H5Ex_D_Sofloat {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -343,7 +346,8 @@ public class H5Ex_D_Sofloat {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
// Check if Scale-Offset compression is available and can be used
|
||||
// for both compression and decompression. Normally we do not
|
||||
|
||||
@@ -30,45 +30,46 @@ import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Soint {
|
||||
|
||||
private static String FILENAME = "H5Ex_D_Soint.h5";
|
||||
private static String FILENAME = "H5Ex_D_Soint.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5Z_filter {
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR), H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE), H5Z_FILTER_DEFLATE(
|
||||
HDF5Constants.H5Z_FILTER_DEFLATE), H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE), H5Z_FILTER_FLETCHER32(
|
||||
HDF5Constants.H5Z_FILTER_FLETCHER32), H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP), H5Z_FILTER_NBIT(
|
||||
HDF5Constants.H5Z_FILTER_NBIT), H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET), H5Z_FILTER_RESERVED(
|
||||
HDF5Constants.H5Z_FILTER_RESERVED), H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR),
|
||||
H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE),
|
||||
H5Z_FILTER_DEFLATE(HDF5Constants.H5Z_FILTER_DEFLATE),
|
||||
H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE),
|
||||
H5Z_FILTER_FLETCHER32(HDF5Constants.H5Z_FILTER_FLETCHER32),
|
||||
H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP),
|
||||
H5Z_FILTER_NBIT(HDF5Constants.H5Z_FILTER_NBIT),
|
||||
H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET),
|
||||
H5Z_FILTER_RESERVED(HDF5Constants.H5Z_FILTER_RESERVED),
|
||||
H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
private static final Map<Integer, H5Z_filter> lookup = new HashMap<Integer, H5Z_filter>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5Z_filter s : EnumSet.allOf(H5Z_filter.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5Z_filter(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5Z_filter(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5Z_filter get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5Z_filter get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static boolean checkScaleoffsetFilter() {
|
||||
private static boolean checkScaleoffsetFilter()
|
||||
{
|
||||
try {
|
||||
int available = H5.H5Zfilter_avail(HDF5Constants.H5Z_FILTER_SCALEOFFSET);
|
||||
if (available == 0) {
|
||||
@@ -82,8 +83,8 @@ public class H5Ex_D_Soint {
|
||||
|
||||
try {
|
||||
int filter_info = H5.H5Zget_filter_info(HDF5Constants.H5Z_FILTER_SCALEOFFSET);
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0)
|
||||
|| ((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) ||
|
||||
((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
System.out.println("Scale-Offset filter not available for encoding and decoding.");
|
||||
return false;
|
||||
}
|
||||
@@ -94,13 +95,14 @@ public class H5Ex_D_Soint {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void writeData() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeData()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data.
|
||||
@@ -111,7 +113,7 @@ public class H5Ex_D_Soint {
|
||||
// Create a new file using the default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -130,7 +132,8 @@ public class H5Ex_D_Soint {
|
||||
try {
|
||||
dcpl_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_CREATE);
|
||||
if (dcpl_id >= 0) {
|
||||
H5.H5Pset_scaleoffset(dcpl_id, HDF5Constants.H5Z_SO_INT, HDF5Constants.H5Z_SO_INT_MINBITS_DEFAULT);
|
||||
H5.H5Pset_scaleoffset(dcpl_id, HDF5Constants.H5Z_SO_INT,
|
||||
HDF5Constants.H5Z_SO_INT_MINBITS_DEFAULT);
|
||||
H5.H5Pset_chunk(dcpl_id, NDIMS, chunk_dims);
|
||||
}
|
||||
}
|
||||
@@ -142,7 +145,7 @@ public class H5Ex_D_Soint {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -151,8 +154,8 @@ public class H5Ex_D_Soint {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -193,10 +196,11 @@ public class H5Ex_D_Soint {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readData() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readData()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open file using the default properties.
|
||||
@@ -229,15 +233,15 @@ public class H5Ex_D_Soint {
|
||||
try {
|
||||
if (dcpl_id >= 0) {
|
||||
// Java lib requires a valid filter_name object and cd_values
|
||||
int[] flags = { 0 };
|
||||
long[] cd_nelmts = { 1 };
|
||||
int[] cd_values = { 0 };
|
||||
String[] filter_name = { "" };
|
||||
int[] filter_config = { 0 };
|
||||
int filter_type = -1;
|
||||
int[] flags = {0};
|
||||
long[] cd_nelmts = {1};
|
||||
int[] cd_values = {0};
|
||||
String[] filter_name = {""};
|
||||
int[] filter_config = {0};
|
||||
int filter_type = -1;
|
||||
|
||||
filter_type = H5
|
||||
.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name, filter_config);
|
||||
filter_type = H5.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name,
|
||||
filter_config);
|
||||
System.out.print("Filter type is: ");
|
||||
switch (H5Z_filter.get(filter_type)) {
|
||||
case H5Z_FILTER_DEFLATE:
|
||||
@@ -271,8 +275,8 @@ public class H5Ex_D_Soint {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -316,7 +320,8 @@ public class H5Ex_D_Soint {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
// Check if Scale-Offset compression is available and can be used
|
||||
// for both compression and decompression. Normally we do not
|
||||
@@ -328,5 +333,4 @@ public class H5Ex_D_Soint {
|
||||
H5Ex_D_Soint.readData();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,45 +29,46 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Szip {
|
||||
private static String FILENAME = "H5Ex_D_Szip.h5";
|
||||
private static String FILENAME = "H5Ex_D_Szip.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 32;
|
||||
private static final int DIM_Y = 64;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 8;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5Z_filter {
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR), H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE), H5Z_FILTER_DEFLATE(
|
||||
HDF5Constants.H5Z_FILTER_DEFLATE), H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE), H5Z_FILTER_FLETCHER32(
|
||||
HDF5Constants.H5Z_FILTER_FLETCHER32), H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP), H5Z_FILTER_NBIT(
|
||||
HDF5Constants.H5Z_FILTER_NBIT), H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET), H5Z_FILTER_RESERVED(
|
||||
HDF5Constants.H5Z_FILTER_RESERVED), H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR),
|
||||
H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE),
|
||||
H5Z_FILTER_DEFLATE(HDF5Constants.H5Z_FILTER_DEFLATE),
|
||||
H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE),
|
||||
H5Z_FILTER_FLETCHER32(HDF5Constants.H5Z_FILTER_FLETCHER32),
|
||||
H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP),
|
||||
H5Z_FILTER_NBIT(HDF5Constants.H5Z_FILTER_NBIT),
|
||||
H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET),
|
||||
H5Z_FILTER_RESERVED(HDF5Constants.H5Z_FILTER_RESERVED),
|
||||
H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
private static final Map<Integer, H5Z_filter> lookup = new HashMap<Integer, H5Z_filter>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5Z_filter s : EnumSet.allOf(H5Z_filter.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5Z_filter(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5Z_filter(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5Z_filter get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5Z_filter get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static boolean checkSzipFilter() {
|
||||
private static boolean checkSzipFilter()
|
||||
{
|
||||
try {
|
||||
int available = H5.H5Zfilter_avail(HDF5Constants.H5Z_FILTER_SZIP);
|
||||
if (available == 0) {
|
||||
@@ -81,8 +82,8 @@ public class H5Ex_D_Szip {
|
||||
|
||||
try {
|
||||
int filter_info = H5.H5Zget_filter_info(HDF5Constants.H5Z_FILTER_SZIP);
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0)
|
||||
|| ((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) ||
|
||||
((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
System.out.println("szip filter not available for encoding and decoding.");
|
||||
return false;
|
||||
}
|
||||
@@ -93,13 +94,14 @@ public class H5Ex_D_Szip {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void writeSzip() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeSzip()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data.
|
||||
@@ -110,7 +112,7 @@ public class H5Ex_D_Szip {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -143,7 +145,7 @@ public class H5Ex_D_Szip {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -152,8 +154,8 @@ public class H5Ex_D_Szip {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -194,10 +196,11 @@ public class H5Ex_D_Szip {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readSzip() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readSzip()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open an existing file.
|
||||
@@ -231,15 +234,15 @@ public class H5Ex_D_Szip {
|
||||
try {
|
||||
if (dcpl_id >= 0) {
|
||||
// Java lib requires a valid filter_name object and cd_values
|
||||
int[] flags = { 0 };
|
||||
long[] cd_nelmts = { 1 };
|
||||
int[] cd_values = { 0 };
|
||||
String[] filter_name = { "" };
|
||||
int[] filter_config = { 0 };
|
||||
int filter_type = -1;
|
||||
int[] flags = {0};
|
||||
long[] cd_nelmts = {1};
|
||||
int[] cd_values = {0};
|
||||
String[] filter_name = {""};
|
||||
int[] filter_config = {0};
|
||||
int filter_type = -1;
|
||||
|
||||
filter_type = H5
|
||||
.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name, filter_config);
|
||||
filter_type = H5.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name,
|
||||
filter_config);
|
||||
System.out.print("Filter type is: ");
|
||||
switch (H5Z_filter.get(filter_type)) {
|
||||
case H5Z_FILTER_DEFLATE:
|
||||
@@ -273,8 +276,8 @@ public class H5Ex_D_Szip {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0) {
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -319,7 +322,8 @@ public class H5Ex_D_Szip {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Check if gzip compression is available and can be used for both
|
||||
// compression and decompression. Normally we do not perform error
|
||||
// checking in these examples for the sake of clarity, but in this
|
||||
@@ -330,5 +334,4 @@ public class H5Ex_D_Szip {
|
||||
H5Ex_D_Szip.readSzip();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,20 +27,21 @@ import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_Transform {
|
||||
|
||||
private static String FILE = "H5Ex_D_Transform.h5";
|
||||
private static String DATASET = "DS1";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static String TRANSFORM = "x+1";
|
||||
private static String FILE = "H5Ex_D_Transform.h5";
|
||||
private static String DATASET = "DS1";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static String TRANSFORM = "x+1";
|
||||
private static String RTRANSFORM = "x-1";
|
||||
|
||||
private static void writeData() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeData()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dxpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dxpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize data.
|
||||
@@ -60,7 +61,7 @@ public class H5Ex_D_Transform {
|
||||
// Create a new file using the default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILE, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -90,7 +91,8 @@ public class H5Ex_D_Transform {
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASET, HDF5Constants.H5T_NATIVE_INT, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -99,8 +101,8 @@ public class H5Ex_D_Transform {
|
||||
// Write the data to the dataset using the dataset transfer property list.
|
||||
try {
|
||||
if ((dataset_id >= 0) && (dxpl_id >= 0))
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
dxpl_id, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, dxpl_id, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -141,11 +143,12 @@ public class H5Ex_D_Transform {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readData() {
|
||||
private static void readData()
|
||||
{
|
||||
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dxpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dxpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Open an existing file using the default properties.
|
||||
@@ -168,8 +171,8 @@ public class H5Ex_D_Transform {
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -197,8 +200,8 @@ public class H5Ex_D_Transform {
|
||||
// Read the data using the dataset transfer property list.
|
||||
try {
|
||||
if ((dataset_id >= 0) && (dxpl_id >= 0))
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
dxpl_id, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, dxpl_id, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -206,8 +209,8 @@ public class H5Ex_D_Transform {
|
||||
|
||||
// Output the data to the screen.
|
||||
|
||||
System.out.println("Data as written with transform '" + TRANSFORM + "' and read with transform '"
|
||||
+ RTRANSFORM + "'");
|
||||
System.out.println("Data as written with transform '" + TRANSFORM + "' and read with transform '" +
|
||||
RTRANSFORM + "'");
|
||||
for (int i = 0; i < DIM_X; i++) {
|
||||
System.out.print(" [");
|
||||
for (int j = 0; j < DIM_Y; j++)
|
||||
@@ -239,9 +242,9 @@ public class H5Ex_D_Transform {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_D_Transform.writeData();
|
||||
H5Ex_D_Transform.readData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,25 +26,26 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_UnlimitedAdd {
|
||||
private static String FILENAME = "H5Ex_D_UnlimitedAdd.h5";
|
||||
private static String FILENAME = "H5Ex_D_UnlimitedAdd.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int EDIM_X = 6;
|
||||
private static final int EDIM_Y = 10;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 4;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int EDIM_X = 6;
|
||||
private static final int EDIM_Y = 10;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 4;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
private static void writeUnlimited() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeUnlimited()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long[] maxdims = { HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
long[] maxdims = {HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize the dataset.
|
||||
@@ -55,7 +56,7 @@ public class H5Ex_D_UnlimitedAdd {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -90,7 +91,7 @@ public class H5Ex_D_UnlimitedAdd {
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -99,8 +100,8 @@ public class H5Ex_D_UnlimitedAdd {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -141,14 +142,15 @@ public class H5Ex_D_UnlimitedAdd {
|
||||
}
|
||||
}
|
||||
|
||||
private static void extendUnlimited() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void extendUnlimited()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] extdims = { EDIM_X, EDIM_Y };
|
||||
long[] start = { 0, 0 };
|
||||
long[] count = new long[2];
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] extdims = {EDIM_X, EDIM_Y};
|
||||
long[] start = {0, 0};
|
||||
long[] count = new long[2];
|
||||
int[][] dset_data;
|
||||
int[][] extend_dset_data = new int[EDIM_X][EDIM_Y];
|
||||
|
||||
@@ -189,13 +191,13 @@ public class H5Ex_D_UnlimitedAdd {
|
||||
}
|
||||
|
||||
// Allocate array of pointers to rows.
|
||||
dset_data = new int[(int) dims[0]][(int) dims[1]];
|
||||
dset_data = new int[(int)dims[0]][(int)dims[1]];
|
||||
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -257,7 +259,7 @@ public class H5Ex_D_UnlimitedAdd {
|
||||
// Write the data to the selected portion of the dataset.
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, extend_dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, extend_dset_data);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -291,11 +293,12 @@ public class H5Ex_D_UnlimitedAdd {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readUnlimited() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readUnlimited()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
int[][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -332,13 +335,13 @@ public class H5Ex_D_UnlimitedAdd {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Allocate array of pointers to rows.
|
||||
dset_data = new int[(int) dims[0]][(int) dims[1]];
|
||||
dset_data = new int[(int)dims[0]][(int)dims[1]];
|
||||
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -381,10 +384,10 @@ public class H5Ex_D_UnlimitedAdd {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_D_UnlimitedAdd.writeUnlimited();
|
||||
H5Ex_D_UnlimitedAdd.extendUnlimited();
|
||||
H5Ex_D_UnlimitedAdd.readUnlimited();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,47 +31,48 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_UnlimitedGzip {
|
||||
private static String FILENAME = "H5Ex_D_UnlimitedGzip.h5";
|
||||
private static String FILENAME = "H5Ex_D_UnlimitedGzip.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int EDIM_X = 6;
|
||||
private static final int EDIM_Y = 10;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 4;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int EDIM_X = 6;
|
||||
private static final int EDIM_Y = 10;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 4;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5Z_filter {
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR), H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE), H5Z_FILTER_DEFLATE(
|
||||
HDF5Constants.H5Z_FILTER_DEFLATE), H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE), H5Z_FILTER_FLETCHER32(
|
||||
HDF5Constants.H5Z_FILTER_FLETCHER32), H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP), H5Z_FILTER_NBIT(
|
||||
HDF5Constants.H5Z_FILTER_NBIT), H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET), H5Z_FILTER_RESERVED(
|
||||
HDF5Constants.H5Z_FILTER_RESERVED), H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
H5Z_FILTER_ERROR(HDF5Constants.H5Z_FILTER_ERROR),
|
||||
H5Z_FILTER_NONE(HDF5Constants.H5Z_FILTER_NONE),
|
||||
H5Z_FILTER_DEFLATE(HDF5Constants.H5Z_FILTER_DEFLATE),
|
||||
H5Z_FILTER_SHUFFLE(HDF5Constants.H5Z_FILTER_SHUFFLE),
|
||||
H5Z_FILTER_FLETCHER32(HDF5Constants.H5Z_FILTER_FLETCHER32),
|
||||
H5Z_FILTER_SZIP(HDF5Constants.H5Z_FILTER_SZIP),
|
||||
H5Z_FILTER_NBIT(HDF5Constants.H5Z_FILTER_NBIT),
|
||||
H5Z_FILTER_SCALEOFFSET(HDF5Constants.H5Z_FILTER_SCALEOFFSET),
|
||||
H5Z_FILTER_RESERVED(HDF5Constants.H5Z_FILTER_RESERVED),
|
||||
H5Z_FILTER_MAX(HDF5Constants.H5Z_FILTER_MAX);
|
||||
private static final Map<Integer, H5Z_filter> lookup = new HashMap<Integer, H5Z_filter>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5Z_filter s : EnumSet.allOf(H5Z_filter.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5Z_filter(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5Z_filter(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5Z_filter get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5Z_filter get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static boolean checkGzipFilter() {
|
||||
private static boolean checkGzipFilter()
|
||||
{
|
||||
try {
|
||||
int available = H5.H5Zfilter_avail(HDF5Constants.H5Z_FILTER_DEFLATE);
|
||||
if (available == 0) {
|
||||
@@ -85,8 +86,8 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
|
||||
try {
|
||||
int filter_info = H5.H5Zget_filter_info(HDF5Constants.H5Z_FILTER_DEFLATE);
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0)
|
||||
|| ((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
if (((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) ||
|
||||
((filter_info & HDF5Constants.H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) {
|
||||
System.out.println("gzip filter not available for encoding and decoding.");
|
||||
return false;
|
||||
}
|
||||
@@ -97,14 +98,15 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void writeUnlimited() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeUnlimited()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long[] maxdims = { HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
long[] maxdims = {HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize the dataset.
|
||||
@@ -115,7 +117,7 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -147,7 +149,7 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -156,8 +158,8 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -198,14 +200,15 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
}
|
||||
}
|
||||
|
||||
private static void extendUnlimited() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void extendUnlimited()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] extdims = { EDIM_X, EDIM_Y };
|
||||
long[] start = { 0, 0 };
|
||||
long[] count = new long[2];
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] extdims = {EDIM_X, EDIM_Y};
|
||||
long[] start = {0, 0};
|
||||
long[] count = new long[2];
|
||||
int[][] dset_data;
|
||||
int[][] extend_dset_data = new int[EDIM_X][EDIM_Y];
|
||||
|
||||
@@ -246,13 +249,13 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
}
|
||||
|
||||
// Allocate array of pointers to rows.
|
||||
dset_data = new int[(int) dims[0]][(int) dims[1]];
|
||||
dset_data = new int[(int)dims[0]][(int)dims[1]];
|
||||
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -314,7 +317,7 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
// Write the data to the selected portion of the dataset.
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, extend_dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, extend_dset_data);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -348,12 +351,13 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readUnlimited() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readUnlimited()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
int[][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -387,14 +391,14 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
try {
|
||||
if (dcpl_id >= 0) {
|
||||
// Java lib requires a valid filter_name object and cd_values
|
||||
int[] flags = { 0 };
|
||||
long[] cd_nelmts = { 1 };
|
||||
int[] cd_values = { 0 };
|
||||
String[] filter_name = { "" };
|
||||
int[] filter_config = { 0 };
|
||||
int filter_type = -1;
|
||||
filter_type = H5
|
||||
.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name, filter_config);
|
||||
int[] flags = {0};
|
||||
long[] cd_nelmts = {1};
|
||||
int[] cd_values = {0};
|
||||
String[] filter_name = {""};
|
||||
int[] filter_config = {0};
|
||||
int filter_type = -1;
|
||||
filter_type = H5.H5Pget_filter(dcpl_id, 0, flags, cd_nelmts, cd_values, 120, filter_name,
|
||||
filter_config);
|
||||
System.out.print("Filter type is: ");
|
||||
switch (H5Z_filter.get(filter_type)) {
|
||||
case H5Z_FILTER_DEFLATE:
|
||||
@@ -436,13 +440,13 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Allocate array of pointers to rows.
|
||||
dset_data = new int[(int) dims[0]][(int) dims[1]];
|
||||
dset_data = new int[(int)dims[0]][(int)dims[1]];
|
||||
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -485,7 +489,8 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Check if gzip compression is available and can be used for both
|
||||
// compression and decompression. Normally we do not perform error
|
||||
// checking in these examples for the sake of clarity, but in this
|
||||
@@ -497,5 +502,4 @@ public class H5Ex_D_UnlimitedGzip {
|
||||
H5Ex_D_UnlimitedGzip.readUnlimited();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,25 +26,26 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_D_UnlimitedMod {
|
||||
private static String FILENAME = "H5Ex_D_UnlimitedMod.h5";
|
||||
private static String FILENAME = "H5Ex_D_UnlimitedMod.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int EDIM_X = 6;
|
||||
private static final int EDIM_Y = 10;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 4;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 7;
|
||||
private static final int EDIM_X = 6;
|
||||
private static final int EDIM_Y = 10;
|
||||
private static final int CHUNK_X = 4;
|
||||
private static final int CHUNK_Y = 4;
|
||||
private static final int RANK = 2;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
private static void writeUnlimited() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void writeUnlimited()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] chunk_dims = { CHUNK_X, CHUNK_Y };
|
||||
long[] maxdims = { HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] chunk_dims = {CHUNK_X, CHUNK_Y};
|
||||
long[] maxdims = {HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize the dataset.
|
||||
@@ -55,7 +56,7 @@ public class H5Ex_D_UnlimitedMod {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -90,7 +91,7 @@ public class H5Ex_D_UnlimitedMod {
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0) && (dcpl_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -99,8 +100,8 @@ public class H5Ex_D_UnlimitedMod {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -141,12 +142,13 @@ public class H5Ex_D_UnlimitedMod {
|
||||
}
|
||||
}
|
||||
|
||||
private static void extendUnlimited() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void extendUnlimited()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long[] extdims = { EDIM_X, EDIM_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
long[] extdims = {EDIM_X, EDIM_Y};
|
||||
int[][] dset_data;
|
||||
int[][] extend_dset_data = new int[EDIM_X][EDIM_Y];
|
||||
|
||||
@@ -187,13 +189,13 @@ public class H5Ex_D_UnlimitedMod {
|
||||
}
|
||||
|
||||
// Allocate array of pointers to rows.
|
||||
dset_data = new int[(int) dims[0]][(int) dims[1]];
|
||||
dset_data = new int[(int)dims[0]][(int)dims[1]];
|
||||
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -244,7 +246,7 @@ public class H5Ex_D_UnlimitedMod {
|
||||
try {
|
||||
if ((dataspace_id >= 0) && (dataset_id >= 0))
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, extend_dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, extend_dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -277,11 +279,12 @@ public class H5Ex_D_UnlimitedMod {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readUnlimited() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void readUnlimited()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
int[][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -318,13 +321,13 @@ public class H5Ex_D_UnlimitedMod {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Allocate array of pointers to rows.
|
||||
dset_data = new int[(int) dims[0]][(int) dims[1]];
|
||||
dset_data = new int[(int)dims[0]][(int)dims[1]];
|
||||
|
||||
// Read the data using the default properties.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -367,10 +370,10 @@ public class H5Ex_D_UnlimitedMod {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_D_UnlimitedMod.writeUnlimited();
|
||||
H5Ex_D_UnlimitedMod.extendUnlimited();
|
||||
H5Ex_D_UnlimitedMod.readUnlimited();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,13 @@ foreach (example ${HDF_JAVA_EXAMPLES})
|
||||
# install_jar (${example} ${HJAVA_INSTALL_DATA_DIR}/examples examples)
|
||||
get_target_property (${example}_CLASSPATH ${example} CLASSDIR)
|
||||
add_dependencies (${example} ${HDF5_JAVA_HDF5_LIB_TARGET})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target to clang-format
|
||||
#-----------------------------------------------------------------------------
|
||||
if (HDF5_ENABLE_FORMATTERS)
|
||||
clang_format (HDF5_JAVA_${example}_SRC_FORMAT ${example}.java)
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
set (CMAKE_JAVA_INCLUDE_PATH "${HDF5_JAVA_JARS};${HDF5_JAVA_LOGGING_JAR};${HDF5_JAVA_LOGGING_NOP_JAR}")
|
||||
|
||||
@@ -24,22 +24,23 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_Array {
|
||||
private static String FILENAME = "H5Ex_T_Array.h5";
|
||||
private static String FILENAME = "H5Ex_T_Array.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int ADIM0 = 3;
|
||||
private static final int ADIM1 = 5;
|
||||
private static final int RANK = 1;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int ADIM0 = 3;
|
||||
private static final int ADIM1 = 5;
|
||||
private static final int RANK = 1;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
long[] adims = { ADIM0, ADIM1 };
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
long[] adims = {ADIM0, ADIM1};
|
||||
int[][][] dset_data = new int[DIM0][ADIM0][ADIM1];
|
||||
|
||||
// Initialize data. indx is the element in the dataspace, jndx and kndx the
|
||||
@@ -52,7 +53,7 @@ public class H5Ex_T_Array {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -86,8 +87,9 @@ public class H5Ex_T_Array {
|
||||
// Create the dataset.
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0) && (filetype_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, filetype_id, dataspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
dataset_id =
|
||||
H5.H5Dcreate(file_id, DATASETNAME, filetype_id, dataspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -97,7 +99,7 @@ public class H5Ex_T_Array {
|
||||
try {
|
||||
if ((dataset_id >= 0) && (memtype_id >= 0))
|
||||
H5.H5Dwrite(dataset_id, memtype_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -147,16 +149,16 @@ public class H5Ex_T_Array {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
long[] adims = { ADIM0, ADIM1 };
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
long[] adims = {ADIM0, ADIM1};
|
||||
int[][][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -196,7 +198,7 @@ public class H5Ex_T_Array {
|
||||
|
||||
// Allocate array of pointers to two-dimensional arrays (the
|
||||
// elements of the dataset.
|
||||
dset_data = new int[(int) dims[0]][(int) (adims[0])][(int) (adims[1])];
|
||||
dset_data = new int[(int)dims[0]][(int)(adims[0])][(int)(adims[1])];
|
||||
|
||||
// Create array datatypes for memory.
|
||||
try {
|
||||
@@ -210,7 +212,7 @@ public class H5Ex_T_Array {
|
||||
try {
|
||||
if ((dataset_id >= 0) && (memtype_id >= 0))
|
||||
H5.H5Dread(dataset_id, memtype_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -264,10 +266,10 @@ public class H5Ex_T_Array {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_Array.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -275,5 +277,4 @@ public class H5Ex_T_Array {
|
||||
// data using malloc().
|
||||
H5Ex_T_Array.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,24 +24,25 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_ArrayAttribute {
|
||||
private static String FILENAME = "H5Ex_T_ArrayAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String FILENAME = "H5Ex_T_ArrayAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String ATTRIBUTENAME = "A1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int ADIM0 = 3;
|
||||
private static final int ADIM1 = 5;
|
||||
private static final int RANK = 1;
|
||||
private static final int NDIMS = 2;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int ADIM0 = 3;
|
||||
private static final int ADIM1 = 5;
|
||||
private static final int RANK = 1;
|
||||
private static final int NDIMS = 2;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
long[] adims = { ADIM0, ADIM1 };
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
long[] adims = {ADIM0, ADIM1};
|
||||
int[][][] dset_data = new int[DIM0][ADIM0][ADIM1];
|
||||
|
||||
// Initialize data. indx is the element in the dataspace, jndx and kndx the
|
||||
@@ -54,7 +55,7 @@ public class H5Ex_T_ArrayAttribute {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -81,7 +82,8 @@ public class H5Ex_T_ArrayAttribute {
|
||||
dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR);
|
||||
if (dataspace_id >= 0) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
H5.H5Sclose(dataspace_id);
|
||||
dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
}
|
||||
@@ -103,7 +105,7 @@ public class H5Ex_T_ArrayAttribute {
|
||||
try {
|
||||
if ((dataset_id >= 0) && (dataspace_id >= 0) && (filetype_id >= 0))
|
||||
attribute_id = H5.H5Acreate(dataset_id, ATTRIBUTENAME, filetype_id, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -170,17 +172,17 @@ public class H5Ex_T_ArrayAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
long[] adims = { ADIM0, ADIM1 };
|
||||
long[] dims = {DIM0};
|
||||
long[] adims = {ADIM0, ADIM1};
|
||||
int[][][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -203,7 +205,7 @@ public class H5Ex_T_ArrayAttribute {
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
attribute_id = H5.H5Aopen_by_name(dataset_id, ".", ATTRIBUTENAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -229,7 +231,7 @@ public class H5Ex_T_ArrayAttribute {
|
||||
|
||||
// Allocate array of pointers to two-dimensional arrays (the
|
||||
// elements of the dataset.
|
||||
dset_data = new int[(int) dims[0]][(int) (adims[0])][(int) (adims[1])];
|
||||
dset_data = new int[(int)dims[0]][(int)(adims[0])][(int)(adims[1])];
|
||||
|
||||
// Create array datatypes for memory.
|
||||
try {
|
||||
@@ -304,10 +306,10 @@ public class H5Ex_T_ArrayAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_ArrayAttribute.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -315,5 +317,4 @@ public class H5Ex_T_ArrayAttribute {
|
||||
// data using malloc().
|
||||
H5Ex_T_ArrayAttribute.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,17 +24,18 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_Bit {
|
||||
private static String FILENAME = "H5Ex_T_Bit.h5";
|
||||
private static String FILENAME = "H5Ex_T_Bit.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0, DIM1};
|
||||
int[][] dset_data = new int[DIM0][DIM1];
|
||||
|
||||
// Initialize data.
|
||||
@@ -42,15 +43,15 @@ public class H5Ex_T_Bit {
|
||||
for (int jndx = 0; jndx < DIM1; jndx++) {
|
||||
dset_data[indx][jndx] = 0;
|
||||
dset_data[indx][jndx] |= (indx * jndx - jndx) & 0x03; /* Field "A" */
|
||||
dset_data[indx][jndx] |= (indx & 0x03) << 2; /* Field "B" */
|
||||
dset_data[indx][jndx] |= (jndx & 0x03) << 4; /* Field "C" */
|
||||
dset_data[indx][jndx] |= (indx & 0x03) << 2; /* Field "B" */
|
||||
dset_data[indx][jndx] |= (jndx & 0x03) << 4; /* Field "C" */
|
||||
dset_data[indx][jndx] |= ((indx + jndx) & 0x03) << 6; /* Field "D" */
|
||||
}
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -69,7 +70,8 @@ public class H5Ex_T_Bit {
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_B8BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -78,8 +80,8 @@ public class H5Ex_T_Bit {
|
||||
// Write the bitfield data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_B8, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_B8, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -111,14 +113,14 @@ public class H5Ex_T_Bit {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0, DIM1};
|
||||
int[][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -157,13 +159,13 @@ public class H5Ex_T_Bit {
|
||||
|
||||
// Allocate array of pointers to two-dimensional arrays (the
|
||||
// elements of the dataset.
|
||||
dset_data = new int[(int) dims[0]][(int) (dims[1])];
|
||||
dset_data = new int[(int)dims[0]][(int)(dims[1])];
|
||||
|
||||
// Read data.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_B8, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_B8, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -209,10 +211,10 @@ public class H5Ex_T_Bit {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_Bit.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -220,5 +222,4 @@ public class H5Ex_T_Bit {
|
||||
// data using malloc().
|
||||
H5Ex_T_Bit.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,19 +24,20 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_BitAttribute {
|
||||
private static String FILENAME = "H5Ex_T_BitAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String FILENAME = "H5Ex_T_BitAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String ATTRIBUTENAME = "A1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
long[] dims = {DIM0, DIM1};
|
||||
int[][] dset_data = new int[DIM0][DIM1];
|
||||
|
||||
// Initialize data.
|
||||
@@ -44,15 +45,15 @@ public class H5Ex_T_BitAttribute {
|
||||
for (int jndx = 0; jndx < DIM1; jndx++) {
|
||||
dset_data[indx][jndx] = 0;
|
||||
dset_data[indx][jndx] |= (indx * jndx - jndx) & 0x03; /* Field "A" */
|
||||
dset_data[indx][jndx] |= (indx & 0x03) << 2; /* Field "B" */
|
||||
dset_data[indx][jndx] |= (jndx & 0x03) << 4; /* Field "C" */
|
||||
dset_data[indx][jndx] |= (indx & 0x03) << 2; /* Field "B" */
|
||||
dset_data[indx][jndx] |= (jndx & 0x03) << 4; /* Field "C" */
|
||||
dset_data[indx][jndx] |= ((indx + jndx) & 0x03) << 6; /* Field "D" */
|
||||
}
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -63,7 +64,8 @@ public class H5Ex_T_BitAttribute {
|
||||
dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR);
|
||||
if (dataspace_id >= 0) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
H5.H5Sclose(dataspace_id);
|
||||
dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
}
|
||||
@@ -84,8 +86,9 @@ public class H5Ex_T_BitAttribute {
|
||||
// Create the attribute and write the array data to it.
|
||||
try {
|
||||
if ((dataset_id >= 0) && (dataspace_id >= 0))
|
||||
attribute_id = H5.H5Acreate(dataset_id, ATTRIBUTENAME, HDF5Constants.H5T_STD_B8BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
attribute_id =
|
||||
H5.H5Acreate(dataset_id, ATTRIBUTENAME, HDF5Constants.H5T_STD_B8BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -134,15 +137,15 @@ public class H5Ex_T_BitAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
long[] dims = {DIM0, DIM1};
|
||||
int[][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -165,7 +168,7 @@ public class H5Ex_T_BitAttribute {
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
attribute_id = H5.H5Aopen_by_name(dataset_id, ".", ATTRIBUTENAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -190,7 +193,7 @@ public class H5Ex_T_BitAttribute {
|
||||
|
||||
// Allocate array of pointers to two-dimensional arrays (the
|
||||
// elements of the dataset.
|
||||
dset_data = new int[(int) dims[0]][(int) (dims[1])];
|
||||
dset_data = new int[(int)dims[0]][(int)(dims[1])];
|
||||
|
||||
// Read data.
|
||||
try {
|
||||
@@ -249,10 +252,10 @@ public class H5Ex_T_BitAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_BitAttribute.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -260,5 +263,4 @@ public class H5Ex_T_BitAttribute {
|
||||
// data using malloc().
|
||||
H5Ex_T_BitAttribute.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,77 +21,74 @@
|
||||
|
||||
package examples.datatypes;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_Commit {
|
||||
private static String FILENAME = "H5Ex_T_Commit.h5";
|
||||
private static String DATATYPENAME = "Sensor_Type";
|
||||
protected static final int INTEGERSIZE = 4;
|
||||
protected static final int DOUBLESIZE = 8;
|
||||
private static String FILENAME = "H5Ex_T_Commit.h5";
|
||||
private static String DATATYPENAME = "Sensor_Type";
|
||||
protected static final int INTEGERSIZE = 4;
|
||||
protected static final int DOUBLESIZE = 8;
|
||||
protected final static int MAXSTRINGSIZE = 80;
|
||||
|
||||
// Values for the various classes of datatypes
|
||||
enum H5T_class {
|
||||
H5T_NO_CLASS(HDF5Constants.H5T_NO_CLASS), // error
|
||||
H5T_INTEGER(HDF5Constants.H5T_INTEGER), // integer types
|
||||
H5T_FLOAT(HDF5Constants.H5T_FLOAT), // floating-point types
|
||||
H5T_TIME(HDF5Constants.H5T_TIME), // date and time types
|
||||
H5T_STRING(HDF5Constants.H5T_STRING), // character string types
|
||||
H5T_BITFIELD(HDF5Constants.H5T_BITFIELD), // bit field types
|
||||
H5T_OPAQUE(HDF5Constants.H5T_OPAQUE), // opaque types
|
||||
H5T_COMPOUND(HDF5Constants.H5T_COMPOUND), // compound types
|
||||
H5T_NO_CLASS(HDF5Constants.H5T_NO_CLASS), // error
|
||||
H5T_INTEGER(HDF5Constants.H5T_INTEGER), // integer types
|
||||
H5T_FLOAT(HDF5Constants.H5T_FLOAT), // floating-point types
|
||||
H5T_TIME(HDF5Constants.H5T_TIME), // date and time types
|
||||
H5T_STRING(HDF5Constants.H5T_STRING), // character string types
|
||||
H5T_BITFIELD(HDF5Constants.H5T_BITFIELD), // bit field types
|
||||
H5T_OPAQUE(HDF5Constants.H5T_OPAQUE), // opaque types
|
||||
H5T_COMPOUND(HDF5Constants.H5T_COMPOUND), // compound types
|
||||
H5T_REFERENCE(HDF5Constants.H5T_REFERENCE), // reference types
|
||||
H5T_ENUM(HDF5Constants.H5T_ENUM), // enumeration types
|
||||
H5T_VLEN(HDF5Constants.H5T_VLEN), // Variable-Length types
|
||||
H5T_ARRAY(HDF5Constants.H5T_ARRAY), // Array types
|
||||
H5T_NCLASSES(11); // this must be last
|
||||
H5T_ENUM(HDF5Constants.H5T_ENUM), // enumeration types
|
||||
H5T_VLEN(HDF5Constants.H5T_VLEN), // Variable-Length types
|
||||
H5T_ARRAY(HDF5Constants.H5T_ARRAY), // Array types
|
||||
H5T_NCLASSES(11); // this must be last
|
||||
|
||||
private static final Map<Long, H5T_class> lookup = new HashMap<Long, H5T_class>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5T_class s : EnumSet.allOf(H5T_class.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private long code;
|
||||
|
||||
H5T_class(long layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5T_class(long layout_type) { this.code = layout_type; }
|
||||
|
||||
public long getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public long getCode() { return this.code; }
|
||||
|
||||
public static H5T_class get(long typeclass_id) {
|
||||
return lookup.get(typeclass_id);
|
||||
}
|
||||
public static H5T_class get(long typeclass_id) { return lookup.get(typeclass_id); }
|
||||
}
|
||||
|
||||
// The supporting Sensor_Datatype class.
|
||||
private static class Sensor_Datatype {
|
||||
static int numberMembers = 4;
|
||||
static int[] memberDims = { 1, 1, 1, 1 };
|
||||
static int[] memberDims = {1, 1, 1, 1};
|
||||
|
||||
String[] memberNames = { "Serial number", "Location", "Temperature (F)", "Pressure (inHg)" };
|
||||
long[] memberFileTypes = { HDF5Constants.H5T_STD_I32BE, HDF5Constants.H5T_C_S1, HDF5Constants.H5T_IEEE_F64BE,
|
||||
HDF5Constants.H5T_IEEE_F64BE };
|
||||
static int[] memberStorage = { INTEGERSIZE, MAXSTRINGSIZE, DOUBLESIZE, DOUBLESIZE };
|
||||
String[] memberNames = {"Serial number", "Location", "Temperature (F)", "Pressure (inHg)"};
|
||||
long[] memberFileTypes = {HDF5Constants.H5T_STD_I32BE, HDF5Constants.H5T_C_S1,
|
||||
HDF5Constants.H5T_IEEE_F64BE, HDF5Constants.H5T_IEEE_F64BE};
|
||||
static int[] memberStorage = {INTEGERSIZE, MAXSTRINGSIZE, DOUBLESIZE, DOUBLESIZE};
|
||||
|
||||
// Data size is the storage size for the members not the object.
|
||||
static long getDataSize() {
|
||||
static long getDataSize()
|
||||
{
|
||||
long data_size = 0;
|
||||
for (int indx = 0; indx < numberMembers; indx++)
|
||||
data_size += memberStorage[indx] * memberDims[indx];
|
||||
return data_size;
|
||||
}
|
||||
|
||||
static int getOffset(int memberItem) {
|
||||
static int getOffset(int memberItem)
|
||||
{
|
||||
int data_offset = 0;
|
||||
for (int indx = 0; indx < memberItem; indx++)
|
||||
data_offset += memberStorage[indx];
|
||||
@@ -99,15 +96,16 @@ public class H5Ex_T_Commit {
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateDataType() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long strtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateDataType()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long strtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
Sensor_Datatype datatypes = new Sensor_Datatype();
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -134,7 +132,8 @@ public class H5Ex_T_Commit {
|
||||
long type_id = datatypes.memberFileTypes[indx];
|
||||
if (type_id == HDF5Constants.H5T_C_S1)
|
||||
type_id = strtype_id;
|
||||
H5.H5Tinsert(filetype_id, datatypes.memberNames[indx], Sensor_Datatype.getOffset(indx), type_id);
|
||||
H5.H5Tinsert(filetype_id, datatypes.memberNames[indx], Sensor_Datatype.getOffset(indx),
|
||||
type_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,8 +144,8 @@ public class H5Ex_T_Commit {
|
||||
// Commit the compound datatype to the file, creating a named datatype.
|
||||
try {
|
||||
if ((file_id >= 0) && (filetype_id >= 0))
|
||||
H5.H5Tcommit(file_id, DATATYPENAME, filetype_id, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
H5.H5Tcommit(file_id, DATATYPENAME, filetype_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -178,13 +177,13 @@ public class H5Ex_T_Commit {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataType() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataType()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long typeclass_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
|
||||
// Open an existing file.
|
||||
try {
|
||||
@@ -247,10 +246,10 @@ public class H5Ex_T_Commit {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_Commit.CreateDataType();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -258,5 +257,4 @@ public class H5Ex_T_Commit {
|
||||
// data using malloc().
|
||||
H5Ex_T_Commit.ReadDataType();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,49 +20,52 @@
|
||||
|
||||
package examples.datatypes;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_Compound {
|
||||
private static String FILENAME = "H5Ex_T_Compound.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int RANK = 1;
|
||||
protected static final int INTEGERSIZE = 4;
|
||||
protected static final int DOUBLESIZE = 8;
|
||||
private static String FILENAME = "H5Ex_T_Compound.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int RANK = 1;
|
||||
protected static final int INTEGERSIZE = 4;
|
||||
protected static final int DOUBLESIZE = 8;
|
||||
protected final static int MAXSTRINGSIZE = 80;
|
||||
|
||||
static class Sensor_Datatype {
|
||||
static int numberMembers = 4;
|
||||
static int[] memberDims = { 1, 1, 1, 1 };
|
||||
static int[] memberDims = {1, 1, 1, 1};
|
||||
|
||||
static String[] memberNames = { "Serial number", "Location", "Temperature (F)", "Pressure (inHg)" };
|
||||
static long[] memberMemTypes = { HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5T_C_S1,
|
||||
HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5T_NATIVE_DOUBLE };
|
||||
static long[] memberFileTypes = { HDF5Constants.H5T_STD_I32BE, HDF5Constants.H5T_C_S1,
|
||||
HDF5Constants.H5T_IEEE_F64BE, HDF5Constants.H5T_IEEE_F64BE };
|
||||
static int[] memberStorage = { INTEGERSIZE, MAXSTRINGSIZE, DOUBLESIZE, DOUBLESIZE };
|
||||
static String[] memberNames = {"Serial number", "Location", "Temperature (F)", "Pressure (inHg)"};
|
||||
static long[] memberMemTypes = {HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5T_C_S1,
|
||||
HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5T_NATIVE_DOUBLE};
|
||||
static long[] memberFileTypes = {HDF5Constants.H5T_STD_I32BE, HDF5Constants.H5T_C_S1,
|
||||
HDF5Constants.H5T_IEEE_F64BE, HDF5Constants.H5T_IEEE_F64BE};
|
||||
static int[] memberStorage = {INTEGERSIZE, MAXSTRINGSIZE, DOUBLESIZE, DOUBLESIZE};
|
||||
|
||||
// Data size is the storage size for the members.
|
||||
static long getTotalDataSize() {
|
||||
static long getTotalDataSize()
|
||||
{
|
||||
long data_size = 0;
|
||||
for (int indx = 0; indx < numberMembers; indx++)
|
||||
data_size += memberStorage[indx] * memberDims[indx];
|
||||
return DIM0 * data_size;
|
||||
}
|
||||
|
||||
static long getDataSize() {
|
||||
static long getDataSize()
|
||||
{
|
||||
long data_size = 0;
|
||||
for (int indx = 0; indx < numberMembers; indx++)
|
||||
data_size += memberStorage[indx] * memberDims[indx];
|
||||
return data_size;
|
||||
}
|
||||
|
||||
static int getOffset(int memberItem) {
|
||||
static int getOffset(int memberItem)
|
||||
{
|
||||
int data_offset = 0;
|
||||
for (int indx = 0; indx < memberItem; indx++)
|
||||
data_offset += memberStorage[indx];
|
||||
@@ -76,60 +79,63 @@ public class H5Ex_T_Compound {
|
||||
public double temperature;
|
||||
public double pressure;
|
||||
|
||||
Sensor(int serial_no, String location, double temperature, double pressure) {
|
||||
this.serial_no = serial_no;
|
||||
this.location = location;
|
||||
Sensor(int serial_no, String location, double temperature, double pressure)
|
||||
{
|
||||
this.serial_no = serial_no;
|
||||
this.location = location;
|
||||
this.temperature = temperature;
|
||||
this.pressure = pressure;
|
||||
this.pressure = pressure;
|
||||
}
|
||||
|
||||
Sensor(ByteBuffer databuf, int dbposition) {
|
||||
readBuffer(databuf, dbposition);
|
||||
}
|
||||
Sensor(ByteBuffer databuf, int dbposition) { readBuffer(databuf, dbposition); }
|
||||
|
||||
void writeBuffer(ByteBuffer databuf, int dbposition) {
|
||||
void writeBuffer(ByteBuffer databuf, int dbposition)
|
||||
{
|
||||
databuf.putInt(dbposition + Sensor_Datatype.getOffset(0), serial_no);
|
||||
byte[] temp_str = location.getBytes(Charset.forName("UTF-8"));
|
||||
int arraylen = (temp_str.length > MAXSTRINGSIZE) ? MAXSTRINGSIZE : temp_str.length;
|
||||
int arraylen = (temp_str.length > MAXSTRINGSIZE) ? MAXSTRINGSIZE : temp_str.length;
|
||||
for (int ndx = 0; ndx < arraylen; ndx++)
|
||||
databuf.put(dbposition + Sensor_Datatype.getOffset(1) + ndx, temp_str[ndx]);
|
||||
for (int ndx = arraylen; ndx < MAXSTRINGSIZE; ndx++)
|
||||
databuf.put(dbposition + Sensor_Datatype.getOffset(1) + arraylen, (byte) 0);
|
||||
databuf.put(dbposition + Sensor_Datatype.getOffset(1) + arraylen, (byte)0);
|
||||
databuf.putDouble(dbposition + Sensor_Datatype.getOffset(2), temperature);
|
||||
databuf.putDouble(dbposition + Sensor_Datatype.getOffset(3), pressure);
|
||||
}
|
||||
|
||||
void readBuffer(ByteBuffer databuf, int dbposition) {
|
||||
this.serial_no = databuf.getInt(dbposition + Sensor_Datatype.getOffset(0));
|
||||
void readBuffer(ByteBuffer databuf, int dbposition)
|
||||
{
|
||||
this.serial_no = databuf.getInt(dbposition + Sensor_Datatype.getOffset(0));
|
||||
ByteBuffer stringbuf = databuf.duplicate();
|
||||
stringbuf.position(dbposition + Sensor_Datatype.getOffset(1));
|
||||
stringbuf.limit(dbposition + Sensor_Datatype.getOffset(1) + MAXSTRINGSIZE);
|
||||
byte[] bytearr = new byte[stringbuf.remaining()];
|
||||
stringbuf.get(bytearr);
|
||||
this.location = new String(bytearr, Charset.forName("UTF-8")).trim();
|
||||
this.location = new String(bytearr, Charset.forName("UTF-8")).trim();
|
||||
this.temperature = databuf.getDouble(dbposition + Sensor_Datatype.getOffset(2));
|
||||
this.pressure = databuf.getDouble(dbposition + Sensor_Datatype.getOffset(3));
|
||||
this.pressure = databuf.getDouble(dbposition + Sensor_Datatype.getOffset(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Serial number : " + serial_no + "%n" +
|
||||
"Location : " + location + "%n" +
|
||||
"Temperature (F) : " + temperature + "%n" +
|
||||
"Pressure (inHg) : " + pressure + "%n");
|
||||
public String toString()
|
||||
{
|
||||
return String.format("Serial number : " + serial_no + "%n"
|
||||
+ "Location : " + location + "%n"
|
||||
+ "Temperature (F) : " + temperature + "%n"
|
||||
+ "Pressure (inHg) : " + pressure + "%n");
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long strtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long strtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
Sensor[] object_data = new Sensor[DIM0];
|
||||
byte[] dset_data = null;
|
||||
byte[] dset_data = null;
|
||||
|
||||
// Initialize data.
|
||||
object_data[0] = new Sensor(1153, new String("Exterior (static)"), 53.23, 24.57);
|
||||
@@ -140,7 +146,7 @@ public class H5Ex_T_Compound {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -164,8 +170,8 @@ public class H5Ex_T_Compound {
|
||||
long type_id = Sensor_Datatype.memberMemTypes[indx];
|
||||
if (type_id == HDF5Constants.H5T_C_S1)
|
||||
type_id = strtype_id;
|
||||
H5.H5Tinsert(memtype_id, Sensor_Datatype.memberNames[indx], Sensor_Datatype.getOffset(indx),
|
||||
type_id);
|
||||
H5.H5Tinsert(memtype_id, Sensor_Datatype.memberNames[indx],
|
||||
Sensor_Datatype.getOffset(indx), type_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,8 +190,8 @@ public class H5Ex_T_Compound {
|
||||
long type_id = Sensor_Datatype.memberFileTypes[indx];
|
||||
if (type_id == HDF5Constants.H5T_C_S1)
|
||||
type_id = strtype_id;
|
||||
H5.H5Tinsert(filetype_id, Sensor_Datatype.memberNames[indx], Sensor_Datatype.getOffset(indx),
|
||||
type_id);
|
||||
H5.H5Tinsert(filetype_id, Sensor_Datatype.memberNames[indx],
|
||||
Sensor_Datatype.getOffset(indx), type_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,8 +211,9 @@ public class H5Ex_T_Compound {
|
||||
// Create the dataset.
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0) && (filetype_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, filetype_id, dataspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
dataset_id =
|
||||
H5.H5Dcreate(file_id, DATASETNAME, filetype_id, dataspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -214,16 +221,16 @@ public class H5Ex_T_Compound {
|
||||
|
||||
// Write the compound data to the dataset.
|
||||
// allocate memory for read buffer.
|
||||
dset_data = new byte[(int)dims[0] * (int)Sensor_Datatype.getDataSize()];
|
||||
dset_data = new byte[(int)dims[0] * (int)Sensor_Datatype.getDataSize()];
|
||||
ByteBuffer outBuf = ByteBuffer.wrap(dset_data);
|
||||
outBuf.order(ByteOrder.nativeOrder());
|
||||
for (int indx = 0; indx < (int) dims[0]; indx++) {
|
||||
for (int indx = 0; indx < (int)dims[0]; indx++) {
|
||||
object_data[indx].writeBuffer(outBuf, indx * (int)Sensor_Datatype.getDataSize());
|
||||
}
|
||||
try {
|
||||
if ((dataset_id >= 0) && (memtype_id >= 0))
|
||||
H5.H5Dwrite(dataset_id, memtype_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -281,16 +288,16 @@ public class H5Ex_T_Compound {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long strtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long strtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
Sensor[] object_data2;
|
||||
byte[] dset_data;
|
||||
|
||||
@@ -346,8 +353,8 @@ public class H5Ex_T_Compound {
|
||||
long type_id = Sensor_Datatype.memberMemTypes[indx];
|
||||
if (type_id == HDF5Constants.H5T_C_S1)
|
||||
type_id = strtype_id;
|
||||
H5.H5Tinsert(memtype_id, Sensor_Datatype.memberNames[indx], Sensor_Datatype.getOffset(indx),
|
||||
type_id);
|
||||
H5.H5Tinsert(memtype_id, Sensor_Datatype.memberNames[indx],
|
||||
Sensor_Datatype.getOffset(indx), type_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -356,19 +363,19 @@ public class H5Ex_T_Compound {
|
||||
}
|
||||
|
||||
// allocate memory for read buffer.
|
||||
dset_data = new byte[(int) dims[0] * (int)Sensor_Datatype.getDataSize()];
|
||||
dset_data = new byte[(int)dims[0] * (int)Sensor_Datatype.getDataSize()];
|
||||
|
||||
object_data2 = new Sensor[(int) dims[0]];
|
||||
object_data2 = new Sensor[(int)dims[0]];
|
||||
|
||||
// Read data.
|
||||
try {
|
||||
if ((dataset_id >= 0) && (memtype_id >= 0))
|
||||
H5.H5Dread(dataset_id, memtype_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
|
||||
ByteBuffer inBuf = ByteBuffer.wrap(dset_data);
|
||||
inBuf.order(ByteOrder.nativeOrder());
|
||||
for (int indx = 0; indx < (int) dims[0]; indx++) {
|
||||
for (int indx = 0; indx < (int)dims[0]; indx++) {
|
||||
object_data2[indx] = new Sensor(inBuf, indx * (int)Sensor_Datatype.getDataSize());
|
||||
}
|
||||
}
|
||||
@@ -425,10 +432,10 @@ public class H5Ex_T_Compound {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_Compound.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -436,5 +443,4 @@ public class H5Ex_T_Compound {
|
||||
// data using malloc().
|
||||
H5Ex_T_Compound.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,52 +20,55 @@
|
||||
|
||||
package examples.datatypes;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_CompoundAttribute {
|
||||
private static String FILENAME = "H5Ex_T_CompoundAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String ATTRIBUTENAME = "A1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int RANK = 1;
|
||||
protected static final int INTEGERSIZE = 4;
|
||||
protected static final int DOUBLESIZE = 8;
|
||||
private static String FILENAME = "H5Ex_T_CompoundAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String ATTRIBUTENAME = "A1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int RANK = 1;
|
||||
protected static final int INTEGERSIZE = 4;
|
||||
protected static final int DOUBLESIZE = 8;
|
||||
protected final static int MAXSTRINGSIZE = 80;
|
||||
|
||||
// Using Java Externalization will add a two-byte object header in
|
||||
// the stream, which needs to be called out in the datatypes.
|
||||
static class Sensor_Datatype {
|
||||
static int numberMembers = 4;
|
||||
static int[] memberDims = { 1, 1, 1, 1 };
|
||||
static int[] memberDims = {1, 1, 1, 1};
|
||||
|
||||
static String[] memberNames = { "Serial number", "Location", "Temperature (F)", "Pressure (inHg)" };
|
||||
static long[] memberMemTypes = { HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5T_C_S1,
|
||||
HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5T_NATIVE_DOUBLE };
|
||||
static long[] memberFileTypes = { HDF5Constants.H5T_STD_I32BE, HDF5Constants.H5T_C_S1,
|
||||
HDF5Constants.H5T_IEEE_F64BE, HDF5Constants.H5T_IEEE_F64BE };
|
||||
static int[] memberStorage = { INTEGERSIZE, MAXSTRINGSIZE, DOUBLESIZE, DOUBLESIZE };
|
||||
static String[] memberNames = {"Serial number", "Location", "Temperature (F)", "Pressure (inHg)"};
|
||||
static long[] memberMemTypes = {HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5T_C_S1,
|
||||
HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5T_NATIVE_DOUBLE};
|
||||
static long[] memberFileTypes = {HDF5Constants.H5T_STD_I32BE, HDF5Constants.H5T_C_S1,
|
||||
HDF5Constants.H5T_IEEE_F64BE, HDF5Constants.H5T_IEEE_F64BE};
|
||||
static int[] memberStorage = {INTEGERSIZE, MAXSTRINGSIZE, DOUBLESIZE, DOUBLESIZE};
|
||||
|
||||
// Data size is the storage size for the members not the object.
|
||||
static long getTotalDataSize() {
|
||||
static long getTotalDataSize()
|
||||
{
|
||||
long data_size = 0;
|
||||
for (int indx = 0; indx < numberMembers; indx++)
|
||||
data_size += memberStorage[indx] * memberDims[indx];
|
||||
return DIM0 * data_size;
|
||||
}
|
||||
|
||||
static long getDataSize() {
|
||||
static long getDataSize()
|
||||
{
|
||||
long data_size = 0;
|
||||
for (int indx = 0; indx < numberMembers; indx++)
|
||||
data_size += memberStorage[indx] * memberDims[indx];
|
||||
return data_size;
|
||||
}
|
||||
|
||||
static int getOffset(int memberItem) {
|
||||
static int getOffset(int memberItem)
|
||||
{
|
||||
int data_offset = 0;
|
||||
for (int indx = 0; indx < memberItem; indx++)
|
||||
data_offset += memberStorage[indx];
|
||||
@@ -79,61 +82,64 @@ public class H5Ex_T_CompoundAttribute {
|
||||
public double temperature;
|
||||
public double pressure;
|
||||
|
||||
Sensor(int serial_no, String location, double temperature, double pressure) {
|
||||
this.serial_no = serial_no;
|
||||
this.location = location;
|
||||
Sensor(int serial_no, String location, double temperature, double pressure)
|
||||
{
|
||||
this.serial_no = serial_no;
|
||||
this.location = location;
|
||||
this.temperature = temperature;
|
||||
this.pressure = pressure;
|
||||
this.pressure = pressure;
|
||||
}
|
||||
|
||||
Sensor(ByteBuffer databuf, int dbposition) {
|
||||
readBuffer(databuf, dbposition);
|
||||
}
|
||||
Sensor(ByteBuffer databuf, int dbposition) { readBuffer(databuf, dbposition); }
|
||||
|
||||
void writeBuffer(ByteBuffer databuf, int dbposition) {
|
||||
void writeBuffer(ByteBuffer databuf, int dbposition)
|
||||
{
|
||||
databuf.putInt(dbposition + Sensor_Datatype.getOffset(0), serial_no);
|
||||
byte[] temp_str = location.getBytes(Charset.forName("UTF-8"));
|
||||
int arraylen = (temp_str.length > MAXSTRINGSIZE) ? MAXSTRINGSIZE : temp_str.length;
|
||||
int arraylen = (temp_str.length > MAXSTRINGSIZE) ? MAXSTRINGSIZE : temp_str.length;
|
||||
for (int ndx = 0; ndx < arraylen; ndx++)
|
||||
databuf.put(dbposition + Sensor_Datatype.getOffset(1) + ndx, temp_str[ndx]);
|
||||
for (int ndx = arraylen; ndx < MAXSTRINGSIZE; ndx++)
|
||||
databuf.put(dbposition + Sensor_Datatype.getOffset(1) + arraylen, (byte) 0);
|
||||
databuf.put(dbposition + Sensor_Datatype.getOffset(1) + arraylen, (byte)0);
|
||||
databuf.putDouble(dbposition + Sensor_Datatype.getOffset(2), temperature);
|
||||
databuf.putDouble(dbposition + Sensor_Datatype.getOffset(3), pressure);
|
||||
}
|
||||
|
||||
void readBuffer(ByteBuffer databuf, int dbposition) {
|
||||
this.serial_no = databuf.getInt(dbposition + Sensor_Datatype.getOffset(0));
|
||||
void readBuffer(ByteBuffer databuf, int dbposition)
|
||||
{
|
||||
this.serial_no = databuf.getInt(dbposition + Sensor_Datatype.getOffset(0));
|
||||
ByteBuffer stringbuf = databuf.duplicate();
|
||||
stringbuf.position(dbposition + Sensor_Datatype.getOffset(1));
|
||||
stringbuf.limit(dbposition + Sensor_Datatype.getOffset(1) + MAXSTRINGSIZE);
|
||||
byte[] bytearr = new byte[stringbuf.remaining()];
|
||||
stringbuf.get(bytearr);
|
||||
this.location = new String(bytearr, Charset.forName("UTF-8")).trim();
|
||||
this.location = new String(bytearr, Charset.forName("UTF-8")).trim();
|
||||
this.temperature = databuf.getDouble(dbposition + Sensor_Datatype.getOffset(2));
|
||||
this.pressure = databuf.getDouble(dbposition + Sensor_Datatype.getOffset(3));
|
||||
this.pressure = databuf.getDouble(dbposition + Sensor_Datatype.getOffset(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Serial number : " + serial_no + "%n" +
|
||||
"Location : " + location + "%n" +
|
||||
"Temperature (F) : " + temperature + "%n" +
|
||||
"Pressure (inHg) : " + pressure + "%n");
|
||||
public String toString()
|
||||
{
|
||||
return String.format("Serial number : " + serial_no + "%n"
|
||||
+ "Location : " + location + "%n"
|
||||
+ "Temperature (F) : " + temperature + "%n"
|
||||
+ "Pressure (inHg) : " + pressure + "%n");
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long strtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long strtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
Sensor[] object_data = new Sensor[DIM0];
|
||||
byte[] dset_data = null;
|
||||
byte[] dset_data = null;
|
||||
|
||||
// Initialize data.
|
||||
object_data[0] = new Sensor(1153, new String("Exterior (static)"), 53.23, 24.57);
|
||||
@@ -144,7 +150,7 @@ public class H5Ex_T_CompoundAttribute {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -168,8 +174,8 @@ public class H5Ex_T_CompoundAttribute {
|
||||
long type_id = Sensor_Datatype.memberMemTypes[indx];
|
||||
if (type_id == HDF5Constants.H5T_C_S1)
|
||||
type_id = strtype_id;
|
||||
H5.H5Tinsert(memtype_id, Sensor_Datatype.memberNames[indx], Sensor_Datatype.getOffset(indx),
|
||||
type_id);
|
||||
H5.H5Tinsert(memtype_id, Sensor_Datatype.memberNames[indx],
|
||||
Sensor_Datatype.getOffset(indx), type_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,8 +194,8 @@ public class H5Ex_T_CompoundAttribute {
|
||||
long type_id = Sensor_Datatype.memberFileTypes[indx];
|
||||
if (type_id == HDF5Constants.H5T_C_S1)
|
||||
type_id = strtype_id;
|
||||
H5.H5Tinsert(filetype_id, Sensor_Datatype.memberNames[indx], Sensor_Datatype.getOffset(indx),
|
||||
type_id);
|
||||
H5.H5Tinsert(filetype_id, Sensor_Datatype.memberNames[indx],
|
||||
Sensor_Datatype.getOffset(indx), type_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,7 +208,8 @@ public class H5Ex_T_CompoundAttribute {
|
||||
dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR);
|
||||
if (dataspace_id >= 0) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
H5.H5Sclose(dataspace_id);
|
||||
dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
}
|
||||
@@ -224,17 +231,17 @@ public class H5Ex_T_CompoundAttribute {
|
||||
try {
|
||||
if ((dataset_id >= 0) && (dataspace_id >= 0) && (filetype_id >= 0))
|
||||
attribute_id = H5.H5Acreate(dataset_id, ATTRIBUTENAME, filetype_id, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Write the compound data.
|
||||
dset_data = new byte[(int) dims[0] * (int)Sensor_Datatype.getDataSize()];
|
||||
dset_data = new byte[(int)dims[0] * (int)Sensor_Datatype.getDataSize()];
|
||||
ByteBuffer outBuf = ByteBuffer.wrap(dset_data);
|
||||
outBuf.order(ByteOrder.nativeOrder());
|
||||
for (int indx = 0; indx < (int) dims[0]; indx++) {
|
||||
for (int indx = 0; indx < (int)dims[0]; indx++) {
|
||||
object_data[indx].writeBuffer(outBuf, indx * (int)Sensor_Datatype.getDataSize());
|
||||
}
|
||||
try {
|
||||
@@ -305,17 +312,17 @@ public class H5Ex_T_CompoundAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long strtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long strtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
long[] dims = {DIM0};
|
||||
Sensor[] object_data2;
|
||||
byte[] dset_data;
|
||||
|
||||
@@ -339,7 +346,7 @@ public class H5Ex_T_CompoundAttribute {
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
attribute_id = H5.H5Aopen_by_name(dataset_id, ".", ATTRIBUTENAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -382,8 +389,8 @@ public class H5Ex_T_CompoundAttribute {
|
||||
long type_id = Sensor_Datatype.memberMemTypes[indx];
|
||||
if (type_id == HDF5Constants.H5T_C_S1)
|
||||
type_id = strtype_id;
|
||||
H5.H5Tinsert(memtype_id, Sensor_Datatype.memberNames[indx], Sensor_Datatype.getOffset(indx),
|
||||
type_id);
|
||||
H5.H5Tinsert(memtype_id, Sensor_Datatype.memberNames[indx],
|
||||
Sensor_Datatype.getOffset(indx), type_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,9 +399,9 @@ public class H5Ex_T_CompoundAttribute {
|
||||
}
|
||||
|
||||
// allocate memory for read buffer.
|
||||
dset_data = new byte[(int) dims[0] * (int)Sensor_Datatype.getDataSize()];
|
||||
dset_data = new byte[(int)dims[0] * (int)Sensor_Datatype.getDataSize()];
|
||||
|
||||
object_data2 = new Sensor[(int) dims[0]];
|
||||
object_data2 = new Sensor[(int)dims[0]];
|
||||
|
||||
// Read data.
|
||||
try {
|
||||
@@ -403,7 +410,7 @@ public class H5Ex_T_CompoundAttribute {
|
||||
|
||||
ByteBuffer inBuf = ByteBuffer.wrap(dset_data);
|
||||
inBuf.order(ByteOrder.nativeOrder());
|
||||
for (int indx = 0; indx < (int) dims[0]; indx++) {
|
||||
for (int indx = 0; indx < (int)dims[0]; indx++) {
|
||||
object_data2[indx] = new Sensor(inBuf, indx * (int)Sensor_Datatype.getDataSize());
|
||||
}
|
||||
}
|
||||
@@ -468,10 +475,10 @@ public class H5Ex_T_CompoundAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_CompoundAttribute.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -479,5 +486,4 @@ public class H5Ex_T_CompoundAttribute {
|
||||
// data using malloc().
|
||||
H5Ex_T_CompoundAttribute.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,17 +28,18 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_Float {
|
||||
private static String FILENAME = "H5Ex_T_Float.h5";
|
||||
private static String FILENAME = "H5Ex_T_Float.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0, DIM1};
|
||||
double[][] dset_data = new double[DIM0][DIM1];
|
||||
|
||||
// Initialize data.
|
||||
@@ -50,7 +51,7 @@ public class H5Ex_T_Float {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -73,7 +74,8 @@ public class H5Ex_T_Float {
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_IEEE_F64LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -82,8 +84,8 @@ public class H5Ex_T_Float {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -115,14 +117,14 @@ public class H5Ex_T_Float {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0, DIM1};
|
||||
double[][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -161,13 +163,13 @@ public class H5Ex_T_Float {
|
||||
|
||||
// Allocate array of pointers to two-dimensional arrays (the
|
||||
// elements of the dataset.
|
||||
dset_data = new double[(int) dims[0]][(int) (dims[1])];
|
||||
dset_data = new double[(int)dims[0]][(int)(dims[1])];
|
||||
|
||||
// Read data.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -211,10 +213,10 @@ public class H5Ex_T_Float {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_Float.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -222,5 +224,4 @@ public class H5Ex_T_Float {
|
||||
// data using malloc().
|
||||
H5Ex_T_Float.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,19 +28,20 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_FloatAttribute {
|
||||
private static String FILENAME = "H5Ex_T_FloatAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String FILENAME = "H5Ex_T_FloatAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String ATTRIBUTENAME = "A1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0, DIM1};
|
||||
double[][] dset_data = new double[DIM0][DIM1];
|
||||
|
||||
// Initialize data.
|
||||
@@ -52,7 +53,7 @@ public class H5Ex_T_FloatAttribute {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -63,7 +64,8 @@ public class H5Ex_T_FloatAttribute {
|
||||
dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR);
|
||||
if (dataspace_id >= 0) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
H5.H5Sclose(dataspace_id);
|
||||
dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
}
|
||||
@@ -84,8 +86,9 @@ public class H5Ex_T_FloatAttribute {
|
||||
// Create the attribute and write the array data to it.
|
||||
try {
|
||||
if ((dataset_id >= 0) && (dataspace_id >= 0))
|
||||
attribute_id = H5.H5Acreate(dataset_id, ATTRIBUTENAME, HDF5Constants.H5T_IEEE_F64LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
attribute_id =
|
||||
H5.H5Acreate(dataset_id, ATTRIBUTENAME, HDF5Constants.H5T_IEEE_F64LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -134,15 +137,15 @@ public class H5Ex_T_FloatAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
long[] dims = {DIM0, DIM1};
|
||||
double[][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -165,7 +168,7 @@ public class H5Ex_T_FloatAttribute {
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
attribute_id = H5.H5Aopen_by_name(dataset_id, ".", ATTRIBUTENAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -190,7 +193,7 @@ public class H5Ex_T_FloatAttribute {
|
||||
|
||||
// Allocate array of pointers to two-dimensional arrays (the
|
||||
// elements of the dataset.
|
||||
dset_data = new double[(int) dims[0]][(int) (dims[1])];
|
||||
dset_data = new double[(int)dims[0]][(int)(dims[1])];
|
||||
|
||||
// Read data.
|
||||
try {
|
||||
@@ -247,10 +250,10 @@ public class H5Ex_T_FloatAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_FloatAttribute.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -258,5 +261,4 @@ public class H5Ex_T_FloatAttribute {
|
||||
// data using malloc().
|
||||
H5Ex_T_FloatAttribute.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,17 +26,18 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_Integer {
|
||||
private static String FILENAME = "H5Ex_T_Integer.h5";
|
||||
private static String FILENAME = "H5Ex_T_Integer.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0, DIM1};
|
||||
int[][] dset_data = new int[DIM0][DIM1];
|
||||
|
||||
// Initialize data.
|
||||
@@ -48,7 +49,7 @@ public class H5Ex_T_Integer {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -70,7 +71,8 @@ public class H5Ex_T_Integer {
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I64BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -79,8 +81,8 @@ public class H5Ex_T_Integer {
|
||||
// Write the data to the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -112,14 +114,14 @@ public class H5Ex_T_Integer {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0, DIM1};
|
||||
int[][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -158,13 +160,13 @@ public class H5Ex_T_Integer {
|
||||
|
||||
// Allocate array of pointers to two-dimensional arrays (the
|
||||
// elements of the dataset.
|
||||
dset_data = new int[(int) dims[0]][(int) (dims[1])];
|
||||
dset_data = new int[(int)dims[0]][(int)(dims[1])];
|
||||
|
||||
// Read data.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -208,10 +210,10 @@ public class H5Ex_T_Integer {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_Integer.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -219,5 +221,4 @@ public class H5Ex_T_Integer {
|
||||
// data using malloc().
|
||||
H5Ex_T_Integer.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,19 +26,20 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_IntegerAttribute {
|
||||
private static String FILENAME = "H5Ex_T_IntegerAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String FILENAME = "H5Ex_T_IntegerAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String ATTRIBUTENAME = "A1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int DIM1 = 7;
|
||||
private static final int RANK = 2;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
long[] dims = {DIM0, DIM1};
|
||||
int[][] dset_data = new int[DIM0][DIM1];
|
||||
|
||||
// Initialize data.
|
||||
@@ -50,7 +51,7 @@ public class H5Ex_T_IntegerAttribute {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -61,7 +62,8 @@ public class H5Ex_T_IntegerAttribute {
|
||||
dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR);
|
||||
if (dataspace_id >= 0) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
H5.H5Sclose(dataspace_id);
|
||||
dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
}
|
||||
@@ -82,8 +84,9 @@ public class H5Ex_T_IntegerAttribute {
|
||||
// Create the attribute and write the array data to it.
|
||||
try {
|
||||
if ((dataset_id >= 0) && (dataspace_id >= 0))
|
||||
attribute_id = H5.H5Acreate(dataset_id, ATTRIBUTENAME, HDF5Constants.H5T_STD_I64BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
attribute_id =
|
||||
H5.H5Acreate(dataset_id, ATTRIBUTENAME, HDF5Constants.H5T_STD_I64BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -132,15 +135,15 @@ public class H5Ex_T_IntegerAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0, DIM1 };
|
||||
long[] dims = {DIM0, DIM1};
|
||||
int[][] dset_data;
|
||||
|
||||
// Open an existing file.
|
||||
@@ -163,7 +166,7 @@ public class H5Ex_T_IntegerAttribute {
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
attribute_id = H5.H5Aopen_by_name(dataset_id, ".", ATTRIBUTENAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -188,7 +191,7 @@ public class H5Ex_T_IntegerAttribute {
|
||||
|
||||
// Allocate array of pointers to two-dimensional arrays (the
|
||||
// elements of the dataset.
|
||||
dset_data = new int[(int) dims[0]][(int) (dims[1])];
|
||||
dset_data = new int[(int)dims[0]][(int)(dims[1])];
|
||||
|
||||
// Read data.
|
||||
try {
|
||||
@@ -245,10 +248,10 @@ public class H5Ex_T_IntegerAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_IntegerAttribute.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -256,5 +259,4 @@ public class H5Ex_T_IntegerAttribute {
|
||||
// data using malloc().
|
||||
H5Ex_T_IntegerAttribute.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,54 +28,50 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_ObjectReference {
|
||||
private static String FILENAME = "H5Ex_T_ObjectReference.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String FILENAME = "H5Ex_T_ObjectReference.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String DATASETNAME2 = "DS2";
|
||||
private static String GROUPNAME = "G1";
|
||||
private static final int DIM0 = 2;
|
||||
private static final int RANK = 1;
|
||||
private static String GROUPNAME = "G1";
|
||||
private static final int DIM0 = 2;
|
||||
private static final int RANK = 1;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5G_obj {
|
||||
H5G_UNKNOWN(HDF5Constants.H5O_TYPE_UNKNOWN), /* Unknown object type */
|
||||
H5G_GROUP(HDF5Constants.H5O_TYPE_GROUP), /* Object is a group */
|
||||
H5G_DATASET(HDF5Constants.H5O_TYPE_DATASET), /* Object is a dataset */
|
||||
H5G_UNKNOWN(HDF5Constants.H5O_TYPE_UNKNOWN), /* Unknown object type */
|
||||
H5G_GROUP(HDF5Constants.H5O_TYPE_GROUP), /* Object is a group */
|
||||
H5G_DATASET(HDF5Constants.H5O_TYPE_DATASET), /* Object is a dataset */
|
||||
H5G_TYPE(HDF5Constants.H5O_TYPE_NAMED_DATATYPE); /* Object is a named data type */
|
||||
private static final Map<Integer, H5G_obj> lookup = new HashMap<Integer, H5G_obj>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5G_obj s : EnumSet.allOf(H5G_obj.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5G_obj(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5G_obj(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5G_obj get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5G_obj get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static void writeObjRef() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
private static void writeObjRef()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filespace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
byte[][] dset_data = new byte[DIM0][HDF5Constants.H5R_REF_BUF_SIZE];
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -86,7 +82,8 @@ public class H5Ex_T_ObjectReference {
|
||||
dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR);
|
||||
if ((file_id >= 0) && (dataspace_id >= 0)) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME2, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dclose(dataset_id);
|
||||
dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
@@ -101,8 +98,8 @@ public class H5Ex_T_ObjectReference {
|
||||
// Create a group in the file.
|
||||
try {
|
||||
if (file_id >= 0)
|
||||
group_id = H5.H5Gcreate(file_id, GROUPNAME, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
group_id = H5.H5Gcreate(file_id, GROUPNAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
if (group_id >= 0)
|
||||
H5.H5Gclose(group_id);
|
||||
group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
@@ -119,7 +116,7 @@ public class H5Ex_T_ObjectReference {
|
||||
catch (Throwable err) {
|
||||
err.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
dset_data[1] = H5.H5Rcreate_object(file_id, DATASETNAME2, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
@@ -127,7 +124,7 @@ public class H5Ex_T_ObjectReference {
|
||||
err.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create dataspace. Setting maximum size to NULL sets the maximum
|
||||
// size to be the current size.
|
||||
try {
|
||||
@@ -136,22 +133,23 @@ public class H5Ex_T_ObjectReference {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// Create the dataset.
|
||||
try {
|
||||
if ((file_id >= 0) && (filespace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_REF, filespace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// Write the object references to it.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_STD_REF, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_STD_REF, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -161,8 +159,16 @@ public class H5Ex_T_ObjectReference {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Rdestroy(dset_data[1]);} catch (Exception ex) {}
|
||||
try {H5.H5Rdestroy(dset_data[0]);} catch (Exception ex) {}
|
||||
try {
|
||||
H5.H5Rdestroy(dset_data[1]);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
try {
|
||||
H5.H5Rdestroy(dset_data[0]);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
// End access to the dataset and release resources used by it.
|
||||
@@ -193,13 +199,14 @@ public class H5Ex_T_ObjectReference {
|
||||
}
|
||||
}
|
||||
|
||||
private static void readObjRef() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int object_type = -1;
|
||||
long object_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
private static void readObjRef()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int object_type = -1;
|
||||
long object_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
byte[][] dset_data = new byte[DIM0][HDF5Constants.H5R_REF_BUF_SIZE];
|
||||
|
||||
// Open an existing file.
|
||||
@@ -209,23 +216,24 @@ public class H5Ex_T_ObjectReference {
|
||||
// Open an existing dataset.
|
||||
try {
|
||||
dataset_id = H5.H5Dopen(file_id, DATASETNAME, HDF5Constants.H5P_DEFAULT);
|
||||
|
||||
|
||||
try {
|
||||
// Get dataspace and allocate memory for read buffer.
|
||||
dataspace_id = H5.H5Dget_space(dataset_id);
|
||||
H5.H5Sget_simple_extent_dims(dataspace_id, dims, null);
|
||||
|
||||
|
||||
// Read data.
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_STD_REF, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_STD_REF, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
|
||||
// Output the data to the screen.
|
||||
for (int indx = 0; indx < dims[0]; indx++) {
|
||||
System.out.println(DATASETNAME + "[" + indx + "]:");
|
||||
System.out.print(" ->");
|
||||
// Open the referenced object, get its name and type.
|
||||
try {
|
||||
object_id = H5.H5Ropen_object(dset_data[indx], HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
object_id = H5.H5Ropen_object(dset_data[indx], HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
try {
|
||||
object_type = H5.H5Rget_obj_type3(dset_data[indx], HDF5Constants.H5R_OBJECT);
|
||||
String obj_name = null;
|
||||
@@ -255,14 +263,22 @@ public class H5Ex_T_ObjectReference {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Oclose(object_id);} catch (Exception e) {}
|
||||
try {
|
||||
H5.H5Oclose(object_id);
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e4) {
|
||||
e4.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Rdestroy(dset_data[indx]);} catch (Exception e4) {}
|
||||
try {
|
||||
H5.H5Rdestroy(dset_data[indx]);
|
||||
}
|
||||
catch (Exception e4) {
|
||||
}
|
||||
}
|
||||
} // end for
|
||||
}
|
||||
@@ -270,25 +286,38 @@ public class H5Ex_T_ObjectReference {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Sclose(dataspace_id);} catch (Exception e3) {}
|
||||
try {
|
||||
H5.H5Sclose(dataspace_id);
|
||||
}
|
||||
catch (Exception e3) {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Dclose(dataset_id);} catch (Exception e2) {}
|
||||
try {
|
||||
H5.H5Dclose(dataset_id);
|
||||
}
|
||||
catch (Exception e2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Fclose(file_id);} catch (Exception e1) {}
|
||||
try {
|
||||
H5.H5Fclose(file_id);
|
||||
}
|
||||
catch (Exception e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Check if gzip compression is available and can be used for both
|
||||
// compression and decompression. Normally we do not perform error
|
||||
// checking in these examples for the sake of clarity, but in this
|
||||
@@ -297,5 +326,4 @@ public class H5Ex_T_ObjectReference {
|
||||
H5Ex_T_ObjectReference.writeObjRef();
|
||||
H5Ex_T_ObjectReference.readObjRef();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,55 +28,51 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_ObjectReferenceAttribute {
|
||||
private static String FILENAME = "H5Ex_T_ObjectReferenceAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String FILENAME = "H5Ex_T_ObjectReferenceAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String ATTRIBUTENAME = "A1";
|
||||
private static String DATASETNAME2 = "DS2";
|
||||
private static String GROUPNAME = "G1";
|
||||
private static final int DIM0 = 2;
|
||||
private static final int RANK = 1;
|
||||
private static String DATASETNAME2 = "DS2";
|
||||
private static String GROUPNAME = "G1";
|
||||
private static final int DIM0 = 2;
|
||||
private static final int RANK = 1;
|
||||
|
||||
// Values for the status of space allocation
|
||||
enum H5G_obj {
|
||||
H5G_UNKNOWN(HDF5Constants.H5O_TYPE_UNKNOWN), /* Unknown object type */
|
||||
H5G_GROUP(HDF5Constants.H5O_TYPE_GROUP), /* Object is a group */
|
||||
H5G_DATASET(HDF5Constants.H5O_TYPE_DATASET), /* Object is a dataset */
|
||||
H5G_UNKNOWN(HDF5Constants.H5O_TYPE_UNKNOWN), /* Unknown object type */
|
||||
H5G_GROUP(HDF5Constants.H5O_TYPE_GROUP), /* Object is a group */
|
||||
H5G_DATASET(HDF5Constants.H5O_TYPE_DATASET), /* Object is a dataset */
|
||||
H5G_TYPE(HDF5Constants.H5O_TYPE_NAMED_DATATYPE); /* Object is a named data type */
|
||||
private static final Map<Integer, H5G_obj> lookup = new HashMap<Integer, H5G_obj>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5G_obj s : EnumSet.allOf(H5G_obj.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5G_obj(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5G_obj(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5G_obj get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5G_obj get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
byte[][] dset_data = new byte[DIM0][HDF5Constants.H5R_REF_BUF_SIZE];
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -87,7 +83,8 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR);
|
||||
if ((file_id >= 0) && (dataspace_id >= 0)) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME2, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dclose(dataset_id);
|
||||
dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
@@ -102,8 +99,8 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
// Create a group in the file.
|
||||
try {
|
||||
if (file_id >= 0)
|
||||
group_id = H5.H5Gcreate(file_id, GROUPNAME, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
group_id = H5.H5Gcreate(file_id, GROUPNAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
if (group_id >= 0)
|
||||
H5.H5Gclose(group_id);
|
||||
group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
@@ -120,7 +117,7 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
catch (Throwable err) {
|
||||
err.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
dset_data[1] = H5.H5Rcreate_object(file_id, DATASETNAME2, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
@@ -135,7 +132,8 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR);
|
||||
if (dataspace_id >= 0) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
H5.H5Sclose(dataspace_id);
|
||||
dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
}
|
||||
@@ -143,7 +141,7 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// Create dataspace. Setting maximum size to NULL sets the maximum
|
||||
// size to be the current size.
|
||||
try {
|
||||
@@ -152,17 +150,18 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// Create the attribute and write the array data to it.
|
||||
try {
|
||||
if ((dataset_id >= 0) && (dataspace_id >= 0))
|
||||
attribute_id = H5.H5Acreate(dataset_id, ATTRIBUTENAME, HDF5Constants.H5T_STD_REF, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
attribute_id =
|
||||
H5.H5Acreate(dataset_id, ATTRIBUTENAME, HDF5Constants.H5T_STD_REF, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// Write the dataset.
|
||||
try {
|
||||
if (attribute_id >= 0)
|
||||
@@ -176,8 +175,16 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Rdestroy(dset_data[1]);} catch (Exception ex) {}
|
||||
try {H5.H5Rdestroy(dset_data[0]);} catch (Exception ex) {}
|
||||
try {
|
||||
H5.H5Rdestroy(dset_data[1]);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
try {
|
||||
H5.H5Rdestroy(dset_data[0]);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
// End access to the dataset and release resources used by it.
|
||||
@@ -215,14 +222,15 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int object_type = -1;
|
||||
long object_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int object_type = -1;
|
||||
long object_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
byte[][] dset_data = new byte[DIM0][HDF5Constants.H5R_REF_BUF_SIZE];
|
||||
|
||||
// Open an existing file.
|
||||
@@ -232,28 +240,30 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
// Open an existing dataset.
|
||||
try {
|
||||
dataset_id = H5.H5Dopen(file_id, DATASETNAME, HDF5Constants.H5P_DEFAULT);
|
||||
|
||||
|
||||
try {
|
||||
attribute_id = H5.H5Aopen_by_name(dataset_id, ".", ATTRIBUTENAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
|
||||
attribute_id = H5.H5Aopen_by_name(dataset_id, ".", ATTRIBUTENAME,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
|
||||
// Get dataspace and allocate memory for read buffer.
|
||||
try {
|
||||
dataspace_id = H5.H5Aget_space(attribute_id);
|
||||
H5.H5Sget_simple_extent_dims(dataspace_id, dims, null);
|
||||
|
||||
|
||||
// Read data.
|
||||
H5.H5Aread(attribute_id, HDF5Constants.H5T_STD_REF, dset_data);
|
||||
|
||||
|
||||
// Output the data to the screen.
|
||||
for (int indx = 0; indx < dims[0]; indx++) {
|
||||
System.out.println(ATTRIBUTENAME + "[" + indx + "]:");
|
||||
System.out.print(" ->");
|
||||
// Open the referenced object, get its name and type.
|
||||
try {
|
||||
object_id = H5.H5Ropen_object(dset_data[indx], HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
object_id = H5.H5Ropen_object(dset_data[indx], HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
try {
|
||||
object_type = H5.H5Rget_obj_type3(dset_data[indx], HDF5Constants.H5R_OBJECT);
|
||||
object_type =
|
||||
H5.H5Rget_obj_type3(dset_data[indx], HDF5Constants.H5R_OBJECT);
|
||||
String obj_name = null;
|
||||
if (object_type >= 0) {
|
||||
// Get the name.
|
||||
@@ -281,14 +291,22 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Oclose(object_id);} catch (Exception e) {}
|
||||
try {
|
||||
H5.H5Oclose(object_id);
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e5) {
|
||||
e5.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Rdestroy(dset_data[indx]);} catch (Exception e5) {}
|
||||
try {
|
||||
H5.H5Rdestroy(dset_data[indx]);
|
||||
}
|
||||
catch (Exception e5) {
|
||||
}
|
||||
}
|
||||
} // end for
|
||||
}
|
||||
@@ -296,32 +314,49 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
e4.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Sclose(dataspace_id);} catch (Exception e3) {}
|
||||
try {
|
||||
H5.H5Sclose(dataspace_id);
|
||||
}
|
||||
catch (Exception e3) {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Aclose(attribute_id);} catch (Exception e4) {}
|
||||
try {
|
||||
H5.H5Aclose(attribute_id);
|
||||
}
|
||||
catch (Exception e4) {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Dclose(dataset_id);} catch (Exception e2) {}
|
||||
try {
|
||||
H5.H5Dclose(dataset_id);
|
||||
}
|
||||
catch (Exception e2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {H5.H5Fclose(file_id);} catch (Exception e1) {}
|
||||
try {
|
||||
H5.H5Fclose(file_id);
|
||||
}
|
||||
catch (Exception e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_ObjectReferenceAttribute.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -329,5 +364,4 @@ public class H5Ex_T_ObjectReferenceAttribute {
|
||||
// data using malloc().
|
||||
H5Ex_T_ObjectReferenceAttribute.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,32 +24,33 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_Opaque {
|
||||
private static String FILENAME = "H5Ex_T_Opaque.h5";
|
||||
private static String FILENAME = "H5Ex_T_Opaque.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int LEN = 7;
|
||||
private static final int RANK = 1;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int LEN = 7;
|
||||
private static final int RANK = 1;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long datatype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
byte[] dset_data = new byte[DIM0 * LEN];
|
||||
byte[] str_data = { 'O', 'P', 'A', 'Q', 'U', 'E' };
|
||||
long datatype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
byte[] dset_data = new byte[DIM0 * LEN];
|
||||
byte[] str_data = {'O', 'P', 'A', 'Q', 'U', 'E'};
|
||||
|
||||
// Initialize data.
|
||||
for (int indx = 0; indx < DIM0; indx++) {
|
||||
for (int jndx = 0; jndx < LEN - 1; jndx++)
|
||||
dset_data[jndx + indx * LEN] = str_data[jndx];
|
||||
dset_data[LEN - 1 + indx * LEN] = (byte) (indx + '0');
|
||||
dset_data[LEN - 1 + indx * LEN] = (byte)(indx + '0');
|
||||
}
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -82,8 +83,9 @@ public class H5Ex_T_Opaque {
|
||||
// automatically converts between different integer types.
|
||||
try {
|
||||
if ((file_id >= 0) && (datatype_id >= 0) && (dataspace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, datatype_id, dataspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
dataset_id =
|
||||
H5.H5Dcreate(file_id, DATASETNAME, datatype_id, dataspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -93,7 +95,7 @@ public class H5Ex_T_Opaque {
|
||||
try {
|
||||
if ((dataset_id >= 0) && (datatype_id >= 0))
|
||||
H5.H5Dwrite(dataset_id, datatype_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -133,16 +135,16 @@ public class H5Ex_T_Opaque {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long datatype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long datatype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long type_len = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long type_len = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
byte[] dset_data;
|
||||
String tag_name = null;
|
||||
|
||||
@@ -194,13 +196,13 @@ public class H5Ex_T_Opaque {
|
||||
}
|
||||
|
||||
// Allocate buffer.
|
||||
dset_data = new byte[(int) (dims[0] * type_len)];
|
||||
dset_data = new byte[(int)(dims[0] * type_len)];
|
||||
|
||||
// Read data.
|
||||
try {
|
||||
if ((dataset_id >= 0) && (datatype_id >= 0))
|
||||
H5.H5Dread(dataset_id, datatype_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -211,7 +213,7 @@ public class H5Ex_T_Opaque {
|
||||
for (int indx = 0; indx < dims[0]; indx++) {
|
||||
System.out.print(DATASETNAME + "[" + indx + "]: ");
|
||||
for (int jndx = 0; jndx < type_len; jndx++) {
|
||||
char temp = (char) dset_data[jndx + indx * (int)type_len];
|
||||
char temp = (char)dset_data[jndx + indx * (int)type_len];
|
||||
System.out.print(temp);
|
||||
}
|
||||
System.out.println("");
|
||||
@@ -252,10 +254,10 @@ public class H5Ex_T_Opaque {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_Opaque.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -263,5 +265,4 @@ public class H5Ex_T_Opaque {
|
||||
// data using malloc().
|
||||
H5Ex_T_Opaque.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,34 +24,35 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_OpaqueAttribute {
|
||||
private static String FILENAME = "H5Ex_T_OpaqueAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String FILENAME = "H5Ex_T_OpaqueAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String ATTRIBUTENAME = "A1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int LEN = 7;
|
||||
private static final int RANK = 1;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int LEN = 7;
|
||||
private static final int RANK = 1;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long datatype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long datatype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
byte[] dset_data = new byte[DIM0 * LEN];
|
||||
byte[] str_data = { 'O', 'P', 'A', 'Q', 'U', 'E' };
|
||||
long[] dims = {DIM0};
|
||||
byte[] dset_data = new byte[DIM0 * LEN];
|
||||
byte[] str_data = {'O', 'P', 'A', 'Q', 'U', 'E'};
|
||||
|
||||
// Initialize data.
|
||||
for (int indx = 0; indx < DIM0; indx++) {
|
||||
for (int jndx = 0; jndx < LEN - 1; jndx++)
|
||||
dset_data[jndx + indx * LEN] = str_data[jndx];
|
||||
dset_data[LEN - 1 + indx * LEN] = (byte) (indx + '0');
|
||||
dset_data[LEN - 1 + indx * LEN] = (byte)(indx + '0');
|
||||
}
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -62,7 +63,8 @@ public class H5Ex_T_OpaqueAttribute {
|
||||
dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR);
|
||||
if (dataspace_id >= 0) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
H5.H5Sclose(dataspace_id);
|
||||
dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
}
|
||||
@@ -96,7 +98,7 @@ public class H5Ex_T_OpaqueAttribute {
|
||||
try {
|
||||
if ((dataset_id >= 0) && (datatype_id >= 0) && (dataspace_id >= 0))
|
||||
attribute_id = H5.H5Acreate(dataset_id, ATTRIBUTENAME, datatype_id, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -153,17 +155,17 @@ public class H5Ex_T_OpaqueAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long datatype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long datatype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long type_len = -1;
|
||||
long[] dims = { DIM0 };
|
||||
long type_len = -1;
|
||||
long[] dims = {DIM0};
|
||||
byte[] dset_data;
|
||||
String tag_name = null;
|
||||
|
||||
@@ -187,7 +189,7 @@ public class H5Ex_T_OpaqueAttribute {
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
attribute_id = H5.H5Aopen_by_name(dataset_id, ".", ATTRIBUTENAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -224,7 +226,7 @@ public class H5Ex_T_OpaqueAttribute {
|
||||
}
|
||||
|
||||
// Allocate buffer.
|
||||
dset_data = new byte[(int) (dims[0] * type_len)];
|
||||
dset_data = new byte[(int)(dims[0] * type_len)];
|
||||
|
||||
// Read data.
|
||||
try {
|
||||
@@ -240,7 +242,7 @@ public class H5Ex_T_OpaqueAttribute {
|
||||
for (int indx = 0; indx < dims[0]; indx++) {
|
||||
System.out.print(ATTRIBUTENAME + "[" + indx + "]: ");
|
||||
for (int jndx = 0; jndx < type_len; jndx++) {
|
||||
char temp = (char) dset_data[jndx + indx * (int)type_len];
|
||||
char temp = (char)dset_data[jndx + indx * (int)type_len];
|
||||
System.out.print(temp);
|
||||
}
|
||||
System.out.println("");
|
||||
@@ -289,10 +291,10 @@ public class H5Ex_T_OpaqueAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_OpaqueAttribute.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -300,5 +302,4 @@ public class H5Ex_T_OpaqueAttribute {
|
||||
// data using malloc().
|
||||
H5Ex_T_OpaqueAttribute.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,27 +24,28 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_String {
|
||||
private static String FILENAME = "H5Ex_T_String.h5";
|
||||
private static String FILENAME = "H5Ex_T_String.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int SDIM = 8;
|
||||
private static final int RANK = 1;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int SDIM = 8;
|
||||
private static final int RANK = 1;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
byte[][] dset_data = new byte[DIM0][SDIM];
|
||||
StringBuffer[] str_data = { new StringBuffer("Parting"), new StringBuffer("is such"),
|
||||
new StringBuffer("sweet"), new StringBuffer("sorrow.") };
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
byte[][] dset_data = new byte[DIM0][SDIM];
|
||||
StringBuffer[] str_data = {new StringBuffer("Parting"), new StringBuffer("is such"),
|
||||
new StringBuffer("sweet"), new StringBuffer("sorrow.")};
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -82,8 +83,9 @@ public class H5Ex_T_String {
|
||||
// Create the dataset and write the string data to it.
|
||||
try {
|
||||
if ((file_id >= 0) && (filetype_id >= 0) && (dataspace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, filetype_id, dataspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
dataset_id =
|
||||
H5.H5Dcreate(file_id, DATASETNAME, filetype_id, dataspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -94,14 +96,14 @@ public class H5Ex_T_String {
|
||||
for (int indx = 0; indx < DIM0; indx++) {
|
||||
for (int jndx = 0; jndx < SDIM; jndx++) {
|
||||
if (jndx < str_data[indx].length())
|
||||
dset_data[indx][jndx] = (byte) str_data[indx].charAt(jndx);
|
||||
dset_data[indx][jndx] = (byte)str_data[indx].charAt(jndx);
|
||||
else
|
||||
dset_data[indx][jndx] = 0;
|
||||
}
|
||||
}
|
||||
if ((dataset_id >= 0) && (memtype_id >= 0))
|
||||
H5.H5Dwrite(dataset_id, memtype_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -151,17 +153,17 @@ public class H5Ex_T_String {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long sdim = 0;
|
||||
long[] dims = { DIM0 };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long sdim = 0;
|
||||
long[] dims = {DIM0};
|
||||
byte[][] dset_data;
|
||||
StringBuffer[] str_data;
|
||||
|
||||
@@ -213,8 +215,8 @@ public class H5Ex_T_String {
|
||||
}
|
||||
|
||||
// Allocate space for data.
|
||||
dset_data = new byte[(int) dims[0]][(int)sdim];
|
||||
str_data = new StringBuffer[(int) dims[0]];
|
||||
dset_data = new byte[(int)dims[0]][(int)sdim];
|
||||
str_data = new StringBuffer[(int)dims[0]];
|
||||
|
||||
// Create the memory datatype.
|
||||
try {
|
||||
@@ -230,9 +232,9 @@ public class H5Ex_T_String {
|
||||
try {
|
||||
if ((dataset_id >= 0) && (memtype_id >= 0))
|
||||
H5.H5Dread(dataset_id, memtype_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
byte[] tempbuf = new byte[(int)sdim];
|
||||
for (int indx = 0; indx < (int) dims[0]; indx++) {
|
||||
for (int indx = 0; indx < (int)dims[0]; indx++) {
|
||||
for (int jndx = 0; jndx < sdim; jndx++) {
|
||||
tempbuf[jndx] = dset_data[indx][jndx];
|
||||
}
|
||||
@@ -293,10 +295,10 @@ public class H5Ex_T_String {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_String.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -304,5 +306,4 @@ public class H5Ex_T_String {
|
||||
// data using malloc().
|
||||
H5Ex_T_String.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,29 +24,30 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_StringAttribute {
|
||||
private static String FILENAME = "H5Ex_T_StringAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String FILENAME = "H5Ex_T_StringAttribute.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
private static String ATTRIBUTENAME = "A1";
|
||||
private static final int DIM0 = 4;
|
||||
private static final int SDIM = 8;
|
||||
private static final int RANK = 1;
|
||||
private static final int DIM0 = 4;
|
||||
private static final int SDIM = 8;
|
||||
private static final int RANK = 1;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM0 };
|
||||
byte[][] dset_data = new byte[DIM0][SDIM];
|
||||
StringBuffer[] str_data = { new StringBuffer("Parting"), new StringBuffer("is such"),
|
||||
new StringBuffer("sweet"), new StringBuffer("sorrow.") };
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM0};
|
||||
byte[][] dset_data = new byte[DIM0][SDIM];
|
||||
StringBuffer[] str_data = {new StringBuffer("Parting"), new StringBuffer("is such"),
|
||||
new StringBuffer("sweet"), new StringBuffer("sorrow.")};
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -77,7 +78,8 @@ public class H5Ex_T_StringAttribute {
|
||||
dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR);
|
||||
if (dataspace_id >= 0) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
H5.H5Sclose(dataspace_id);
|
||||
dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
}
|
||||
@@ -99,7 +101,7 @@ public class H5Ex_T_StringAttribute {
|
||||
try {
|
||||
if ((dataset_id >= 0) && (dataspace_id >= 0) && (filetype_id >= 0))
|
||||
attribute_id = H5.H5Acreate(dataset_id, ATTRIBUTENAME, filetype_id, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -110,7 +112,7 @@ public class H5Ex_T_StringAttribute {
|
||||
for (int indx = 0; indx < DIM0; indx++) {
|
||||
for (int jndx = 0; jndx < SDIM; jndx++) {
|
||||
if (jndx < str_data[indx].length())
|
||||
dset_data[indx][jndx] = (byte) str_data[indx].charAt(jndx);
|
||||
dset_data[indx][jndx] = (byte)str_data[indx].charAt(jndx);
|
||||
else
|
||||
dset_data[indx][jndx] = 0;
|
||||
}
|
||||
@@ -174,18 +176,18 @@ public class H5Ex_T_StringAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ReadDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long filetype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long memtype_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long sdim = 0;
|
||||
long[] dims = { DIM0 };
|
||||
long sdim = 0;
|
||||
long[] dims = {DIM0};
|
||||
byte[][] dset_data;
|
||||
StringBuffer[] str_data;
|
||||
|
||||
@@ -209,7 +211,7 @@ public class H5Ex_T_StringAttribute {
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
attribute_id = H5.H5Aopen_by_name(dataset_id, ".", ATTRIBUTENAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -246,8 +248,8 @@ public class H5Ex_T_StringAttribute {
|
||||
}
|
||||
|
||||
// Allocate space for data.
|
||||
dset_data = new byte[(int) dims[0]][(int)sdim];
|
||||
str_data = new StringBuffer[(int) dims[0]];
|
||||
dset_data = new byte[(int)dims[0]][(int)sdim];
|
||||
str_data = new StringBuffer[(int)dims[0]];
|
||||
|
||||
// Create the memory datatype.
|
||||
try {
|
||||
@@ -264,7 +266,7 @@ public class H5Ex_T_StringAttribute {
|
||||
if ((attribute_id >= 0) && (memtype_id >= 0))
|
||||
H5.H5Aread(attribute_id, memtype_id, dset_data);
|
||||
byte[] tempbuf = new byte[(int)sdim];
|
||||
for (int indx = 0; indx < (int) dims[0]; indx++) {
|
||||
for (int indx = 0; indx < (int)dims[0]; indx++) {
|
||||
for (int jndx = 0; jndx < sdim; jndx++) {
|
||||
tempbuf[jndx] = dset_data[indx][jndx];
|
||||
}
|
||||
@@ -333,10 +335,10 @@ public class H5Ex_T_StringAttribute {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_StringAttribute.CreateDataset();
|
||||
// Now we begin the read section of this example. Here we assume
|
||||
// the dataset and array have the same name and rank, but can have
|
||||
@@ -344,5 +346,4 @@ public class H5Ex_T_StringAttribute {
|
||||
// data using malloc().
|
||||
H5Ex_T_StringAttribute.ReadDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,24 +19,24 @@ package examples.datatypes;
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_T_VLString
|
||||
{
|
||||
private static String FILENAME = "H5Ex_T_VLString.h5";
|
||||
public class H5Ex_T_VLString {
|
||||
private static String FILENAME = "H5Ex_T_VLString.h5";
|
||||
private static String DATASETNAME = "DS1";
|
||||
|
||||
private static void createDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long type_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void createDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long type_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int rank = 1;
|
||||
String[] str_data = { "Parting", "is such", "sweet", "sorrow." };
|
||||
long[] dims = { str_data.length };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int rank = 1;
|
||||
String[] str_data = {"Parting", "is such", "sweet", "sorrow."};
|
||||
long[] dims = {str_data.length};
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -62,8 +62,9 @@ public class H5Ex_T_VLString
|
||||
// Create the dataset and write the string data to it.
|
||||
try {
|
||||
if ((file_id >= 0) && (type_id >= 0) && (dataspace_id >= 0)) {
|
||||
dataset_id = H5.H5Dcreate(file_id, DATASETNAME, type_id, dataspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
dataset_id =
|
||||
H5.H5Dcreate(file_id, DATASETNAME, type_id, dataspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -74,7 +75,7 @@ public class H5Ex_T_VLString
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite_VLStrings(dataset_id, type_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, str_data);
|
||||
HDF5Constants.H5P_DEFAULT, str_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -91,11 +92,12 @@ public class H5Ex_T_VLString
|
||||
}
|
||||
}
|
||||
|
||||
private static void readDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long type_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
String[] str_data = { "", "", "", "" };
|
||||
private static void readDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long type_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
String[] str_data = {"", "", "", ""};
|
||||
|
||||
try {
|
||||
file_id = H5.H5Fopen(FILENAME, HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
|
||||
@@ -106,9 +108,9 @@ public class H5Ex_T_VLString
|
||||
|
||||
try {
|
||||
dataset_id = H5.H5Dopen(file_id, DATASETNAME, HDF5Constants.H5P_DEFAULT);
|
||||
type_id = H5.H5Dget_type(dataset_id);
|
||||
H5.H5Dread_VLStrings(dataset_id, type_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT,
|
||||
str_data);
|
||||
type_id = H5.H5Dget_type(dataset_id);
|
||||
H5.H5Dread_VLStrings(dataset_id, type_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, str_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -127,9 +129,9 @@ public class H5Ex_T_VLString
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5Ex_T_VLString.createDataset();
|
||||
H5Ex_T_VLString.readDataset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,13 @@ foreach (example ${HDF_JAVA_EXAMPLES})
|
||||
# install_jar (${example} ${HJAVA_INSTALL_DATA_DIR}/examples examples)
|
||||
get_target_property (${example}_CLASSPATH ${example} CLASSDIR)
|
||||
add_dependencies (${example} ${HDF5_JAVA_HDF5_LIB_TARGET})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target to clang-format
|
||||
#-----------------------------------------------------------------------------
|
||||
if (HDF5_ENABLE_FORMATTERS)
|
||||
clang_format (HDF5_JAVA_${example}_SRC_FORMAT ${example}.java)
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
set (CMAKE_JAVA_INCLUDE_PATH "${HDF5_JAVA_JARS};${HDF5_JAVA_LOGGING_JAR};${HDF5_JAVA_LOGGING_NOP_JAR}")
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package examples.groups;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
import hdf.hdf5lib.structs.H5G_info_t;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
import hdf.hdf5lib.structs.H5G_info_t;
|
||||
|
||||
public class H5Ex_G_Compact {
|
||||
|
||||
private static final String FILE1 = "H5Ex_G_Compact1.h5";
|
||||
@@ -38,44 +38,42 @@ public class H5Ex_G_Compact {
|
||||
|
||||
private static final Map<Integer, H5G_storage> lookup = new HashMap<Integer, H5G_storage>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5G_storage s : EnumSet.allOf(H5G_storage.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5G_storage(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5G_storage(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5G_storage get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5G_storage get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
public static void CreateGroup() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
public static void CreateGroup()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long fapl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long fapl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
H5G_info_t ginfo;
|
||||
long size;
|
||||
|
||||
// Create file 1. This file will use original format groups.
|
||||
try {
|
||||
file_id = H5.H5Fcreate (FILE1, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
file_id = H5.H5Fcreate(FILE1, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Create a group in the file1.
|
||||
try {
|
||||
if(file_id >= 0)
|
||||
group_id = H5.H5Gcreate(file_id, GROUP, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
if (file_id >= 0)
|
||||
group_id = H5.H5Gcreate(file_id, GROUP, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -83,7 +81,7 @@ public class H5Ex_G_Compact {
|
||||
|
||||
// Obtain the group info and print the group storage type.
|
||||
try {
|
||||
if(group_id >= 0) {
|
||||
if (group_id >= 0) {
|
||||
ginfo = H5.H5Gget_info(group_id);
|
||||
System.out.print("Group storage type for " + FILE1 + " is: ");
|
||||
switch (H5G_storage.get(ginfo.storage_type)) {
|
||||
@@ -160,7 +158,8 @@ public class H5Ex_G_Compact {
|
||||
try {
|
||||
fapl_id = H5.H5Pcreate(HDF5Constants.H5P_FILE_ACCESS);
|
||||
if (fapl_id >= 0)
|
||||
H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_LATEST, HDF5Constants.H5F_LIBVER_LATEST);
|
||||
H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_LATEST,
|
||||
HDF5Constants.H5F_LIBVER_LATEST);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -175,8 +174,9 @@ public class H5Ex_G_Compact {
|
||||
}
|
||||
// Create group in file2.
|
||||
try {
|
||||
if(file_id >= 0)
|
||||
group_id = H5.H5Gcreate(file_id, GROUP, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
if (file_id >= 0)
|
||||
group_id = H5.H5Gcreate(file_id, GROUP, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -257,7 +257,5 @@ public class H5Ex_G_Compact {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5Ex_G_Compact.CreateGroup();
|
||||
}
|
||||
public static void main(String[] args) { H5Ex_G_Compact.CreateGroup(); }
|
||||
}
|
||||
|
||||
@@ -23,11 +23,12 @@ import hdf.hdf5lib.structs.H5G_info_t;
|
||||
public class H5Ex_G_Corder {
|
||||
private static String FILE = "H5Ex_G_Corder.h5";
|
||||
|
||||
private static void CreateGroup() throws Exception {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateGroup() throws Exception
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long subgroup_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long gcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long gcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int status;
|
||||
H5G_info_t ginfo;
|
||||
int i;
|
||||
@@ -36,35 +37,35 @@ public class H5Ex_G_Corder {
|
||||
try {
|
||||
// Create a new file using default properties.
|
||||
file_id = H5.H5Fcreate(FILE, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
|
||||
// Create group creation property list and enable link creation order tracking.
|
||||
gcpl_id = H5.H5Pcreate(HDF5Constants.H5P_GROUP_CREATE);
|
||||
status = H5.H5Pset_link_creation_order(gcpl_id, HDF5Constants.H5P_CRT_ORDER_TRACKED
|
||||
+ HDF5Constants.H5P_CRT_ORDER_INDEXED);
|
||||
status = H5.H5Pset_link_creation_order(gcpl_id, HDF5Constants.H5P_CRT_ORDER_TRACKED +
|
||||
HDF5Constants.H5P_CRT_ORDER_INDEXED);
|
||||
|
||||
// Create primary group using the property list.
|
||||
if (status >= 0)
|
||||
group_id = H5.H5Gcreate(file_id, "index_group", HDF5Constants.H5P_DEFAULT, gcpl_id,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
|
||||
try {
|
||||
/*
|
||||
* Create subgroups in the primary group. These will be tracked by creation order. Note that these
|
||||
* groups do not have to have the creation order tracking property set.
|
||||
* Create subgroups in the primary group. These will be tracked by creation order. Note that
|
||||
* these groups do not have to have the creation order tracking property set.
|
||||
*/
|
||||
subgroup_id = H5.H5Gcreate(group_id, "H", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
status = H5.H5Gclose(subgroup_id);
|
||||
subgroup_id = H5.H5Gcreate(group_id, "D", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
status = H5.H5Gclose(subgroup_id);
|
||||
subgroup_id = H5.H5Gcreate(group_id, "F", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
status = H5.H5Gclose(subgroup_id);
|
||||
subgroup_id = H5.H5Gcreate(group_id, "5", HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
status = H5.H5Gclose(subgroup_id);
|
||||
subgroup_id = H5.H5Gcreate(group_id, "H", HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
status = H5.H5Gclose(subgroup_id);
|
||||
subgroup_id = H5.H5Gcreate(group_id, "D", HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
status = H5.H5Gclose(subgroup_id);
|
||||
subgroup_id = H5.H5Gcreate(group_id, "F", HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
status = H5.H5Gclose(subgroup_id);
|
||||
subgroup_id = H5.H5Gcreate(group_id, "5", HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
status = H5.H5Gclose(subgroup_id);
|
||||
|
||||
// Get group info.
|
||||
ginfo = H5.H5Gget_info(group_id);
|
||||
@@ -73,8 +74,8 @@ public class H5Ex_G_Corder {
|
||||
System.out.println("Traversing group using alphabetical indices:");
|
||||
for (i = 0; i < ginfo.nlinks; i++) {
|
||||
// Retrieve the name of the ith link in a group
|
||||
name = H5.H5Lget_name_by_idx(group_id, ".", HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_INC,
|
||||
i, HDF5Constants.H5P_DEFAULT);
|
||||
name = H5.H5Lget_name_by_idx(group_id, ".", HDF5Constants.H5_INDEX_NAME,
|
||||
HDF5Constants.H5_ITER_INC, i, HDF5Constants.H5P_DEFAULT);
|
||||
System.out.println("Index " + i + ": " + name);
|
||||
}
|
||||
|
||||
@@ -83,10 +84,9 @@ public class H5Ex_G_Corder {
|
||||
for (i = 0; i < ginfo.nlinks; i++) {
|
||||
// Retrieve the name of the ith link in a group
|
||||
name = H5.H5Lget_name_by_idx(group_id, ".", HDF5Constants.H5_INDEX_CRT_ORDER,
|
||||
HDF5Constants.H5_ITER_INC, i, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5_ITER_INC, i, HDF5Constants.H5P_DEFAULT);
|
||||
System.out.println("Index " + i + ": " + name);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -106,7 +106,8 @@ public class H5Ex_G_Corder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
try {
|
||||
H5Ex_G_Corder.CreateGroup();
|
||||
}
|
||||
@@ -114,5 +115,4 @@ public class H5Ex_G_Corder {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,17 +20,18 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5Ex_G_Create {
|
||||
private static String FILENAME = "H5Ex_G_Create.h5";
|
||||
private static String FILENAME = "H5Ex_G_Create.h5";
|
||||
private static String GROUPNAME = "G1";
|
||||
|
||||
private static void CreateGroup() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateGroup()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -39,8 +40,8 @@ public class H5Ex_G_Create {
|
||||
// Create a group in the file.
|
||||
try {
|
||||
if (file_id >= 0)
|
||||
group_id = H5.H5Gcreate(file_id, "/" + GROUPNAME, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
group_id = H5.H5Gcreate(file_id, "/" + GROUPNAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -81,11 +82,7 @@ public class H5Ex_G_Create {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5Ex_G_Create.CreateGroup();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5Ex_G_Create.CreateGroup(); }
|
||||
}
|
||||
|
||||
@@ -16,47 +16,49 @@
|
||||
************************************************************/
|
||||
package examples.groups;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
import hdf.hdf5lib.callbacks.H5O_iterate_t;
|
||||
import hdf.hdf5lib.callbacks.H5O_iterate_opdata_t;
|
||||
import hdf.hdf5lib.callbacks.H5O_iterate_t;
|
||||
import hdf.hdf5lib.structs.H5O_info_t;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class H5Ex_G_Intermediate {
|
||||
|
||||
private static String FILE = "H5Ex_G_Intermediate.h5";
|
||||
|
||||
private void CreateGroup() throws Exception {
|
||||
private void CreateGroup() throws Exception
|
||||
{
|
||||
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long gcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long gcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
|
||||
try {
|
||||
// Create a new file_id using the default properties.
|
||||
file_id = H5.H5Fcreate(FILE, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
|
||||
// Create group_id creation property list and set it to allow creation of intermediate group_ids.
|
||||
gcpl_id = H5.H5Pcreate(HDF5Constants.H5P_LINK_CREATE);
|
||||
H5.H5Pset_create_intermediate_group(gcpl_id, true);
|
||||
|
||||
/*
|
||||
* Create the group_id /G1/G2/G3. Note that /G1 and /G1/G2 do not exist yet. This call would cause an error
|
||||
* if we did not use the previously created property list.
|
||||
* Create the group_id /G1/G2/G3. Note that /G1 and /G1/G2 do not exist yet. This call would cause
|
||||
* an error if we did not use the previously created property list.
|
||||
*/
|
||||
group_id = H5
|
||||
.H5Gcreate(file_id, "/G1/G2/G3", gcpl_id, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
group_id = H5.H5Gcreate(file_id, "/G1/G2/G3", gcpl_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
// Print all the objects in the file_ids to show that intermediate group_ids have been created.
|
||||
System.out.println("Objects in the file_id:");
|
||||
|
||||
// H5O_iterate_opdata_t iter_data = null;
|
||||
H5O_iterate_opdata_t iter_data = new H5O_iter_data();
|
||||
H5O_iterate_t iter_cb = new H5O_iter_callback();
|
||||
H5O_iterate_t iter_cb = new H5O_iter_callback();
|
||||
|
||||
H5.H5Ovisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb, iter_data);
|
||||
H5.H5Ovisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb,
|
||||
iter_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -72,7 +74,8 @@ public class H5Ex_G_Intermediate {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
try {
|
||||
(new H5Ex_G_Intermediate()).CreateGroup();
|
||||
}
|
||||
@@ -83,9 +86,10 @@ public class H5Ex_G_Intermediate {
|
||||
|
||||
private class idata {
|
||||
public String link_name = null;
|
||||
public int link_type = -1;
|
||||
public int link_type = -1;
|
||||
|
||||
idata(String name, int type) {
|
||||
idata(String name, int type)
|
||||
{
|
||||
this.link_name = name;
|
||||
this.link_type = type;
|
||||
}
|
||||
@@ -96,9 +100,10 @@ public class H5Ex_G_Intermediate {
|
||||
}
|
||||
|
||||
private class H5O_iter_callback implements H5O_iterate_t {
|
||||
public int callback(long group, String name, H5O_info_t info, H5O_iterate_opdata_t op_data) {
|
||||
public int callback(long group, String name, H5O_info_t info, H5O_iterate_opdata_t op_data)
|
||||
{
|
||||
idata id = new idata(name, info.type);
|
||||
((H5O_iter_data) op_data).iterdata.add(id);
|
||||
((H5O_iter_data)op_data).iterdata.add(id);
|
||||
|
||||
System.out.print("/"); /* Print root group in object path */
|
||||
|
||||
@@ -118,5 +123,4 @@ public class H5Ex_G_Intermediate {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,47 +16,43 @@
|
||||
************************************************************/
|
||||
package examples.groups;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
import hdf.hdf5lib.structs.H5O_token_t;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
import hdf.hdf5lib.structs.H5O_token_t;
|
||||
|
||||
public class H5Ex_G_Iterate {
|
||||
private static String FILENAME = "groups/h5ex_g_iterate.h5";
|
||||
private static String FILENAME = "groups/h5ex_g_iterate.h5";
|
||||
private static String DATASETNAME = "/";
|
||||
|
||||
enum H5O_type {
|
||||
H5O_TYPE_UNKNOWN(-1), // Unknown object type
|
||||
H5O_TYPE_GROUP(0), // Object is a group
|
||||
H5O_TYPE_DATASET(1), // Object is a dataset
|
||||
H5O_TYPE_UNKNOWN(-1), // Unknown object type
|
||||
H5O_TYPE_GROUP(0), // Object is a group
|
||||
H5O_TYPE_DATASET(1), // Object is a dataset
|
||||
H5O_TYPE_NAMED_DATATYPE(2), // Object is a named data type
|
||||
H5O_TYPE_NTYPES(3); // Number of different object types
|
||||
H5O_TYPE_NTYPES(3); // Number of different object types
|
||||
private static final Map<Integer, H5O_type> lookup = new HashMap<Integer, H5O_type>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5O_type s : EnumSet.allOf(H5O_type.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5O_type(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5O_type(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5O_type get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5O_type get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static void do_iterate() {
|
||||
private static void do_iterate()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
|
||||
// Open a file using default properties.
|
||||
@@ -71,12 +67,13 @@ public class H5Ex_G_Iterate {
|
||||
System.out.println("Objects in root group:");
|
||||
try {
|
||||
if (file_id >= 0) {
|
||||
int count = (int) H5.H5Gn_members(file_id, DATASETNAME);
|
||||
String[] oname = new String[count];
|
||||
int[] otype = new int[count];
|
||||
int[] ltype = new int[count];
|
||||
int count = (int)H5.H5Gn_members(file_id, DATASETNAME);
|
||||
String[] oname = new String[count];
|
||||
int[] otype = new int[count];
|
||||
int[] ltype = new int[count];
|
||||
H5O_token_t[] otokens = new H5O_token_t[count];
|
||||
H5.H5Gget_obj_info_all(file_id, DATASETNAME, oname, otype, ltype, otokens, HDF5Constants.H5_INDEX_NAME);
|
||||
H5.H5Gget_obj_info_all(file_id, DATASETNAME, oname, otype, ltype, otokens,
|
||||
HDF5Constants.H5_INDEX_NAME);
|
||||
|
||||
// Get type of the object and display its name and type.
|
||||
for (int indx = 0; indx < otype.length; indx++) {
|
||||
@@ -110,8 +107,5 @@ public class H5Ex_G_Iterate {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5Ex_G_Iterate.do_iterate();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5Ex_G_Iterate.do_iterate(); }
|
||||
}
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
************************************************************/
|
||||
package examples.groups;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
import hdf.hdf5lib.structs.H5G_info_t;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
import hdf.hdf5lib.structs.H5G_info_t;
|
||||
|
||||
public class H5Ex_G_Phase {
|
||||
private static String FILE = "H5Ex_G_Phase.h5";
|
||||
private static int MAX_GROUPS = 7;
|
||||
private static String FILE = "H5Ex_G_Phase.h5";
|
||||
private static int MAX_GROUPS = 7;
|
||||
private static int MAX_COMPACT = 5;
|
||||
private static int MIN_DENSE = 3;
|
||||
private static int MIN_DENSE = 3;
|
||||
|
||||
enum H5G_storage {
|
||||
H5G_STORAGE_TYPE_UNKNOWN(-1),
|
||||
@@ -38,42 +38,39 @@ public class H5Ex_G_Phase {
|
||||
|
||||
private static final Map<Integer, H5G_storage> lookup = new HashMap<Integer, H5G_storage>();
|
||||
|
||||
static {
|
||||
static
|
||||
{
|
||||
for (H5G_storage s : EnumSet.allOf(H5G_storage.class))
|
||||
lookup.put(s.getCode(), s);
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
H5G_storage(int layout_type) {
|
||||
this.code = layout_type;
|
||||
}
|
||||
H5G_storage(int layout_type) { this.code = layout_type; }
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
public int getCode() { return this.code; }
|
||||
|
||||
public static H5G_storage get(int code) {
|
||||
return lookup.get(code);
|
||||
}
|
||||
public static H5G_storage get(int code) { return lookup.get(code); }
|
||||
}
|
||||
|
||||
private static void CreateGroup() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateGroup()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long subgroup_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long fapl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long gcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long fapl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long gcpl_id = HDF5Constants.H5I_INVALID_HID;
|
||||
H5G_info_t ginfo;
|
||||
String name = "G0"; // Name of subgroup_id
|
||||
int i;
|
||||
|
||||
// Set file access property list to allow the latest file format.This will allow the library to create new
|
||||
// format groups.
|
||||
// Set file access property list to allow the latest file format.This will allow the library to create
|
||||
// new format groups.
|
||||
try {
|
||||
fapl_id = H5.H5Pcreate(HDF5Constants.H5P_FILE_ACCESS);
|
||||
if (fapl_id >= 0)
|
||||
H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_LATEST, HDF5Constants.H5F_LIBVER_LATEST);
|
||||
H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_LATEST,
|
||||
HDF5Constants.H5F_LIBVER_LATEST);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -101,21 +98,23 @@ public class H5Ex_G_Phase {
|
||||
// Create primary group.
|
||||
try {
|
||||
if ((file_id >= 0) && (gcpl_id >= 0))
|
||||
group_id = H5.H5Gcreate(file_id, name, HDF5Constants.H5P_DEFAULT, gcpl_id, HDF5Constants.H5P_DEFAULT);
|
||||
group_id = H5.H5Gcreate(file_id, name, HDF5Constants.H5P_DEFAULT, gcpl_id,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Add subgroups to "group" one at a time, print the storage type for "group" after each subgroup is created.
|
||||
// Add subgroups to "group" one at a time, print the storage type for "group" after each subgroup is
|
||||
// created.
|
||||
for (i = 1; i <= MAX_GROUPS; i++) {
|
||||
// Define the subgroup name and create the subgroup.
|
||||
char append = (char) (((char) i) + '0');
|
||||
name = name + append; /* G1, G2, G3 etc. */
|
||||
char append = (char)(((char)i) + '0');
|
||||
name = name + append; /* G1, G2, G3 etc. */
|
||||
try {
|
||||
if (group_id >= 0) {
|
||||
subgroup_id = H5.H5Gcreate(group_id, name, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
subgroup_id = H5.H5Gcreate(group_id, name, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
H5.H5Gclose(subgroup_id);
|
||||
}
|
||||
}
|
||||
@@ -127,7 +126,8 @@ public class H5Ex_G_Phase {
|
||||
try {
|
||||
if (group_id >= 0) {
|
||||
ginfo = H5.H5Gget_info(group_id);
|
||||
System.out.print(ginfo.nlinks + " Group" + (ginfo.nlinks == 1 ? " " : "s") + ": Storage type is ");
|
||||
System.out.print(ginfo.nlinks + " Group" + (ginfo.nlinks == 1 ? " " : "s") +
|
||||
": Storage type is ");
|
||||
switch (H5G_storage.get(ginfo.storage_type)) {
|
||||
case H5G_STORAGE_TYPE_COMPACT:
|
||||
System.out.println("H5G_STORAGE_TYPE_COMPACT"); // New compact format
|
||||
@@ -169,7 +169,8 @@ public class H5Ex_G_Phase {
|
||||
try {
|
||||
if (group_id >= 0) {
|
||||
ginfo = H5.H5Gget_info(group_id);
|
||||
System.out.print(ginfo.nlinks + " Group" + (ginfo.nlinks == 1 ? " " : "s") + ": Storage type is ");
|
||||
System.out.print(ginfo.nlinks + " Group" + (ginfo.nlinks == 1 ? " " : "s") +
|
||||
": Storage type is ");
|
||||
switch (H5G_storage.get(ginfo.storage_type)) {
|
||||
case H5G_STORAGE_TYPE_COMPACT:
|
||||
System.out.println("H5G_STORAGE_TYPE_COMPACT"); // New compact format
|
||||
@@ -228,11 +229,7 @@ public class H5Ex_G_Phase {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5Ex_G_Phase.CreateGroup();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5Ex_G_Phase.CreateGroup(); }
|
||||
}
|
||||
|
||||
@@ -24,10 +24,11 @@ package examples.groups;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
import hdf.hdf5lib.callbacks.H5L_iterate_t;
|
||||
import hdf.hdf5lib.callbacks.H5L_iterate_opdata_t;
|
||||
import hdf.hdf5lib.callbacks.H5L_iterate_t;
|
||||
import hdf.hdf5lib.structs.H5L_info_t;
|
||||
import hdf.hdf5lib.structs.H5O_info_t;
|
||||
|
||||
import examples.groups.H5Ex_G_Iterate.H5O_type;
|
||||
|
||||
class opdata implements H5L_iterate_opdata_t {
|
||||
@@ -38,10 +39,11 @@ class opdata implements H5L_iterate_opdata_t {
|
||||
|
||||
public class H5Ex_G_Traverse {
|
||||
|
||||
private static String FILE = "h5ex_g_traverse.h5";
|
||||
private static String FILE = "h5ex_g_traverse.h5";
|
||||
public static H5L_iterate_t iter_cb = new H5L_iter_callbackT();
|
||||
|
||||
private static void OpenGroup() {
|
||||
private static void OpenGroup()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
H5O_info_t infobuf;
|
||||
opdata od = new opdata();
|
||||
@@ -50,9 +52,9 @@ public class H5Ex_G_Traverse {
|
||||
try {
|
||||
file_id = H5.H5Fopen(FILE, HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
|
||||
if (file_id >= 0) {
|
||||
infobuf = H5.H5Oget_info(file_id);
|
||||
od.recurs = 0;
|
||||
od.prev = null;
|
||||
infobuf = H5.H5Oget_info(file_id);
|
||||
od.recurs = 0;
|
||||
od.prev = null;
|
||||
od.obj_token = infobuf.token;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +66,8 @@ public class H5Ex_G_Traverse {
|
||||
try {
|
||||
System.out.println("/ {");
|
||||
// H5L_iterate_t iter_cb = new H5L_iter_callbackT();
|
||||
H5.H5Literate(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, 0L, iter_cb, od);
|
||||
H5.H5Literate(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, 0L, iter_cb,
|
||||
od);
|
||||
System.out.println("}");
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -81,18 +84,17 @@ public class H5Ex_G_Traverse {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5Ex_G_Traverse.OpenGroup();
|
||||
}
|
||||
public static void main(String[] args) { H5Ex_G_Traverse.OpenGroup(); }
|
||||
}
|
||||
|
||||
class H5L_iter_callbackT implements H5L_iterate_t {
|
||||
public int callback(long group, String name, H5L_info_t info, H5L_iterate_opdata_t op_data) {
|
||||
public int callback(long group, String name, H5L_info_t info, H5L_iterate_opdata_t op_data)
|
||||
{
|
||||
|
||||
H5O_info_t infobuf;
|
||||
int return_val = 0;
|
||||
opdata od = (opdata) op_data; // Type conversion
|
||||
int spaces = 2 * (od.recurs + 1); // Number of white spaces to prepend to output.
|
||||
opdata od = (opdata)op_data; // Type conversion
|
||||
int spaces = 2 * (od.recurs + 1); // Number of white spaces to prepend to output.
|
||||
|
||||
// Get type of the object and display its name and type.
|
||||
// The name of the object is passed to this function by the Library.
|
||||
@@ -123,13 +125,14 @@ class H5L_iter_callbackT implements H5L_iterate_t {
|
||||
// recursive iteration on the discovered
|
||||
// group. The new opdata is given a pointer to the
|
||||
// current one.
|
||||
opdata nextod = new opdata();
|
||||
nextod.recurs = od.recurs + 1;
|
||||
nextod.prev = od;
|
||||
nextod.obj_token = infobuf.token;
|
||||
opdata nextod = new opdata();
|
||||
nextod.recurs = od.recurs + 1;
|
||||
nextod.prev = od;
|
||||
nextod.obj_token = infobuf.token;
|
||||
H5L_iterate_t iter_cb2 = new H5L_iter_callbackT();
|
||||
return_val = H5.H5Literate_by_name(group, name, HDF5Constants.H5_INDEX_NAME,
|
||||
HDF5Constants.H5_ITER_NATIVE, 0L, iter_cb2, nextod, HDF5Constants.H5P_DEFAULT);
|
||||
return_val = H5.H5Literate_by_name(group, name, HDF5Constants.H5_INDEX_NAME,
|
||||
HDF5Constants.H5_ITER_NATIVE, 0L, iter_cb2, nextod,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
for (int i = 0; i < spaces; i++)
|
||||
System.out.print(" ");
|
||||
@@ -152,7 +155,8 @@ class H5L_iter_callbackT implements H5L_iterate_t {
|
||||
return return_val;
|
||||
}
|
||||
|
||||
public boolean group_check(opdata od, H5O_token_t target_token) {
|
||||
public boolean group_check(opdata od, H5O_token_t target_token)
|
||||
{
|
||||
if (od.obj_token.equals(target_token))
|
||||
return true; // Object tokens match
|
||||
else if (od.recurs == 0)
|
||||
@@ -160,5 +164,4 @@ class H5L_iter_callbackT implements H5L_iterate_t {
|
||||
else
|
||||
return group_check(od.prev, target_token); // Recursively examine the next node
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,22 +20,23 @@
|
||||
************************************************************/
|
||||
package examples.groups;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
import hdf.hdf5lib.callbacks.H5L_iterate_t;
|
||||
import hdf.hdf5lib.callbacks.H5L_iterate_opdata_t;
|
||||
import hdf.hdf5lib.callbacks.H5O_iterate_t;
|
||||
import hdf.hdf5lib.callbacks.H5L_iterate_t;
|
||||
import hdf.hdf5lib.callbacks.H5O_iterate_opdata_t;
|
||||
import hdf.hdf5lib.callbacks.H5O_iterate_t;
|
||||
import hdf.hdf5lib.structs.H5L_info_t;
|
||||
import hdf.hdf5lib.structs.H5O_info_t;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class H5Ex_G_Visit {
|
||||
|
||||
private static String FILE = "groups/h5ex_g_visit.h5";
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
try {
|
||||
(new H5Ex_G_Visit()).VisitGroup();
|
||||
}
|
||||
@@ -44,7 +45,8 @@ public class H5Ex_G_Visit {
|
||||
}
|
||||
}
|
||||
|
||||
private void VisitGroup() throws Exception {
|
||||
private void VisitGroup() throws Exception
|
||||
{
|
||||
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
|
||||
@@ -55,15 +57,16 @@ public class H5Ex_G_Visit {
|
||||
// Begin iteration using H5Ovisit
|
||||
System.out.println("Objects in the file:");
|
||||
H5O_iterate_opdata_t iter_data = new H5O_iter_data();
|
||||
H5O_iterate_t iter_cb = new H5O_iter_callback();
|
||||
H5.H5Ovisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb, iter_data);
|
||||
H5O_iterate_t iter_cb = new H5O_iter_callback();
|
||||
H5.H5Ovisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb,
|
||||
iter_data);
|
||||
System.out.println();
|
||||
// Repeat the same process using H5Lvisit
|
||||
H5L_iterate_opdata_t iter_data2 = new H5L_iter_data();
|
||||
H5L_iterate_t iter_cb2 = new H5L_iter_callback();
|
||||
H5L_iterate_t iter_cb2 = new H5L_iter_callback();
|
||||
System.out.println("Links in the file:");
|
||||
H5.H5Lvisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb2, iter_data2);
|
||||
|
||||
H5.H5Lvisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb2,
|
||||
iter_data2);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -76,15 +79,16 @@ public class H5Ex_G_Visit {
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Operator function for H5Lvisit. This function simply retrieves the info for the object the current link points
|
||||
* to, and calls the operator function for H5Ovisit.
|
||||
* Operator function for H5Lvisit. This function simply retrieves the info for the object the current link
|
||||
*points to, and calls the operator function for H5Ovisit.
|
||||
************************************************************/
|
||||
|
||||
private class idata {
|
||||
public String link_name = null;
|
||||
public int link_type = -1;
|
||||
public int link_type = -1;
|
||||
|
||||
idata(String name, int type) {
|
||||
idata(String name, int type)
|
||||
{
|
||||
this.link_name = name;
|
||||
this.link_type = type;
|
||||
}
|
||||
@@ -95,20 +99,21 @@ public class H5Ex_G_Visit {
|
||||
}
|
||||
|
||||
private class H5L_iter_callback implements H5L_iterate_t {
|
||||
public int callback(long group, String name, H5L_info_t info, H5L_iterate_opdata_t op_data) {
|
||||
public int callback(long group, String name, H5L_info_t info, H5L_iterate_opdata_t op_data)
|
||||
{
|
||||
|
||||
idata id = new idata(name, info.type);
|
||||
((H5L_iter_data) op_data).iterdata.add(id);
|
||||
((H5L_iter_data)op_data).iterdata.add(id);
|
||||
|
||||
H5O_info_t infobuf;
|
||||
int ret = 0;
|
||||
try {
|
||||
// Get type of the object and display its name and type. The name of the object is passed to this
|
||||
// function by the Library.
|
||||
infobuf = H5.H5Oget_info_by_name(group, name, HDF5Constants.H5P_DEFAULT);
|
||||
// Get type of the object and display its name and type. The name of the object is passed to
|
||||
// this function by the Library.
|
||||
infobuf = H5.H5Oget_info_by_name(group, name, HDF5Constants.H5P_DEFAULT);
|
||||
H5O_iterate_t iter_cbO = new H5O_iter_callback();
|
||||
H5O_iterate_opdata_t iter_dataO = new H5O_iter_data();
|
||||
ret = iter_cbO.callback(group, name, infobuf, iter_dataO);
|
||||
ret = iter_cbO.callback(group, name, infobuf, iter_dataO);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -123,9 +128,10 @@ public class H5Ex_G_Visit {
|
||||
}
|
||||
|
||||
private class H5O_iter_callback implements H5O_iterate_t {
|
||||
public int callback(long group, String name, H5O_info_t info, H5O_iterate_opdata_t op_data) {
|
||||
public int callback(long group, String name, H5O_info_t info, H5O_iterate_opdata_t op_data)
|
||||
{
|
||||
idata id = new idata(name, info.type);
|
||||
((H5O_iter_data) op_data).iterdata.add(id);
|
||||
((H5O_iter_data)op_data).iterdata.add(id);
|
||||
|
||||
System.out.print("/"); /* Print root group in object path */
|
||||
|
||||
@@ -145,5 +151,4 @@ public class H5Ex_G_Visit {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,13 @@ foreach (example ${HDF_JAVA_EXAMPLES})
|
||||
# install_jar (${example} ${HJAVA_INSTALL_DATA_DIR}/examples examples)
|
||||
get_target_property (${example}_CLASSPATH ${example} CLASSDIR)
|
||||
add_dependencies (${example} ${HDF5_JAVA_HDF5_LIB_TARGET})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target to clang-format
|
||||
#-----------------------------------------------------------------------------
|
||||
if (HDF5_ENABLE_FORMATTERS)
|
||||
clang_format (HDF5_JAVA_${example}_SRC_FORMAT ${example}.java)
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
set (CMAKE_JAVA_INCLUDE_PATH "${HDF5_JAVA_JARS};${HDF5_JAVA_LOGGING_JAR};${HDF5_JAVA_LOGGING_NOP_JAR}")
|
||||
|
||||
@@ -20,25 +20,26 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5_CreateAttribute {
|
||||
private static String FILENAME = "H5_CreateAttribute.h5";
|
||||
private static String DATASETNAME = "dset";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 6;
|
||||
private static String FILENAME = "H5_CreateAttribute.h5";
|
||||
private static String DATASETNAME = "dset";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 6;
|
||||
private static String DATASETATTRIBUTE = "Units";
|
||||
|
||||
private static void CreateDatasetAttribute() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateDatasetAttribute()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long attribute_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims1 = { DIM_X, DIM_Y };
|
||||
long[] dims = { 2 };
|
||||
int[] attr_data = { 100, 200 };
|
||||
long[] dims1 = {DIM_X, DIM_Y};
|
||||
long[] dims = {2};
|
||||
int[] attr_data = {100, 200};
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -55,8 +56,9 @@ public class H5_CreateAttribute {
|
||||
// Create the dataset.
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, "/" + DATASETNAME, HDF5Constants.H5T_STD_I32BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
dataset_id = H5.H5Dcreate(file_id, "/" + DATASETNAME, HDF5Constants.H5T_STD_I32BE,
|
||||
dataspace_id, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -82,8 +84,9 @@ public class H5_CreateAttribute {
|
||||
// Create a dataset attribute.
|
||||
try {
|
||||
if ((dataset_id >= 0) && (dataspace_id >= 0))
|
||||
attribute_id = H5.H5Acreate(dataset_id, DATASETATTRIBUTE, HDF5Constants.H5T_STD_I32BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
attribute_id =
|
||||
H5.H5Acreate(dataset_id, DATASETATTRIBUTE, HDF5Constants.H5T_STD_I32BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -135,8 +138,5 @@ public class H5_CreateAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5_CreateAttribute.CreateDatasetAttribute();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5_CreateAttribute.CreateDatasetAttribute(); }
|
||||
}
|
||||
|
||||
@@ -20,21 +20,22 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5_CreateDataset {
|
||||
private static String FILENAME = "H5_CreateDataset.h5";
|
||||
private static String FILENAME = "H5_CreateDataset.h5";
|
||||
private static String DATASETNAME = "dset";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 6;
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 6;
|
||||
|
||||
private static void CreateDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -51,8 +52,9 @@ public class H5_CreateDataset {
|
||||
// Create the dataset.
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, "/" + DATASETNAME, HDF5Constants.H5T_STD_I32BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
dataset_id = H5.H5Dcreate(file_id, "/" + DATASETNAME, HDF5Constants.H5T_STD_I32BE,
|
||||
dataspace_id, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -84,11 +86,7 @@ public class H5_CreateDataset {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5_CreateDataset.CreateDataset();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5_CreateDataset.CreateDataset(); }
|
||||
}
|
||||
|
||||
@@ -22,13 +22,14 @@ import hdf.hdf5lib.HDF5Constants;
|
||||
public class H5_CreateFile {
|
||||
static final String FILENAME = "H5_CreateFile.h5";
|
||||
|
||||
private static void CreateFile() {
|
||||
private static void CreateFile()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -42,11 +43,7 @@ public class H5_CreateFile {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5_CreateFile.CreateFile();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5_CreateFile.CreateFile(); }
|
||||
}
|
||||
|
||||
@@ -20,17 +20,18 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5_CreateGroup {
|
||||
private static String FILENAME = "H5_CreateGroup.h5";
|
||||
private static String FILENAME = "H5_CreateGroup.h5";
|
||||
private static String GROUPNAME = "MyGroup";
|
||||
|
||||
private static void CreateGroup() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateGroup()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -39,8 +40,8 @@ public class H5_CreateGroup {
|
||||
// Create a group in the file.
|
||||
try {
|
||||
if (file_id >= 0)
|
||||
group_id = H5.H5Gcreate(file_id, "/" + GROUPNAME, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
group_id = H5.H5Gcreate(file_id, "/" + GROUPNAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -63,11 +64,7 @@ public class H5_CreateGroup {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5_CreateGroup.CreateGroup();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5_CreateGroup.CreateGroup(); }
|
||||
}
|
||||
|
||||
@@ -20,13 +20,14 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5_CreateGroupAbsoluteRelative {
|
||||
private static String FILENAME = "H5_CreateGroupAbsoluteRelative.h5";
|
||||
private static String GROUPNAME = "MyGroup";
|
||||
private static String FILENAME = "H5_CreateGroupAbsoluteRelative.h5";
|
||||
private static String GROUPNAME = "MyGroup";
|
||||
private static String GROUPNAME_A = "GroupA";
|
||||
private static String GROUPNAME_B = "GroupB";
|
||||
|
||||
private static void CreateGroupAbsoluteAndRelative() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void CreateGroupAbsoluteAndRelative()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group1_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group2_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group3_id = HDF5Constants.H5I_INVALID_HID;
|
||||
@@ -34,7 +35,7 @@ public class H5_CreateGroupAbsoluteRelative {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -44,7 +45,7 @@ public class H5_CreateGroupAbsoluteRelative {
|
||||
try {
|
||||
if (file_id >= 0)
|
||||
group1_id = H5.H5Gcreate(file_id, "/" + GROUPNAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -53,8 +54,9 @@ public class H5_CreateGroupAbsoluteRelative {
|
||||
// Create group "Group_A" in group "MyGroup" using absolute name.
|
||||
try {
|
||||
if (file_id >= 0)
|
||||
group2_id = H5.H5Gcreate(file_id, "/" + GROUPNAME + "/" + GROUPNAME_A, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
group2_id =
|
||||
H5.H5Gcreate(file_id, "/" + GROUPNAME + "/" + GROUPNAME_A, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -63,8 +65,8 @@ public class H5_CreateGroupAbsoluteRelative {
|
||||
// Create group "Group_B" in group "MyGroup" using relative name.
|
||||
try {
|
||||
if (group1_id >= 0)
|
||||
group3_id = H5.H5Gcreate(group1_id, GROUPNAME_B, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
group3_id = H5.H5Gcreate(group1_id, GROUPNAME_B, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -105,11 +107,10 @@ public class H5_CreateGroupAbsoluteRelative {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
H5_CreateGroupAbsoluteRelative.CreateGroupAbsoluteAndRelative();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,27 +20,28 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5_CreateGroupDataset {
|
||||
private static String FILENAME = "H5_CreateGroupDataset.h5";
|
||||
private static String GROUPNAME = "MyGroup";
|
||||
private static String GROUPNAME_A = "GroupA";
|
||||
private static String FILENAME = "H5_CreateGroupDataset.h5";
|
||||
private static String GROUPNAME = "MyGroup";
|
||||
private static String GROUPNAME_A = "GroupA";
|
||||
private static String DATASETNAME1 = "dset1";
|
||||
private static String DATASETNAME2 = "dset2";
|
||||
private static final int DIM1_X = 3;
|
||||
private static final int DIM1_Y = 3;
|
||||
private static final int DIM2_X = 2;
|
||||
private static final int DIM2_Y = 10;
|
||||
private static final int DIM1_X = 3;
|
||||
private static final int DIM1_Y = 3;
|
||||
private static final int DIM2_X = 2;
|
||||
private static final int DIM2_Y = 10;
|
||||
|
||||
private static void h5_crtgrpd() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group1_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group2_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void h5_crtgrpd()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group1_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long group2_id = HDF5Constants.H5I_INVALID_HID;
|
||||
int[][] dset1_data = new int[DIM1_X][DIM1_Y];
|
||||
int[][] dset2_data = new int[DIM2_X][DIM2_Y];
|
||||
long[] dims1 = { DIM1_X, DIM1_Y };
|
||||
long[] dims2 = { DIM2_X, DIM2_Y };
|
||||
long[] dims1 = {DIM1_X, DIM1_Y};
|
||||
long[] dims2 = {DIM2_X, DIM2_Y};
|
||||
|
||||
// Initialize the first dataset.
|
||||
for (int indx = 0; indx < DIM1_X; indx++)
|
||||
@@ -55,15 +56,16 @@ public class H5_CreateGroupDataset {
|
||||
// Create a file.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
// Create a group named "/MyGroup" in the file.
|
||||
if (file_id >= 0) {
|
||||
group1_id = H5.H5Gcreate(file_id, "/" + GROUPNAME, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
// Create group "Group_A" in group "MyGroup" using absolute name.
|
||||
if (group1_id >= 0) {
|
||||
group2_id = H5.H5Gcreate(file_id, "/" + GROUPNAME + "/" + GROUPNAME_A, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
group2_id =
|
||||
H5.H5Gcreate(file_id, "/" + GROUPNAME + "/" + GROUPNAME_A, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
if (group2_id >= 0)
|
||||
H5.H5Gclose(group2_id);
|
||||
}
|
||||
@@ -86,8 +88,9 @@ public class H5_CreateGroupDataset {
|
||||
// Create the dataset in group "MyGroup".
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, "/" + GROUPNAME + "/" + DATASETNAME1, HDF5Constants.H5T_STD_I32BE,
|
||||
dataspace_id, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
dataset_id = H5.H5Dcreate(
|
||||
file_id, "/" + GROUPNAME + "/" + DATASETNAME1, HDF5Constants.H5T_STD_I32BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -96,8 +99,8 @@ public class H5_CreateGroupDataset {
|
||||
// Write the first dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset1_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset1_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -126,7 +129,8 @@ public class H5_CreateGroupDataset {
|
||||
// Open an existing group of the specified file.
|
||||
try {
|
||||
if (file_id >= 0)
|
||||
group_id = H5.H5Gopen(file_id, "/" + GROUPNAME + "/" + GROUPNAME_A, HDF5Constants.H5P_DEFAULT);
|
||||
group_id =
|
||||
H5.H5Gopen(file_id, "/" + GROUPNAME + "/" + GROUPNAME_A, HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -144,7 +148,8 @@ public class H5_CreateGroupDataset {
|
||||
try {
|
||||
if ((group_id >= 0) && (dataspace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(group_id, DATASETNAME2, HDF5Constants.H5T_STD_I32BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -153,8 +158,8 @@ public class H5_CreateGroupDataset {
|
||||
// Write the second dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset2_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset2_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -197,8 +202,5 @@ public class H5_CreateGroupDataset {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5_CreateGroupDataset.h5_crtgrpd();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5_CreateGroupDataset.h5_crtgrpd(); }
|
||||
}
|
||||
|
||||
@@ -20,16 +20,17 @@ import hdf.hdf5lib.H5;
|
||||
import hdf.hdf5lib.HDF5Constants;
|
||||
|
||||
public class H5_ReadWrite {
|
||||
private static String FILENAME = "H5_ReadWrite.h5";
|
||||
private static String FILENAME = "H5_ReadWrite.h5";
|
||||
private static String DATASETNAME = "dset";
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 6;
|
||||
private static final int DIM_X = 4;
|
||||
private static final int DIM_Y = 6;
|
||||
|
||||
private static void ReadWriteDataset() {
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
private static void ReadWriteDataset()
|
||||
{
|
||||
long file_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = { DIM_X, DIM_Y };
|
||||
long dataset_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {DIM_X, DIM_Y};
|
||||
int[][] dset_data = new int[DIM_X][DIM_Y];
|
||||
|
||||
// Initialize the dataset.
|
||||
@@ -40,7 +41,7 @@ public class H5_ReadWrite {
|
||||
// Create a new file using default properties.
|
||||
try {
|
||||
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -57,8 +58,9 @@ public class H5_ReadWrite {
|
||||
// Create the dataset.
|
||||
try {
|
||||
if ((file_id >= 0) && (dataspace_id >= 0))
|
||||
dataset_id = H5.H5Dcreate(file_id, "/" + DATASETNAME, HDF5Constants.H5T_STD_I32BE, dataspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
dataset_id = H5.H5Dcreate(file_id, "/" + DATASETNAME, HDF5Constants.H5T_STD_I32BE,
|
||||
dataspace_id, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -67,8 +69,8 @@ public class H5_ReadWrite {
|
||||
// Write the dataset.
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -76,8 +78,8 @@ public class H5_ReadWrite {
|
||||
|
||||
try {
|
||||
if (dataset_id >= 0)
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -102,8 +104,5 @@ public class H5_ReadWrite {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
H5_ReadWrite.ReadWriteDataset();
|
||||
}
|
||||
|
||||
public static void main(String[] args) { H5_ReadWrite.ReadWriteDataset(); }
|
||||
}
|
||||
|
||||
@@ -132,6 +132,9 @@ SET_GLOBAL_VARIABLE (HDF5_JAVA_JARS ${${HDF5_JAVA_HDF5_LIB_TARGET}_JAR_FILE})
|
||||
|
||||
add_dependencies (${HDF5_JAVA_HDF5_LIB_TARGET} ${HDF5_JAVA_JNI_LIB_TARGET})
|
||||
set_target_properties (${HDF5_JAVA_HDF5_LIB_TARGET} PROPERTIES FOLDER libraries/java)
|
||||
if (HDF5_ENABLE_FORMATTERS)
|
||||
clang_format (HDF5_JAVA_SRC_FORMAT ${HDF5_JAVA_HDF_HDF5_CALLBACKS_SOURCES} ${HDF5_JAVA_HDF_HDF5_EXCEPTIONS_SOURCES} ${HDF5_JAVA_HDF_HDF5_STRUCTS_SOURCES} ${HDF5_JAVA_HDF_HDF5_SOURCES})
|
||||
endif ()
|
||||
|
||||
create_javadoc(hdf5_java_doc
|
||||
FILES ${HDF5_JAVADOC_HDF_HDF5_CALLBACKS_SOURCES} ${HDF5_JAVADOC_HDF_HDF5_EXCEPTIONS_SOURCES} ${HDF5_JAVADOC_HDF_HDF5_STRUCTS_SOURCES} ${HDF5_JAVADOC_HDF_HDF5_SOURCES}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,6 @@
|
||||
* help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
|
||||
package hdf.hdf5lib;
|
||||
|
||||
import hdf.hdf5lib.structs.H5O_token_t;
|
||||
@@ -27,15 +26,13 @@ import hdf.hdf5lib.structs.H5O_token_t;
|
||||
* <b>See also:</b> hdf.hdf5lib.HDF5Library
|
||||
*/
|
||||
public class HDF5Constants {
|
||||
static {
|
||||
H5.loadH5Lib();
|
||||
}
|
||||
static { H5.loadH5Lib(); }
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
// Get the HDF5 constants from the library //
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//public static final long H5_QUARTER_HADDR_MAX = H5_QUARTER_HADDR_MAX();
|
||||
// public static final long H5_QUARTER_HADDR_MAX = H5_QUARTER_HADDR_MAX();
|
||||
|
||||
/** Special parameters for szip compression */
|
||||
public static final int H5_SZIP_MAX_PIXELS_PER_BLOCK = H5_SZIP_MAX_PIXELS_PER_BLOCK();
|
||||
@@ -70,9 +67,11 @@ public class HDF5Constants {
|
||||
/** */
|
||||
public static final int H5AC_MAX_TRACE_FILE_NAME_LEN = H5AC_MAX_TRACE_FILE_NAME_LEN();
|
||||
/** */
|
||||
public static final int H5AC_METADATA_WRITE_STRATEGY_PROCESS_ZERO_ONLY = H5AC_METADATA_WRITE_STRATEGY_PROCESS_ZERO_ONLY();
|
||||
public static final int H5AC_METADATA_WRITE_STRATEGY_PROCESS_ZERO_ONLY =
|
||||
H5AC_METADATA_WRITE_STRATEGY_PROCESS_ZERO_ONLY();
|
||||
/** */
|
||||
public static final int H5AC_METADATA_WRITE_STRATEGY_DISTRIBUTED = H5AC_METADATA_WRITE_STRATEGY_DISTRIBUTED();
|
||||
public static final int H5AC_METADATA_WRITE_STRATEGY_DISTRIBUTED =
|
||||
H5AC_METADATA_WRITE_STRATEGY_DISTRIBUTED();
|
||||
/** */
|
||||
public static final int H5C_incr_off = H5C_incr_off();
|
||||
/** */
|
||||
@@ -681,22 +680,22 @@ public class HDF5Constants {
|
||||
/** */
|
||||
public static final long H5FD_MEM_DEFAULT_OHDR_SIZE = H5FD_MEM_DEFAULT_OHDR_SIZE();
|
||||
|
||||
// public static final int H5G_DATASET = H5G_DATASET();
|
||||
// public static final int H5G_GROUP = H5G_GROUP();
|
||||
// public static final int H5G_LINK = H5G_LINK();
|
||||
// public static final int H5G_UDLINK = H5G_UDLINK();
|
||||
// public static final int H5G_LINK_ERROR = H5G_LINK_ERROR();
|
||||
// public static final int H5G_LINK_HARD = H5G_LINK_HARD();
|
||||
// public static final int H5G_LINK_SOFT = H5G_LINK_SOFT();
|
||||
// public static final int H5G_NLIBTYPES = H5G_NLIBTYPES();
|
||||
// public static final int H5G_NTYPES = H5G_NTYPES();
|
||||
// public static final int H5G_NUSERTYPES = H5G_NUSERTYPES();
|
||||
// public static final int H5G_RESERVED_5 = H5G_RESERVED_5();
|
||||
// public static final int H5G_RESERVED_6 = H5G_RESERVED_6();
|
||||
// public static final int H5G_RESERVED_7 = H5G_RESERVED_7();
|
||||
// public static final int H5G_SAME_LOC = H5G_SAME_LOC();
|
||||
// public static final int H5G_TYPE = H5G_TYPE();
|
||||
// public static final int H5G_UNKNOWN = H5G_UNKNOWN();
|
||||
// public static final int H5G_DATASET = H5G_DATASET();
|
||||
// public static final int H5G_GROUP = H5G_GROUP();
|
||||
// public static final int H5G_LINK = H5G_LINK();
|
||||
// public static final int H5G_UDLINK = H5G_UDLINK();
|
||||
// public static final int H5G_LINK_ERROR = H5G_LINK_ERROR();
|
||||
// public static final int H5G_LINK_HARD = H5G_LINK_HARD();
|
||||
// public static final int H5G_LINK_SOFT = H5G_LINK_SOFT();
|
||||
// public static final int H5G_NLIBTYPES = H5G_NLIBTYPES();
|
||||
// public static final int H5G_NTYPES = H5G_NTYPES();
|
||||
// public static final int H5G_NUSERTYPES = H5G_NUSERTYPES();
|
||||
// public static final int H5G_RESERVED_5 = H5G_RESERVED_5();
|
||||
// public static final int H5G_RESERVED_6 = H5G_RESERVED_6();
|
||||
// public static final int H5G_RESERVED_7 = H5G_RESERVED_7();
|
||||
// public static final int H5G_SAME_LOC = H5G_SAME_LOC();
|
||||
// public static final int H5G_TYPE = H5G_TYPE();
|
||||
// public static final int H5G_UNKNOWN = H5G_UNKNOWN();
|
||||
|
||||
/** */
|
||||
public static final int H5G_STORAGE_TYPE_UNKNOWN = H5G_STORAGE_TYPE_UNKNOWN();
|
||||
@@ -756,7 +755,7 @@ public class HDF5Constants {
|
||||
/** */
|
||||
public static final int H5O_COPY_SHALLOW_HIERARCHY_FLAG = H5O_COPY_SHALLOW_HIERARCHY_FLAG();
|
||||
/** */
|
||||
public static final int H5O_COPY_EXPAND_SOFT_LINK_FLAG = H5O_COPY_EXPAND_SOFT_LINK_FLAG();
|
||||
public static final int H5O_COPY_EXPAND_SOFT_LINK_FLAG = H5O_COPY_EXPAND_SOFT_LINK_FLAG();
|
||||
/** */
|
||||
public static final int H5O_COPY_EXPAND_EXT_LINK_FLAG = H5O_COPY_EXPAND_EXT_LINK_FLAG();
|
||||
/** */
|
||||
@@ -1438,23 +1437,35 @@ public class HDF5Constants {
|
||||
public static final int H5Z_FILTER_SHUFFLE = H5Z_FILTER_SHUFFLE();
|
||||
/** Filter IDs - szip compression */
|
||||
public static final int H5Z_FILTER_SZIP = H5Z_FILTER_SZIP();
|
||||
/** Flags for filter definition (stored)
|
||||
* definition flag mask */
|
||||
/**
|
||||
* Flags for filter definition (stored)
|
||||
* definition flag mask
|
||||
*/
|
||||
public static final int H5Z_FLAG_DEFMASK = H5Z_FLAG_DEFMASK();
|
||||
/** Additional flags for filter invocation (not stored)
|
||||
* invocation flag mask */
|
||||
/**
|
||||
* Additional flags for filter invocation (not stored)
|
||||
* invocation flag mask
|
||||
*/
|
||||
public static final int H5Z_FLAG_INVMASK = H5Z_FLAG_INVMASK();
|
||||
/** Flags for filter definition (stored)
|
||||
* filter is mandatory */
|
||||
/**
|
||||
* Flags for filter definition (stored)
|
||||
* filter is mandatory
|
||||
*/
|
||||
public static final int H5Z_FLAG_MANDATORY = H5Z_FLAG_MANDATORY();
|
||||
/** Flags for filter definition (stored)
|
||||
* filter is optional */
|
||||
/**
|
||||
* Flags for filter definition (stored)
|
||||
* filter is optional
|
||||
*/
|
||||
public static final int H5Z_FLAG_OPTIONAL = H5Z_FLAG_OPTIONAL();
|
||||
/** Additional flags for filter invocation (not stored)
|
||||
* reverse direction; read */
|
||||
/**
|
||||
* Additional flags for filter invocation (not stored)
|
||||
* reverse direction; read
|
||||
*/
|
||||
public static final int H5Z_FLAG_REVERSE = H5Z_FLAG_REVERSE();
|
||||
/** Additional flags for filter invocation (not stored)
|
||||
* skip EDC filters for read */
|
||||
/**
|
||||
* Additional flags for filter invocation (not stored)
|
||||
* skip EDC filters for read
|
||||
*/
|
||||
public static final int H5Z_FLAG_SKIP_EDC = H5Z_FLAG_SKIP_EDC();
|
||||
/** Symbol to remove all filters in H5Premove_filter */
|
||||
public static final int H5Z_FILTER_ALL = H5Z_FILTER_ALL();
|
||||
@@ -2953,5 +2964,4 @@ public class HDF5Constants {
|
||||
private static native final int H5Z_SCALEOFFSET_USER_NPARMS();
|
||||
|
||||
private static native final int H5Z_FILTER_ALL();
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
* help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
|
||||
package hdf.hdf5lib;
|
||||
|
||||
/**
|
||||
@@ -41,14 +40,17 @@ public class HDF5GroupInfo {
|
||||
long mtime;
|
||||
int linklen;
|
||||
|
||||
/** Container for the information reported about an HDF5 Object
|
||||
* from the H5Gget_obj_info() method */
|
||||
public HDF5GroupInfo() {
|
||||
fileno = new long[2];
|
||||
objno = new long[2];
|
||||
nlink = -1;
|
||||
type = -1;
|
||||
mtime = 0;
|
||||
/**
|
||||
* Container for the information reported about an HDF5 Object
|
||||
* from the H5Gget_obj_info() method
|
||||
*/
|
||||
public HDF5GroupInfo()
|
||||
{
|
||||
fileno = new long[2];
|
||||
objno = new long[2];
|
||||
nlink = -1;
|
||||
type = -1;
|
||||
mtime = 0;
|
||||
linklen = 0;
|
||||
}
|
||||
|
||||
@@ -68,84 +70,79 @@ public class HDF5GroupInfo {
|
||||
* @param len
|
||||
* Length of link
|
||||
**/
|
||||
public void setGroupInfo(long[] fn, long[] on, int nl, int t, long mt,
|
||||
int len) {
|
||||
fileno = fn;
|
||||
objno = on;
|
||||
nlink = nl;
|
||||
type = t;
|
||||
mtime = mt;
|
||||
public void setGroupInfo(long[] fn, long[] on, int nl, int t, long mt, int len)
|
||||
{
|
||||
fileno = fn;
|
||||
objno = on;
|
||||
nlink = nl;
|
||||
type = t;
|
||||
mtime = mt;
|
||||
linklen = len;
|
||||
}
|
||||
|
||||
/** Resets all the group information to defaults. */
|
||||
public void reset() {
|
||||
public void reset()
|
||||
{
|
||||
fileno[0] = 0;
|
||||
fileno[1] = 0;
|
||||
objno[0] = 0;
|
||||
objno[1] = 0;
|
||||
nlink = -1;
|
||||
type = -1;
|
||||
mtime = 0;
|
||||
linklen = 0;
|
||||
objno[0] = 0;
|
||||
objno[1] = 0;
|
||||
nlink = -1;
|
||||
type = -1;
|
||||
mtime = 0;
|
||||
linklen = 0;
|
||||
}
|
||||
|
||||
/** fileno accessors
|
||||
/**
|
||||
* fileno accessors
|
||||
* @return the file number if successful
|
||||
*/
|
||||
public long[] getFileno() {
|
||||
return fileno;
|
||||
}
|
||||
public long[] getFileno() { return fileno; }
|
||||
|
||||
/** accessors
|
||||
/**
|
||||
* accessors
|
||||
* @return the object number if successful
|
||||
*/
|
||||
public long[] getObjno() {
|
||||
return objno;
|
||||
}
|
||||
public long[] getObjno() { return objno; }
|
||||
|
||||
/** accessors
|
||||
/**
|
||||
* accessors
|
||||
* @return type of group if successful
|
||||
*/
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
public int getType() { return type; }
|
||||
|
||||
/** accessors
|
||||
/**
|
||||
* accessors
|
||||
* @return the number of links in the group if successful
|
||||
*/
|
||||
public int getNlink() {
|
||||
return nlink;
|
||||
}
|
||||
public int getNlink() { return nlink; }
|
||||
|
||||
/** accessors
|
||||
/**
|
||||
* accessors
|
||||
* @return the modified time value if successful
|
||||
*/
|
||||
public long getMtime() {
|
||||
return mtime;
|
||||
}
|
||||
public long getMtime() { return mtime; }
|
||||
|
||||
/** accessors
|
||||
/**
|
||||
* accessors
|
||||
* @return a length of link name if successful
|
||||
*/
|
||||
public int getLinklen() {
|
||||
return linklen;
|
||||
}
|
||||
public int getLinklen() { return linklen; }
|
||||
|
||||
/**
|
||||
* The fileno and objno fields contain four values which uniquely identify
|
||||
* an object among those HDF5 files.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof HDF5GroupInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HDF5GroupInfo target = (HDF5GroupInfo) obj;
|
||||
if ((fileno[0] == target.fileno[0]) && (fileno[1] == target.fileno[1])
|
||||
&& (objno[0] == target.objno[0])
|
||||
&& (objno[1] == target.objno[1])) {
|
||||
HDF5GroupInfo target = (HDF5GroupInfo)obj;
|
||||
if ((fileno[0] == target.fileno[0]) && (fileno[1] == target.fileno[1]) &&
|
||||
(objno[0] == target.objno[0]) && (objno[1] == target.objno[1])) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -158,9 +155,7 @@ public class HDF5GroupInfo {
|
||||
*
|
||||
* @return the object id
|
||||
*/
|
||||
public long getOID() {
|
||||
return objno[0];
|
||||
}
|
||||
public long getOID() { return objno[0]; }
|
||||
|
||||
/**
|
||||
* /** Converts this object to a String representation.
|
||||
@@ -168,9 +163,10 @@ public class HDF5GroupInfo {
|
||||
* @return a string representation of this object
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
String fileStr = "fileno=null";
|
||||
String objStr = "objno=null";
|
||||
String objStr = "objno=null";
|
||||
|
||||
if (fileno != null) {
|
||||
fileStr = "fileno[0]=" + fileno[0] + ",fileno[1]=" + fileno[1];
|
||||
@@ -180,9 +176,7 @@ public class HDF5GroupInfo {
|
||||
objStr = "objno[0]=" + objno[0] + ",objno[1]=" + objno[1];
|
||||
}
|
||||
|
||||
return getClass().getName() + "[" + fileStr + "," + objStr + ",type="
|
||||
+ type + ",nlink=" + nlink + ",mtime=" + mtime + ",linklen="
|
||||
+ linklen + "]";
|
||||
return getClass().getName() + "[" + fileStr + "," + objStr + ",type=" + type + ",nlink=" + nlink +
|
||||
",mtime=" + mtime + ",linklen=" + linklen + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,36 +13,34 @@
|
||||
|
||||
package hdf.hdf5lib;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import hdf.hdf5lib.exceptions.HDF5Exception;
|
||||
import hdf.hdf5lib.exceptions.HDF5JavaException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This is a class for handling multidimensional arrays for HDF.
|
||||
* <p>
|
||||
* The purpose is to allow the storage and retrieval of arbitrary array types containing scientific data.
|
||||
* <p>
|
||||
* The methods support the conversion of an array to and from Java to a one-dimensional array of bytes suitable for I/O
|
||||
* by the C library.
|
||||
* <p>
|
||||
* This class heavily uses the <a href="./hdf.hdf5lib.HDFNativeData.html">HDFNativeData</a> class to convert between
|
||||
* Java and C representations.
|
||||
* The methods support the conversion of an array to and from Java to a one-dimensional array of bytes
|
||||
* suitable for I/O by the C library. <p> This class heavily uses the <a
|
||||
* href="./hdf.hdf5lib.HDFNativeData.html">HDFNativeData</a> class to convert between Java and C
|
||||
* representations.
|
||||
*/
|
||||
|
||||
public class HDFArray {
|
||||
private Object _theArray = null;
|
||||
private Object _theArray = null;
|
||||
private ArrayDescriptor _desc = null;
|
||||
private byte[] _barray = null;
|
||||
private byte[] _barray = null;
|
||||
|
||||
// public HDFArray() {}
|
||||
|
||||
/**
|
||||
* The input must be a Java Array (possibly multidimensional) of primitive numbers or sub-classes of Number.
|
||||
* <p>
|
||||
* The input is analysed to determine the number of dimensions and size of each dimension, as well as the type of
|
||||
* the elements.
|
||||
* <p>
|
||||
* The description is saved in private variables, and used to convert data.
|
||||
* The input must be a Java Array (possibly multidimensional) of primitive numbers or sub-classes of
|
||||
* Number. <p> The input is analysed to determine the number of dimensions and size of each dimension, as
|
||||
* well as the type of the elements. <p> The description is saved in private variables, and used to
|
||||
* convert data.
|
||||
*
|
||||
* @param anArray
|
||||
* The array object.
|
||||
@@ -58,25 +56,26 @@ public class HDFArray {
|
||||
if (tc.isArray() == false) {
|
||||
/* exception: not an array */
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: not an array?: ");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
_theArray = anArray;
|
||||
_desc = new ArrayDescriptor(_theArray);
|
||||
_desc = new ArrayDescriptor(_theArray);
|
||||
|
||||
/* extra error checking -- probably not needed */
|
||||
if (_desc == null) {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: internal error: array description failed?: ");
|
||||
throw (ex);
|
||||
HDF5JavaException ex =
|
||||
new HDF5JavaException("HDFArray: internal error: array description failed?: ");
|
||||
throw(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a one-dimensional array of bytes sufficient to store the array.
|
||||
*
|
||||
* @return A one-D array of bytes, filled with zeroes. The bytes are sufficient to hold the data of the Array passed
|
||||
* to the constructor.
|
||||
* @return A one-D array of bytes, filled with zeroes. The bytes are sufficient to hold the data of the
|
||||
* Array passed to the constructor.
|
||||
* @exception hdf.hdf5lib.exceptions.HDF5JavaException
|
||||
* Allocation failed.
|
||||
* Allocation failed.
|
||||
*/
|
||||
|
||||
public byte[] emptyBytes() throws HDF5JavaException
|
||||
@@ -84,14 +83,14 @@ public class HDFArray {
|
||||
byte[] b = null;
|
||||
|
||||
if ((ArrayDescriptor.dims == 1) && (ArrayDescriptor.NT == 'B')) {
|
||||
b = (byte[]) _theArray;
|
||||
b = (byte[])_theArray;
|
||||
}
|
||||
else {
|
||||
b = new byte[ArrayDescriptor.totalSize];
|
||||
}
|
||||
if (b == null) {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: emptyBytes: allocation failed");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
return (b);
|
||||
}
|
||||
@@ -112,14 +111,14 @@ public class HDFArray {
|
||||
if (_theArray == null) {
|
||||
/* exception: not an array */
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: byteify not an array?: ");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
|
||||
if (ArrayDescriptor.dims == 1) {
|
||||
/* special case */
|
||||
if (ArrayDescriptor.NT == 'B') {
|
||||
/* really special case! */
|
||||
_barray = (byte[]) _theArray;
|
||||
_barray = (byte[])_theArray;
|
||||
return _barray;
|
||||
}
|
||||
else {
|
||||
@@ -128,54 +127,56 @@ public class HDFArray {
|
||||
|
||||
byte[] therow;
|
||||
if (ArrayDescriptor.NT == 'I') {
|
||||
therow = HDFNativeData.intToByte(0, ArrayDescriptor.dimlen[1], (int[]) _theArray);
|
||||
therow = HDFNativeData.intToByte(0, ArrayDescriptor.dimlen[1], (int[])_theArray);
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'S') {
|
||||
therow = HDFNativeData.shortToByte(0, ArrayDescriptor.dimlen[1], (short[]) _theArray);
|
||||
therow = HDFNativeData.shortToByte(0, ArrayDescriptor.dimlen[1], (short[])_theArray);
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'F') {
|
||||
therow = HDFNativeData.floatToByte(0, ArrayDescriptor.dimlen[1], (float[]) _theArray);
|
||||
therow = HDFNativeData.floatToByte(0, ArrayDescriptor.dimlen[1], (float[])_theArray);
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'J') {
|
||||
therow = HDFNativeData.longToByte(0, ArrayDescriptor.dimlen[1], (long[]) _theArray);
|
||||
therow = HDFNativeData.longToByte(0, ArrayDescriptor.dimlen[1], (long[])_theArray);
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'D') {
|
||||
therow = HDFNativeData.doubleToByte(0, ArrayDescriptor.dimlen[1], (double[]) _theArray);
|
||||
therow =
|
||||
HDFNativeData.doubleToByte(0, ArrayDescriptor.dimlen[1], (double[])_theArray);
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'L') {
|
||||
if (ArrayDescriptor.className.equals("java.lang.Byte")) {
|
||||
therow = ByteObjToByte((Byte[]) _theArray);
|
||||
therow = ByteObjToByte((Byte[])_theArray);
|
||||
}
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Integer")) {
|
||||
therow = IntegerToByte((Integer[]) _theArray);
|
||||
therow = IntegerToByte((Integer[])_theArray);
|
||||
}
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Short")) {
|
||||
therow = ShortToByte((Short[]) _theArray);
|
||||
therow = ShortToByte((Short[])_theArray);
|
||||
}
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Float")) {
|
||||
therow = FloatObjToByte((Float[]) _theArray);
|
||||
therow = FloatObjToByte((Float[])_theArray);
|
||||
}
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Double")) {
|
||||
therow = DoubleObjToByte((Double[]) _theArray);
|
||||
therow = DoubleObjToByte((Double[])_theArray);
|
||||
}
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Long")) {
|
||||
therow = LongObjToByte((Long[]) _theArray);
|
||||
therow = LongObjToByte((Long[])_theArray);
|
||||
}
|
||||
else {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: unknown type of Object?");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: unknown type of data?");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
System.arraycopy(therow, 0, _barray, 0, (ArrayDescriptor.dimlen[1] * ArrayDescriptor.NTsize));
|
||||
System.arraycopy(therow, 0, _barray, 0,
|
||||
(ArrayDescriptor.dimlen[1] * ArrayDescriptor.NTsize));
|
||||
return _barray;
|
||||
}
|
||||
catch (OutOfMemoryError err) {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: byteify array too big?");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,15 +186,15 @@ public class HDFArray {
|
||||
}
|
||||
catch (OutOfMemoryError err) {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: byteify array too big?");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
|
||||
Object oo = _theArray;
|
||||
int n = 0; /* the current byte */
|
||||
int n = 0; /* the current byte */
|
||||
int index = 0;
|
||||
int i;
|
||||
while (n < ArrayDescriptor.totalSize) {
|
||||
oo = ArrayDescriptor.objs[0];
|
||||
oo = ArrayDescriptor.objs[0];
|
||||
index = n / ArrayDescriptor.bytetoindex[0];
|
||||
index %= ArrayDescriptor.dimlen[0];
|
||||
for (i = 0; i < (ArrayDescriptor.dims); i++) {
|
||||
@@ -209,9 +210,9 @@ public class HDFArray {
|
||||
if (index > (ArrayDescriptor.dimlen[i] - 1)) {
|
||||
throw new java.lang.IndexOutOfBoundsException("HDFArray: byteify index OOB?");
|
||||
}
|
||||
oo = java.lang.reflect.Array.get(oo, index);
|
||||
oo = java.lang.reflect.Array.get(oo, index);
|
||||
ArrayDescriptor.currentindex[i] = index;
|
||||
ArrayDescriptor.objs[i] = oo;
|
||||
ArrayDescriptor.objs[i] = oo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,85 +221,90 @@ public class HDFArray {
|
||||
try {
|
||||
if (ArrayDescriptor.NT == 'J') {
|
||||
arow = HDFNativeData.longToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims],
|
||||
(long[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
(long[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'I') {
|
||||
arow = HDFNativeData.intToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims],
|
||||
(int[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
(int[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'S') {
|
||||
arow = HDFNativeData.shortToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims],
|
||||
(short[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
(short[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'B') {
|
||||
arow = (byte[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1];
|
||||
arow = (byte[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1];
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'F') {
|
||||
/* 32 bit float */
|
||||
arow = HDFNativeData.floatToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims],
|
||||
(float[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
(float[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'D') {
|
||||
/* 64 bit float */
|
||||
arow = HDFNativeData.doubleToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims],
|
||||
(double[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
arow =
|
||||
HDFNativeData.doubleToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims],
|
||||
(double[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else if (ArrayDescriptor.NT == 'L') {
|
||||
if (ArrayDescriptor.className.equals("java.lang.Byte")) {
|
||||
arow = ByteObjToByte((Byte[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
arow = ByteObjToByte((Byte[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Integer")) {
|
||||
arow = IntegerToByte((Integer[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
arow = IntegerToByte((Integer[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Short")) {
|
||||
arow = ShortToByte((Short[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
arow = ShortToByte((Short[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Float")) {
|
||||
arow = FloatObjToByte((Float[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
arow = FloatObjToByte((Float[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Double")) {
|
||||
arow = DoubleObjToByte((Double[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
arow = DoubleObjToByte((Double[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Long")) {
|
||||
arow = LongObjToByte((Long[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
arow = LongObjToByte((Long[])ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
|
||||
}
|
||||
else {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: byteify Object type not implemented?");
|
||||
throw (ex);
|
||||
HDF5JavaException ex =
|
||||
new HDF5JavaException("HDFArray: byteify Object type not implemented?");
|
||||
throw(ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: byteify unknown type not implemented?");
|
||||
throw (ex);
|
||||
HDF5JavaException ex =
|
||||
new HDF5JavaException("HDFArray: byteify unknown type not implemented?");
|
||||
throw(ex);
|
||||
}
|
||||
System.arraycopy(arow, 0, _barray, n,
|
||||
(ArrayDescriptor.dimlen[ArrayDescriptor.dims] * ArrayDescriptor.NTsize));
|
||||
(ArrayDescriptor.dimlen[ArrayDescriptor.dims] * ArrayDescriptor.NTsize));
|
||||
n += ArrayDescriptor.bytetoindex[ArrayDescriptor.dims - 1];
|
||||
}
|
||||
catch (OutOfMemoryError err) {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: byteify array too big?");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
}
|
||||
/* assert: the whole array is completed--currentindex should == len - 1 */
|
||||
/* error checks */
|
||||
if (n < ArrayDescriptor.totalSize) {
|
||||
throw new java.lang.InternalError(new String("HDFArray::byteify: Panic didn't complete all input data: n= "
|
||||
+ n + " size = " + ArrayDescriptor.totalSize));
|
||||
throw new java.lang.InternalError(
|
||||
new String("HDFArray::byteify: Panic didn't complete all input data: n= " + n +
|
||||
" size = " + ArrayDescriptor.totalSize));
|
||||
}
|
||||
for (i = 0; i < ArrayDescriptor.dims; i++) {
|
||||
if (ArrayDescriptor.currentindex[i] != ArrayDescriptor.dimlen[i] - 1) {
|
||||
throw new java.lang.InternalError(new String(
|
||||
"Panic didn't complete all data: currentindex[" + i + "] = " + ArrayDescriptor.currentindex[i]
|
||||
+ " (should be " + (ArrayDescriptor.dimlen[i] - 1) + " ?)"));
|
||||
throw new java.lang.InternalError(new String("Panic didn't complete all data: currentindex[" +
|
||||
i + "] = " + ArrayDescriptor.currentindex[i] +
|
||||
" (should be " +
|
||||
(ArrayDescriptor.dimlen[i] - 1) + " ?)"));
|
||||
}
|
||||
}
|
||||
return _barray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a one-dimensional array of bytes representing numbers, convert it to a java array of the shape and size
|
||||
* passed to the constructor.
|
||||
* Given a one-dimensional array of bytes representing numbers, convert it to a java array of the shape
|
||||
* and size passed to the constructor.
|
||||
*
|
||||
* @param bytes
|
||||
* The bytes to construct the Array.
|
||||
@@ -312,13 +318,13 @@ public class HDFArray {
|
||||
if (_theArray == null) {
|
||||
/* exception: not an array */
|
||||
HDF5JavaException ex = new HDF5JavaException("arrayify: not an array?: ");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
|
||||
if (java.lang.reflect.Array.getLength(bytes) != ArrayDescriptor.totalSize) {
|
||||
/* exception: array not right size */
|
||||
HDF5JavaException ex = new HDF5JavaException("arrayify: array is wrong size?: ");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
_barray = bytes; /* hope that the bytes are correct.... */
|
||||
|
||||
@@ -387,74 +393,77 @@ public class HDFArray {
|
||||
return _theArray;
|
||||
}
|
||||
else {
|
||||
HDF5JavaException ex = new HDF5JavaException("arrayify: Object type not implemented yet...");
|
||||
throw (ex);
|
||||
HDF5JavaException ex =
|
||||
new HDF5JavaException("arrayify: Object type not implemented yet...");
|
||||
throw(ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
HDF5JavaException ex = new HDF5JavaException("arrayify: unknown type not implemented yet...");
|
||||
throw (ex);
|
||||
HDF5JavaException ex =
|
||||
new HDF5JavaException("arrayify: unknown type not implemented yet...");
|
||||
throw(ex);
|
||||
}
|
||||
}
|
||||
catch (OutOfMemoryError err) {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: arrayify array too big?");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
}
|
||||
/* Assert dims >= 2 */
|
||||
|
||||
Object oo = _theArray;
|
||||
int n = 0; /* the current byte */
|
||||
int m = 0; /* the current array index */
|
||||
int n = 0; /* the current byte */
|
||||
int m = 0; /* the current array index */
|
||||
int index = 0;
|
||||
int i;
|
||||
Object flattenedArray = null;
|
||||
|
||||
switch (ArrayDescriptor.NT) {
|
||||
case 'J':
|
||||
flattenedArray = (Object) HDFNativeData.byteToLong(_barray);
|
||||
flattenedArray = (Object)HDFNativeData.byteToLong(_barray);
|
||||
break;
|
||||
case 'S':
|
||||
flattenedArray = (Object) HDFNativeData.byteToShort(_barray);
|
||||
flattenedArray = (Object)HDFNativeData.byteToShort(_barray);
|
||||
break;
|
||||
case 'I':
|
||||
flattenedArray = (Object) HDFNativeData.byteToInt(_barray);
|
||||
flattenedArray = (Object)HDFNativeData.byteToInt(_barray);
|
||||
break;
|
||||
case 'F':
|
||||
flattenedArray = (Object) HDFNativeData.byteToFloat(_barray);
|
||||
flattenedArray = (Object)HDFNativeData.byteToFloat(_barray);
|
||||
break;
|
||||
case 'D':
|
||||
flattenedArray = (Object) HDFNativeData.byteToDouble(_barray);
|
||||
flattenedArray = (Object)HDFNativeData.byteToDouble(_barray);
|
||||
break;
|
||||
case 'B':
|
||||
flattenedArray = (Object) _barray;
|
||||
flattenedArray = (Object)_barray;
|
||||
break;
|
||||
case 'L':
|
||||
{
|
||||
if (ArrayDescriptor.className.equals("java.lang.Byte"))
|
||||
flattenedArray = (Object) ByteToByteObj(_barray);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Short"))
|
||||
flattenedArray = (Object) ByteToShort(_barray);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Integer"))
|
||||
flattenedArray = (Object) ByteToInteger(_barray);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Long"))
|
||||
flattenedArray = (Object) ByteToLongObj(_barray);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Float"))
|
||||
flattenedArray = (Object) ByteToFloatObj(_barray);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Double"))
|
||||
flattenedArray = (Object) ByteToDoubleObj(_barray);
|
||||
else {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: unsupported Object type: " + ArrayDescriptor.NT);
|
||||
throw (ex);
|
||||
}
|
||||
} // end of statement for arrays of boxed objects
|
||||
case 'L': {
|
||||
if (ArrayDescriptor.className.equals("java.lang.Byte"))
|
||||
flattenedArray = (Object)ByteToByteObj(_barray);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Short"))
|
||||
flattenedArray = (Object)ByteToShort(_barray);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Integer"))
|
||||
flattenedArray = (Object)ByteToInteger(_barray);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Long"))
|
||||
flattenedArray = (Object)ByteToLongObj(_barray);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Float"))
|
||||
flattenedArray = (Object)ByteToFloatObj(_barray);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Double"))
|
||||
flattenedArray = (Object)ByteToDoubleObj(_barray);
|
||||
else {
|
||||
HDF5JavaException ex =
|
||||
new HDF5JavaException("HDFArray: unsupported Object type: " + ArrayDescriptor.NT);
|
||||
throw(ex);
|
||||
}
|
||||
} // end of statement for arrays of boxed objects
|
||||
default:
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: unknown or unsupported type: " + ArrayDescriptor.NT);
|
||||
throw (ex);
|
||||
HDF5JavaException ex =
|
||||
new HDF5JavaException("HDFArray: unknown or unsupported type: " + ArrayDescriptor.NT);
|
||||
throw(ex);
|
||||
} // end of switch statement for arrays of primitives
|
||||
|
||||
while (n < ArrayDescriptor.totalSize) {
|
||||
oo = ArrayDescriptor.objs[0];
|
||||
oo = ArrayDescriptor.objs[0];
|
||||
index = n / ArrayDescriptor.bytetoindex[0];
|
||||
index %= ArrayDescriptor.dimlen[0];
|
||||
for (i = 0; i < (ArrayDescriptor.dims); i++) {
|
||||
@@ -471,86 +480,88 @@ public class HDFArray {
|
||||
System.out.println("out of bounds?");
|
||||
return null;
|
||||
}
|
||||
oo = java.lang.reflect.Array.get(oo, index);
|
||||
oo = java.lang.reflect.Array.get(oo, index);
|
||||
ArrayDescriptor.currentindex[i] = index;
|
||||
ArrayDescriptor.objs[i] = oo;
|
||||
ArrayDescriptor.objs[i] = oo;
|
||||
}
|
||||
}
|
||||
|
||||
/* array-ify */
|
||||
try {
|
||||
Object arow = null;
|
||||
int mm = m + ArrayDescriptor.dimlen[ArrayDescriptor.dims];
|
||||
int mm = m + ArrayDescriptor.dimlen[ArrayDescriptor.dims];
|
||||
switch (ArrayDescriptor.NT) {
|
||||
case 'B':
|
||||
arow = (Object) Arrays.copyOfRange((byte[]) flattenedArray, m, mm);
|
||||
arow = (Object)Arrays.copyOfRange((byte[])flattenedArray, m, mm);
|
||||
break;
|
||||
case 'S':
|
||||
arow = (Object) Arrays.copyOfRange((short[]) flattenedArray, m, mm);
|
||||
arow = (Object)Arrays.copyOfRange((short[])flattenedArray, m, mm);
|
||||
break;
|
||||
case 'I':
|
||||
arow = (Object) Arrays.copyOfRange((int[]) flattenedArray, m, mm);
|
||||
arow = (Object)Arrays.copyOfRange((int[])flattenedArray, m, mm);
|
||||
break;
|
||||
case 'J':
|
||||
arow = (Object) Arrays.copyOfRange((long[]) flattenedArray, m, mm);
|
||||
arow = (Object)Arrays.copyOfRange((long[])flattenedArray, m, mm);
|
||||
break;
|
||||
case 'F':
|
||||
arow = (Object) Arrays.copyOfRange((float[]) flattenedArray, m, mm);
|
||||
arow = (Object)Arrays.copyOfRange((float[])flattenedArray, m, mm);
|
||||
break;
|
||||
case 'D':
|
||||
arow = (Object) Arrays.copyOfRange((double[]) flattenedArray, m, mm);
|
||||
arow = (Object)Arrays.copyOfRange((double[])flattenedArray, m, mm);
|
||||
break;
|
||||
case 'L':
|
||||
{
|
||||
if (ArrayDescriptor.className.equals("java.lang.Byte"))
|
||||
arow = (Object) Arrays.copyOfRange((Byte[]) flattenedArray, m, mm);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Short"))
|
||||
arow = (Object) Arrays.copyOfRange((Short[]) flattenedArray, m, mm);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Integer"))
|
||||
arow = (Object) Arrays.copyOfRange((Integer[]) flattenedArray, m, mm);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Long"))
|
||||
arow = (Object) Arrays.copyOfRange((Long[]) flattenedArray, m, mm);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Float"))
|
||||
arow = (Object) Arrays.copyOfRange((Float[]) flattenedArray, m, mm);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Double"))
|
||||
arow = (Object) Arrays.copyOfRange((Double[]) flattenedArray, m, mm);
|
||||
else {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: unsupported Object type: " + ArrayDescriptor.NT);
|
||||
throw (ex);
|
||||
}
|
||||
} // end of statement for arrays of boxed numerics
|
||||
case 'L': {
|
||||
if (ArrayDescriptor.className.equals("java.lang.Byte"))
|
||||
arow = (Object)Arrays.copyOfRange((Byte[])flattenedArray, m, mm);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Short"))
|
||||
arow = (Object)Arrays.copyOfRange((Short[])flattenedArray, m, mm);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Integer"))
|
||||
arow = (Object)Arrays.copyOfRange((Integer[])flattenedArray, m, mm);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Long"))
|
||||
arow = (Object)Arrays.copyOfRange((Long[])flattenedArray, m, mm);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Float"))
|
||||
arow = (Object)Arrays.copyOfRange((Float[])flattenedArray, m, mm);
|
||||
else if (ArrayDescriptor.className.equals("java.lang.Double"))
|
||||
arow = (Object)Arrays.copyOfRange((Double[])flattenedArray, m, mm);
|
||||
else {
|
||||
HDF5JavaException ex =
|
||||
new HDF5JavaException("HDFArray: unsupported Object type: " + ArrayDescriptor.NT);
|
||||
throw(ex);
|
||||
}
|
||||
} // end of statement for arrays of boxed numerics
|
||||
} // end of switch statement for arrays of primitives
|
||||
|
||||
java.lang.reflect.Array.set(ArrayDescriptor.objs[ArrayDescriptor.dims - 2],
|
||||
(ArrayDescriptor.currentindex[ArrayDescriptor.dims - 1]), arow);
|
||||
(ArrayDescriptor.currentindex[ArrayDescriptor.dims - 1]), arow);
|
||||
n += ArrayDescriptor.bytetoindex[ArrayDescriptor.dims - 1];
|
||||
ArrayDescriptor.currentindex[ArrayDescriptor.dims - 1]++;
|
||||
m = mm;
|
||||
}
|
||||
catch (OutOfMemoryError err) {
|
||||
HDF5JavaException ex = new HDF5JavaException("HDFArray: arrayify array too big?");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/* assert: the whole array is completed--currentindex should == len - 1 */
|
||||
/* error checks */
|
||||
if (n < ArrayDescriptor.totalSize) {
|
||||
throw new java.lang.InternalError(new String("HDFArray::arrayify Panic didn't complete all input data: n= "
|
||||
+ n + " size = " + ArrayDescriptor.totalSize));
|
||||
throw new java.lang.InternalError(
|
||||
new String("HDFArray::arrayify Panic didn't complete all input data: n= " + n +
|
||||
" size = " + ArrayDescriptor.totalSize));
|
||||
}
|
||||
for (i = 0; i <= ArrayDescriptor.dims - 2; i++) {
|
||||
if (ArrayDescriptor.currentindex[i] != ArrayDescriptor.dimlen[i] - 1) {
|
||||
throw new java.lang.InternalError(
|
||||
new String("HDFArray::arrayify Panic didn't complete all data: currentindex[" + i + "] = "
|
||||
+ ArrayDescriptor.currentindex[i] + " (should be " + (ArrayDescriptor.dimlen[i] - 1)
|
||||
+ "?"));
|
||||
new String("HDFArray::arrayify Panic didn't complete all data: currentindex[" + i +
|
||||
"] = " + ArrayDescriptor.currentindex[i] + " (should be " +
|
||||
(ArrayDescriptor.dimlen[i] - 1) + "?"));
|
||||
}
|
||||
}
|
||||
if (ArrayDescriptor.currentindex[ArrayDescriptor.dims - 1] != ArrayDescriptor.dimlen[ArrayDescriptor.dims - 1]) {
|
||||
throw new java.lang.InternalError(
|
||||
new String("HDFArray::arrayify Panic didn't complete all data: currentindex[" + i + "] = "
|
||||
+ ArrayDescriptor.currentindex[i] + " (should be " + (ArrayDescriptor.dimlen[i]) + "?"));
|
||||
if (ArrayDescriptor.currentindex[ArrayDescriptor.dims - 1] !=
|
||||
ArrayDescriptor.dimlen[ArrayDescriptor.dims - 1]) {
|
||||
throw new java.lang.InternalError(new String(
|
||||
"HDFArray::arrayify Panic didn't complete all data: currentindex[" + i + "] = " +
|
||||
ArrayDescriptor.currentindex[i] + " (should be " + (ArrayDescriptor.dimlen[i]) + "?"));
|
||||
}
|
||||
|
||||
return _theArray;
|
||||
@@ -559,7 +570,7 @@ public class HDFArray {
|
||||
private byte[] IntegerToByte(Integer in[])
|
||||
{
|
||||
int nelems = java.lang.reflect.Array.getLength(in);
|
||||
int[] out = new int[nelems];
|
||||
int[] out = new int[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
out[i] = in[i].intValue();
|
||||
@@ -569,8 +580,8 @@ public class HDFArray {
|
||||
|
||||
private Integer[] ByteToInteger(byte[] bin)
|
||||
{
|
||||
int in[] = HDFNativeData.byteToInt(bin);
|
||||
int nelems = java.lang.reflect.Array.getLength(in);
|
||||
int in[] = HDFNativeData.byteToInt(bin);
|
||||
int nelems = java.lang.reflect.Array.getLength(in);
|
||||
Integer[] out = new Integer[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -581,8 +592,8 @@ public class HDFArray {
|
||||
|
||||
private Integer[] ByteToInteger(int start, int len, byte[] bin)
|
||||
{
|
||||
int in[] = HDFNativeData.byteToInt(start, len, bin);
|
||||
int nelems = java.lang.reflect.Array.getLength(in);
|
||||
int in[] = HDFNativeData.byteToInt(start, len, bin);
|
||||
int nelems = java.lang.reflect.Array.getLength(in);
|
||||
Integer[] out = new Integer[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -593,7 +604,7 @@ public class HDFArray {
|
||||
|
||||
private byte[] ShortToByte(Short in[])
|
||||
{
|
||||
int nelems = java.lang.reflect.Array.getLength(in);
|
||||
int nelems = java.lang.reflect.Array.getLength(in);
|
||||
short[] out = new short[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -604,8 +615,8 @@ public class HDFArray {
|
||||
|
||||
private Short[] ByteToShort(byte[] bin)
|
||||
{
|
||||
short in[] = HDFNativeData.byteToShort(bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
short in[] = HDFNativeData.byteToShort(bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
Short[] out = new Short[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -616,8 +627,8 @@ public class HDFArray {
|
||||
|
||||
private Short[] ByteToShort(int start, int len, byte[] bin)
|
||||
{
|
||||
short in[] = (short[]) HDFNativeData.byteToShort(start, len, bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
short in[] = (short[])HDFNativeData.byteToShort(start, len, bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
Short[] out = new Short[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -628,7 +639,7 @@ public class HDFArray {
|
||||
|
||||
private byte[] ByteObjToByte(Byte in[])
|
||||
{
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
byte[] out = new byte[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -639,7 +650,7 @@ public class HDFArray {
|
||||
|
||||
private Byte[] ByteToByteObj(byte[] bin)
|
||||
{
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)bin);
|
||||
Byte[] out = new Byte[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -660,7 +671,7 @@ public class HDFArray {
|
||||
|
||||
private byte[] FloatObjToByte(Float in[])
|
||||
{
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
float[] out = new float[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -671,8 +682,8 @@ public class HDFArray {
|
||||
|
||||
private Float[] ByteToFloatObj(byte[] bin)
|
||||
{
|
||||
float in[] = (float[]) HDFNativeData.byteToFloat(bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
float in[] = (float[])HDFNativeData.byteToFloat(bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
Float[] out = new Float[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -683,8 +694,8 @@ public class HDFArray {
|
||||
|
||||
private Float[] ByteToFloatObj(int start, int len, byte[] bin)
|
||||
{
|
||||
float in[] = (float[]) HDFNativeData.byteToFloat(start, len, bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
float in[] = (float[])HDFNativeData.byteToFloat(start, len, bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
Float[] out = new Float[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -695,7 +706,7 @@ public class HDFArray {
|
||||
|
||||
private byte[] DoubleObjToByte(Double in[])
|
||||
{
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
double[] out = new double[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -706,8 +717,8 @@ public class HDFArray {
|
||||
|
||||
private Double[] ByteToDoubleObj(byte[] bin)
|
||||
{
|
||||
double in[] = (double[]) HDFNativeData.byteToDouble(bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
double in[] = (double[])HDFNativeData.byteToDouble(bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
Double[] out = new Double[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -718,8 +729,8 @@ public class HDFArray {
|
||||
|
||||
private Double[] ByteToDoubleObj(int start, int len, byte[] bin)
|
||||
{
|
||||
double in[] = (double[]) HDFNativeData.byteToDouble(start, len, bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
double in[] = (double[])HDFNativeData.byteToDouble(start, len, bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
Double[] out = new Double[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -730,7 +741,7 @@ public class HDFArray {
|
||||
|
||||
private byte[] LongObjToByte(Long in[])
|
||||
{
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
long[] out = new long[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -741,8 +752,8 @@ public class HDFArray {
|
||||
|
||||
private Long[] ByteToLongObj(byte[] bin)
|
||||
{
|
||||
long in[] = (long[]) HDFNativeData.byteToLong(bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
long in[] = (long[])HDFNativeData.byteToLong(bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
Long[] out = new Long[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -753,8 +764,8 @@ public class HDFArray {
|
||||
|
||||
private Long[] ByteToLongObj(int start, int len, byte[] bin)
|
||||
{
|
||||
long in[] = (long[]) HDFNativeData.byteToLong(start, len, bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object) in);
|
||||
long in[] = (long[])HDFNativeData.byteToLong(start, len, bin);
|
||||
int nelems = java.lang.reflect.Array.getLength((Object)in);
|
||||
Long[] out = new Long[nelems];
|
||||
|
||||
for (int i = 0; i < nelems; i++) {
|
||||
@@ -770,18 +781,18 @@ public class HDFArray {
|
||||
* We use java.lang.reflection here.
|
||||
*/
|
||||
class ArrayDescriptor {
|
||||
static String theType = "";
|
||||
static Class theClass = null;
|
||||
static int[] dimlen = null;
|
||||
static int[] dimstart = null;
|
||||
static String theType = "";
|
||||
static Class theClass = null;
|
||||
static int[] dimlen = null;
|
||||
static int[] dimstart = null;
|
||||
static int[] currentindex = null;
|
||||
static int[] bytetoindex = null;
|
||||
static int totalSize = 0;
|
||||
static int totalElements = 0;
|
||||
static Object[] objs = null;
|
||||
static char NT = ' '; /* must be B,S,I,L,F,D, else error */
|
||||
static int NTsize = 0;
|
||||
static int dims = 0;
|
||||
static int[] bytetoindex = null;
|
||||
static int totalSize = 0;
|
||||
static int totalElements = 0;
|
||||
static Object[] objs = null;
|
||||
static char NT = ' '; /* must be B,S,I,L,F,D, else error */
|
||||
static int NTsize = 0;
|
||||
static int dims = 0;
|
||||
static String className;
|
||||
|
||||
public ArrayDescriptor(Object anArray) throws HDF5JavaException
|
||||
@@ -790,7 +801,7 @@ class ArrayDescriptor {
|
||||
if (tc.isArray() == false) {
|
||||
/* exception: not an array */
|
||||
HDF5JavaException ex = new HDF5JavaException("ArrayDescriptor: not an array?: ");
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
|
||||
theClass = tc;
|
||||
@@ -799,10 +810,10 @@ class ArrayDescriptor {
|
||||
* parse the type descriptor to discover the shape of the array
|
||||
*/
|
||||
String ss = tc.toString();
|
||||
theType = ss;
|
||||
int n = 6;
|
||||
dims = 0;
|
||||
char c = ' ';
|
||||
theType = ss;
|
||||
int n = 6;
|
||||
dims = 0;
|
||||
char c = ' ';
|
||||
while (n < ss.length()) {
|
||||
c = ss.charAt(n);
|
||||
n++;
|
||||
@@ -811,10 +822,10 @@ class ArrayDescriptor {
|
||||
}
|
||||
}
|
||||
|
||||
String css = ss.substring(ss.lastIndexOf('[') + 1);
|
||||
String css = ss.substring(ss.lastIndexOf('[') + 1);
|
||||
Class compC = tc.getComponentType();
|
||||
String cs = compC.toString();
|
||||
NT = c; /* must be B,S,I,L,F,D, else error */
|
||||
String cs = compC.toString();
|
||||
NT = c; /* must be B,S,I,L,F,D, else error */
|
||||
if (NT == 'B') {
|
||||
NTsize = 1;
|
||||
}
|
||||
@@ -828,68 +839,69 @@ class ArrayDescriptor {
|
||||
NTsize = 8;
|
||||
}
|
||||
else if (css.startsWith("Ljava.lang.Byte")) {
|
||||
NT = 'L';
|
||||
NT = 'L';
|
||||
className = "java.lang.Byte";
|
||||
NTsize = 1;
|
||||
NTsize = 1;
|
||||
}
|
||||
else if (css.startsWith("Ljava.lang.Short")) {
|
||||
NT = 'L';
|
||||
NT = 'L';
|
||||
className = "java.lang.Short";
|
||||
NTsize = 2;
|
||||
NTsize = 2;
|
||||
}
|
||||
else if (css.startsWith("Ljava.lang.Integer")) {
|
||||
NT = 'L';
|
||||
NT = 'L';
|
||||
className = "java.lang.Integer";
|
||||
NTsize = 4;
|
||||
NTsize = 4;
|
||||
}
|
||||
else if (css.startsWith("Ljava.lang.Float")) {
|
||||
NT = 'L';
|
||||
NT = 'L';
|
||||
className = "java.lang.Float";
|
||||
NTsize = 4;
|
||||
NTsize = 4;
|
||||
}
|
||||
else if (css.startsWith("Ljava.lang.Double")) {
|
||||
NT = 'L';
|
||||
NT = 'L';
|
||||
className = "java.lang.Double";
|
||||
NTsize = 8;
|
||||
NTsize = 8;
|
||||
}
|
||||
else if (css.startsWith("Ljava.lang.Long")) {
|
||||
NT = 'L';
|
||||
NT = 'L';
|
||||
className = "java.lang.Long";
|
||||
NTsize = 8;
|
||||
NTsize = 8;
|
||||
}
|
||||
else if (css.startsWith("Ljava.lang.String")) {
|
||||
NT = 'L';
|
||||
NT = 'L';
|
||||
className = "java.lang.String";
|
||||
NTsize = 1;
|
||||
throw new HDF5JavaException(new String("ArrayDesciptor: Warning: String array not fully supported yet"));
|
||||
NTsize = 1;
|
||||
throw new HDF5JavaException(
|
||||
new String("ArrayDesciptor: Warning: String array not fully supported yet"));
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* exception: not a numeric type
|
||||
*/
|
||||
throw new HDF5JavaException(
|
||||
new String("ArrayDesciptor: Error: array is not numeric (type is " + css + ") ?"));
|
||||
new String("ArrayDesciptor: Error: array is not numeric (type is " + css + ") ?"));
|
||||
}
|
||||
|
||||
/* fill in the table */
|
||||
dimlen = new int[dims + 1];
|
||||
dimstart = new int[dims + 1];
|
||||
dimlen = new int[dims + 1];
|
||||
dimstart = new int[dims + 1];
|
||||
currentindex = new int[dims + 1];
|
||||
bytetoindex = new int[dims + 1];
|
||||
objs = new Object[dims + 1];
|
||||
bytetoindex = new int[dims + 1];
|
||||
objs = new Object[dims + 1];
|
||||
|
||||
Object o = anArray;
|
||||
objs[0] = o;
|
||||
dimlen[0] = 1;
|
||||
dimstart[0] = 0;
|
||||
Object o = anArray;
|
||||
objs[0] = o;
|
||||
dimlen[0] = 1;
|
||||
dimstart[0] = 0;
|
||||
currentindex[0] = 0;
|
||||
int elements = 1;
|
||||
int elements = 1;
|
||||
int i;
|
||||
for (i = 1; i <= dims; i++) {
|
||||
dimlen[i] = java.lang.reflect.Array.getLength((Object) o);
|
||||
o = java.lang.reflect.Array.get((Object) o, 0);
|
||||
objs[i] = o;
|
||||
dimstart[i] = 0;
|
||||
dimlen[i] = java.lang.reflect.Array.getLength((Object)o);
|
||||
o = java.lang.reflect.Array.get((Object)o, 0);
|
||||
objs[i] = o;
|
||||
dimstart[i] = 0;
|
||||
currentindex[i] = 0;
|
||||
elements *= dimlen[i];
|
||||
}
|
||||
@@ -917,14 +929,15 @@ class ArrayDescriptor {
|
||||
System.out.println("Type: " + theType);
|
||||
System.out.println("Class: " + theClass);
|
||||
System.out.println("NT: " + NT + " NTsize: " + NTsize);
|
||||
System.out.println("Array has " + dims + " dimensions (" + totalSize
|
||||
+ " bytes, " + totalElements + " elements)");
|
||||
System.out.println("Array has " + dims + " dimensions (" + totalSize + " bytes, " + totalElements +
|
||||
" elements)");
|
||||
int i;
|
||||
for (i = 0; i <= dims; i++) {
|
||||
Class tc = objs[i].getClass();
|
||||
Class tc = objs[i].getClass();
|
||||
String ss = tc.toString();
|
||||
System.out.println(i + ": start " + dimstart[i] + ": len " + dimlen[i] + " current " + currentindex[i]
|
||||
+ " bytetoindex " + bytetoindex[i] + " object " + objs[i] + " otype " + ss);
|
||||
System.out.println(i + ": start " + dimstart[i] + ": len " + dimlen[i] + " current " +
|
||||
currentindex[i] + " bytetoindex " + bytetoindex[i] + " object " + objs[i] +
|
||||
" otype " + ss);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,8 +95,7 @@ public class HDFNativeData {
|
||||
* The input array of bytes
|
||||
* @return an array of 'len' int
|
||||
*/
|
||||
public synchronized static native int[] byteToInt(int start, int len,
|
||||
byte[] data);
|
||||
public synchronized static native int[] byteToInt(int start, int len, byte[] data);
|
||||
|
||||
/**
|
||||
* Convert 4 bytes from an array of bytes into a single int
|
||||
@@ -107,9 +106,10 @@ public class HDFNativeData {
|
||||
* The input array of bytes
|
||||
* @return The integer value of the bytes.
|
||||
*/
|
||||
public synchronized static int byteToInt(byte[] data, int start) {
|
||||
public synchronized static int byteToInt(byte[] data, int start)
|
||||
{
|
||||
int[] ival = new int[1];
|
||||
ival = byteToInt(start, 1, data);
|
||||
ival = byteToInt(start, 1, data);
|
||||
return (ival[0]);
|
||||
}
|
||||
|
||||
@@ -124,8 +124,7 @@ public class HDFNativeData {
|
||||
* The input array of bytes
|
||||
* @return an array of 'len' short
|
||||
*/
|
||||
public synchronized static native short[] byteToShort(int start, int len,
|
||||
byte[] data);
|
||||
public synchronized static native short[] byteToShort(int start, int len, byte[] data);
|
||||
|
||||
/**
|
||||
* Convert 2 bytes from an array of bytes into a single short
|
||||
@@ -136,9 +135,10 @@ public class HDFNativeData {
|
||||
* The input array of bytes
|
||||
* @return The short value of the bytes.
|
||||
*/
|
||||
public synchronized static short byteToShort(byte[] data, int start) {
|
||||
public synchronized static short byteToShort(byte[] data, int start)
|
||||
{
|
||||
short[] sval = new short[1];
|
||||
sval = byteToShort(start, 1, data);
|
||||
sval = byteToShort(start, 1, data);
|
||||
return (sval[0]);
|
||||
}
|
||||
|
||||
@@ -164,9 +164,10 @@ public class HDFNativeData {
|
||||
* The input array of bytes
|
||||
* @return The float value of the bytes.
|
||||
*/
|
||||
public synchronized static float byteToFloat(byte[] data, int start) {
|
||||
public synchronized static float byteToFloat(byte[] data, int start)
|
||||
{
|
||||
float[] fval = new float[1];
|
||||
fval = byteToFloat(start, 1, data);
|
||||
fval = byteToFloat(start, 1, data);
|
||||
return (fval[0]);
|
||||
}
|
||||
|
||||
@@ -181,8 +182,7 @@ public class HDFNativeData {
|
||||
* The input array of bytes
|
||||
* @return an array of 'len' long
|
||||
*/
|
||||
public synchronized static native long[] byteToLong(int start, int len,
|
||||
byte[] data);
|
||||
public synchronized static native long[] byteToLong(int start, int len, byte[] data);
|
||||
|
||||
/**
|
||||
* Convert 8 bytes from an array of bytes into a single long
|
||||
@@ -193,9 +193,10 @@ public class HDFNativeData {
|
||||
* The input array of bytes
|
||||
* @return The long value of the bytes.
|
||||
*/
|
||||
public synchronized static long byteToLong(byte[] data, int start) {
|
||||
public synchronized static long byteToLong(byte[] data, int start)
|
||||
{
|
||||
long[] lval = new long[1];
|
||||
lval = byteToLong(start, 1, data);
|
||||
lval = byteToLong(start, 1, data);
|
||||
return (lval[0]);
|
||||
}
|
||||
|
||||
@@ -210,8 +211,7 @@ public class HDFNativeData {
|
||||
* The input array of bytes
|
||||
* @return an array of 'len' double
|
||||
*/
|
||||
public synchronized static native double[] byteToDouble(int start, int len,
|
||||
byte[] data);
|
||||
public synchronized static native double[] byteToDouble(int start, int len, byte[] data);
|
||||
|
||||
/**
|
||||
* Convert 8 bytes from an array of bytes into a single double
|
||||
@@ -222,9 +222,10 @@ public class HDFNativeData {
|
||||
* The input array of bytes
|
||||
* @return The double value of the bytes.
|
||||
*/
|
||||
public synchronized static double byteToDouble(byte[] data, int start) {
|
||||
public synchronized static double byteToDouble(byte[] data, int start)
|
||||
{
|
||||
double[] dval = new double[1];
|
||||
dval = byteToDouble(start, 1, data);
|
||||
dval = byteToDouble(start, 1, data);
|
||||
return (dval[0]);
|
||||
}
|
||||
|
||||
@@ -239,8 +240,7 @@ public class HDFNativeData {
|
||||
* The input array of int
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static native byte[] intToByte(int start, int len,
|
||||
int[] data);
|
||||
public synchronized static native byte[] intToByte(int start, int len, int[] data);
|
||||
|
||||
/**
|
||||
* Convert a range from an array of short into an array of bytes.
|
||||
@@ -253,8 +253,7 @@ public class HDFNativeData {
|
||||
* The input array of short
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static native byte[] shortToByte(int start, int len,
|
||||
short[] data);
|
||||
public synchronized static native byte[] shortToByte(int start, int len, short[] data);
|
||||
|
||||
/**
|
||||
* Convert a range from an array of float into an array of bytes.
|
||||
@@ -267,8 +266,7 @@ public class HDFNativeData {
|
||||
* The input array of float
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static native byte[] floatToByte(int start, int len,
|
||||
float[] data);
|
||||
public synchronized static native byte[] floatToByte(int start, int len, float[] data);
|
||||
|
||||
/**
|
||||
* Convert a range from an array of long into an array of bytes.
|
||||
@@ -281,8 +279,7 @@ public class HDFNativeData {
|
||||
* The input array of long
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static native byte[] longToByte(int start, int len,
|
||||
long[] data);
|
||||
public synchronized static native byte[] longToByte(int start, int len, long[] data);
|
||||
|
||||
/**
|
||||
* Convert a range from an array of double into an array of bytes.
|
||||
@@ -295,8 +292,7 @@ public class HDFNativeData {
|
||||
* The input array of double
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static native byte[] doubleToByte(int start, int len,
|
||||
double[] data);
|
||||
public synchronized static native byte[] doubleToByte(int start, int len, double[] data);
|
||||
|
||||
/**
|
||||
* Convert a single byte into an array of one byte.
|
||||
@@ -318,9 +314,7 @@ public class HDFNativeData {
|
||||
* The input Byte
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static byte[] byteToByte(Byte data) {
|
||||
return byteToByte(data.byteValue());
|
||||
}
|
||||
public synchronized static byte[] byteToByte(Byte data) { return byteToByte(data.byteValue()); }
|
||||
|
||||
/**
|
||||
* Convert a single int into an array of 4 bytes.
|
||||
@@ -338,9 +332,7 @@ public class HDFNativeData {
|
||||
* The input Integer
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static byte[] intToByte(Integer data) {
|
||||
return intToByte(data.intValue());
|
||||
}
|
||||
public synchronized static byte[] intToByte(Integer data) { return intToByte(data.intValue()); }
|
||||
|
||||
/**
|
||||
* Convert a single short into an array of 2 bytes.
|
||||
@@ -358,9 +350,7 @@ public class HDFNativeData {
|
||||
* The input Short
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static byte[] shortToByte(Short data) {
|
||||
return shortToByte(data.shortValue());
|
||||
}
|
||||
public synchronized static byte[] shortToByte(Short data) { return shortToByte(data.shortValue()); }
|
||||
|
||||
/**
|
||||
* Convert a single float into an array of 4 bytes.
|
||||
@@ -378,9 +368,7 @@ public class HDFNativeData {
|
||||
* The input Float
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static byte[] floatToByte(Float data) {
|
||||
return floatToByte(data.floatValue());
|
||||
};
|
||||
public synchronized static byte[] floatToByte(Float data) { return floatToByte(data.floatValue()); };
|
||||
|
||||
/**
|
||||
* Convert a single long into an array of 8 bytes.
|
||||
@@ -398,9 +386,7 @@ public class HDFNativeData {
|
||||
* The input Long
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static byte[] longToByte(Long data) {
|
||||
return longToByte(data.longValue());
|
||||
}
|
||||
public synchronized static byte[] longToByte(Long data) { return longToByte(data.longValue()); }
|
||||
|
||||
/**
|
||||
* Convert a single double into an array of 8 bytes.
|
||||
@@ -418,9 +404,7 @@ public class HDFNativeData {
|
||||
* The input Double
|
||||
* @return an array of bytes
|
||||
*/
|
||||
public synchronized static byte[] doubleToByte(Double data) {
|
||||
return doubleToByte(data.doubleValue());
|
||||
}
|
||||
public synchronized static byte[] doubleToByte(Double data) { return doubleToByte(data.doubleValue()); }
|
||||
|
||||
/**
|
||||
* Create a Number object from an array of bytes.
|
||||
@@ -435,40 +419,39 @@ public class HDFNativeData {
|
||||
* @exception HDF5Exception
|
||||
* - Error unsupported type.
|
||||
*/
|
||||
public synchronized static Object byteToNumber(byte[] barray, Object obj)
|
||||
throws HDF5Exception
|
||||
public synchronized static Object byteToNumber(byte[] barray, Object obj) throws HDF5Exception
|
||||
{
|
||||
Class theClass = obj.getClass();
|
||||
String type = theClass.getName();
|
||||
Object retobj = null;
|
||||
String type = theClass.getName();
|
||||
Object retobj = null;
|
||||
|
||||
if (type.equals("java.lang.Integer")) {
|
||||
int[] i = hdf.hdf5lib.HDFNativeData.byteToInt(0, 1, barray);
|
||||
retobj = Integer.valueOf(i[0]);
|
||||
retobj = Integer.valueOf(i[0]);
|
||||
}
|
||||
else if (type.equals("java.lang.Byte")) {
|
||||
retobj = Byte.valueOf(barray[0]);
|
||||
}
|
||||
else if (type.equals("java.lang.Short")) {
|
||||
short[] f = hdf.hdf5lib.HDFNativeData.byteToShort(0, 1, barray);
|
||||
retobj = Short.valueOf(f[0]);
|
||||
retobj = Short.valueOf(f[0]);
|
||||
}
|
||||
else if (type.equals("java.lang.Float")) {
|
||||
float[] f = hdf.hdf5lib.HDFNativeData.byteToFloat(0, 1, barray);
|
||||
retobj = Float.valueOf(f[0]);
|
||||
retobj = Float.valueOf(f[0]);
|
||||
}
|
||||
else if (type.equals("java.lang.Long")) {
|
||||
long[] f = hdf.hdf5lib.HDFNativeData.byteToLong(0, 1, barray);
|
||||
retobj = Long.valueOf(f[0]);
|
||||
retobj = Long.valueOf(f[0]);
|
||||
}
|
||||
else if (type.equals("java.lang.Double")) {
|
||||
double[] f = hdf.hdf5lib.HDFNativeData.byteToDouble(0, 1, barray);
|
||||
retobj = Double.valueOf(f[0]);
|
||||
retobj = Double.valueOf(f[0]);
|
||||
}
|
||||
else {
|
||||
/* exception: unsupported type */
|
||||
HDF5Exception ex = new HDF5JavaException("byteToNumber: setfield bad type: " + obj + " " + type);
|
||||
throw (ex);
|
||||
throw(ex);
|
||||
}
|
||||
return (retobj);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
|
||||
package hdf.hdf5lib.callbacks;
|
||||
|
||||
/** All callback definitions must derive from this interface. Any
|
||||
/**
|
||||
* All callback definitions must derive from this interface. Any
|
||||
* derived interfaces must define a single public method named "callback".
|
||||
* You are responsible for deregistering your callback (if necessary)
|
||||
* in its {@link Object#finalize} method. If native code attempts to call
|
||||
@@ -26,5 +27,4 @@ package hdf.hdf5lib.callbacks;
|
||||
* handler.
|
||||
*/
|
||||
public interface Callbacks {
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ package hdf.hdf5lib.callbacks;
|
||||
*
|
||||
*/
|
||||
public interface H5A_iterate_t {
|
||||
/** public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
/**
|
||||
* public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ package hdf.hdf5lib.callbacks;
|
||||
*
|
||||
*/
|
||||
public interface H5D_append_t {
|
||||
/** public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
/**
|
||||
* public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ package hdf.hdf5lib.callbacks;
|
||||
*
|
||||
*/
|
||||
public interface H5D_iterate_t {
|
||||
/** public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
/**
|
||||
* public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ package hdf.hdf5lib.callbacks;
|
||||
*
|
||||
*/
|
||||
public interface H5E_walk_t {
|
||||
/** public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
/**
|
||||
* public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -17,5 +17,4 @@ package hdf.hdf5lib.callbacks;
|
||||
*
|
||||
*/
|
||||
public interface H5L_iterate_opdata_t {
|
||||
|
||||
}
|
||||
|
||||
@@ -17,5 +17,4 @@ package hdf.hdf5lib.callbacks;
|
||||
*
|
||||
*/
|
||||
public interface H5O_iterate_opdata_t {
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ package hdf.hdf5lib.callbacks;
|
||||
*
|
||||
*/
|
||||
public interface H5P_cls_close_func_t {
|
||||
/** public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
/**
|
||||
* public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ package hdf.hdf5lib.callbacks;
|
||||
*
|
||||
*/
|
||||
public interface H5P_cls_copy_func_t {
|
||||
/** public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
/**
|
||||
* public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ package hdf.hdf5lib.callbacks;
|
||||
*
|
||||
*/
|
||||
public interface H5P_cls_create_func_t {
|
||||
/** public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
/**
|
||||
* public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ package hdf.hdf5lib.callbacks;
|
||||
*
|
||||
*/
|
||||
public interface H5P_iterate_t {
|
||||
/** public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
/**
|
||||
* public ArrayList iterdata = new ArrayList();
|
||||
* Any derived interfaces must define the single public variable as above.
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/** All callback definitions must derive from the Callbacks interface. Any
|
||||
/**
|
||||
* All callback definitions must derive from the Callbacks interface. Any
|
||||
* derived interfaces must define a single public method named "callback".
|
||||
* You are responsible for deregistering your callback (if necessary)
|
||||
* in its {@link Object#finalize} method. If native code attempts to call
|
||||
|
||||
@@ -23,9 +23,7 @@ public class HDF5AttributeException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5AttributeException</code> with no specified
|
||||
* detail message.
|
||||
*/
|
||||
public HDF5AttributeException() {
|
||||
super();
|
||||
}
|
||||
public HDF5AttributeException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5AttributeException</code> with the specified
|
||||
@@ -34,7 +32,5 @@ public class HDF5AttributeException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5AttributeException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5AttributeException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ public class HDF5BtreeException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5BtreeException</code> with no specified detail
|
||||
* message.
|
||||
*/
|
||||
public HDF5BtreeException() {
|
||||
super();
|
||||
}
|
||||
public HDF5BtreeException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5BtreeException</code> with the specified detail
|
||||
@@ -34,7 +32,5 @@ public class HDF5BtreeException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5BtreeException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5BtreeException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ public class HDF5DataFiltersException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5DataFiltersException</code> with no specified
|
||||
* detail message.
|
||||
*/
|
||||
public HDF5DataFiltersException() {
|
||||
super();
|
||||
}
|
||||
public HDF5DataFiltersException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5DataFiltersException</code> with the specified
|
||||
@@ -34,7 +32,5 @@ public class HDF5DataFiltersException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5DataFiltersException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5DataFiltersException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5DataStorageException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5DataStorageExceptionn</code> with no specified
|
||||
* detail message.
|
||||
*/
|
||||
public HDF5DataStorageException() {
|
||||
super();
|
||||
}
|
||||
public HDF5DataStorageException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5DataStorageException</code> with the specified
|
||||
@@ -35,7 +33,5 @@ public class HDF5DataStorageException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5DataStorageException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5DataStorageException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ public class HDF5DatasetInterfaceException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5DatasetInterfaceException</code> with no
|
||||
* specified detail message.
|
||||
*/
|
||||
public HDF5DatasetInterfaceException() {
|
||||
super();
|
||||
}
|
||||
public HDF5DatasetInterfaceException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5DatasetInterfaceException</code> with the
|
||||
@@ -34,7 +32,5 @@ public class HDF5DatasetInterfaceException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5DatasetInterfaceException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5DatasetInterfaceException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5DataspaceInterfaceException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5DataspaceInterfaceException</code> with no
|
||||
* specified detail message.
|
||||
*/
|
||||
public HDF5DataspaceInterfaceException() {
|
||||
super();
|
||||
}
|
||||
public HDF5DataspaceInterfaceException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5DataspaceInterfaceException</code> with the
|
||||
@@ -35,7 +33,5 @@ public class HDF5DataspaceInterfaceException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5DataspaceInterfaceException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5DataspaceInterfaceException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5DatatypeInterfaceException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5DatatypeInterfaceException</code> with no
|
||||
* specified detail message.
|
||||
*/
|
||||
public HDF5DatatypeInterfaceException() {
|
||||
super();
|
||||
}
|
||||
public HDF5DatatypeInterfaceException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5DatatypeInterfaceException</code> with the
|
||||
@@ -35,7 +33,5 @@ public class HDF5DatatypeInterfaceException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5DatatypeInterfaceException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5DatatypeInterfaceException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -40,9 +40,7 @@ public class HDF5Exception extends RuntimeException {
|
||||
* Constructs an <code>HDF5Exception</code> with no specified detail
|
||||
* message.
|
||||
*/
|
||||
public HDF5Exception() {
|
||||
super();
|
||||
}
|
||||
public HDF5Exception() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5Exception</code> with the specified detail
|
||||
@@ -51,7 +49,8 @@ public class HDF5Exception extends RuntimeException {
|
||||
* @param message
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5Exception(String message) {
|
||||
public HDF5Exception(String message)
|
||||
{
|
||||
super();
|
||||
detailMessage = message;
|
||||
}
|
||||
@@ -63,7 +62,8 @@ public class HDF5Exception extends RuntimeException {
|
||||
* have a detail message.
|
||||
*/
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getMessage()
|
||||
{
|
||||
return detailMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5ExternalFileListException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5ExternalFileListException</code> with no
|
||||
* specified detail message.
|
||||
*/
|
||||
public HDF5ExternalFileListException() {
|
||||
super();
|
||||
}
|
||||
public HDF5ExternalFileListException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5ExternalFileListException</code> with the
|
||||
@@ -35,7 +33,5 @@ public class HDF5ExternalFileListException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5ExternalFileListException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5ExternalFileListException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5FileInterfaceException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5FileInterfaceException</code> with no specified
|
||||
* detail message.
|
||||
*/
|
||||
public HDF5FileInterfaceException() {
|
||||
super();
|
||||
}
|
||||
public HDF5FileInterfaceException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5FileInterfaceException</code> with the specified
|
||||
@@ -35,7 +33,5 @@ public class HDF5FileInterfaceException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5FileInterfaceException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5FileInterfaceException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5FunctionArgumentException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5FunctionArgumentException</code> with no
|
||||
* specified detail message.
|
||||
*/
|
||||
public HDF5FunctionArgumentException() {
|
||||
super();
|
||||
}
|
||||
public HDF5FunctionArgumentException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5FunctionArgumentException</code> with the
|
||||
@@ -35,7 +33,5 @@ public class HDF5FunctionArgumentException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5FunctionArgumentException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5FunctionArgumentException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5FunctionEntryExitException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5FunctionEntryExitException</code> with no
|
||||
* specified detail message.
|
||||
*/
|
||||
public HDF5FunctionEntryExitException() {
|
||||
super();
|
||||
}
|
||||
public HDF5FunctionEntryExitException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5FunctionEntryExitException</code> with the
|
||||
@@ -35,7 +33,5 @@ public class HDF5FunctionEntryExitException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5FunctionEntryExitException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5FunctionEntryExitException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5HeapException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5HeapException</code> with no specified detail
|
||||
* message.
|
||||
*/
|
||||
public HDF5HeapException() {
|
||||
super();
|
||||
}
|
||||
public HDF5HeapException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5HeapException</code> with the specified detail
|
||||
@@ -35,7 +33,5 @@ public class HDF5HeapException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5HeapException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5HeapException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5IdException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5IdException</code> with no specified detail
|
||||
* message.
|
||||
*/
|
||||
public HDF5IdException() {
|
||||
super();
|
||||
}
|
||||
public HDF5IdException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5IdException</code> with the specified detail
|
||||
@@ -35,8 +33,5 @@ public class HDF5IdException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5IdException(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public HDF5IdException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5InternalErrorException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5InternalErrorException</code> with no specified
|
||||
* detail message.
|
||||
*/
|
||||
public HDF5InternalErrorException() {
|
||||
super();
|
||||
}
|
||||
public HDF5InternalErrorException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5InternalErrorException</code> with the specified
|
||||
@@ -35,7 +33,5 @@ public class HDF5InternalErrorException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5InternalErrorException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5InternalErrorException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -26,9 +26,7 @@ public class HDF5JavaException extends HDF5Exception {
|
||||
* Constructs an <code>HDF5JavaException</code> with no specified detail
|
||||
* message.
|
||||
*/
|
||||
public HDF5JavaException() {
|
||||
super();
|
||||
}
|
||||
public HDF5JavaException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5JavaException</code> with the specified detail
|
||||
@@ -37,7 +35,5 @@ public class HDF5JavaException extends HDF5Exception {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5JavaException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5JavaException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ public class HDF5LibraryException extends HDF5Exception {
|
||||
* Constructs an <code>HDF5LibraryException</code> with no specified detail
|
||||
* message.
|
||||
*/
|
||||
public HDF5LibraryException() {
|
||||
public HDF5LibraryException()
|
||||
{
|
||||
super();
|
||||
|
||||
// this code forces the loading of the HDF-5 library
|
||||
@@ -52,7 +53,7 @@ public class HDF5LibraryException extends HDF5Exception {
|
||||
|
||||
this.majorErrorNumber = _getMajorErrorNumber();
|
||||
this.minorErrorNumber = _getMinorErrorNumber();
|
||||
detailMessage = getMinorError(minorErrorNumber);
|
||||
detailMessage = getMinorError(minorErrorNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +63,8 @@ public class HDF5LibraryException extends HDF5Exception {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5LibraryException(String s) {
|
||||
public HDF5LibraryException(String s)
|
||||
{
|
||||
super(s);
|
||||
// this code forces the loading of the HDF-5 library
|
||||
// to assure that the native methods are available
|
||||
@@ -81,10 +83,7 @@ public class HDF5LibraryException extends HDF5Exception {
|
||||
*
|
||||
* @return the major error number
|
||||
*/
|
||||
public long getMajorErrorNumber()
|
||||
{
|
||||
return majorErrorNumber;
|
||||
}
|
||||
public long getMajorErrorNumber() { return majorErrorNumber; }
|
||||
private native long _getMajorErrorNumber();
|
||||
|
||||
/**
|
||||
@@ -93,10 +92,7 @@ public class HDF5LibraryException extends HDF5Exception {
|
||||
*
|
||||
* @return the minor error number
|
||||
*/
|
||||
public long getMinorErrorNumber()
|
||||
{
|
||||
return minorErrorNumber;
|
||||
}
|
||||
public long getMinorErrorNumber() { return minorErrorNumber; }
|
||||
private native long _getMinorErrorNumber();
|
||||
|
||||
/**
|
||||
@@ -109,7 +105,8 @@ public class HDF5LibraryException extends HDF5Exception {
|
||||
*
|
||||
* @return the string of the minor error
|
||||
*/
|
||||
public String getMinorError(long err_code) {
|
||||
public String getMinorError(long err_code)
|
||||
{
|
||||
if (err_code == 0) {
|
||||
return "special zero no error";
|
||||
}
|
||||
@@ -356,9 +353,10 @@ public class HDF5LibraryException extends HDF5Exception {
|
||||
* stack, and and the Java stack trace to the standard error stream.
|
||||
*/
|
||||
@Override
|
||||
public void printStackTrace() {
|
||||
public void printStackTrace()
|
||||
{
|
||||
System.err.println(this);
|
||||
printStackTrace0(null); // the HDF-5 Library error stack
|
||||
printStackTrace0(null); // the HDF-5 Library error stack
|
||||
super.printStackTrace(); // the Java stack trace
|
||||
}
|
||||
|
||||
@@ -369,21 +367,21 @@ public class HDF5LibraryException extends HDF5Exception {
|
||||
* @param f
|
||||
* the file print stream.
|
||||
*/
|
||||
public void printStackTrace(java.io.File f) {
|
||||
public void printStackTrace(java.io.File f)
|
||||
{
|
||||
if ((f == null) || !f.exists() || f.isDirectory() || !f.canWrite()) {
|
||||
printStackTrace();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
java.io.FileOutputStream o = new java.io.FileOutputStream(f);
|
||||
java.io.PrintWriter p = new java.io.PrintWriter(o);
|
||||
java.io.PrintWriter p = new java.io.PrintWriter(o);
|
||||
p.println(this);
|
||||
p.close();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println(this);
|
||||
}
|
||||
;
|
||||
};
|
||||
// the HDF-5 Library error stack
|
||||
printStackTrace0(f.getPath());
|
||||
super.printStackTrace(); // the Java stack trace
|
||||
@@ -395,5 +393,4 @@ public class HDF5LibraryException extends HDF5Exception {
|
||||
* and error stack.
|
||||
*/
|
||||
private native void printStackTrace0(String s);
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5LowLevelIOException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5LowLevelIOException</code> with no specified
|
||||
* detail message.
|
||||
*/
|
||||
public HDF5LowLevelIOException() {
|
||||
super();
|
||||
}
|
||||
public HDF5LowLevelIOException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5LowLevelIOException</code> with the specified
|
||||
@@ -35,7 +33,5 @@ public class HDF5LowLevelIOException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5LowLevelIOException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5LowLevelIOException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5MetaDataCacheException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5MetaDataCacheException</code> with no specified
|
||||
* detail message.
|
||||
*/
|
||||
public HDF5MetaDataCacheException() {
|
||||
super();
|
||||
}
|
||||
public HDF5MetaDataCacheException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5MetaDataCacheException</code> with the specified
|
||||
@@ -35,7 +33,5 @@ public class HDF5MetaDataCacheException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5MetaDataCacheException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5MetaDataCacheException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5ObjectHeaderException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5ObjectHeaderException</code> with no specified
|
||||
* detail message.
|
||||
*/
|
||||
public HDF5ObjectHeaderException() {
|
||||
super();
|
||||
}
|
||||
public HDF5ObjectHeaderException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5ObjectHeaderException</code> with the specified
|
||||
@@ -35,7 +33,5 @@ public class HDF5ObjectHeaderException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5ObjectHeaderException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5ObjectHeaderException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5PropertyListInterfaceException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5PropertyListInterfaceException</code> with no
|
||||
* specified detail message.
|
||||
*/
|
||||
public HDF5PropertyListInterfaceException() {
|
||||
super();
|
||||
}
|
||||
public HDF5PropertyListInterfaceException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5PropertyListInterfaceException</code> with the
|
||||
@@ -35,7 +33,5 @@ public class HDF5PropertyListInterfaceException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5PropertyListInterfaceException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5PropertyListInterfaceException(String s) { super(s); }
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ public class HDF5ReferenceException extends HDF5LibraryException {
|
||||
* Constructs an <code>HDF5ReferenceException</code> with no specified
|
||||
* detail message.
|
||||
*/
|
||||
public HDF5ReferenceException() {
|
||||
super();
|
||||
}
|
||||
public HDF5ReferenceException() { super(); }
|
||||
|
||||
/**
|
||||
* Constructs an <code>HDF5ReferenceException</code> with the specified
|
||||
@@ -35,7 +33,5 @@ public class HDF5ReferenceException extends HDF5LibraryException {
|
||||
* @param s
|
||||
* the detail message.
|
||||
*/
|
||||
public HDF5ReferenceException(String s) {
|
||||
super(s);
|
||||
}
|
||||
public HDF5ReferenceException(String s) { super(s); }
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user