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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* For details of the HDF libraries, see the HDF Documentation at:
* http://hdfgroup.org/HDF5/doc/
*
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include "hdf5.h"
#include "h5fImp.h"
#include "h5util.h"
extern JavaVM *jvm;
extern jobject visit_callback;
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fopen
* Signature: (Ljava/lang/String;IJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Fopen
(JNIEnv *env, jclass clss, jstring name, jint flags, jlong access_id)
{
hid_t status = -1;
const char *fileName;
PIN_JAVA_STRING(name, fileName);
if (fileName != NULL) {
status = H5Fopen(fileName, (unsigned)flags, (hid_t)access_id );
UNPIN_JAVA_STRING(name, fileName);
if (status < 0)
h5libraryError(env);
}
return (jlong)status;
} /* end Java_hdf_hdf5lib_H5__1H5Fopen */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fcreate
* Signature: (Ljava/lang/String;IJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Fcreate
(JNIEnv *env, jclass clss, jstring name, jint flags, jlong create_id, jlong access_id)
{
hid_t status = -1;
const char *fileName;
PIN_JAVA_STRING(name, fileName);
if (fileName != NULL) {
status = H5Fcreate(fileName, (unsigned)flags, create_id, access_id);
UNPIN_JAVA_STRING(name, fileName);
if (status < 0)
h5libraryError(env);
}
return (jlong)status;
} /* end Java_hdf_hdf5lib_H5__1H5Fcreate */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fflush
* Signature: (JI)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Fflush
(JNIEnv *env, jclass clss, jlong object_id, jint scope)
{
herr_t retVal = -1;
retVal = H5Fflush((hid_t)object_id, (H5F_scope_t)scope );
if (retVal < 0)
h5libraryError(env);
return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Fflush */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_name
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1name
(JNIEnv *env, jclass cls, jlong file_id)
{
char *namePtr;
jstring str = NULL;
ssize_t buf_size;
/* get the length of the name */
buf_size = H5Fget_name((hid_t)file_id, NULL, 0);
if (buf_size <= 0) {
h5badArgument(env, "H5Fget_name: buf_size <= 0");
} /* end if */
else {
buf_size++; /* add extra space for the null terminator */
namePtr = (char*)HDmalloc(sizeof(char) * (size_t)buf_size);
if (namePtr == NULL) {
h5outOfMemory(env, "H5Fget_name: malloc failed");
} /* end if */
else {
buf_size = H5Fget_name((hid_t)file_id, namePtr, (size_t)buf_size);
if (buf_size < 0) {
HDfree(namePtr);
h5libraryError(env);
} /* end if */
else {
str = ENVPTR->NewStringUTF(ENVPAR namePtr);
HDfree(namePtr);
}/* end else */
}/* end else */
}/* end else */
return str;
} /* end Java_hdf_hdf5lib_H5_H5Fget_1name */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fis_hdf5
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL
Java_hdf_hdf5lib_H5_H5Fis_1hdf5
(JNIEnv *env, jclass clss, jstring name)
{
htri_t bval = JNI_FALSE;
const char *fileName;
PIN_JAVA_STRING(name, fileName);
if (fileName != NULL) {
bval = H5Fis_hdf5(fileName);
UNPIN_JAVA_STRING(name, fileName);
if (bval > 0)
bval = JNI_TRUE;
else if (bval < 0)
h5libraryError(env);
}
return (jboolean)bval;
} /* end Java_hdf_hdf5lib_H5_H5Fis_1hdf5 */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_create_plist
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist
(JNIEnv *env, jclass clss, jlong file_id)
{
hid_t retVal = -1;
retVal = H5Fget_create_plist((hid_t)file_id );
if (retVal < 0)
h5libraryError(env);
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_access_plist
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist
(JNIEnv *env, jclass clss, jlong file_id)
{
hid_t retVal = -1;
retVal = H5Fget_access_plist((hid_t)file_id);
if (retVal < 0)
h5libraryError(env);
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_intent
* Signature: (J)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1intent
(JNIEnv *env, jclass cls, jlong file_id)
{
unsigned intent = 0;
if (H5Fget_intent((hid_t)file_id, &intent) < 0)
h5libraryError(env);
return (jint)intent;
} /* end Java_hdf_hdf5lib_H5_H5Fget_1intent */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fclose
* Signature: (J)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5__1H5Fclose
(JNIEnv *env, jclass clss, jlong file_id)
{
herr_t status = -1;
if (file_id > 0)
status = H5Fclose((hid_t)file_id );
if (status < 0)
h5libraryError(env);
return (jint)status;
} /* end Java_hdf_hdf5lib_H5__1H5Fclose */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fmount
* Signature: (JLjava/lang/String;JJ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Fmount
(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong child_id, jlong plist_id)
{
herr_t status = -1;
const char *fileName;
PIN_JAVA_STRING(name, fileName);
if (fileName != NULL) {
status = H5Fmount((hid_t)loc_id, fileName, (hid_t)child_id, (hid_t)plist_id);
UNPIN_JAVA_STRING(name, fileName);
if (status < 0)
h5libraryError(env);
}
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Fmount */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Funmount
* Signature: (JLjava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Funmount
(JNIEnv *env, jclass clss, jlong loc_id, jstring name)
{
herr_t status = -1;
const char *fileName;
PIN_JAVA_STRING(name, fileName);
if (fileName != NULL) {
status = H5Funmount((hid_t)loc_id, fileName);
UNPIN_JAVA_STRING(name, fileName);
if (status < 0)
h5libraryError(env);
}
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Funmount */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_freespace
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1freespace
(JNIEnv *env, jclass cls, jlong file_id)
{
hssize_t ret_val = H5Fget_freespace((hid_t)file_id);
if (ret_val < 0)
h5libraryError(env);
return (jlong)ret_val;
} /* end Java_hdf_hdf5lib_H5_H5Fget_1freespace */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Freopen
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Freopen
(JNIEnv *env, jclass clss, jlong file_id)
{
hid_t retVal = -1;
retVal = H5Freopen((hid_t)file_id);
if (retVal < 0)
h5libraryError(env);
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Freopen */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_obj_ids
* Signature: (JIJ[J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids
(JNIEnv *env, jclass cls, jlong file_id, jint types, jlong maxObjs,
jlongArray obj_id_list)
{
ssize_t ret_val = -1;
jlong *obj_id_listP;
jboolean isCopy;
hid_t *id_list;
size_t rank;
size_t i;
if (obj_id_list == NULL) {
h5nullArgument(env, "H5Fget_obj_ids: obj_id_list is NULL");
} /* end if */
else {
obj_id_listP = ENVPTR->GetLongArrayElements(ENVPAR obj_id_list, &isCopy);
if (obj_id_listP == NULL) {
h5JNIFatalError(env, "H5Fget_obj_ids: obj_id_list not pinned");
} /* end if */
else {
rank = (size_t)ENVPTR->GetArrayLength(ENVPAR obj_id_list);
id_list = (hid_t *)HDmalloc(rank * sizeof(hid_t));
if (id_list == NULL) {
ENVPTR->ReleaseLongArrayElements(ENVPAR obj_id_list, obj_id_listP, JNI_ABORT);
h5JNIFatalError(env, "H5Fget_obj_ids: obj_id_list not converted to hid_t");
} /* end if */
else {
ret_val = H5Fget_obj_ids((hid_t)file_id, (unsigned int)types, (size_t)maxObjs, id_list);
if (ret_val < 0) {
ENVPTR->ReleaseLongArrayElements(ENVPAR obj_id_list, obj_id_listP, JNI_ABORT);
HDfree(id_list);
h5libraryError(env);
} /* end if */
else {
for (i = 0; i < rank; i++) {
obj_id_listP[i] = (jlong)id_list[i];
} /* end for */
HDfree(id_list);
ENVPTR->ReleaseLongArrayElements(ENVPAR obj_id_list, obj_id_listP, 0);
} /* end else */
} /* end else */
} /* end else */
} /* end else */
return (jlong)ret_val;
} /* end Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_obj_count
* Signature: (JI)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1obj_1count
(JNIEnv *env, jclass cls, jlong file_id, jint types)
{
ssize_t ret_val = H5Fget_obj_count((hid_t)file_id, (unsigned int)types);
if (ret_val < 0)
h5libraryError(env);
return (jlong)ret_val;
} /* end Java_hdf_hdf5lib_H5_H5Fget_1obj_1count_1long */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_filesize
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1filesize
(JNIEnv *env, jclass clss, jlong file_id)
{
hsize_t size = 0;
if (H5Fget_filesize ((hid_t)file_id, &size) < 0)
h5libraryError(env);
return (jlong) size;
} /* end Java_hdf_hdf5lib_H5_H5Fget_1filesize */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_mdc_hit_rate
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate
(JNIEnv *env, jclass cls, jlong file_id)
{
double rate = 0.0;
if (H5Fget_mdc_hit_rate((hid_t)file_id, &rate) < 0)
h5libraryError(env);
return (jdouble)rate;
} /* end Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_mdc_size
* Signature: (J[J)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size
(JNIEnv *env, jclass cls, jlong file_id, jlongArray metadata_cache)
{
jint size = 0;
jlong *metadata_cache_ptr;
size_t max_size = 0, min_clean_size = 0, cur_size = 0;
int cur_num_entries = -1;
jboolean isCopy;
if (metadata_cache == NULL) {
h5nullArgument(env, "H5Fget_mdc_size: metadata_cache is NULL");
} /* end if */
else {
size = (int)ENVPTR->GetArrayLength(ENVPAR metadata_cache);
if (size < 3) {
h5badArgument(env, "H5Fget_mdc_size: length of metadata_cache < 3.");
} /* end if */
else {
if (H5Fget_mdc_size((hid_t)file_id, &max_size, &min_clean_size, &cur_size, &cur_num_entries) < 0) {
h5libraryError(env);
} /* end if */
else {
metadata_cache_ptr = ENVPTR->GetLongArrayElements(ENVPAR metadata_cache, &isCopy);
metadata_cache_ptr[0] = (jlong)max_size;
metadata_cache_ptr[1] = (jlong)min_clean_size;
metadata_cache_ptr[2] = (jlong)cur_size;
ENVPTR->ReleaseLongArrayElements(ENVPAR metadata_cache, metadata_cache_ptr, 0);
} /* end else */
} /* end else */
} /* end else */
return (jint)cur_num_entries;
} /* end Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_info
* Signature: (J)Lhdf/hdf5lib/structs/H5F_info2_t;
*/
JNIEXPORT jobject JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1info
(JNIEnv *env, jclass clss, jlong obj_id)
{
H5F_info2_t finfo;
jvalue args[9];
jobject ihinfobuf;
jobject ret_obj = NULL;
if (H5Fget_info2((hid_t)obj_id, &finfo) < 0) {
h5libraryError(env);
} /* end if */
else {
args[0].j = (jlong)finfo.sohm.msgs_info.index_size;
args[1].j = (jlong)finfo.sohm.msgs_info.heap_size;
CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args);
ihinfobuf = ret_obj;
args[0].i = (jint)finfo.super.version;
args[1].j = (jlong)finfo.super.super_size;
args[2].j = (jlong)finfo.super.super_ext_size;
args[3].i = (jint)finfo.free.version;
args[4].j = (jlong)finfo.free.meta_size;
args[5].j = (jlong)finfo.free.tot_space;
args[6].j = (jint)finfo.sohm.version;
args[7].j = (jlong)finfo.sohm.hdr_size;
args[8].l = ihinfobuf;
CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5F_info2_t", "(IJJIJJIJLhdf/hdf5lib/structs/H5_ih_info_t;)V", args);
} /* end else */
return ret_obj;
} /* end Java_hdf_hdf5lib_H5_H5Fget_1info */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Freset_mdc_hit_rate_stats
* Signature: (J)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats
(JNIEnv *env, jclass cls, jlong file_id)
{
if (H5Freset_mdc_hit_rate_stats((hid_t)file_id) < 0)
h5libraryError(env);
} /* end Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fclear_elink_file_cache
* Signature: (J)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache
(JNIEnv *env, jclass cls, jlong file_id)
{
if (H5Fclear_elink_file_cache((hid_t)file_id) < 0)
h5libraryError(env);
} /* end Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fstart_swmr_write
* Signature: (J)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write
(JNIEnv *env, jclass cls, jlong file_id)
{
if (H5Fstart_swmr_write((hid_t)file_id) < 0)
h5libraryError(env);
} /* end Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fstart_mdc_logging
* Signature: (J)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging
(JNIEnv *env, jclass cls, jlong file_id)
{
if (H5Fstart_mdc_logging((hid_t)file_id) < 0)
h5libraryError(env);
} /* end Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fstop_mdc_logging
* Signature: (J)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging
(JNIEnv *env, jclass cls, jlong file_id)
{
if (H5Fstop_mdc_logging((hid_t)file_id) < 0)
h5libraryError(env);
} /* end Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Fget_mdc_logging_status
* Signature: (J[Z)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status
(JNIEnv *env, jclass cls, jlong file_id, jbooleanArray mdc_logging_status)
{
hbool_t is_enabled;
hbool_t is_currently_logging;
jboolean *mdc_logging_status_ptr;
jint size;
jboolean isCopy;
if (mdc_logging_status == NULL) {
h5nullArgument(env, "H5Fget_mdc_logging_status: mdc_logging_status is NULL");
} /* end if */
else {
size = (int)ENVPTR->GetArrayLength(ENVPAR mdc_logging_status);
if (size < 2) {
h5badArgument(env, "H5Fget_mdc_logging_status: length of mdc_logging_status < 2.");
} /* end if */
else {
if (H5Fget_mdc_logging_status((hid_t)file_id, &is_enabled, &is_currently_logging) < 0) {
h5libraryError(env);
} /* end if */
else {
mdc_logging_status_ptr = ENVPTR->GetBooleanArrayElements(ENVPAR mdc_logging_status, &isCopy);
mdc_logging_status_ptr[0] = (jboolean)is_enabled;
mdc_logging_status_ptr[1] = (jboolean)is_currently_logging;
ENVPTR->ReleaseBooleanArrayElements(ENVPAR mdc_logging_status, mdc_logging_status_ptr, 0);
} /* end else */
} /* end else */
} /* end else */
} /* end Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status */
#ifdef __cplusplus
} /* end extern "C" */
#endif /* __cplusplus */
|