69 d_maps =
new D4Maps(*a.d_maps,
this);
89 for (
Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
97 unsigned long long length = 1;
98 for (
const auto &i : _shape) {
178 if (!(*dap2_dim).name.empty()) {
183 d4_dim =
new D4Dimension((*dap2_dim).name, (*dap2_dim).size);
186 DBG(cerr << __func__ <<
"() -" <<
" Using Existing D4Dimension '" << d4_dim->
name() <<
"' ("
187 << (
void *)d4_dim <<
")" << endl);
189 if (d4_dim->
size() != (
unsigned long)(*dap2_dim).size) {
201 d4_dim =
new D4Dimension((*dap2_dim).name +
"_" +
name(), (*dap2_dim).size);
202 DBG(cerr << __func__ <<
"() -" <<
" Utilizing Name/Size Conflict Naming Artifice. name'"
203 << d4_dim->
name() <<
"' (" << (
void *)d4_dim <<
")" << endl);
209 (*dap2_dim).dim = d4_dim;
217 DBG(cerr << __func__ <<
"() - END (array:" <<
name() <<
")" << endl);
221 bool is_grid =
false;
223 DBG(cerr << __func__ <<
"() - Array '" <<
name() <<
"' is DAP4 object!" << endl);
226 throw InternalErr(__FILE__, __LINE__,
string(
"Could not get the root group for ").append(this->
name()));
228 is_grid = d4_maps->
size();
230 DBG(cerr << __func__ <<
"() - Array '" <<
name() <<
"' has D4Maps." << endl);
235 DBG(cerr << __func__ <<
"() - Map '" << (*i)->array()->name() <<
" has " << (*i)->array()->_shape.size()
236 <<
" dimension(s)." << endl);
237 if ((*i)->array(root)->_shape.size() > 1) {
245 DBG(cerr << __func__ <<
"() - Array '" <<
name() <<
"' has no D4Maps." << endl);
249 DBG(cerr << __func__ <<
"() - is_grid: " << (is_grid ?
"true" :
"false") << endl);
269 DBG(cerr << __func__ <<
"() - BEGIN Array '" <<
name() <<
"'" << endl);
280 DBG(cerr << __func__ <<
"() - Array '" <<
name() <<
"' is dap2 Grid!" << endl);
294 throw InternalErr(__FILE__, __LINE__,
string(
"Could not get the root group for ").append(this->
name()));
296 vector<BaseType *> dropped_maps;
299 for (; miter != end; miter++) {
300 D4Map *d4_map = (*miter);
304 if (d2_result->size() > 1)
308 Array *d2_map_array =
dynamic_cast<Array *
>((*d2_result)[0]);
312 "DAP2 array from D4Map Array conversion has more than 1 dimension.");
315 g->
add_map(d2_map_array,
false);
317 DBG(cerr << __func__ <<
"() - " <<
"DAS For Grid Map '" << d2_map_array->
name() <<
"':" << endl;
324 dropped_maps.push_back(d4_map_array);
329 if (!dropped_maps.empty()) {
335 DBG(cerr << __func__ <<
"() - Array '" <<
name() <<
"' is not a Grid!" << endl);
338 switch (proto->
type()) {
373 vector<BaseType *> *result =
nullptr;
375 result =
new vector<BaseType *>();
376 result->push_back(dest);
379 DBG(cerr << __func__ <<
"() - END Array '" <<
name() <<
"'" << endl);
395 std::vector<dimension>::iterator i = _shape.begin(), e = _shape.end();
398 while (old_i != old_e) {
399 if ((*i).dim == *old_i) {
400 (*i).dim = new_dims->
find_dim((*old_i)->name());
508 _shape.insert(_shape.begin(), d);
516 _shape.insert(_shape.begin(), d);
532 std::vector<dimension>::iterator i = _shape.begin(), e = _shape.end();
535 if (d.
name == oldName) {
536 DBG(cerr <<
"Old name = " << d.
name <<
" newName = " << newName << endl);
552 for (
Dim_iter i = _shape.begin(); i != _shape.end(); i++) {
554 (*i).stop = (*i).size - 1;
556 (*i).c_size = (*i).size;
575static const char *array_sss =
"Invalid constraint parameters: At least one of the start, stride or stop \n\
576specified do not match the array variable.";
601 DBG(cerr <<
"add_constraint: d_size = " << d.
size << endl);
602 DBG(cerr <<
"add_constraint: start = " << start << endl);
603 DBG(cerr <<
"add_constraint: stop = " << stop << endl);
604 DBG(cerr <<
"add_constraint: stride = " << stride << endl);
621 if (start >= d.
size || stop >= d.
size || stride > d.
size || stride <= 0)
624 if (((stop - start) / stride + 1) > d.
size)
631 d.
c_size = (stop - start) / stride + 1;
633 DBG(cerr <<
"add_constraint: c_size = " << d.
c_size << endl);
642 DBG(cerr <<
"add_constraint_ll: d_size = " << d.
size << endl);
643 DBG(cerr <<
"add_constraint_ll: start = " << start << endl);
644 DBG(cerr <<
"add_constraint_ll: stop = " << stop << endl);
645 DBG(cerr <<
"add_constraint_ll: stride = " << stride << endl);
656 if (start >= d.
size || stop >= d.
size || stride > d.
size || stride <= 0)
659 if (((stop - start) / stride + 1) > d.
size)
666 d.
c_size = (stop - start) / stride + 1;
668 DBG(cerr <<
"add_constraint: c_size = " << d.
c_size << endl);
676 DBG(cerr <<
"add_constraint d4dimension: stride = " << dim->
c_stride() << endl);
726 if (!_shape.empty()) {
763 throw Error(
malformed_expr,
"The dimension start value is too large. Use dimension_start_ll()");
765 return (!_shape.empty()) ? (*i).start : 0;
788 throw Error(
malformed_expr,
"The dimension stop value is too large. Use dimension_stop_ll()");
790 return (!_shape.empty()) ? (*i).stop : 0;
814 throw Error(
malformed_expr,
"The dimension stride value is too large. Use dimension_stride_ll()");
816 return (!_shape.empty()) ? (*i).stride : 0;
822 if (!_shape.empty()) {
854 throw InternalErr(__FILE__, __LINE__,
"*This* array has no dimensions.");
862 d_maps =
new D4Maps(
this);
866void Array::print_dim_element(
const XMLWriter &xml,
const dimension &d,
bool constrained) {
867 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"Dim") < 0)
868 throw InternalErr(__FILE__, __LINE__,
"Could not write Dim element");
870 string name = (d.dim) ? d.dim->fully_qualified_name() : d.name;
873 if (!constrained && !
name.empty()) {
874 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"name", (
const xmlChar *)
name.c_str()) < 0)
875 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
876 }
else if (d.use_sdim_for_slice) {
877 assert(!
name.empty());
878 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"name", (
const xmlChar *)
name.c_str()) < 0)
879 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
882 size << (constrained ? d.c_size : d.size);
883 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"size",
884 (
const xmlChar *)size.str().c_str()) < 0)
885 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
888 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
889 throw InternalErr(__FILE__, __LINE__,
"Could not end Dim element");
898 if (constrained && !
send_p())
905 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"name", (
const xmlChar *)
name().c_str()) < 0)
906 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
916 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"enum", (
const xmlChar *)path.c_str()) < 0)
917 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for enum");
922 for (
auto var : c.variables()) {
923 var->print_dap4(xml, constrained);
927 for (
auto const &d :
shape()) {
928 print_dim_element(xml, d, constrained);
933 auto print_d4_map = [&xml](
D4Map *m) { m->print_dap4(xml); };
935 for_each(
maps()->map_begin(),
maps()->map_end(), print_d4_map);
937 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
958void Array::print_decl(FILE *out,
string space,
bool print_semi,
bool constraint_info,
bool constrained) {
960 print_decl(oss, space, print_semi, constraint_info, constrained);
961 fwrite(oss.str().data(),
sizeof(
char), oss.str().length(), out);
981void Array::print_decl(ostream &out,
string space,
bool print_semi,
bool constraint_info,
bool constrained) {
982 if (constrained && !
send_p())
986 var()->
print_decl(out, space,
false, constraint_info, constrained);
988 for (
Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
990 if ((*i).name !=
"") {
991 out <<
id2www((*i).name) <<
" = ";
994 out << (*i).c_size <<
"]";
996 out << (*i).size <<
"]";
1066 if (constrained && !
send_p())
1069 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)tag.c_str()) < 0)
1070 throw InternalErr(__FILE__, __LINE__,
"Could not write " + tag +
" element");
1072 if (!
name().empty() &&
1073 xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"name", (
const xmlChar *)
name().c_str()) < 0)
1074 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
1079 string tmp_name = btp->
name();
1084 for (
auto const &d :
shape()) {
1085 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"dimension") < 0)
1086 throw InternalErr(__FILE__, __LINE__,
"Could not write dimension element");
1088 if (!d.name.empty())
1089 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"name",
1090 (
const xmlChar *)d.name.c_str()) < 0)
1091 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
1094 size << (constrained ? d.c_size : d.size);
1095 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"size",
1096 (
const xmlChar *)size.str().c_str()) < 0)
1097 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
1099 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
1100 throw InternalErr(__FILE__, __LINE__,
"Could not end dimension element");
1103 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
1104 throw InternalErr(__FILE__, __LINE__,
"Could not end " + tag +
" element");
1121 fwrite(oss.str().data(),
sizeof(
char), oss.str().length(), out);
1142 if (
shape[0] >= 1) {
1143 for (uint64_t i = 0; i <
shape[0] - 1; ++i) {
1167 for (uint64_t i = 0; i <
shape[0] - 1; ++i) {
1184 fwrite(oss.str().data(),
sizeof(
char), oss.str().length(), out);
1200 unsigned int index = 0;
1201 for (
auto i = _shape.begin(); i != _shape.end() && index <
dimensions(
true); ++i)
1227 msg =
"An array variable must have dimensions";
1239 stringstream sqr_brkty_stuff;
1241 sqr_brkty_stuff <<
"[";
1243 if (!dim_name.empty()) {
1244 sqr_brkty_stuff << dim_name <<
"=";
1248 return sqr_brkty_stuff.str();
1258 bool has_projected_dap4 =
false;
1261 has_projected_dap4 =
1266 if (has_projected_dap4) {
1272 return has_projected_dap4;
1284 strm <<
DapIndent::LMarg <<
"Array::dump - (" <<
static_cast<const void *
>(
this) <<
")\n";
1291 unsigned int dim_num = 0;
1292 for (
const auto &dim : _shape) {
1296 auto print_attr = [&strm](
const std::string &
name,
const auto &
value) {
1300 print_attr(
"name", dim.name);
1301 print_attr(
"size", dim.size);
1302 print_attr(
"start", dim.start);
1303 print_attr(
"stop", dim.stop);
1304 print_attr(
"stride", dim.stride);
1305 print_attr(
"constrained size", dim.c_size);
1322 vs_info.filter = my_vs_info.
filter;
1325 vs_info.deflate_levels.push_back(def_lev);
1327 for (
const auto &chunk_dim : my_vs_info.
chunk_dims)
1328 vs_info.chunk_dims.push_back(chunk_dim);
1335 for (
const auto &chunk_coord : vci.chunk_coords)
1337 vs_info.var_chunk_info.push_back(vci_t);
#define internal_error
Internal server error (500)
#define malformed_expr
(400)
A multidimensional array of identical data types.
virtual void print_as_map_xml_writer(XMLWriter &xml, bool constrained)
void print_dap4(XMLWriter &xml, bool constrained=false) override
Print the DAP4 representation of an array.
virtual int dimension_start(Dim_iter i, bool constrained=false)
Return the start index of a dimension.
virtual void clear_constraint()
Clears the projection; add each projected dimension explicitly using add_constraint.
virtual void add_constraint_ll(Dim_iter i, int64_t start, int64_t stride, int64_t stop)
virtual int64_t dimension_start_ll(Dim_iter i, bool constrained=false)
virtual int64_t dimension_stop_ll(Dim_iter i, bool constrained=false)
virtual int dimension_stop(Dim_iter i, bool constrained=false)
Return the stop index of the constraint.
void dump(ostream &strm) const override
dumps information about this object
virtual void update_length(int size=0)
bool is_dap4_projected(std::vector< std::string > &projected_dap4_inventory) override
virtual void add_constraint(Dim_iter i, int start, int stride, int stop)
Adds a constraint to an Array dimension.
virtual string dimension_name(Dim_iter i)
Returns the name of the specified dimension.
void print_decl(ostream &out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false) override
Prints a DDS entry for the Array.
virtual int64_t dimension_size_ll(Dim_iter i, bool constrained=false)
void print_xml(ostream &out, string space=" ", bool constrained=false) override
void print_val(ostream &out, string space="", bool print_decl_p=true) override
Prints the value of the variable.
BaseType * ptr_duplicate() override
void append_dim(int size, const string &name="")
Add a dimension of a given size.
std::vector< dimension >::iterator Dim_iter
virtual D4Dimension * dimension_D4dim(Dim_iter i)
void rename_dim(const string &oldName="", const string &newName="")
Renames dimension.
std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table) override
Transforms this instance of a D4Array into the corresponding DAP2 object.
std::vector< dimension > & shape()
virtual int dimension_size(Dim_iter i, bool constrained=false)
Returns the size of the dimension.
virtual void print_xml_writer_core(XMLWriter &out, bool constrained, string tag)
std::vector< dimension >::const_iterator Dim_citer
void add_var(BaseType *v, Part p=nil) override
Add the BaseType pointer to this constructor type instance.
uint64_t print_array(FILE *out, uint64_t index, unsigned int dims, uint64_t shape[])
Print the value given the current constraint.
virtual void print_as_map_xml(ostream &out, string space=" ", bool constrained=false)
void print_xml_writer(XMLWriter &xml, bool constrained=false) override
virtual void reset_constraint()
Reset constraint to select entire array.
void set_var_storage_info(const var_storage_info &my_vs_info)
Set the variable storage information for direct IO optimization.
virtual ~Array()
The Array destructor.
virtual void print_xml_core(FILE *out, string space, bool constrained, string tag)
void add_var_nocopy(BaseType *v, Part p=nil) override
void append_dim_ll(int64_t size, const string &name="")
void prepend_dim(int size, const string &name="")
void transform_to_dap4(D4Group *root, Constructor *container) override
DAP2 to DAP4 transform.
Array(const string &n, BaseType *v, bool is_dap4=false)
Array constructor.
bool check_semantics(string &msg, bool all=false) override
Check semantic features of the Array.
virtual void update_length_ll(unsigned long long size=0)
virtual unsigned int dimensions(bool constrained=false)
Return the total number of dimensions in the array.
virtual int64_t dimension_stride_ll(Dim_iter i, bool constrained=false)
void _duplicate(const Array &a)
Array & operator=(const Array &rhs)
virtual int dimension_stride(Dim_iter i, bool constrained=false)
Returns the stride value of the constraint.
Contains the attributes for a dataset.
virtual AttrTable * append_container(const string &name)
Add a container to the attribute table.
virtual void set_name(const string &n)
Set the name of this attribute table.
virtual string get_name() const
Get the name of this attribute table.
void print_xml_writer(XMLWriter &xml)
virtual void print(FILE *out, string pad=" ", bool dereference=false)
Prints the attribute table.
virtual unsigned int get_size() const
Get the number of entries in this attribute table.
The basic data type for the DODS DAP types.
virtual bool is_dap4_projected(std::vector< string > &projected_dap4_inventory)
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
virtual string type_name() const
Returns the type of the class instance as a string.
virtual AttrTable & get_attr_table()
virtual string name() const
Returns the name of the class instance.
virtual void print_decl(FILE *out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Print an ASCII representation of the variable structure.
virtual bool is_dap4() const
virtual void set_name(const string &n)
Sets the name of the class instance.
virtual bool is_constructor_type() const
Returns true if the instance is a constructor (i.e., Structure, Sequence or Grid) type variable.
virtual D4Attributes * attributes()
virtual std::string FQN() const
virtual bool send_p()
Should this variable be sent?
virtual void set_is_dap4(const bool v)
virtual BaseType * get_ancestor()
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
virtual Type type() const
Returns the type of the class instance.
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
static AttrTable * make_dropped_vars_attr_table(vector< BaseType * > *dropped_vars)
void add_var_nocopy(BaseType *bt, Part part=nil) override
void transform_to_dap4(AttrTable &at)
copy attributes from DAP2 to DAP4
void print_dap4(XMLWriter &xml) const
void transform_attrs_to_dap2(AttrTable *d2_attr_table)
Copy the attributes from this D4Attributes object to a DAP2 AttrTable.
bool has_dap4_types(const std::string &path, std::vector< std::string > &inventory) const
unsigned long long size() const
void set_used_by_projected_var(bool state)
vector< D4Dimension * >::iterator D4DimensionsIter
Iterator used for D4Dimensions.
void add_dim_nocopy(D4Dimension *dim)
D4Dimension * find_dim(const string &name)
D4DimensionsIter dim_end()
Get an iterator to the end of the dimensions.
D4DimensionsIter dim_begin()
Get an iterator to the start of the dimensions.
D4EnumDefs * parent() const
Holds a DAP4 enumeration.
virtual D4EnumDef * enumeration() const
D4Dimensions * dims()
Get the dimensions defined for this Group.
Array * array(D4Group *root)
This will always return the correct pointer for a valid data set.
vector< D4Map * >::iterator D4MapsIter
static ostream & LMarg(ostream &strm)
A class for error processing.
Holds the Grid data type.
virtual void set_array(Array *p_new_arr)
virtual Array * add_map(Array *p_new_map, bool add_copy)
A class for software fault reporting.
void dump(ostream &strm) const override
dumps information about this object
Vector & operator=(const Vector &rhs)
void add_var_nocopy(BaseType *v, Part p=nil) override
void add_var(BaseType *v, Part p=nil) override
Add the BaseType pointer to this constructor type instance.
int length() const override
Returns the number of elements in the vector. Note that some child classes of Vector use the length o...
virtual void value(dods_byte *b) const
void set_length_ll(int64_t l) override
Set the number of elements in this Vector/Array This version of the function deprecates set_length() ...
BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=nullptr) override
virtual BaseType * prototype() const
Vector(const string &n, BaseType *v, const Type &t, bool is_dap4=false)
The Vector constructor.
virtual BaseType * var_ll(uint64_t i)
void set_length(int64_t l) override
Sets the length of the vector. This function does not allocate any new space.
unsigned int get_doc_size()
xmlTextWriterPtr get_writer() const
top level DAP object to house generic methods
Type
Identifies the data type.
string get_dims_decl(Array &a)
string www2id(const string &in, const string &escape, const string &except)
Part
Names the parts of multi-section constructor data types.
string id2www(string in, const string &allowable)
int64_t start
The constraint start index.
int64_t stride
The constraint stride.
string name
The name of this dimension.
D4Dimension * dim
If not null, a weak pointer to the D4Dimension.
int64_t size
The unconstrained dimension size.
int64_t stop
The constraint end index.
bool use_sdim_for_slice
Used to control printing the DMR in data responses.
int64_t c_size
Size of dimension once constrained.
unsigned long long chunk_buffer_size
vector< unsigned long long > chunk_coords
unsigned long long chunk_direct_io_offset
vector< size_t > chunk_dims
vector< var_chunk_info_t > var_chunk_info
vector< unsigned int > deflate_levels