1 Star 0 Fork 0

submodule/hdf5

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
H5Pdxpl.c 91.43 KB
一键复制 编辑 原始数据 按行查看 历史
Larry Knox 提交于 2022-11-02 05:02 +08:00 . Update copyright headers (#2184)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*-------------------------------------------------------------------------
*
* Created: H5Pdxpl.c
* March 16 1998
* Robb Matzke
*
* Purpose: Data transfer property list class routines
*
*-------------------------------------------------------------------------
*/
/****************/
/* Module Setup */
/****************/
#include "H5Pmodule.h" /* This source code file is part of the H5P module */
/***********/
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Cache */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FDprivate.h" /* File drivers */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Ppkg.h" /* Property lists */
/****************/
/* Local Macros */
/****************/
/* ======== Data transfer properties ======== */
/* Definitions for maximum temp buffer size property */
#define H5D_XFER_MAX_TEMP_BUF_SIZE sizeof(size_t)
#define H5D_XFER_MAX_TEMP_BUF_DEF H5D_TEMP_BUF_SIZE
#define H5D_XFER_MAX_TEMP_BUF_ENC H5P__encode_size_t
#define H5D_XFER_MAX_TEMP_BUF_DEC H5P__decode_size_t
/* Definitions for type conversion buffer property */
#define H5D_XFER_TCONV_BUF_SIZE sizeof(void *)
#define H5D_XFER_TCONV_BUF_DEF NULL
/* Definitions for background buffer property */
#define H5D_XFER_BKGR_BUF_SIZE sizeof(void *)
#define H5D_XFER_BKGR_BUF_DEF NULL
/* Definitions for background buffer type property */
#define H5D_XFER_BKGR_BUF_TYPE_SIZE sizeof(H5T_bkg_t)
#define H5D_XFER_BKGR_BUF_TYPE_DEF H5T_BKG_NO
#define H5D_XFER_BKGR_BUF_TYPE_ENC H5P__dxfr_bkgr_buf_type_enc
#define H5D_XFER_BKGR_BUF_TYPE_DEC H5P__dxfr_bkgr_buf_type_dec
/* Definitions for B-tree node splitting ratio property */
/* (These default B-tree node splitting ratios are also used for splitting
* group's B-trees as well as chunked dataset's B-trees - QAK)
*/
#define H5D_XFER_BTREE_SPLIT_RATIO_SIZE sizeof(double[3])
#define H5D_XFER_BTREE_SPLIT_RATIO_DEF \
{ \
0.1, 0.5, 0.9 \
}
#define H5D_XFER_BTREE_SPLIT_RATIO_ENC H5P__dxfr_btree_split_ratio_enc
#define H5D_XFER_BTREE_SPLIT_RATIO_DEC H5P__dxfr_btree_split_ratio_dec
/* Definitions for vlen allocation function property */
#define H5D_XFER_VLEN_ALLOC_SIZE sizeof(H5MM_allocate_t)
#define H5D_XFER_VLEN_ALLOC_DEF H5D_VLEN_ALLOC
/* Definitions for vlen allocation info property */
#define H5D_XFER_VLEN_ALLOC_INFO_SIZE sizeof(void *)
#define H5D_XFER_VLEN_ALLOC_INFO_DEF H5D_VLEN_ALLOC_INFO
/* Definitions for vlen free function property */
#define H5D_XFER_VLEN_FREE_SIZE sizeof(H5MM_free_t)
#define H5D_XFER_VLEN_FREE_DEF H5D_VLEN_FREE
/* Definitions for vlen free info property */
#define H5D_XFER_VLEN_FREE_INFO_SIZE sizeof(void *)
#define H5D_XFER_VLEN_FREE_INFO_DEF H5D_VLEN_FREE_INFO
/* Definitions for hyperslab vector size property */
/* (Be cautious about increasing the default size, there are arrays allocated
* on the stack which depend on it - QAK)
*/
#define H5D_XFER_HYPER_VECTOR_SIZE_SIZE sizeof(size_t)
#define H5D_XFER_HYPER_VECTOR_SIZE_DEF H5D_IO_VECTOR_SIZE
#define H5D_XFER_HYPER_VECTOR_SIZE_ENC H5P__encode_size_t
#define H5D_XFER_HYPER_VECTOR_SIZE_DEC H5P__decode_size_t
/* Parallel I/O properties */
/* Note: Some of these are registered with the DXPL class even when parallel
* is disabled, so that property list comparisons of encoded property
* lists (between parallel & non-parallel builds) work properly. -QAK
*/
/* Definitions for I/O transfer mode property */
#define H5D_XFER_IO_XFER_MODE_SIZE sizeof(H5FD_mpio_xfer_t)
#define H5D_XFER_IO_XFER_MODE_DEF H5FD_MPIO_INDEPENDENT
#define H5D_XFER_IO_XFER_MODE_ENC H5P__dxfr_io_xfer_mode_enc
#define H5D_XFER_IO_XFER_MODE_DEC H5P__dxfr_io_xfer_mode_dec
/* Definitions for optimization of MPI-IO transfer mode property */
#define H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE sizeof(H5FD_mpio_collective_opt_t)
#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEF H5FD_MPIO_COLLECTIVE_IO
#define H5D_XFER_MPIO_COLLECTIVE_OPT_ENC H5P__dxfr_mpio_collective_opt_enc
#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEC H5P__dxfr_mpio_collective_opt_dec
#define H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE sizeof(H5FD_mpio_chunk_opt_t)
#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF H5FD_MPIO_CHUNK_DEFAULT
#define H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC H5P__dxfr_mpio_chunk_opt_hard_enc
#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC H5P__dxfr_mpio_chunk_opt_hard_dec
#define H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE sizeof(unsigned)
#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF H5D_ONE_LINK_CHUNK_IO_THRESHOLD
#define H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC H5P__encode_unsigned
#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC H5P__decode_unsigned
#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE sizeof(unsigned)
#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF H5D_MULTI_CHUNK_IO_COL_THRESHOLD
#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC H5P__encode_unsigned
#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC H5P__decode_unsigned
/* Definitions for chunk opt mode property. */
#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE sizeof(H5D_mpio_actual_chunk_opt_mode_t)
#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF H5D_MPIO_NO_CHUNK_OPTIMIZATION
/* Definitions for chunk io mode property. */
#define H5D_MPIO_ACTUAL_IO_MODE_SIZE sizeof(H5D_mpio_actual_io_mode_t)
#define H5D_MPIO_ACTUAL_IO_MODE_DEF H5D_MPIO_NO_COLLECTIVE
/* Definitions for cause of broken collective io property */
#define H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE sizeof(uint32_t)
#define H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF H5D_MPIO_COLLECTIVE
/* Definitions for EDC property */
#define H5D_XFER_EDC_SIZE sizeof(H5Z_EDC_t)
#define H5D_XFER_EDC_DEF H5Z_ENABLE_EDC
#define H5D_XFER_EDC_ENC H5P__dxfr_edc_enc
#define H5D_XFER_EDC_DEC H5P__dxfr_edc_dec
/* Definitions for filter callback function property */
#define H5D_XFER_FILTER_CB_SIZE sizeof(H5Z_cb_t)
#define H5D_XFER_FILTER_CB_DEF \
{ \
NULL, NULL \
}
/* Definitions for type conversion callback function property */
#define H5D_XFER_CONV_CB_SIZE sizeof(H5T_conv_cb_t)
#define H5D_XFER_CONV_CB_DEF \
{ \
NULL, NULL \
}
/* Definitions for data transform property */
#define H5D_XFER_XFORM_SIZE sizeof(void *)
#define H5D_XFER_XFORM_DEF NULL
#define H5D_XFER_XFORM_SET H5P__dxfr_xform_set
#define H5D_XFER_XFORM_GET H5P__dxfr_xform_get
#define H5D_XFER_XFORM_ENC H5P__dxfr_xform_enc
#define H5D_XFER_XFORM_DEC H5P__dxfr_xform_dec
#define H5D_XFER_XFORM_DEL H5P__dxfr_xform_del
#define H5D_XFER_XFORM_COPY H5P__dxfr_xform_copy
#define H5D_XFER_XFORM_CMP H5P__dxfr_xform_cmp
#define H5D_XFER_XFORM_CLOSE H5P__dxfr_xform_close
/* Definitions for dataset I/O selection property */
#define H5D_XFER_DSET_IO_SEL_SIZE sizeof(H5S_t *)
#define H5D_XFER_DSET_IO_SEL_DEF NULL
#define H5D_XFER_DSET_IO_SEL_COPY H5P__dxfr_dset_io_hyp_sel_copy
#define H5D_XFER_DSET_IO_SEL_CMP H5P__dxfr_dset_io_hyp_sel_cmp
#define H5D_XFER_DSET_IO_SEL_CLOSE H5P__dxfr_dset_io_hyp_sel_close
#ifdef QAK
#define H5D_XFER_DSET_IO_SEL_ENC H5P__dxfr_edc_enc
#define H5D_XFER_DSET_IO_SEL_DEC H5P__dxfr_edc_dec
#endif /* QAK */
/******************/
/* Local Typedefs */
/******************/
/********************/
/* Package Typedefs */
/********************/
/********************/
/* Local Prototypes */
/********************/
/* Property class callbacks */
static herr_t H5P__dxfr_reg_prop(H5P_genclass_t *pclass);
/* Property list callbacks */
static herr_t H5P__dxfr_bkgr_buf_type_enc(const void *value, void **pp, size_t *size);
static herr_t H5P__dxfr_bkgr_buf_type_dec(const void **pp, void *value);
static herr_t H5P__dxfr_btree_split_ratio_enc(const void *value, void **pp, size_t *size);
static herr_t H5P__dxfr_btree_split_ratio_dec(const void **pp, void *value);
static herr_t H5P__dxfr_io_xfer_mode_enc(const void *value, void **pp, size_t *size);
static herr_t H5P__dxfr_io_xfer_mode_dec(const void **pp, void *value);
static herr_t H5P__dxfr_mpio_collective_opt_enc(const void *value, void **pp, size_t *size);
static herr_t H5P__dxfr_mpio_collective_opt_dec(const void **pp, void *value);
static herr_t H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **pp, size_t *size);
static herr_t H5P__dxfr_mpio_chunk_opt_hard_dec(const void **pp, void *value);
static herr_t H5P__dxfr_edc_enc(const void *value, void **pp, size_t *size);
static herr_t H5P__dxfr_edc_dec(const void **pp, void *value);
static herr_t H5P__dxfr_xform_set(hid_t prop_id, const char *name, size_t size, void *value);
static herr_t H5P__dxfr_xform_get(hid_t prop_id, const char *name, size_t size, void *value);
static herr_t H5P__dxfr_xform_enc(const void *value, void **pp, size_t *size);
static herr_t H5P__dxfr_xform_dec(const void **pp, void *value);
static herr_t H5P__dxfr_xform_del(hid_t prop_id, const char *name, size_t size, void *value);
static herr_t H5P__dxfr_xform_copy(const char *name, size_t size, void *value);
static int H5P__dxfr_xform_cmp(const void *value1, const void *value2, size_t size);
static herr_t H5P__dxfr_xform_close(const char *name, size_t size, void *value);
static herr_t H5P__dxfr_dset_io_hyp_sel_copy(const char *name, size_t size, void *value);
static int H5P__dxfr_dset_io_hyp_sel_cmp(const void *value1, const void *value2, size_t size);
static herr_t H5P__dxfr_dset_io_hyp_sel_close(const char *name, size_t size, void *value);
/*********************/
/* Package Variables */
/*********************/
/* Data transfer property list class library initialization object */
const H5P_libclass_t H5P_CLS_DXFR[1] = {{
"data transfer", /* Class name for debugging */
H5P_TYPE_DATASET_XFER, /* Class type */
&H5P_CLS_ROOT_g, /* Parent class */
&H5P_CLS_DATASET_XFER_g, /* Pointer to class */
&H5P_CLS_DATASET_XFER_ID_g, /* Pointer to class ID */
&H5P_LST_DATASET_XFER_ID_g, /* Pointer to default property list ID */
H5P__dxfr_reg_prop, /* Default property registration routine */
NULL, /* Class creation callback */
NULL, /* Class creation callback info */
NULL, /* Class copy callback */
NULL, /* Class copy callback info */
NULL, /* Class close callback */
NULL /* Class close callback info */
}};
/*****************************/
/* Library Private Variables */
/*****************************/
/***************************/
/* Local Private Variables */
/***************************/
/* Property value defaults */
static const size_t H5D_def_max_temp_buf_g =
H5D_XFER_MAX_TEMP_BUF_DEF; /* Default value for maximum temp buffer size */
static const void *H5D_def_tconv_buf_g =
H5D_XFER_TCONV_BUF_DEF; /* Default value for type conversion buffer */
static const void *H5D_def_bkgr_buf_g = H5D_XFER_BKGR_BUF_DEF; /* Default value for background buffer */
static const H5T_bkg_t H5D_def_bkgr_buf_type_g = H5D_XFER_BKGR_BUF_TYPE_DEF;
static const double H5D_def_btree_split_ratio_g[3] =
H5D_XFER_BTREE_SPLIT_RATIO_DEF; /* Default value for B-tree node split ratios */
static const H5MM_allocate_t H5D_def_vlen_alloc_g =
H5D_XFER_VLEN_ALLOC_DEF; /* Default value for vlen allocation function */
static const void *H5D_def_vlen_alloc_info_g =
H5D_XFER_VLEN_ALLOC_INFO_DEF; /* Default value for vlen allocation information */
static const H5MM_free_t H5D_def_vlen_free_g =
H5D_XFER_VLEN_FREE_DEF; /* Default value for vlen free function */
static const void *H5D_def_vlen_free_info_g =
H5D_XFER_VLEN_FREE_INFO_DEF; /* Default value for vlen free information */
static const size_t H5D_def_hyp_vec_size_g =
H5D_XFER_HYPER_VECTOR_SIZE_DEF; /* Default value for vector size */
static const H5FD_mpio_xfer_t H5D_def_io_xfer_mode_g =
H5D_XFER_IO_XFER_MODE_DEF; /* Default value for I/O transfer mode */
static const H5FD_mpio_chunk_opt_t H5D_def_mpio_chunk_opt_mode_g = H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF;
static const H5FD_mpio_collective_opt_t H5D_def_mpio_collective_opt_mode_g = H5D_XFER_MPIO_COLLECTIVE_OPT_DEF;
static const unsigned H5D_def_mpio_chunk_opt_num_g = H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF;
static const unsigned H5D_def_mpio_chunk_opt_ratio_g = H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF;
static const H5D_mpio_actual_chunk_opt_mode_t H5D_def_mpio_actual_chunk_opt_mode_g =
H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF;
static const H5D_mpio_actual_io_mode_t H5D_def_mpio_actual_io_mode_g = H5D_MPIO_ACTUAL_IO_MODE_DEF;
static const H5D_mpio_no_collective_cause_t H5D_def_mpio_no_collective_cause_g =
H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF;
static const H5Z_EDC_t H5D_def_enable_edc_g = H5D_XFER_EDC_DEF; /* Default value for EDC property */
static const H5Z_cb_t H5D_def_filter_cb_g = H5D_XFER_FILTER_CB_DEF; /* Default value for filter callback */
static const H5T_conv_cb_t H5D_def_conv_cb_g =
H5D_XFER_CONV_CB_DEF; /* Default value for datatype conversion callback */
static const void *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */
static const H5S_t *H5D_def_dset_io_sel_g =
H5D_XFER_DSET_IO_SEL_DEF; /* Default value for dataset I/O selection */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_reg_prop
*
* Purpose: Register the data transfer property list class's properties
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* October 31, 2006
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_reg_prop(H5P_genclass_t *pclass)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Register the max. temp buffer size property */
if (H5P__register_real(pclass, H5D_XFER_MAX_TEMP_BUF_NAME, H5D_XFER_MAX_TEMP_BUF_SIZE,
&H5D_def_max_temp_buf_g, NULL, NULL, NULL, H5D_XFER_MAX_TEMP_BUF_ENC,
H5D_XFER_MAX_TEMP_BUF_DEC, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the type conversion buffer property */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_XFER_TCONV_BUF_NAME, H5D_XFER_TCONV_BUF_SIZE, &H5D_def_tconv_buf_g,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the background buffer property */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_XFER_BKGR_BUF_NAME, H5D_XFER_BKGR_BUF_SIZE, &H5D_def_bkgr_buf_g, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the background buffer type property */
if (H5P__register_real(pclass, H5D_XFER_BKGR_BUF_TYPE_NAME, H5D_XFER_BKGR_BUF_TYPE_SIZE,
&H5D_def_bkgr_buf_type_g, NULL, NULL, NULL, H5D_XFER_BKGR_BUF_TYPE_ENC,
H5D_XFER_BKGR_BUF_TYPE_DEC, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the B-Tree node splitting ratios property */
if (H5P__register_real(pclass, H5D_XFER_BTREE_SPLIT_RATIO_NAME, H5D_XFER_BTREE_SPLIT_RATIO_SIZE,
H5D_def_btree_split_ratio_g, NULL, NULL, NULL, H5D_XFER_BTREE_SPLIT_RATIO_ENC,
H5D_XFER_BTREE_SPLIT_RATIO_DEC, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the vlen allocation function property */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_NAME, H5D_XFER_VLEN_ALLOC_SIZE, &H5D_def_vlen_alloc_g,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the vlen allocation information property */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_INFO_NAME, H5D_XFER_VLEN_ALLOC_INFO_SIZE,
&H5D_def_vlen_alloc_info_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the vlen free function property */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_XFER_VLEN_FREE_NAME, H5D_XFER_VLEN_FREE_SIZE, &H5D_def_vlen_free_g,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the vlen free information property */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_XFER_VLEN_FREE_INFO_NAME, H5D_XFER_VLEN_FREE_INFO_SIZE,
&H5D_def_vlen_free_info_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the vector size property */
if (H5P__register_real(pclass, H5D_XFER_HYPER_VECTOR_SIZE_NAME, H5D_XFER_HYPER_VECTOR_SIZE_SIZE,
&H5D_def_hyp_vec_size_g, NULL, NULL, NULL, H5D_XFER_HYPER_VECTOR_SIZE_ENC,
H5D_XFER_HYPER_VECTOR_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the I/O transfer mode properties */
if (H5P__register_real(pclass, H5D_XFER_IO_XFER_MODE_NAME, H5D_XFER_IO_XFER_MODE_SIZE,
&H5D_def_io_xfer_mode_g, NULL, NULL, NULL, H5D_XFER_IO_XFER_MODE_ENC,
H5D_XFER_IO_XFER_MODE_DEC, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
if (H5P__register_real(pclass, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE,
&H5D_def_mpio_collective_opt_mode_g, NULL, NULL, NULL,
H5D_XFER_MPIO_COLLECTIVE_OPT_ENC, H5D_XFER_MPIO_COLLECTIVE_OPT_DEC, NULL, NULL,
NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE,
&H5D_def_mpio_chunk_opt_mode_g, NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC,
H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE,
&H5D_def_mpio_chunk_opt_num_g, NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC,
H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE,
&H5D_def_mpio_chunk_opt_ratio_g, NULL, NULL, NULL,
H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC, H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC, NULL, NULL,
NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the chunk optimization mode property. */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE,
&H5D_def_mpio_actual_chunk_opt_mode_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the actual I/O mode property. */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_MPIO_ACTUAL_IO_MODE_NAME, H5D_MPIO_ACTUAL_IO_MODE_SIZE,
&H5D_def_mpio_actual_io_mode_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the local cause of broken collective I/O */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE,
&H5D_def_mpio_no_collective_cause_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the global cause of broken collective I/O */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME,
H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE, &H5D_def_mpio_no_collective_cause_g, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the EDC property */
if (H5P__register_real(pclass, H5D_XFER_EDC_NAME, H5D_XFER_EDC_SIZE, &H5D_def_enable_edc_g, NULL, NULL,
NULL, H5D_XFER_EDC_ENC, H5D_XFER_EDC_DEC, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the filter callback property */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_XFER_FILTER_CB_NAME, H5D_XFER_FILTER_CB_SIZE, &H5D_def_filter_cb_g,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the type conversion callback property */
/* (Note: this property should not have an encode/decode callback -QAK) */
if (H5P__register_real(pclass, H5D_XFER_CONV_CB_NAME, H5D_XFER_CONV_CB_SIZE, &H5D_def_conv_cb_g, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the data transform property */
if (H5P__register_real(pclass, H5D_XFER_XFORM_NAME, H5D_XFER_XFORM_SIZE, &H5D_def_xfer_xform_g, NULL,
H5D_XFER_XFORM_SET, H5D_XFER_XFORM_GET, H5D_XFER_XFORM_ENC, H5D_XFER_XFORM_DEC,
H5D_XFER_XFORM_DEL, H5D_XFER_XFORM_COPY, H5D_XFER_XFORM_CMP,
H5D_XFER_XFORM_CLOSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the dataset I/O selection property */
if (H5P__register_real(pclass, H5D_XFER_DSET_IO_SEL_NAME, H5D_XFER_DSET_IO_SEL_SIZE,
&H5D_def_dset_io_sel_g, NULL, NULL, NULL, NULL, NULL, NULL,
H5D_XFER_DSET_IO_SEL_COPY, H5D_XFER_DSET_IO_SEL_CMP,
H5D_XFER_DSET_IO_SEL_CLOSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_reg_prop() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_bkgr_buf_type_enc
*
* Purpose: Callback routine which is called whenever the background
* buffer type property in the dataset transfer property list
* is encoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_bkgr_buf_type_enc(const void *value, void **_pp, size_t *size)
{
const H5T_bkg_t *bkgr_buf_type = (const H5T_bkg_t *)value; /* Create local alias for values */
uint8_t **pp = (uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(bkgr_buf_type);
HDassert(size);
if (NULL != *pp)
/* Encode background buffer type */
*(*pp)++ = (uint8_t)*bkgr_buf_type;
/* Size of background buffer type */
(*size)++;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_bkgr_buf_type_enc() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_bkgr_buf_type_dec
*
* Purpose: Callback routine which is called whenever the background
* buffer type property in the dataset transfer property list
* is decoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_bkgr_buf_type_dec(const void **_pp, void *_value)
{
H5T_bkg_t *bkgr_buf_type = (H5T_bkg_t *)_value; /* Background buffer type */
const uint8_t **pp = (const uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity checks */
HDassert(pp);
HDassert(*pp);
HDassert(bkgr_buf_type);
/* Decode background buffer type */
*bkgr_buf_type = (H5T_bkg_t) * (*pp)++;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_bkgr_buf_type_dec() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_btree_split_ratio_enc
*
* Purpose: Callback routine which is called whenever the B-tree split
* ratio property in the dataset transfer property list
* is encoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size)
{
const double *btree_split_ratio = (const double *)value; /* Create local alias for values */
uint8_t **pp = (uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(btree_split_ratio);
HDassert(size);
if (NULL != *pp) {
/* Encode the size of a double*/
*(*pp)++ = (uint8_t)sizeof(double);
/* Encode the left split value */
H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio)
btree_split_ratio++;
/* Encode the middle split value */
H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio)
btree_split_ratio++;
/* Encode the right split value */
H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio)
} /* end if */
/* Size of B-tree split ratio values */
*size += 1 + (3 * sizeof(double));
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_btree_split_ratio_enc() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_btree_split_ratio_dec
*
* Purpose: Callback routine which is called whenever the B-tree split
* ratio property in the dataset transfer property list
* is decoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_btree_split_ratio_dec(const void **_pp, void *_value)
{
double *btree_split_ratio = (double *)_value; /* B-tree split ratio */
unsigned enc_size; /* Size of encoded property */
const uint8_t **pp = (const uint8_t **)_pp;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(pp);
HDassert(*pp);
HDassert(btree_split_ratio);
/* Decode the size */
enc_size = *(*pp)++;
if (enc_size != sizeof(double))
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded")
/* Decode the left, middle & left B-tree split ratios */
H5_DECODE_DOUBLE(*pp, btree_split_ratio[0])
H5_DECODE_DOUBLE(*pp, btree_split_ratio[1])
H5_DECODE_DOUBLE(*pp, btree_split_ratio[2])
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_btree_split_ratio_dec() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_xform_set
*
* Purpose: Copies a data transform property when it's set for a property list
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, Sept 1, 2015
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_xform_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
void *value)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
HDassert(value);
/* Make copy of data transform */
if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_xform_set() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_xform_get
*
* Purpose: Copies a data transform property when it's retrieved for a property list
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, Sept 1, 2015
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_xform_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
void *value)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
HDassert(value);
/* Make copy of data transform */
if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_xform_get() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_xform_enc
*
* Purpose: Callback routine which is called whenever the data transform
* property in the dataset transfer property list
* is encoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Monday, August 6, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size)
{
const H5Z_data_xform_t *data_xform_prop =
*(const H5Z_data_xform_t *const *)value; /* Create local alias for values */
const char *pexp = NULL; /* Pointer to transform expression */
size_t len = 0; /* Length of transform expression */
uint8_t **pp = (uint8_t **)_pp;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
HDassert(size);
/* Check for data transform set */
if (NULL != data_xform_prop) {
/* Get the transform expression */
if (NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression")
/* Get the transform string expression size */
len = HDstrlen(pexp) + 1;
} /* end if */
if (NULL != *pp) {
uint64_t enc_value;
unsigned enc_size;
/* encode the length of the prefix */
enc_value = (uint64_t)len;
enc_size = H5VM_limit_enc_size(enc_value);
HDassert(enc_size < 256);
*(*pp)++ = (uint8_t)enc_size;
UINT64ENCODE_VAR(*pp, enc_value, enc_size);
if (NULL != data_xform_prop) {
/* Sanity check */
HDassert(pexp);
/* Copy the expression into the buffer */
H5MM_memcpy(*pp, (const uint8_t *)pexp, len);
*pp += len;
*pp[0] = '\0';
} /* end if */
} /* end if */
/* Size of encoded data transform */
*size += (1 + H5VM_limit_enc_size((uint64_t)len));
if (NULL != pexp)
*size += len;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_xform_enc() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_xform_dec
*
* Purpose: Callback routine which is called whenever the data transform
* property in the dataset transfer property list
* is decoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Monday, August 6, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_xform_dec(const void **_pp, void *_value)
{
H5Z_data_xform_t **data_xform_prop = (H5Z_data_xform_t **)_value; /* New data xform property */
size_t len; /* Length of encoded string */
const uint8_t **pp = (const uint8_t **)_pp;
unsigned enc_size;
uint64_t enc_value;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(pp);
HDassert(*pp);
HDassert(data_xform_prop);
HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
/* Decode the length of xform expression */
enc_size = *(*pp)++;
HDassert(enc_size < 256);
UINT64DECODE_VAR(*pp, enc_value, enc_size);
len = (size_t)enc_value;
if (0 != len) {
if (NULL == (*data_xform_prop = H5Z_xform_create((const char *)*pp)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create data transform info")
*pp += len;
} /* end if */
else
*data_xform_prop = H5D_XFER_XFORM_DEF;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_xform_dec() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_xform_del
*
* Purpose: Frees memory allocated by H5P_dxfr_xform_set
*
* Return: Success: SUCCEED, Failure: FAIL
*
* Programmer: Leon Arber
*
* Date: April 9, 2004
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_xform_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
void *value)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
HDassert(value);
if (H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing the parse tree")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_xform_del() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_xform_copy
*
* Purpose: Creates a copy of the user's data transform string and its
* associated parse tree.
*
* Return: Success: SUCCEED, Failure: FAIL
*
* Programmer: Leon Arber
*
* Date: April 9, 2004
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_xform_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
HDassert(value);
/* Make copy of data transform */
if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_xform_copy() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_xform_cmp
*
* Purpose: Compare two data transforms.
*
* Return: positive if VALUE1 is greater than VALUE2, negative if VALUE2 is
* greater than VALUE1 and zero if VALUE1 and VALUE2 are equal.
*
* Programmer: Quincey Koziol
* Wednesday, August 15, 2012
*
*-------------------------------------------------------------------------
*/
static int
H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNUSED size)
{
const H5Z_data_xform_t *const *xform1 =
(const H5Z_data_xform_t *const *)_xform1; /* Create local aliases for values */
const H5Z_data_xform_t *const *xform2 =
(const H5Z_data_xform_t *const *)_xform2; /* Create local aliases for values */
const char *pexp1, *pexp2; /* Pointers to transform expressions */
herr_t ret_value = 0; /* Return value */
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(xform1);
HDassert(xform2);
HDassert(size == sizeof(H5Z_data_xform_t *));
/* Check for a property being set */
if (*xform1 == NULL && *xform2 != NULL)
HGOTO_DONE(-1);
if (*xform1 != NULL && *xform2 == NULL)
HGOTO_DONE(1);
if (*xform1) {
HDassert(*xform2);
/* Get the transform expressions */
pexp1 = H5Z_xform_extract_xform_str(*xform1);
pexp2 = H5Z_xform_extract_xform_str(*xform2);
/* Check for property expressions */
if (pexp1 == NULL && pexp2 != NULL)
HGOTO_DONE(-1);
if (pexp1 != NULL && pexp2 == NULL)
HGOTO_DONE(1);
if (pexp1) {
HDassert(pexp2);
ret_value = HDstrcmp(pexp1, pexp2);
} /* end if */
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_xform_cmp() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_xform_close
*
* Purpose: Frees memory allocated by H5P_dxfr_xform_set
*
* Return: Success: SUCCEED, Failure: FAIL
*
* Programmer: Leon Arber
*
* Date: April 9, 2004
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_xform_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
HDassert(value);
if (H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing the parse tree")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_xform_close() */
/*-------------------------------------------------------------------------
* Function: H5Pset_data_transform
*
* Purpose: Sets data transform expression.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Leon Arber
* Monday, March 07, 2004
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_data_transform(hid_t plist_id, const char *expression)
{
H5P_genplist_t *plist; /* Property list pointer */
H5Z_data_xform_t *data_xform_prop = NULL; /* New data xform property */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*s", 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_ID, H5E_BADID, FAIL, "can't find object for ID")
/* See if a data transform is already set, and free it if it is */
if (H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data transform expression")
/* Destroy previous data transform property */
if (H5Z_xform_destroy(data_xform_prop) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release data transform expression")
/* Create data transform info from expression */
if (NULL == (data_xform_prop = H5Z_xform_create(expression)))
HGOTO_ERROR(H5E_PLIST, H5E_NOSPACE, FAIL, "unable to create data transform info")
/* Update property list (takes ownership of transform) */
if (H5P_poke(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Error setting data transform expression")
done:
if (ret_value < 0)
if (data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0)
HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release data transform expression")
FUNC_LEAVE_API(ret_value)
} /* end H5Pset_data_transform() */
/*-------------------------------------------------------------------------
* Function: H5Pget_data_transform
*
* Purpose: Gets data transform expression.
*
* Return: Non-negative on success/Negative on failure
*
* Comments:
* If `expression' is non-NULL then write up to `size' bytes into that
* buffer and always return the length of the transform name.
* Otherwise `size' is ignored and the function does not store the expression,
* just returning the number of characters required to store the expression.
* If an error occurs then the buffer pointed to by `expression' (NULL or non-NULL)
* is unchanged and the function returns a negative value.
* If a zero is returned for the name's length, then there is no name
* associated with the ID.
*
* Programmer: Leon Arber
* August 27, 2004
*
*-------------------------------------------------------------------------
*/
ssize_t
H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size)
{
H5P_genplist_t *plist; /* Property list pointer */
H5Z_data_xform_t *data_xform_prop = NULL; /* New data xform property */
size_t len;
const char *pexp;
ssize_t ret_value; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("Zs", "ixz", plist_id, expression, size);
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID")
if (H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data transform expression")
if (NULL == data_xform_prop)
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "data transform has not been set")
/* Get the data transform string */
if (NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression")
/* Copy into application buffer */
len = HDstrlen(pexp);
if (expression) {
HDstrncpy(expression, pexp, size);
if (len >= size)
expression[size - 1] = '\0';
} /* end if */
ret_value = (ssize_t)len;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_data_transform() */
/*-------------------------------------------------------------------------
* 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 transferred 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
*
*-------------------------------------------------------------------------
*/
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(FAIL)
H5TRACE4("e", "iz*x*x", 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_ID, H5E_BADID, 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)
} /* end H5Pset_buffer() */
/*-------------------------------------------------------------------------
* Function: H5Pget_buffer
*
* Purpose: Reads values previously set with H5Pset_buffer().
*
* Return: Success: Buffer size.
*
* Failure: 0
*
* Programmer: Robb Matzke
* Monday, March 16, 1998
*
*-------------------------------------------------------------------------
*/
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(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_ID, H5E_BADID, 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)
} /* end H5Pget_buffer() */
/*-------------------------------------------------------------------------
* 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
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_preserve(hid_t plist_id, hbool_t status)
{
H5P_genplist_t *plist; /* Property list pointer */
H5T_bkg_t need_bkg; /* Value for background buffer type */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(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_ID, H5E_BADID, 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)
} /* end H5Pset_preserve() */
/*-------------------------------------------------------------------------
* Function: H5Pget_preserve
*
* Purpose: The inverse of H5Pset_preserve()
*
* Return: Success: TRUE or FALSE
*
* Failure: Negative
*
* Programmer: Robb Matzke
* Tuesday, March 17, 1998
*
*-------------------------------------------------------------------------
*/
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(FAIL)
H5TRACE1("Is", "i", plist_id);
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID")
/* Get value */
if (H5P_get(plist, H5D_XFER_BKGR_BUF_TYPE_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)
} /* end H5Pget_preserve() */
/*-------------------------------------------------------------------------
* 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
*
*-------------------------------------------------------------------------
*/
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(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_ID, H5E_BADID, 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)
} /* end H5Pset_edc_check() */
/*-------------------------------------------------------------------------
* 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
*
*-------------------------------------------------------------------------
*/
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(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_ID, H5E_BADID, 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")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_edc_check() */
/*-------------------------------------------------------------------------
* 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
*
*-------------------------------------------------------------------------
*/
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(FAIL)
H5TRACE3("e", "iZF*x", plist_id, func, op_data);
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ID, H5E_BADID, 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
*
*-------------------------------------------------------------------------
*/
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(FAIL)
H5TRACE3("e", "iTE*x", plist_id, op, operate_data);
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ID, H5E_BADID, 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
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t *op /*out*/, void **operate_data /*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
H5T_conv_cb_t cb_struct;
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(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_ID, H5E_BADID, 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
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_btree_ratios(hid_t plist_id, double *left /*out*/, double *middle /*out*/, double *right /*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
double btree_split_ratio[3]; /* B-tree node split ratios */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(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_ID, H5E_BADID, 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)
} /* end H5Pget_btree_ratios() */
/*-------------------------------------------------------------------------
* 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
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_btree_ratios(hid_t plist_id, double left, double middle, double right)
{
H5P_genplist_t *plist; /* Property list pointer */
double split_ratio[3]; /* B-tree node split ratios */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(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_ID, H5E_BADID, 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)
} /* end H5Pset_btree_ratios() */
/*-------------------------------------------------------------------------
* 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 H5Treclaim 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
*
*-------------------------------------------------------------------------
*/
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(FAIL)
HDassert(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 H5Treclaim 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
*
*-------------------------------------------------------------------------
*/
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(FAIL)
H5TRACE5("e", "iMa*xMf*x", 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
*
*-------------------------------------------------------------------------
*/
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(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_ID, H5E_BADID, FAIL, "can't find object for ID")
if (alloc_func)
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)
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)
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)
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)
} /* end H5Pget_vlen_mem_manager() */
/*-------------------------------------------------------------------------
* 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
*
*-------------------------------------------------------------------------
*/
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(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_ID, H5E_BADID, 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
*
*-------------------------------------------------------------------------
*/
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(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_ID, H5E_BADID, 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() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_io_xfer_mode_enc
*
* Purpose: Callback routine which is called whenever the I/O transfer
* mode property in the dataset transfer property list
* is encoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_io_xfer_mode_enc(const void *value, void **_pp, size_t *size)
{
const H5FD_mpio_xfer_t *xfer_mode = (const H5FD_mpio_xfer_t *)value; /* Create local alias for values */
uint8_t **pp = (uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(xfer_mode);
HDassert(size);
if (NULL != *pp)
/* Encode I/O transfer mode */
*(*pp)++ = (uint8_t)*xfer_mode;
/* Size of I/O transfer mode */
(*size)++;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_io_xfer_mode_enc() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_io_xfer_mode_dec
*
* Purpose: Callback routine which is called whenever the I/O transfer
* mode property in the dataset transfer property list
* is decoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_io_xfer_mode_dec(const void **_pp, void *_value)
{
H5FD_mpio_xfer_t *xfer_mode = (H5FD_mpio_xfer_t *)_value; /* I/O transfer mode */
const uint8_t **pp = (const uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity checks */
HDassert(pp);
HDassert(*pp);
HDassert(xfer_mode);
/* Decode I/O transfer mode */
*xfer_mode = (H5FD_mpio_xfer_t) * (*pp)++;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_io_xfer_mode_dec() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_mpio_collective_opt_enc
*
* Purpose: Callback routine which is called whenever the MPI-I/O
* collective optimization property in the dataset transfer
* property list is encoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_mpio_collective_opt_enc(const void *value, void **_pp, size_t *size)
{
const H5FD_mpio_collective_opt_t *coll_opt =
(const H5FD_mpio_collective_opt_t *)value; /* Create local alias for values */
uint8_t **pp = (uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(coll_opt);
HDassert(size);
if (NULL != *pp)
/* Encode MPI-I/O collective optimization property */
*(*pp)++ = (uint8_t)*coll_opt;
/* Size of MPI-I/O collective optimization property */
(*size)++;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_mpio_collective_opt_enc() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_mpio_collective_opt_dec
*
* Purpose: Callback routine which is called whenever the MPI-I/O
* collective optimization property in the dataset transfer
* property list is decoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_mpio_collective_opt_dec(const void **_pp, void *_value)
{
H5FD_mpio_collective_opt_t *coll_opt =
(H5FD_mpio_collective_opt_t *)_value; /* MPI-I/O collective optimization mode */
const uint8_t **pp = (const uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity checks */
HDassert(pp);
HDassert(*pp);
HDassert(coll_opt);
/* Decode MPI-I/O collective optimization mode */
*coll_opt = (H5FD_mpio_collective_opt_t) * (*pp)++;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_mpio_collective_opt_dec() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_mpio_chunk_opt_hard_enc
*
* Purpose: Callback routine which is called whenever the MPI-I/O
* chunk optimization property in the dataset transfer
* property list is encoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **_pp, size_t *size)
{
const H5FD_mpio_chunk_opt_t *chunk_opt =
(const H5FD_mpio_chunk_opt_t *)value; /* Create local alias for values */
uint8_t **pp = (uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(chunk_opt);
HDassert(size);
if (NULL != *pp)
/* Encode MPI-I/O chunk optimization property */
*(*pp)++ = (uint8_t)*chunk_opt;
/* Size of MPI-I/O chunk optimization property */
(*size)++;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_mpio_chunk_opt_hard_enc() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_mpio_chunk_opt_hard_enc
*
* Purpose: Callback routine which is called whenever the MPI-I/O
* chunk collective optimization property in the dataset transfer
* property list is decoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_mpio_chunk_opt_hard_dec(const void **_pp, void *_value)
{
H5FD_mpio_chunk_opt_t *chunk_opt = (H5FD_mpio_chunk_opt_t *)_value; /* MPI-I/O chunk optimization mode */
const uint8_t **pp = (const uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity checks */
HDassert(pp);
HDassert(*pp);
HDassert(chunk_opt);
/* Decode MPI-I/O chunk optimization mode */
*chunk_opt = (H5FD_mpio_chunk_opt_t) * (*pp)++;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_mpio_chunk_opt_hard_dec() */
#ifdef H5_HAVE_PARALLEL
/*-------------------------------------------------------------------------
* Function: H5Pget_mpio_actual_chunk_opt_mode
*
* Purpose: Retrieves the chunked io optimization scheme that library chose
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Jacob Gruber
* Wednesday, May 4, 2011
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id,
H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode /*out*/)
{
H5P_genplist_t *plist;
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "ix", plist_id, actual_chunk_opt_mode);
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID")
/* Return values */
if (actual_chunk_opt_mode)
if (H5P_get(plist, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, actual_chunk_opt_mode) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_mpio_actual_chunk_opt_mode() */
/*-------------------------------------------------------------------------
* Function: H5Pget_mpio_actual_io_mode
*
* Purpose: Retrieves the type of I/O actually performed when collective I/O
* is requested.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Jacob Gruber
* Wednesday, May 4, 2011
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_mode /*out*/)
{
H5P_genplist_t *plist;
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "ix", plist_id, actual_io_mode);
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID")
/* Return values */
if (actual_io_mode)
if (H5P_get(plist, H5D_MPIO_ACTUAL_IO_MODE_NAME, actual_io_mode) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_mpio_actual_io_mode() */
/*-------------------------------------------------------------------------
* Function: H5Pget_mpio_no_collective_cause
*
* Purpose: Retrieves cause for the broke collective I/O
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Jonathan Kim
* Aug 3, 2012
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause /*out*/,
uint32_t *global_no_collective_cause /*out*/)
{
H5P_genplist_t *plist;
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "ixx", plist_id, local_no_collective_cause, global_no_collective_cause);
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID")
/* Return values */
if (local_no_collective_cause)
if (H5P_get(plist, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, local_no_collective_cause) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get local value")
if (global_no_collective_cause)
if (H5P_get(plist, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, global_no_collective_cause) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get global value")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_mpio_no_collective_cause() */
#endif /* H5_HAVE_PARALLEL */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_edc_enc
*
* Purpose: Callback routine which is called whenever the error detect
* property in the dataset transfer property list
* is encoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_edc_enc(const void *value, void **_pp, size_t *size)
{
const H5Z_EDC_t *check = (const H5Z_EDC_t *)value; /* Create local alias for values */
uint8_t **pp = (uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(check);
HDassert(size);
if (NULL != *pp)
/* Encode EDC property */
*(*pp)++ = (uint8_t)*check;
/* Size of EDC property */
(*size)++;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_edc_enc() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_edc_dec
*
* Purpose: Callback routine which is called whenever the error detect
* property in the dataset transfer property list
* is decoded.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, August 3, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_edc_dec(const void **_pp, void *_value)
{
H5Z_EDC_t *check = (H5Z_EDC_t *)_value; /* EDC property */
const uint8_t **pp = (const uint8_t **)_pp;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity checks */
HDassert(pp);
HDassert(*pp);
HDassert(check);
/* Decode EDC property */
*check = (H5Z_EDC_t) * (*pp)++;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dxfr_edc_dec() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_dset_io_hyp_sel_copy
*
* Purpose: Creates a copy of the dataset I/O selection.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Sunday, January 31, 2021
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_dset_io_hyp_sel_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
{
H5S_t *orig_space = *(H5S_t **)value; /* Original dataspace for property */
H5S_t *new_space = NULL; /* New dataspace for property */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* If there's a dataspace I/O selection set, copy it */
if (orig_space) {
/* Make copy of dataspace */
if (NULL == (new_space = H5S_copy(orig_space, FALSE, TRUE)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the dataset I/O selection")
/* Set new value for property */
*(void **)value = new_space;
} /* end if */
done:
/* Cleanup on error */
if (ret_value < 0)
if (new_space && H5S_close(new_space) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing dataset I/O selection dataspace")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_dset_io_hyp_sel_copy() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_dset_io_hyp_sel_cmp
*
* Purpose: Compare two dataset I/O selections.
*
* Return: positive if VALUE1 is greater than VALUE2, negative if VALUE2 is
* greater than VALUE1 and zero if VALUE1 and VALUE2 are equal.
*
* Programmer: Quincey Koziol
* Sunday, January 31, 2021
*
*-------------------------------------------------------------------------
*/
static int
H5P__dxfr_dset_io_hyp_sel_cmp(const void *_space1, const void *_space2, size_t H5_ATTR_UNUSED size)
{
const H5S_t *const *space1 = (const H5S_t *const *)_space1; /* Create local aliases for values */
const H5S_t *const *space2 = (const H5S_t *const *)_space2; /* Create local aliases for values */
herr_t ret_value = 0; /* Return value */
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(space1);
HDassert(space1);
HDassert(size == sizeof(H5S_t *));
/* Check for a property being set */
if (*space1 == NULL && *space2 != NULL)
HGOTO_DONE(-1);
if (*space1 != NULL && *space2 == NULL)
HGOTO_DONE(1);
if (*space1) {
HDassert(*space2);
/* Compare the extents of the dataspaces */
/* (Error & not-equal count the same) */
if (TRUE != H5S_extent_equal(*space1, *space2))
HGOTO_DONE(-1);
/* Compare the selection "shape" of the dataspaces
* (Error & not-equal count the same)
*
* Since H5S_select_shape_same() can result in the dataspaces being
* rebuilt, the parameters are not const which makes it impossible
* to match the cmp prototype. Since we need to compare them,
* we quiet the const warning.
*/
H5_GCC_CLANG_DIAG_OFF("cast-qual")
if (TRUE != H5S_select_shape_same((H5S_t *)*space1, (H5S_t *)*space2))
HGOTO_DONE(-1);
H5_GCC_CLANG_DIAG_ON("cast-qual")
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_dset_io_hyp_sel_cmp() */
/*-------------------------------------------------------------------------
* Function: H5P__dxfr_dset_io_hyp_sel_close
*
* Purpose: Frees resources for dataset I/O selection
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Sunday, January 31, 2021
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P__dxfr_dset_io_hyp_sel_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *_value)
{
H5S_t *space = *(H5S_t **)_value; /* Dataspace for property */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Release any dataspace */
if (space && H5S_close(space) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing dataset I/O selection dataspace")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dxfr_dset_io_hyp_sel_close() */
/*-------------------------------------------------------------------------
* Function: H5Pset_dataset_io_hyperslab_selection
*
* Purpose: H5Pset_dataset_io_hyperslab_selection() is designed to be used
* in conjunction with using H5S_PLIST for the file dataspace
* ID when making a call to H5Dread() or H5Dwrite(). When used
* with H5S_PLIST, the selection created by one or more calls to
* this routine is used for determining which dataset elements to
* access.
*
* 'rank' is the dimensionality of the selection and determines
* the size of the 'start', 'stride', 'count', and 'block' arrays.
* 'rank' must be between 1 and H5S_MAX_RANK, inclusive.
*
* The 'op', 'start', 'stride', 'count', and 'block' parameters
* behave identically to their behavior for H5Sselect_hyperslab(),
* please see the documentation for that routine for details about
* their use.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Saturday, January 30, 2021
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_dataset_io_hyperslab_selection(hid_t plist_id, unsigned rank, H5S_seloper_t op, const hsize_t start[],
const hsize_t stride[], const hsize_t count[], const hsize_t block[])
{
H5P_genplist_t *plist = NULL; /* Property list pointer */
H5S_t *space; /* Dataspace to hold selection */
hbool_t space_created = FALSE; /* Whether a new dataspace has been created */
hbool_t reset_prop_on_error = FALSE; /* Whether to reset the property on failure */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE7("e", "iIuSs*h*h*h*h", plist_id, rank, op, start, stride, count, block);
/* Check arguments */
if (rank < 1 || rank > H5S_MAX_RANK)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank value: %u", rank)
if (!(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID))
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation")
if (start == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "'count' pointer is NULL")
if (stride != NULL) {
unsigned u; /* Local index variable */
/* Check for 0-sized strides */
for (u = 0; u < rank; u++)
if (stride[u] == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid value - stride[%u]==0", u)
} /* end if */
if (count == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "'start' pointer is NULL")
/* block is allowed to be NULL, and will be assumed to be all '1's when NULL */
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID")
/* 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_PLIST, H5E_CANTGET, FAIL, "error getting dataset I/O selection")
/* Check for operation on existing dataspace selection */
if (NULL != space) {
int sndims; /* Rank of existing dataspace */
/* Get dimensions from current dataspace for selection */
if ((sndims = H5S_GET_EXTENT_NDIMS(space)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get selection's dataspace rank")
/* Check for different # of dimensions */
if ((unsigned)sndims != rank) {
/* Set up new dataspace for 'set' operation, otherwise fail */
if (op == H5S_SELECT_SET) {
/* Close previous dataspace */
if (H5S_close(space) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
/* Reset 'space' pointer, so it's re-created */
space = NULL;
/* Set flag to reset property list on error */
reset_prop_on_error = TRUE;
} /* end if */
else
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "different rank for previous and new selections")
} /* end if */
} /* end if */
/* Check for first time called */
if (NULL == space) {
hsize_t dims[H5S_MAX_RANK]; /* Dimensions for new dataspace */
unsigned u; /* Local index variable */
/* Initialize dimensions to largest possible actual size */
for (u = 0; u < rank; u++)
dims[u] = (H5S_UNLIMITED - 1);
/* Create dataspace of the correct dimensionality, with maximum dimensions */
if (NULL == (space = H5S_create_simple(rank, dims, NULL)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create dataspace for selection")
space_created = TRUE;
} /* end if */
/* Set selection for dataspace */
if (H5S_select_hyperslab(space, op, start, stride, count, block) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSELECT, FAIL, "can't create selection")
/* Update property list (takes ownership of dataspace, if new) */
if (H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection")
space_created = FALSE; /* Reset now that property owns the dataspace */
done:
/* Cleanup on failure */
if (ret_value < 0) {
if (reset_prop_on_error && plist && H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0)
HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection")
if (space_created && H5S_close(space) < 0)
HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
} /* end if */
FUNC_LEAVE_API(ret_value)
} /* end H5Pset_dataset_io_hyperslab_selection() */
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/submodule_xiaohu/hdf5.git
git@gitee.com:submodule_xiaohu/hdf5.git
submodule_xiaohu
hdf5
hdf5
architecture_docs

搜索帮助