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
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#define H5P_PACKAGE /*suppress error about including H5Ppkg */
/* Private header files */
#include "H5private.h" /* Generic Functions */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Ppkg.h" /* Property lists */
/* Pablo mask */
#define PABLO_MASK H5Pdxpl_mask
/* Interface initialization */
#define INTERFACE_INIT NULL
static int interface_initialize_g = 0;
/* Local datatypes */
/* Static function prototypes */
/*-------------------------------------------------------------------------
* Function: H5Pset_data_transform
*
* Purpose:
* Sets data transform expression.
*
*
* Return: Returns a non-negative value if successful; otherwise returns a negative value.
*
*
* Programmer: Leon Arber
* Monday, March 07, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t H5Pset_data_transform(hid_t plist_id, char* expression)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_data_transform, FAIL);
/* H5TRACE4("e","izxx",plist_id,expression); */
/* Check arguments */
if (expression == NULL)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "expression cannot be NULL");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Update property list */
if(H5P_set(plist, H5D_XFER_XFORM, &expression)<0)
HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "Error setting data transform expression");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pset_buffer
*
* Purpose: Given a dataset transfer property list, set the maximum size
* for the type conversion buffer and background buffer and
* optionally supply pointers to application-allocated buffers.
* If the buffer size is smaller than the entire amount of data
* being transfered between application and file, and a type
* conversion buffer or background buffer is required then
* strip mining will be used.
*
* If TCONV and/or BKG are null pointers then buffers will be
* allocated and freed during the data transfer.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Monday, March 16, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_buffer, FAIL);
H5TRACE4("e","izxx",plist_id,size,tconv,bkg);
/* Check arguments */
if (size<=0)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size must not be zero");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Update property list */
if(H5P_set(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size)<0)
HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "Can't set transfer buffer size");
if(H5P_set(plist, H5D_XFER_TCONV_BUF_NAME, &tconv)<0)
HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "Can't set transfer type conversion buffer");
if(H5P_set(plist, H5D_XFER_BKGR_BUF_NAME, &bkg)<0)
HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "Can't set background type conversion buffer");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_buffer
*
* Purpose: Reads values previously set with H5Pset_buffer().
*
* Return: Success: Buffer size.
*
* Failure: 0
*
* Programmer: Robb Matzke
* Monday, March 16, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
size_t
H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
size_t size; /* Type conversion buffer size */
size_t ret_value; /* Return value */
FUNC_ENTER_API(H5Pget_buffer, 0);
H5TRACE3("z","ixx",plist_id,tconv,bkg);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, 0, "can't find object for ID");
/* Return values */
if (tconv)
if(H5P_get(plist, H5D_XFER_TCONV_BUF_NAME, tconv)<0)
HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, 0, "Can't get transfer type conversion buffer");
if (bkg)
if(H5P_get(plist, H5D_XFER_BKGR_BUF_NAME, bkg)<0)
HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, 0, "Can't get background type conversion buffer");
/* Get the size */
if(H5P_get(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size)<0)
HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, 0, "Can't set transfer buffer size");
/* Set the return value */
ret_value=size;
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pset_preserve
*
* Purpose: When reading or writing compound data types and the
* destination is partially initialized and the read/write is
* intended to initialize the other members, one must set this
* property to TRUE. Otherwise the I/O pipeline treats the
* destination datapoints as completely uninitialized.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Tuesday, March 17, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_preserve(hid_t plist_id, hbool_t status)
{
H5T_bkg_t need_bkg; /* Value for background buffer type */
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_preserve, FAIL);
H5TRACE2("e","ib",plist_id,status);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Update property list */
need_bkg = status ? H5T_BKG_YES : H5T_BKG_NO;
if (H5P_set(plist,H5D_XFER_BKGR_BUF_TYPE_NAME,&need_bkg)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_preserve
*
* Purpose: The inverse of H5Pset_preserve()
*
* Return: Success: TRUE or FALSE
*
* Failure: Negative
*
* Programmer: Robb Matzke
* Tuesday, March 17, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
H5Pget_preserve(hid_t plist_id)
{
H5T_bkg_t need_bkg; /* Background value */
H5P_genplist_t *plist; /* Property list pointer */
int ret_value; /* return value */
FUNC_ENTER_API(H5Pget_preserve, FAIL);
H5TRACE1("Is","i",plist_id);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get value */
if (H5P_get(plist,H5D_XFER_BKGR_BUF_NAME,&need_bkg)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
/* Set return value */
ret_value= need_bkg ? TRUE : FALSE;
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pset_edc_check
*
* Purpose: Enable or disable error-detecting for a dataset reading
* process. This error-detecting algorithm is whichever
* user chooses earlier. This function cannot control
* writing process.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* Jan 3, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_edc_check, FAIL);
H5TRACE2("e","iZe",plist_id,check);
/* Check argument */
if (check != H5Z_ENABLE_EDC && check != H5Z_DISABLE_EDC)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid value");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Update property list */
if (H5P_set(plist,H5D_XFER_EDC_NAME,&check)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_edc_check
*
* Purpose: Enable or disable error-detecting for a dataset reading
* process. This error-detecting algorithm is whichever
* user chooses earlier. This function cannot control
* writing process.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* Jan 3, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5Z_EDC_t
H5Pget_edc_check(hid_t plist_id)
{
H5P_genplist_t *plist; /* Property list pointer */
H5Z_EDC_t ret_value; /* return value */
FUNC_ENTER_API(H5Pget_edc_check, H5Z_ERROR_EDC);
H5TRACE1("Ze","i",plist_id);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_ERROR_EDC, "can't find object for ID");
/* Update property list */
if (H5P_get(plist,H5D_XFER_EDC_NAME,&ret_value)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5Z_ERROR_EDC, "unable to set value");
/* check valid value */
if (ret_value != H5Z_ENABLE_EDC && ret_value != H5Z_DISABLE_EDC)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_ERROR_EDC, "not a valid value");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pset_filter_callback
*
* Purpose: Sets user's callback function for dataset transfer property
* list. This callback function defines what user wants to do
* if certain filter fails.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* Jan 14, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, void *op_data)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
H5Z_cb_t cb_struct;
FUNC_ENTER_API(H5Pset_filter_callback, FAIL);
H5TRACE3("e","ixx",plist_id,func,op_data);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Update property list */
cb_struct.func = func;
cb_struct.op_data = op_data;
if (H5P_set(plist,H5D_XFER_FILTER_CB_NAME,&cb_struct)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pset_type_conv_cb
*
* Purpose: Sets user's callback function for dataset transfer property
* list. This callback function defines what user wants to do
* if there's exception during datatype conversion.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* April 15, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t op, void *operate_data)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
H5T_conv_cb_t cb_struct;
FUNC_ENTER_API(H5Pset_type_conv_cb, FAIL);
H5TRACE3("e","ixx",plist_id,op,operate_data);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Update property list */
cb_struct.func = op;
cb_struct.user_data = operate_data;
if (H5P_set(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_type_conv_cb
*
* Purpose: Gets callback function for dataset transfer property
* list. This callback function defines what user wants to do
* if there's exception during datatype conversion.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* April 15, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t *op, void **operate_data)
{
H5P_genplist_t *plist; /* Property list pointer */
H5T_conv_cb_t cb_struct;
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pget_type_conv_cb, FAIL);
H5TRACE3("e","ixx",plist_id,op,operate_data);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get property */
if (H5P_get(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
/* Assign return value */
*op = cb_struct.func;
*operate_data = cb_struct.user_data;
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_btree_ratios
*
* Purpose: Queries B-tree split ratios. See H5Pset_btree_ratios().
*
* Return: Success: Non-negative with split ratios returned through
* the non-null arguments.
*
* Failure: Negative
*
* Programmer: Robb Matzke
* Monday, September 28, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_btree_ratios(hid_t plist_id, double *left/*out*/, double *middle/*out*/,
double *right/*out*/)
{
double btree_split_ratio[3]; /* B-tree node split ratios */
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pget_btree_ratios, FAIL);
H5TRACE4("e","ixxx",plist_id,left,middle,right);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get the split ratios */
if (H5P_get(plist,H5D_XFER_BTREE_SPLIT_RATIO_NAME,&btree_split_ratio)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
/* Get values */
if (left)
*left = btree_split_ratio[0];
if (middle)
*middle = btree_split_ratio[1];
if (right)
*right = btree_split_ratio[2];
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pset_btree_ratios
*
* Purpose: Sets B-tree split ratios for a dataset transfer property
* list. The split ratios determine what percent of children go
* in the first node when a node splits. The LEFT ratio is
* used when the splitting node is the left-most node at its
* level in the tree; the RIGHT ratio is when the splitting node
* is the right-most node at its level; and the MIDDLE ratio for
* all other cases. A node which is the only node at its level
* in the tree uses the RIGHT ratio when it splits. All ratios
* are real numbers between 0 and 1, inclusive.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Monday, September 28, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_btree_ratios(hid_t plist_id, double left, double middle,
double right)
{
double split_ratio[3]; /* B-tree node split ratios */
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_btree_ratios, FAIL);
H5TRACE4("e","iddd",plist_id,left,middle,right);
/* Check arguments */
if (left<0.0 || left>1.0 || middle<0.0 || middle>1.0 ||
right<0.0 || right>1.0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "split ratio must satisfy 0.0<=X<=1.0");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Set values */
split_ratio[0] = left;
split_ratio[1] = middle;
split_ratio[2] = right;
/* Set the split ratios */
if (H5P_set(plist,H5D_XFER_BTREE_SPLIT_RATIO_NAME,&split_ratio)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5P_set_vlen_mem_manager
*
* Purpose: Sets the memory allocate/free pair for VL datatypes. The
* allocation routine is called when data is read into a new
* array and the free routine is called when H5Dvlen_reclaim is
* called. The alloc_info and free_info are user parameters
* which are passed to the allocation and freeing functions
* respectively. To reset the allocate/free functions to the
* default setting of using the system's malloc/free functions,
* call this routine with alloc_func and free_func set to NULL.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Thursday, July 1, 1999
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func,
void *alloc_info, H5MM_free_t free_func, void *free_info)
{
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_NOAPI(H5P_set_vlen_mem_manager, FAIL);
assert(plist);
/* Update property list */
if (H5P_set(plist,H5D_XFER_VLEN_ALLOC_NAME,&alloc_func)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
if (H5P_set(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&alloc_info)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
if (H5P_set(plist,H5D_XFER_VLEN_FREE_NAME,&free_func)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
if (H5P_set(plist,H5D_XFER_VLEN_FREE_INFO_NAME,&free_info)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5P_set_vlen_mem_manager() */
/*-------------------------------------------------------------------------
* Function: H5Pset_vlen_mem_manager
*
* Purpose: Sets the memory allocate/free pair for VL datatypes. The
* allocation routine is called when data is read into a new
* array and the free routine is called when H5Dvlen_reclaim is
* called. The alloc_info and free_info are user parameters
* which are passed to the allocation and freeing functions
* respectively. To reset the allocate/free functions to the
* default setting of using the system's malloc/free functions,
* call this routine with alloc_func and free_func set to NULL.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Thursday, July 1, 1999
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func,
void *alloc_info, H5MM_free_t free_func, void *free_info)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_vlen_mem_manager, FAIL);
H5TRACE5("e","ixxxx",plist_id,alloc_func,alloc_info,free_func,free_info);
/* Check arguments */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
/* Update property list */
if (H5P_set_vlen_mem_manager(plist,alloc_func,alloc_info,free_func,free_info)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set values");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pset_vlen_mem_manager() */
/*-------------------------------------------------------------------------
* Function: H5Pget_vlen_mem_manager
*
* Purpose: The inverse of H5Pset_vlen_mem_manager()
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Thursday, July 1, 1999
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func/*out*/,
void **alloc_info/*out*/,
H5MM_free_t *free_func/*out*/,
void **free_info/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pget_vlen_mem_manager, FAIL);
H5TRACE5("e","ixxxx",plist_id,alloc_func,alloc_info,free_func,free_info);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
if(alloc_func!=NULL)
if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,alloc_func)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
if(alloc_info!=NULL)
if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,alloc_info)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
if(free_func!=NULL)
if (H5P_get(plist,H5D_XFER_VLEN_FREE_NAME,free_func)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
if(free_info!=NULL)
if (H5P_get(plist,H5D_XFER_VLEN_FREE_INFO_NAME,free_info)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pset_hyper_vector_size
*
* Purpose: Given a dataset transfer property list, set the number of
* "I/O vectors" (offset and length pairs) which are to be
* accumulated in memory before being issued to the lower levels
* of the library for reading or writing the actual data.
* Increasing the number should give better performance, but use
* more memory during hyperslab I/O. The vector size must be
* greater than 1.
*
* The default is to use 1024 vectors for I/O during hyperslab
* reading/writing.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Monday, July 9, 2001
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_hyper_vector_size(hid_t plist_id, size_t vector_size)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_hyper_vector_size, FAIL);
H5TRACE2("e","iz",plist_id,vector_size);
/* Check arguments */
if (vector_size<1)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "vector size too small");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Update property list */
if (H5P_set(plist,H5D_XFER_HYPER_VECTOR_SIZE_NAME,&vector_size)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pset_hyper_vector_size() */
/*-------------------------------------------------------------------------
* Function: H5Pget_hyper_vector_size
*
* Purpose: Reads values previously set with H5Pset_hyper_vector_size().
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Monday, July 9, 2001
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_hyper_vector_size(hid_t plist_id, size_t *vector_size/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pget_hyper_vector_size, FAIL);
H5TRACE2("e","ix",plist_id,vector_size);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Return values */
if (vector_size)
if (H5P_get(plist,H5D_XFER_HYPER_VECTOR_SIZE_NAME,vector_size)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pget_hyper_vector_size() */
|