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
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Purpose: Dataset callbacks for the native VOL connector
*
*/
/****************/
/* Module Setup */
/****************/
#define H5D_FRIEND /* Suppress error about including H5Dpkg */
/***********/
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5CXprivate.h" /* API Contexts */
#include "H5Dpkg.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* Files */
#include "H5Gprivate.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
#include "H5Pprivate.h" /* Property lists */
#include "H5Sprivate.h" /* Dataspaces */
#include "H5VLprivate.h" /* Virtual Object Layer */
#include "H5VLnative_private.h" /* Native VOL connector */
/****************/
/* Local Macros */
/****************/
/******************/
/* Local Typedefs */
/******************/
/********************/
/* Local Prototypes */
/********************/
/* Helper routines for read/write API calls */
static herr_t H5VL__native_dataset_io_setup(H5D_t *dset, hid_t dxpl_id, hid_t file_space_id,
hid_t mem_space_id, H5S_t **file_space, H5S_t **mem_space);
/*********************/
/* Package Variables */
/*********************/
/*****************************/
/* Library Private Variables */
/*****************************/
/*******************/
/* Local Variables */
/*******************/
/*-------------------------------------------------------------------------
* Function: H5VL__native_dataset_io_setup
*
* Purpose: Set up file and memory dataspaces for dataset I/O operation
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL__native_dataset_io_setup(H5D_t *dset, hid_t dxpl_id, hid_t file_space_id, hid_t mem_space_id,
H5S_t **file_space, H5S_t **mem_space)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(dset);
HDassert(file_space && NULL == *file_space);
HDassert(mem_space && NULL == *mem_space);
/* Set up file dataspace */
if (H5S_ALL == file_space_id)
/* Use dataspace for dataset */
*file_space = dset->shared->space;
else if (H5S_BLOCK == file_space_id)
HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "H5S_BLOCK is not allowed for file dataspace")
else if (H5S_PLIST == file_space_id) {
H5P_genplist_t *plist; /* Property list pointer */
H5S_t *space; /* Dataspace to hold selection */
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_DATASET, H5E_BADID, FAIL, "bad dataset transfer property list")
/* See if a dataset I/O selection is already set, and free it if it is */
if (H5P_peek(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error getting dataset I/O selection")
/* Use dataspace for dataset */
*file_space = dset->shared->space;
/* Copy, but share, selection from property list to dataset's dataspace */
if (H5S_SELECT_COPY(*file_space, space, TRUE) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dataset I/O selection")
} /* end else-if */
else {
/* Get the dataspace pointer */
if (NULL == (*file_space = (H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "file_space_id is not a dataspace ID")
} /* end else */
/* Get dataspace for memory buffer */
if (H5S_ALL == mem_space_id)
*mem_space = *file_space;
else if (H5S_BLOCK == mem_space_id) {
hsize_t nelmts; /* # of selected elements in file */
/* Get the # of elements selected */
nelmts = H5S_GET_SELECT_NPOINTS(*file_space);
/* Check for any elements */
if (nelmts > 0) {
/* Create a 1-D dataspace of the same # of elements */
if (NULL == (*mem_space = H5S_create_simple(1, &nelmts, NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "unable to create simple memory dataspace")
} /* end if */
else {
/* Create a NULL dataspace of the same # of elements */
if (NULL == (*mem_space = H5S_create(H5S_NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "unable to create NULL memory dataspace")
} /* end else */
} /* end if */
else if (H5S_PLIST == mem_space_id)
HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "H5S_PLIST is not allowed for memory dataspace")
else {
/* Get the dataspace pointer */
if (NULL == (*mem_space = (H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "mem_space_id is not a dataspace ID")
} /* end else */
/* Check for valid selections */
if (H5S_SELECT_VALID(*file_space) != TRUE)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
"selection + offset not within extent for file dataspace")
if (H5S_SELECT_VALID(*mem_space) != TRUE)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
"selection + offset not within extent for memory dataspace")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_dataset_io_setup() */
/*-------------------------------------------------------------------------
* Function: H5VL__native_dataset_create
*
* Purpose: Handles the dataset create callback
*
* Return: Success: dataset pointer
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
void *
H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id,
hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5G_loc_t loc; /* Object location to insert dataset into */
H5D_t *dset = NULL; /* New dataset's info */
const H5S_t *space; /* Dataspace for dataset */
void *ret_value;
FUNC_ENTER_PACKAGE
/* Check arguments */
if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
if (H5I_DATATYPE != H5I_get_type(type_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID")
if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID")
/* H5Dcreate_anon */
if (NULL == name) {
/* build and open the new dataset */
if (NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset")
} /* end if */
/* H5Dcreate2 */
else {
/* Create the new dataset & get its ID */
if (NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset")
} /* end else */
ret_value = (void *)dset;
done:
if (NULL == name) {
/* Release the dataset's object header, if it was created */
if (dset) {
H5O_loc_t *oloc; /* Object location for dataset */
/* Get the new dataset's object location */
if (NULL == (oloc = H5D_oloc(dset)))
HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset")
/* Decrement refcount on dataset's object header in memory */
if (H5O_dec_rc_by_loc(oloc) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL,
"unable to decrement refcount on newly created object")
} /* end if */
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_dataset_create() */
/*-------------------------------------------------------------------------
* Function: H5VL__native_dataset_open
*
* Purpose: Handles the dataset open callback
*
* Return: Success: dataset pointer
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
void *
H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id,
hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
H5D_t *dset = NULL;
H5G_loc_t loc; /* Object location of group */
void *ret_value = NULL;
FUNC_ENTER_PACKAGE
if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
/* Open the dataset */
if (NULL == (dset = H5D__open_name(&loc, name, dapl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset")
ret_value = (void *)dset;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_dataset_open() */
/*-------------------------------------------------------------------------
* Function: H5VL__native_dataset_read
*
* Purpose: Handles the dataset read callback
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id,
hid_t dxpl_id, void *buf, void H5_ATTR_UNUSED **req)
{
H5D_t *dset = (H5D_t *)obj;
H5S_t *mem_space = NULL;
H5S_t *file_space = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check arguments */
if (NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file")
/* Get file & memory dataspaces */
if (H5VL__native_dataset_io_setup(dset, dxpl_id, file_space_id, mem_space_id, &file_space, &mem_space) <
0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up file and memory dataspaces")
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
/* Read raw data */
if (H5D__read(dset, mem_type_id, mem_space, file_space, buf /*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
done:
/* Clean up */
if (H5S_BLOCK == mem_space_id && mem_space) {
if (H5S_close(mem_space) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL,
"unable to release temporary memory dataspace for H5S_BLOCK")
} /* end if */
else if (H5S_PLIST == file_space_id && file_space)
if (H5S_select_all(file_space, TRUE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL,
"unable to release file dataspace selection for H5S_PLIST")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_dataset_read() */
/*-------------------------------------------------------------------------
* Function: H5VL__native_dataset_write
*
* Purpose: Handles the dataset write callback
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id,
hid_t dxpl_id, const void *buf, void H5_ATTR_UNUSED **req)
{
H5D_t *dset = (H5D_t *)obj;
H5S_t *mem_space = NULL;
H5S_t *file_space = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* check arguments */
if (NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file")
/* Get file & memory dataspaces */
if (H5VL__native_dataset_io_setup(dset, dxpl_id, file_space_id, mem_space_id, &file_space, &mem_space) <
0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up file and memory dataspaces")
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
/* Write the data */
if (H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")
done:
/* Clean up */
if (H5S_BLOCK == mem_space_id && mem_space) {
if (H5S_close(mem_space) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL,
"unable to release temporary memory dataspace for H5S_BLOCK")
} /* end if */
else if (H5S_PLIST == file_space_id && file_space)
if (H5S_select_all(file_space, TRUE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL,
"unable to release file dataspace selection for H5S_PLIST")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_dataset_write() */
/*-------------------------------------------------------------------------
* Function: H5VL__native_dataset_get
*
* Purpose: Handles the dataset get callback
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL__native_dataset_get(void *obj, H5VL_dataset_get_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id,
void H5_ATTR_UNUSED **req)
{
H5D_t *dset = (H5D_t *)obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
switch (args->op_type) {
/* H5Dget_space */
case H5VL_DATASET_GET_SPACE: {
if ((args->args.get_space.space_id = H5D__get_space(dset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get space ID of dataset")
break;
}
/* H5Dget_space_status */
case H5VL_DATASET_GET_SPACE_STATUS: {
if (H5D__get_space_status(dset, args->args.get_space_status.status) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status")
break;
}
/* H5Dget_type */
case H5VL_DATASET_GET_TYPE: {
if ((args->args.get_type.type_id = H5D__get_type(dset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype ID of dataset")
break;
}
/* H5Dget_create_plist */
case H5VL_DATASET_GET_DCPL: {
if ((args->args.get_dcpl.dcpl_id = H5D_get_create_plist(dset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get creation property list for dataset")
break;
}
/* H5Dget_access_plist */
case H5VL_DATASET_GET_DAPL: {
if ((args->args.get_dapl.dapl_id = H5D_get_access_plist(dset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get access property list for dataset")
break;
}
/* H5Dget_storage_size */
case H5VL_DATASET_GET_STORAGE_SIZE: {
if (H5D__get_storage_size(dset, args->args.get_storage_size.storage_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset")
} /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_dataset_get() */
/*-------------------------------------------------------------------------
* Function: H5VL__native_dataset_specific
*
* Purpose: Handles the dataset specific callback
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_args_t *args, hid_t H5_ATTR_UNUSED dxpl_id,
void H5_ATTR_UNUSED **req)
{
H5D_t *dset = (H5D_t *)obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
switch (args->op_type) {
/* H5Dset_extent (H5Dextend - deprecated) */
case H5VL_DATASET_SET_EXTENT: {
if (H5D__set_extent(dset, args->args.set_extent.size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set extent of dataset")
break;
}
/* H5Dflush */
case H5VL_DATASET_FLUSH: {
if (H5D__flush(dset, args->args.flush.dset_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset")
break;
}
/* H5Drefresh */
case H5VL_DATASET_REFRESH: {
if (H5D__refresh(dset, args->args.refresh.dset_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset")
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation")
} /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_dataset_specific() */
/*-------------------------------------------------------------------------
* Function: H5VL__native_dataset_optional
*
* Purpose: Handles the dataset optional callback
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL__native_dataset_optional(void *obj, H5VL_optional_args_t *args, hid_t dxpl_id, void H5_ATTR_UNUSED **req)
{
H5D_t *dset = (H5D_t *)obj; /* Dataset */
H5VL_native_dataset_optional_args_t *opt_args = args->args; /* Pointer to native operation's arguments */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(dset);
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
switch (args->op_type) {
/* H5Dformat_convert */
case H5VL_NATIVE_DATASET_FORMAT_CONVERT: {
switch (dset->shared->layout.type) {
case H5D_CHUNKED:
/* Convert the chunk indexing type to version 1 B-tree if not */
if (dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE)
if (H5D__format_convert(dset) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL,
"unable to downgrade chunk indexing type for dataset")
break;
case H5D_CONTIGUOUS:
case H5D_COMPACT:
/* Downgrade the layout version to 3 if greater than 3 */
if (dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT)
if (H5D__format_convert(dset) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL,
"unable to downgrade layout version for dataset")
break;
case H5D_VIRTUAL:
/* Nothing to do even though layout is version 4 */
break;
case H5D_LAYOUT_ERROR:
case H5D_NLAYOUTS:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type")
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type")
} /* end switch */
break;
}
/* H5Dget_chunk_index_type */
case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: {
/* Make sure the dataset is chunked */
if (H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Get the chunk indexing type */
*opt_args->get_chunk_idx_type.idx_type = dset->shared->layout.u.chunk.idx_type;
break;
}
/* H5Dget_chunk_storage_size */
case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: {
H5VL_native_dataset_get_chunk_storage_size_t *gcss_args = &opt_args->get_chunk_storage_size;
/* Make sure the dataset is chunked */
if (H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Call private function */
if (H5D__get_chunk_storage_size(dset, gcss_args->offset, gcss_args->size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk")
break;
}
/* H5Dget_num_chunks */
case H5VL_NATIVE_DATASET_GET_NUM_CHUNKS: {
H5VL_native_dataset_get_num_chunks_t *gnc_args = &opt_args->get_num_chunks;
const H5S_t *space = NULL;
HDassert(dset->shared);
HDassert(dset->shared->space);
/* When default dataspace is given, use the dataset's dataspace */
if (gnc_args->space_id == H5S_ALL)
space = dset->shared->space;
else /* otherwise, use the given space ID */
if (NULL == (space = (const H5S_t *)H5I_object_verify(gnc_args->space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace ID")
/* Make sure the dataset is chunked */
if (H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Call private function */
if (H5D__get_num_chunks(dset, space, gnc_args->nchunks) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of chunks")
break;
}
/* H5Dget_chunk_info */
case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX: {
H5VL_native_dataset_get_chunk_info_by_idx_t *gcibi_args = &opt_args->get_chunk_info_by_idx;
const H5S_t *space;
HDassert(dset->shared);
HDassert(dset->shared->space);
/* When default dataspace is given, use the dataset's dataspace */
if (gcibi_args->space_id == H5S_ALL)
space = dset->shared->space;
else /* otherwise, use the given space ID */
if (NULL == (space = (const H5S_t *)H5I_object_verify(gcibi_args->space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace ID")
/* Make sure the dataset is chunked */
if (H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Call private function */
if (H5D__get_chunk_info(dset, space, gcibi_args->chk_index, gcibi_args->offset,
gcibi_args->filter_mask, gcibi_args->addr, gcibi_args->size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by index")
break;
}
/* H5Dget_chunk_info_by_coord */
case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD: {
H5VL_native_dataset_get_chunk_info_by_coord_t *gcibc_args = &opt_args->get_chunk_info_by_coord;
HDassert(dset->shared);
/* Make sure the dataset is chunked */
if (H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Call private function */
if (H5D__get_chunk_info_by_coord(dset, gcibc_args->offset, gcibc_args->filter_mask,
gcibc_args->addr, gcibc_args->size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by its logical coordinates")
break;
}
/* H5Dread_chunk */
case H5VL_NATIVE_DATASET_CHUNK_READ: {
H5VL_native_dataset_chunk_read_t *chunk_read_args = &opt_args->chunk_read;
hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */
/* Check arguments */
if (NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file")
if (H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Copy the user's offset array so we can be sure it's terminated properly.
* (we don't want to mess with the user's buffer).
*/
if (H5D__chunk_get_offset_copy(dset, chunk_read_args->offset, offset_copy) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "failure to copy offset array")
/* Read the raw chunk */
if (H5D__chunk_direct_read(dset, offset_copy, &chunk_read_args->filters, chunk_read_args->buf) <
0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data")
break;
}
/* H5Dwrite_chunk */
case H5VL_NATIVE_DATASET_CHUNK_WRITE: {
H5VL_native_dataset_chunk_write_t *chunk_write_args = &opt_args->chunk_write;
hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */
/* Check arguments */
if (NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file")
if (H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Copy the user's offset array so we can be sure it's terminated properly.
* (we don't want to mess with the user's buffer).
*/
if (H5D__chunk_get_offset_copy(dset, chunk_write_args->offset, offset_copy) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "failure to copy offset array")
/* Write chunk */
if (H5D__chunk_direct_write(dset, chunk_write_args->filters, offset_copy, chunk_write_args->size,
chunk_write_args->buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data")
break;
}
/* H5Dvlen_get_buf_size */
case H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE: {
H5VL_native_dataset_get_vlen_buf_size_t *gvbs_args = &opt_args->get_vlen_buf_size;
if (H5D__vlen_get_buf_size(dset, gvbs_args->type_id, gvbs_args->space_id, gvbs_args->size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of vlen buf needed")
break;
}
/* H5Dget_offset */
case H5VL_NATIVE_DATASET_GET_OFFSET: {
/* Get offset */
*opt_args->get_offset.offset = H5D__get_offset(dset);
break;
}
/* H5Dchunk_iter */
case H5VL_NATIVE_DATASET_CHUNK_ITER: {
/* Sanity check */
HDassert(dset->shared);
/* Make sure the dataset is chunked */
if (H5D_CHUNKED != dset->shared->layout.type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
/* Call private function */
if ((ret_value = H5D__chunk_iter(dset, opt_args->chunk_iter.op, opt_args->chunk_iter.op_data)) <
0)
HERROR(H5E_DATASET, H5E_BADITER, "chunk iteration failed");
break;
}
default:
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation")
} /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_dataset_optional() */
/*-------------------------------------------------------------------------
* Function: H5VL__native_dataset_close
*
* Purpose: Handles the dataset close callback
*
* Return: Success: SUCCEED
* Failure: FAIL (dataset will not be closed)
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL__native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
if (H5D_close((H5D_t *)dset) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL__native_dataset_close() */
|