bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
HDF5Array.h
Go to the documentation of this file.
1// This file is part of hdf5_handler a HDF5 file handler for the OPeNDAP
2// data server.
3
4// Author: Hyo-Kyung Lee <hyoklee@hdfgroup.org> and Kent Yang
5// <myang6@hdfgroup.org>
6
7// Copyright (c) 2009-2023 The HDF Group, Inc. and OPeNDAP, Inc.
8//
9// This is free software; you can redistribute it and/or modify it under the
10// terms of the GNU Lesser General Public License as published by the Free
11// Software Foundation; either version 2.1 of the License, or (at your
12// option) any later version.
13//
14// This software is distributed in the hope that it will be useful, but
15// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17// License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24// You can contact The HDF Group, Inc. at 410 E University Ave,
25// Suite 200, Champaign, IL 61820
26
27#ifndef _HDF5ARRAY_H
28#define _HDF5ARRAY_H
29
30#include <H5Ipublic.h>
31#include <H5Rpublic.h>
32
33#include <libdap/Array.h>
34
35#include "h5get.h"
36
37
49class HDF5Array:public libdap::Array {
50
51 private:
52
53 int d_num_dim = 0;
54 hsize_t d_num_elm = 0;
55
56 hsize_t d_memneed = 0;
57 string var_path;
58
59 // Parse constraint expression and make HDF5 coordinate point location.
60 // return number of elements to read.
61 int64_t format_constraint(int64_t *cor, int64_t *step, int64_t *edg);
62
63
64 bool m_array_of_structure(hid_t dsetid, std::vector<char>&values,bool has_values, size_t values_offset,
65 int64_t nelms,const int64_t* offset,const int64_t* count,const int64_t *step);
66
67 void m_array_of_structure_member(libdap::BaseType *field, hid_t memtype, unsigned int u,hid_t dsetid,
68 std::vector<char>&values,bool has_values, size_t struct_elem_offset ) const;
69 void m_array_of_structure_close_hdf5_ids(std::vector<char> &values, bool has_values, hid_t mspace,
70 hid_t dtypeid, hid_t memtype) const;
71 void m_array_of_structure_catch_close_hdf5_ids(hid_t memb_id, char * memb_name, std::vector<char> &values,
72 bool has_values, hid_t mspace, hid_t dtypeid, hid_t memtype) const;
73
74 bool m_array_of_reference(hid_t dset_id,hid_t dtype_id);
75 void m_array_of_region_reference(hid_t d_dset_id,std::vector<std::string>& v_str, int64_t nelms,
76 const std::vector<int64_t>& offset, const std::vector<int64_t> &step);
77 void m_array_of_object_reference(hid_t d_dset_id, std::vector<std::string>& v_str, int64_t nelms,
78 const std::vector<int64_t>& offset, const std::vector<int64_t> &step) const;
79
80 bool m_array_of_reference_new_h5_apis(hid_t dset_id,hid_t dtype_id);
81
82 void m_intern_plain_array_data(char *convbuf,hid_t memtype);
83 void m_array_of_atomic(hid_t, hid_t,int64_t ,const int64_t *,const int64_t *,const int64_t *);
84 void handle_vlen_string(hid_t dset_id, hid_t memtype, int64_t nelms, const std::vector<hsize_t>& hoffset,
85 const std::vector<hsize_t>& hcount, const std::vector<hsize_t>& hstep);
86 void handle_array_read_whole(hid_t dset_id, hid_t memtype, int64_t nelms);
87 void handle_array_read_slab(hid_t dset_id, hid_t memtype, int64_t nelms,
88 const int64_t *offset, const int64_t *step, const int64_t *count);
89
90 void do_array_read(hid_t dset_id,hid_t dtype_id,std::vector<char>&values,
91 int64_t nelms,const int64_t* offset,const int64_t* count, const int64_t* step);
92 bool do_h5_array_type_read(hid_t dsetid, hid_t memb_id,std::vector<char>&values,bool has_values,size_t values_offset,
93 int64_t at_nelms,int64_t* at_offset,int64_t*at_count,int64_t* at_step);
94 void do_h5_array_type_read_base_compound_member(hid_t dsetid, libdap::BaseType *field, hid_t child_memb_id,
95 H5T_class_t child_memb_cls, std::vector<char>&values, bool has_values,
96 size_t values_offset, int64_t at_nelms, int64_t at_total_nelms,
97 size_t at_base_type_size, int64_t array_index,
98 int64_t at_orig_index, size_t child_memb_offset) const;
99 void do_h5_array_type_read_base_compound_member_string(libdap::BaseType *field, hid_t child_memb_id,
100 const std::vector<char> &values, size_t data_offset) const;
101
102 void do_h5_array_type_read_base_atomic(H5T_class_t array_cls, hid_t at_base_type, size_t at_base_type_size,
103 std::vector<char>&values, size_t values_offset, int64_t at_nelms,
104 int64_t at_total_nelms, int at_ndims, std::vector<int64_t> &at_dims,
105 int64_t* at_offset, int64_t* at_step, int64_t *at_count);
106 void do_h5_array_type_read_base_atomic_whole_data(H5T_class_t array_cls, hid_t at_base_type,int64_t at_nelms,
107 std::vector<char> &values, size_t values_offset);
108 inline int64_t INDEX_nD_TO_1D (const std::vector < int64_t > &dims, const std::vector < int64_t > &pos) const;
109 bool obtain_next_pos(std::vector<int64_t>& pos, std::vector<int64_t>&start,std::vector<int64_t>&end,
110 std::vector<int64_t>&step,int rank_change);
111
112 template<typename T> int subset(
113 const T input[],
114 int rank,
115 std::vector<int64_t> & dim,
116 int64_t start[],
117 int64_t stride[],
118 int64_t edge[],
119 std::vector<T> *poutput,
120 std::vector<int64_t>& pos,
121 int index);
122
123 bool handle_one_dim(libdap::Array::Dim_iter d, libdap::D4Group *temp_grp, libdap::D4Dimension * &d4_dim,
124 const vector<string> &dimpath, int k) const;
125 void m_array_of_region_reference_point_selection(hid_t space_id, int ndim, const std::string &varname,
126 std::vector<std::string> &v_str,int64_t i) const;
127 void m_array_of_region_reference_hyperslab_selection(hid_t space_id, int ndim, const std::string &varname,
128 std::vector<std::string> &v_str,int64_t i) const;
129 friend class HDF5Structure;
130 public:
131
133 HDF5Array(const std::string & n, const std::string &d, libdap::BaseType * v);
134 ~ HDF5Array() override = default;
135
141 libdap::BaseType *ptr_duplicate() override;
142
144 bool read() override;
145
147 void set_memneed(size_t need);
148
150 void set_numdim(int ndims);
151
153 int get_numdim() const { return d_num_dim;}
154
156 void set_numelm(hsize_t nelms);
157
158 void set_varpath(const std::string& vpath) { var_path = vpath;}
159 libdap::BaseType *h5dims_transform_to_dap4(libdap::D4Group *root,const std::vector<std::string> &dimpath);
160
161};
162
163#endif
void set_numelm(hsize_t nelms)
remembers number of elements in this array.
libdap::BaseType * ptr_duplicate() override
Definition HDF5Array.cc:48
bool read() override
Reads HDF5 array data into local buffer.
Definition HDF5Array.cc:103
void set_numdim(int ndims)
remembers number of dimensions of this array.
HDF5Array(const std::string &n, const std::string &d, libdap::BaseType *v)
Constructor.
Definition HDF5Array.cc:53
void set_memneed(size_t need)
remembers memory size needed.
int get_numdim() const
obtain the number of dimensions of this array.
Definition HDF5Array.h:153
STL class.