bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
FONcTransform.h
1// FONcTransform.h
2
3// This file is part of BES Netcdf File Out Module
4
5// Copyright (c) 2004,2005 University Corporation for Atmospheric Research
6// Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Lesser General Public
10// License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// Lesser General Public License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21//
22// You can contact University Corporation for Atmospheric Research at
23// 3080 Center Green Drive, Boulder, CO 80301
24
25// (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
26// Please read the full copyright statement in the file COPYRIGHT_UCAR.
27//
28// Authors:
29// pwest Patrick West <pwest@ucar.edu>
30// jgarcia Jose Garcia <jgarcia@ucar.edu>
31
32#ifndef FONcTransfrom_h_
33#define FONcTransfrom_h_ 1
34
35#include <string>
36#include <vector>
37#include <map>
38#include <unordered_map>
39#include <set>
40
41#include <BESObj.h>
42
43namespace libdap {
44class DDS;
45class DMR;
46class D4Group;
47}
48
49class FONcBaseType;
52
60class FONcTransform: public BESObj {
61private:
62 int _ncid = {0};
63 libdap::DDS *_dds = {nullptr};
64 libdap::DMR *_dmr = {nullptr};
65 BESResponseObject *d_obj = {nullptr};
66 BESDataHandlerInterface *d_dhi = {nullptr};
67 std::string _localfile;
68 std::string _returnAs;
69 std::vector<FONcBaseType *> _fonc_vars;
70 std::vector<FONcBaseType *> _total_fonc_vars_in_grp;
71 std::set<std::string> _included_grp_names;
72 std::map<std::string,int64_t> GFQN_dimname_to_dimsize;
73 std::map<std::string,int64_t> VFQN_dimname_to_dimsize;
74
75 // TODO: This is for the temporary memory usage optimization. Once we can support the define() with or without dio for individual array.
76 // This flag is not necessary and should be removed. KY 11/29/23
77 bool global_dio_flag = false;
78
79 bool do_reduce_dim = false;
80 std::unordered_map<int64_t, std::vector<std::string>> dimsize_to_dup_dimnames;
81 int reduced_dim_num = 0;
82
83public:
84 FONcTransform(BESResponseObject *obj, BESDataHandlerInterface *dhi, const std::string &localfile, const std::string &ncVersion = "netcdf");
85 virtual ~FONcTransform();
86 virtual void transform_dap2();
87 virtual void transform_dap4();
88
89 virtual void dump(ostream &strm) const;
90
91 // TODO: This is for the temporary memory usage optimization. Once we can support the define() with or without dio for individual array.
92 // This flag is not necessary and should be removed. KY 11/29/23
93 bool get_gdio_flag() const {return global_dio_flag; }
94 void set_gdio_flag(bool dio_flag_value = true) { global_dio_flag = dio_flag_value; }
95
96
97private:
98 virtual void transform_dap4_no_group();
99 virtual void transform_dap4_group(libdap::D4Group*,bool is_root, int par_grp_id, std::map<std::string, int>&, std::vector<int>&);
100 virtual void transform_dap4_group_internal(libdap::D4Group*, bool is_root, int par_grp_id, std::map<std::string, int>&, std::vector<int>&);
101 virtual void check_and_obtain_dimensions(libdap::D4Group *grp, bool);
102 virtual void check_and_obtain_dimensions_internal(libdap::D4Group *grp);
103 virtual bool check_group_support();
104 virtual void gen_included_grp_list(libdap::D4Group *grp);
105
106 virtual bool check_reduce_dim();
107 virtual bool check_reduce_dim_internal(libdap::D4Group *grp);
108 virtual bool check_var_dim(libdap::BaseType *bt);
109 virtual void build_reduce_dim();
110 virtual void build_reduce_dim_internal(libdap::D4Group *grp, libdap::D4Group *root_grp);
111
112 void throw_if_dap2_response_too_big(DDS *dds, const string &dap2_ce="");
113 void throw_if_dap4_response_too_big(DMR *dmr, const string &dap4_ce="");
114 string too_big_error_msg(
115 const unsigned dap_version,
116 const string &return_encoding,
117 const unsigned long long config_max_response_size_kb,
118 const unsigned long long contextual_max_response_size_kb,
119 const string &ce);
120 void set_max_size_and_encoding(unsigned long long &max_request_size_kb, string &return_encoding);
121
122 void set_constraint_var_dio_flag(libdap::BaseType*) const;
123 void set_constraint_var_dio_flag(libdap::Array*) const;
124
125};
126
127#endif // FONcTransfrom_h_
128
Structure storing information used by the BES to handle the request.
top level BES object to house generic methods
Definition BESObj.h:54
Abstract base class representing a specific set of information in response to a request to the BES.
A DAP BaseType with file out netcdf information included.
virtual void dump(ostream &strm) const
dumps information about this transformation object for debugging purposes
virtual void transform_dap2()
Transforms each of the variables of the DataDDS to the NetCDF file.
FONcTransform(BESResponseObject *obj, BESDataHandlerInterface *dhi, const std::string &localfile, const std::string &ncVersion="netcdf")
Constructor that creates transformation object from the specified BESResponseObject object to the spe...
virtual void transform_dap4()
Transforms each of the variables of the DMR to the NetCDF file.
virtual ~FONcTransform()
Destructor.
STL class.