20 #include "SheafSystem/attributes_record_set.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/error_message.h" 24 #include "SheafSystem/interval_index_space_handle.h" 25 #include "SheafSystem/namespace_poset.h" 26 #include "SheafSystem/poset_bounds.h" 27 #include "SheafSystem/poset_bounds_descriptor.h" 28 #include "SheafSystem/sheaf_file.h" 40 const int DATASPACE_RANK = 1;
45 const int RECORD_BUFFER_UB = 12;
58 _general_attributes(xother._general_attributes),
59 _table_dof_tuple(xother._table_dof_tuple),
60 _member_names(xother._member_names),
61 _member_class_names(xother._member_class_names),
62 _subposet_names(xother._subposet_names),
63 _id_space_names(xother._id_space_names),
64 _dof_tuple_types(xother._dof_tuple_types),
65 _dof_tuple_class_names(xother._dof_tuple_class_names),
66 _dof_tuple_schema_versions(xother._dof_tuple_schema_versions),
67 _dof_tuple_schema_ids(xother._dof_tuple_schema_ids),
68 _dof_tuple_col_bounds(xother._dof_tuple_col_bounds),
69 _dof_tuple_domain_offsets(xother._dof_tuple_domain_offsets)
194 :
record_set(xfile, RECORD_BUFFER_UB, xscaffold),
203 _dof_tuple_schema_versions(const_cast<
poset_scaffold&>(xscaffold)),
231 hsize_t linit_dims[DATASPACE_RANK];
237 post_fatal_error_message(
"can't create interior data space");
265 static const string result(
".attributes");
284 require(!
scaffold().structure().is_external() ?
scaffold().structure().state_is_read_write_accessible() :
true);
288 hdf_buf_type* lhdf_buf = _hdf_bufs;
383 post_warning_message(
"Unable to reclaim memory from HDF variable length data.");
388 ensure(!
scaffold().structure().is_external());
389 ensure(
scaffold().structure().state_is_read_write_accessible());
404 require(
scaffold().structure().state_is_read_accessible());
408 hdf_buf_type* lhdf_buf = _hdf_bufs;
512 require(
file().mode() == sheaf_file::READ_WRITE);
518 hsize_t linit_dims[DATASPACE_RANK];
534 post_fatal_error_message(
"Unable to create dataset.");
569 post_fatal_error_message(
"Can't create internal data type");
583 sheaf::attributes_record_set::
595 H5S_ALL, H5P_DEFAULT, _hdf_bufs);
598 post_fatal_error_message(
"unable to read poset attributes dataset");
617 sheaf::attributes_record_set::
630 H5P_DEFAULT, _hdf_bufs);
633 post_fatal_error_message(
"unable to write poset attributes dataset");
668 ensure(unexecutable(
"all attributes opened, read, and closed"));
690 ensure(unexecutable(
"all attributes created, written, and closed"));
701 static const char result[] =
"toc_bounds";
718 #ifdef DIAGNOSTIC_OUTPUT 720 cout <<
"attributes_record_set::read_toc_bounds_attribute poset name: " <<
scaffold().
structure().
name() << endl;
728 if(ltoc_bounds_hdf_id >= 0)
732 hid_t ltoc_bounds_dataspace_hdf_id = H5Aget_space(ltoc_bounds_hdf_id);
733 if(ltoc_bounds_dataspace_hdf_id < 0)
735 post_fatal_error_message(
"Unable to get dof tuple toc_bounds attribute dataspace.");
738 hsize_t ltoc_bounds_ct;
739 lstatus = H5Sget_simple_extent_dims(ltoc_bounds_dataspace_hdf_id, <oc_bounds_ct, NULL);
742 post_fatal_error_message(
"Unable to get dof tuple toc_bounds attribute extent.");
755 lstatus = H5Aread(ltoc_bounds_hdf_id,
756 type_map().converter(POD_INDEX_TYPE)->internal_type(),
760 post_fatal_error_message(
"Unable to read dof tuple toc_bounds attribute.");
763 #ifdef DIAGNOSTIC_OUTPUT 764 cout <<
"attribute_record_set::read_toc_bounds_attribute toc_bounds:" 765 <<
" " << ltoc_bounds[0]
766 <<
" " << ltoc_bounds[1]
767 <<
" " << ltoc_bounds[2]
775 if(ltoc_bounds[0] == 1)
779 lmode = poset_bounds_descriptor::MEMBER_MEMBER;
785 lmode = poset_bounds_descriptor::SUBPOSET_MEMBER;
794 H5Sclose(ltoc_bounds_dataspace_hdf_id);
795 H5Aclose(ltoc_bounds_hdf_id);
802 post_fatal_error_message(
"Unable to open toc_bounds attribute");
821 require(
scaffold().row_bounds().lb_is_singleton() ?
822 scaffold().member_id_space().contains_hub(
scaffold().row_bounds().lb_id()) :
834 if(
scaffold().row_bounds().lb_is_singleton())
843 ltoc_bounds[1] = lext_lb_id;
849 post_fatal_error_message(
"Invalid lower bound for table of contents.");
866 ltoc_bounds[2] = TOP_INDEX;
868 #ifdef DIAGNOSTIC_OUTPUT 869 cout <<
"attribute_record_set::write_toc_bounds_attribute for poset: " 872 <<
" " << ltoc_bounds[0]
873 <<
" " << ltoc_bounds[1]
874 <<
" " << ltoc_bounds[2]
883 if(ltoc_bounds_hdf_id < 0)
889 hid_t ltoc_bounds_dataspace_hdf_id = H5Screate(H5S_SIMPLE);
890 if(ltoc_bounds_dataspace_hdf_id < 0)
892 post_fatal_error_message(
"Unable to create dof tuple toc_bounds attribute dataspace.");
897 lstatus = H5Sset_extent_simple(ltoc_bounds_dataspace_hdf_id, 1, &
TOC_BOUNDS_EXTENT, NULL);
900 post_fatal_error_message(
"Unable to set dof tuple toc_bounds attribute extent.");
906 ltoc_bounds_hdf_id = H5Acreate1(
_hdf_id,
908 type_map().converter(POD_INDEX_TYPE)->external_type(),
909 ltoc_bounds_dataspace_hdf_id,
912 if(ltoc_bounds_hdf_id < 0)
914 post_fatal_error_message(
"Unable to create dof tuple toc_bounds attribute.");
919 H5Sclose(ltoc_bounds_dataspace_hdf_id);
924 lstatus = H5Awrite(ltoc_bounds_hdf_id,
925 type_map().converter(POD_INDEX_TYPE)->internal_type(),
929 post_fatal_error_message(
"Unable to write dof tuple toc_bounds attribute.");
934 H5Aclose(ltoc_bounds_hdf_id);
938 ensure(unexecutable(
"all attributes created, written, and closed"));
An encapsulation of an HDF file containing sheaf data.
int _ext_dataspace_rank
The rank of the dataspace for the record_set.
hsize_t * _ext_dataspace_dims
The current dimensions of the external dataspace.
virtual void write_toc_bounds_attribute()
Writes the table of contents lower bound attribute into the file.
void externalize(hdf_buf_type *xhdf_buffer)
Converts the record from internal to external form.
std::string data_set_alias(const std::string &xname) const
The data set alias for a poset with name xname.
virtual ~attributes_record_set()
Destructor.
int record_buffer_ct() const
The number of active records in record buffer.
virtual void create_int_data_type()
Creates a new HDF internal data type.
int _record_buffer_ub
The maximum number of records the buffer can hold.
bool is_open() const
True if this record_set is open.
virtual const std::string & suffix() const
The name suffix for this data set.
void update_toc_bounds(const poset_bounds_descriptor &xdesc)
Replaces toc_bounds() with the bounds specified in descriptor xdesc.
virtual bool invariant() const
Class invariant.
virtual attributes_record_set * clone() const
Virtual constructor; makes a new instance of the same type as this.
hid_t int_data_type_hdf_id()
The HDF internal data type id for this record set.
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
std::string alias() const
The standard alias for this data set.
hid_t _hdf_id
The HDF id for this record set.
void internalize(hdf_buf_type *xhdf_buffer)
Converts the record from external to internal form.
attributes_record_set(const attributes_record_set &xother)
Copy constructor.
virtual bool invariant() const
Class invariant.
Abstract base class with useful features for all objects.
std::string _alias
The standard alias for this record_set.
hid_t _ext_data_type_hdf_id
The HDF external data type id for this record set.
specification_mode
Enumeration for mode of specifying the lower and upper bounds.
virtual void read_dataset_attributes()
Reads the dataset attribute objects from the file.
hid_t _int_data_type_hdf_id
The HDF internal data type id for this record set.
bool is_open() const
True if this file is open.
std::string _name
The name of this record_set.
hid_t hdf_id()
The HDF id for this record set.
int record_buffer_ub() const
The maximum number of records the buffer can hold.
An abstract, indexed collection of records on secondary storage.
std::string data_set_name(const std::string &xname) const
The data set name for a poset with name xname.
virtual void write_dataset_attributes()
Writes the dataset attribute objects into the file.
poset_bounds & row_bounds()
The bounds for the rows in this transaction (mutable version).
void internalize()
Internalize the record set from disk.
poset_scaffold & scaffold()
Scaffold for constructing poset associated with this record set (mutable version).
virtual std::string name() const
The name of this poset.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
static const hsize_t TOC_BOUNDS_EXTENT
The extent of the table of contents lower bound attribute dataspace.
poset_state_handle & structure()
The handle for the poset being transferred. (Name chosen to void name conflict with class poset...
member_index_space_type & member_id_space()
External to internal member index space for structure() (mutable version).
std::string name() const
The name of this data set.
A description of a (lower, upper) bounds pair for a poset. Specifies a portion of a poset for a bound...
A record set for storing various poset attributes.
void externalize()
Externalize the reccord set to disk.
subposet_index_space_type & subposet_id_space()
External to internal subposet index map for powerset() (mutable version).
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
bool invariant_check() const
True if invariant checking is enabled.
virtual void read_toc_bounds_attribute()
Reads the table of contents lower bound attribute into the file.
const sheaf_file & file() const
The file this record_set belongs to.
pod_index_type pod_type
The "plain old data" storage type for this.
int_type pod_index_type
The plain old data index type.
static const char * TOC_BOUNDS_ATTRIBUTE_NAME()
The name of the table of contents lower bound attribute.
poset_data_type_map & type_map()
Data type map for records in this record set (mutable version)
A poset specific collection of data converters, various buffers and other data used while transferrin...
pod_index_type lb_id() const
The index of the lower bound member, if the lower bound contains a single member. ...
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
bool is_same_type(const any *other) const
True if other is the same type as this.
hid_t _ext_dataspace_hdf_id
The HDF id for the external dataspace of this record set.
void enable_invariant_check() const
Enable invariant checking.
int _record_buffer_ct
The number of active records in record buffer.
hid_t _int_dataspace_hdf_id
The hdf5 id of the dataspace associated with the record buffer.
virtual hid_t create_dataset()
Creates the HDF dataset associated with this.