File: h5pHelperImp.c

package info (click to toggle)
libsis-jhdf5-java 19.04.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,188 kB
  • sloc: java: 79,645; ansic: 18,989; sh: 333; makefile: 49; xml: 12
file content (141 lines) | stat: -rw-r--r-- 4,140 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
 * Copyright 2007 - 2018 ETH Zuerich, CISD and SIS.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "hdf5.h"
#include "H5Ppublic.h"
#include "h5jni.h"
#include <jni.h>

/*
/////////////////////////////////////////////////////////////////////////////////
//
// H5P helper methods for controlling the behavior on numeric conversions.
//
/////////////////////////////////////////////////////////////////////////////////
*/

H5T_conv_ret_t abort_on_overflow_cb(int except_type, hid_t *src_id, hid_t *dst_id, void *src_buf, void *dst_buf, void *op_data)
{
    if (except_type == H5T_CONV_EXCEPT_RANGE_HI || except_type == H5T_CONV_EXCEPT_RANGE_LOW)
    {
        return H5T_CONV_ABORT;
    }
    return H5T_CONV_UNHANDLED;
}

/*
 * Class:     ch_systemsx_cisd_cisd_hdf5_hdf5lib_HDFHelper
 * Method:    _H5Pcreate_xfer_abort_overflow
 * Signature: hid_t _H5Pcreate_xfer_abort_overflow()
 */
JNIEXPORT jlong JNICALL Java_ch_systemsx_cisd_hdf5_hdf5lib_HDFHelper__1H5Pcreate_1xfer_1abort_1overflow
  (JNIEnv *env, jclass clss)
{
    hid_t plist;
    herr_t status;

    plist = H5Pcreate(H5P_DATASET_XFER);
    if (plist < 0) {
        h5libraryError(env);
    }
    status = H5Pset_type_conv_cb(plist, (H5T_conv_except_func_t) abort_on_overflow_cb, NULL);
    if (status < 0)
    {
        h5libraryError(env);
    }
    return plist;
}

H5T_conv_ret_t abort_cb(int except_type, hid_t *src_id, hid_t *dst_id, void *src_buf, void *dst_buf, void *op_data)
{
    return H5T_CONV_ABORT;
}

/*
 * Class:     ch_systemsx_cisd_hdf5_hdf5lib_HDFHelper
 * Method:    _H5Pcreate_xfer_abort
 * Signature: hid_t _H5Pcreate_xfer_abort()
 */
JNIEXPORT jlong JNICALL Java_ch_systemsx_cisd_hdf5_hdf5lib_HDFHelper__1H5Pcreate_1xfer_1abort
  (JNIEnv *env, jclass clss)
{
    hid_t plist;
    herr_t status;

    plist = H5Pcreate(H5P_DATASET_XFER);
    if (plist < 0) {
        h5libraryError(env);
    }
    status = H5Pset_type_conv_cb(plist, (H5T_conv_except_func_t) abort_cb, NULL);
    if (status < 0)
    {
        h5libraryError(env);
    }
    return plist;
}

/*
/////////////////////////////////////////////////////////////////////////////////
//
// H5P helper methods for setting / getting the metadata cache image configuration. 
//
/////////////////////////////////////////////////////////////////////////////////
*/

/*
 * Class:     ch_systemsx_cisd_hdf5_hdf5lib_HDFHelper
 * Method:    _H5Pset_mdc_image_config
 * Signature: herr_t _H5Pset_mdc_image_config(hid_t, bool)
 */
JNIEXPORT jlong JNICALL Java_ch_systemsx_cisd_hdf5_hdf5lib_HDFHelper__1H5Pset_1mdc_1image_1config
  (JNIEnv *env, jclass clss, hid_t plist, jboolean generate_image)
{
    herr_t status;
    H5AC_cache_image_config_t config;
    
    config.version = H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION;
    config.generate_image = generate_image;
    config.save_resize_status = 0;
    config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE;

    status = H5Pset_mdc_image_config(plist, &config);
    if (status < 0)
    {
        h5libraryError(env);
    }
    return status;
}

/*
 * Class:     ch_systemsx_cisd_hdf5_hdf5lib_HDFHelper
 * Method:    _H5Pget_mdc_image_enabled
 * Signature: hbool _H5Pget_mdc_image_enabled(hid_t)
 */
JNIEXPORT jboolean JNICALL Java_ch_systemsx_cisd_hdf5_hdf5lib_HDFHelper__1H5Pget_1mdc_1image_1enabled
  (JNIEnv *env, jclass clss, hid_t plist)
{
    herr_t status;
    H5AC_cache_image_config_t config;
    
    config.version = H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION;
    
    status = H5Pget_mdc_image_config(plist, &config);
    if (status < 0)
    {
        h5libraryError(env);
    }
    return config.generate_image;
}