20 #include "SheafSystem/member_record_set.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/biorder_itr.h" 24 #include "SheafSystem/data_converter.h" 25 #include "SheafSystem/error_message.h" 26 #include "SheafSystem/implicit_crg_interval.h" 27 #include "SheafSystem/index_space_iterator.h" 28 #include "SheafSystem/interval_index_space_state.h" 29 #include "SheafSystem/preorder_itr.h" 30 #include "SheafSystem/sheaf_file.h" 31 #include "SheafSystem/std_unordered_set.h" 32 #include "SheafSystem/std_string.h" 33 #include "SheafSystem/std_sstream.h" 34 #include "SheafSystem/std_iostream.h" 35 #include "SheafSystem/std_sstream.h" 47 const int DATASPACE_RANK = 1;
72 ensure(is_same_type(result));
93 result = result && record_set::invariant();
99 disable_invariant_check();
101 invariance(is_open() ? _ext_dataspace_rank == DATASPACE_RANK :
true);
105 enable_invariant_check();
145 int xrecord_buffer_ub,
148 :
record_set(xfile, xrecord_buffer_ub, xscaffold),
152 _id_space_record(*this)
158 require(xrecord_buffer_ub > 0);
159 require(
scaffold().structure().state_is_read_accessible());
169 stringstream linterval_id_space_str;
170 linterval_id_space_str << _record_id_space.
name() <<
"_interval";
171 linterval_id_space_str >> _interval_id_space_name;
175 _interval_id_space_name,
192 hvl_t* ltmp = _hdf_bufs+i;
215 _record(xother._record),
216 _scaffold(xother._scaffold),
217 _dof_tuple_records(xother._dof_tuple_records),
218 _id_space_record(xother._id_space_record),
219 _record_id_space(xother._record_id_space),
220 _interval_id_space_name(xother._interval_id_space_name),
221 _interval_id_space(xother._interval_id_space)
245 delete [] _hdf_selection;
277 static const string result(
".members");
298 require(
scaffold().structure().state_is_read_write_accessible());
302 #ifdef DIAGNOSTIC_OUTPUT 303 cout << endl << endl <<
"member_record_set::internalize: internalizing record set " <<
name() << endl;
314 read_id_space_record(_record_id_space, record_id_space_record());
315 read_id_space_record(_interval_id_space, interval_id_space_record());
403 while(!litr.is_done())
406 #ifdef DIAGNOSTIC_OUTPUT 407 cout <<
"member_record_set::internalize: internalizing member: " << litr.index()
408 <<
" is_resident= " << boolalpha << lresident_sp.
contains_member(litr.index()) << noboolalpha
423 if(lhub_pod == linterval_begin)
427 read_member(litr.index(), lext_id);
431 set<pod_index_type> ldown_set;
433 lmax_row_mbr.host()->crg().explicit_down_set_members(*linterval, ldown_set);
435 set<pod_index_type>::const_iterator litr;
436 for(litr = ldown_set.begin(); litr != ldown_set.end(); ++litr)
444 read_member(lmbr_id, lext_id);
461 read_member(litr.index(), lext_id);
487 clean_upper_covers();
509 require(
scaffold().structure().state_is_read_write_accessible());
531 require(
scaffold().structure().state_is_read_accessible());
532 require(!
record().has_equivalence_iterator());
536 #ifdef DIAGNOSTIC_OUTPUT 537 cout << endl << endl <<
"externalizing record set " <<
name() << endl;
553 lmax_row_mbr->
put_version(COARSEST_COMMON_REFINEMENT_VERSION);
561 make_idorder_file_id_spaces(*lmax_row_mbr);
565 write_id_space_record(_record_id_space, record_id_space_record());
566 write_id_space_record(_interval_id_space, interval_id_space_record());
580 lext_id = litr.
pod();
609 write_record_buffer();
622 write_record_buffer();
637 ensure(!
record().has_equivalence_iterator());
651 require(
scaffold().structure().state_is_read_accessible());
652 require(!
record().has_equivalence_iterator());
661 ensure(!
record().has_equivalence_iterator());
672 return _dof_tuple_records;
687 static const pod_index_type result = interval_id_space_record() + 1;
704 require(
file().mode() == sheaf_file::READ_WRITE);
713 hsize_t linit_dims[DATASPACE_RANK];
719 hsize_t lmax_dims[DATASPACE_RANK];
720 lmax_dims[0] = H5S_UNLIMITED;
725 post_fatal_error_message(
"can't create exterior dataspace");
731 hsize_t lchunk_dims[DATASPACE_RANK];
736 hid_t lparms = H5Pcreate(H5P_DATASET_CREATE);
737 herr_t status = H5Pset_chunk( lparms, DATASPACE_RANK, lchunk_dims);
740 post_fatal_error_message(
"can't set chunk size");
754 post_fatal_error_message(
"Unable to create dataset.");
780 H5Tvlen_create(
type_map().converter(POD_INDEX_TYPE)->internal_type());
784 post_fatal_error_message(
"Can't create internal data type");
831 lmbr_id = _record_id_space.
hub_pod(_hdf_selection[i][0]);
836 hvl_t* lhdf_buf = _hdf_bufs+i;
838 #ifdef DIAGNOSTIC_OUTPUT 839 cout <<
"member_record_set::read_record: record: " << _hdf_selection[i][0]
840 <<
" member id: " << lmbr_id
841 <<
" buf len: " << lhdf_buf->len
848 assertion(lhdf_buf->len > 0);
855 delete_hdf_buffers();
893 const hsize_t* lselect = &(_hdf_selection[0][0]);
898 post_fatal_error_message(
"can't set member record read selection");
907 post_fatal_error_message(
"can't read member record selection");
937 hsize_t ldims[DATASPACE_RANK];
949 const hsize_t* lselect = &(_hdf_selection[0][0]);
954 post_fatal_error_message(
"can't set member record write selection");
963 post_fatal_error_message(
"can't write member record selection");
993 hsize_t linit_dims[DATASPACE_RANK];
999 post_fatal_error_message(
"can't create interior data space");
1018 sheaf::member_record_set::
1019 delete_external_buffers()
1027 hvl_t* ltmp = _hdf_bufs+i;
1030 delete []
reinterpret_cast<int*
>(ltmp->p);
1049 sheaf::member_record_set::
1050 delete_hdf_buffers()
1058 H5P_DEFAULT, _hdf_bufs);
1061 post_fatal_error_message(
"can't delete hdf buffers");
1070 hvl_t* lbuf = _hdf_bufs;
1072 while(lbuf < lbuf_ub)
1094 sheaf::member_record_set::
1095 write_record_buffer()
1104 #ifdef DIAGNOSTIC_OUTPUT 1105 cout <<
"member_record_set::write_record_buffer" << endl;
1106 cout <<
"\twriting member_record buffer for dataset " <<
name() << endl;
1110 delete_external_buffers();
1123 sheaf::member_record_set::
1124 clean_upper_covers()
1157 sheaf::member_record_set::
1158 record_id_space_record()
1166 sheaf::member_record_set::
1167 interval_id_space_record()
1175 sheaf::member_record_set::
1191 _id_space_record.
externalize(lhdf_buf, xid_space);
1213 sheaf::member_record_set::
1242 hvl_t* lhdf_buf = _hdf_bufs+i;
1244 #ifdef DIAGNOSTIC_OUTPUT 1245 cout <<
"member_record_set::read_id_space_record: record: " << _hdf_selection[i][0]
1246 <<
" buf len: " << lhdf_buf->len
1253 _id_space_record.
internalize(lhdf_buf, xid_space);
1258 delete_hdf_buffers();
1273 sheaf::member_record_set::
1283 if(xext_id.is_valid())
1315 sheaf::member_record_set::
1320 require(
record().has_equivalence_iterator());
1324 #ifdef DIAGNOSTIC_OUTPUT 1325 cout <<
"make_id_order_file_id_spaces for " << xmbr.
host()->
name() << endl;
1335 _interval_id_space.
clear();
1337 set<pod_index_type> ldown_set;
1350 ldown_set.insert(lhub_pod);
1370 ldown_set.insert(lhub_pod);
1383 ldown_set.insert(BOTTOM_INDEX);
1388 set<pod_index_type>::iterator litr = ldown_set.begin();
1390 while(litr != ldown_set.end())
1395 _record_id_space.
insert(lext_id_pod, *litr);
1423 #ifdef DIAGNOSTIC_OUTPUT 1424 cout <<
"inserting interval map interval: " 1435 #ifdef DIAGNOSTIC_OUTPUT 1436 cout <<
"id: " << lint_id <<
" linterval:" << linterval;
1447 #ifdef DIAGNOSTIC_OUTPUT 1448 cout << xmbr.
host()->
name() <<
" file id space:" << endl;
1450 cout << _record_id_space << endl;
1451 cout << endl <<
"interval id space:" << endl;
1453 cout << _interval_id_space << endl;
An implementation of class scattered_insertion_index_space_handle that has a interval id space state...
An encapsulation of an HDF file containing sheaf data.
virtual void put_version(int xversion, bool xunalias=false)
Sets version to (possibly aliased) xversion. If unalias == true, set version to the actual version al...
int _ext_dataspace_rank
The rank of the dataspace for the record_set.
poset_state_handle * host() const
The poset which this is a handle to a component of.
A client handle for a subposet.
void delete_equivalence_iterator()
Destroy the equivalence iterator.
hsize_t * _ext_dataspace_dims
The current dimensions of the external dataspace.
void reset_record_buffer_ct()
The set the number of active records in record buffer to 0.
The data structure representing the cover relation graph of a poset.
bool is_done() const
True if iteration finished.
bool record_buffer_is_full() const
True if there are no inactive records in the buffer.
virtual void attach_to(pod_type xindex)
Attach to the state with index xindex in the id space family id_spaces().
abstract_poset_member & top()
The top member of the poset (mutable version)
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
An abstract iterator over the ids of an id space.
std::string data_set_alias(const std::string &xname) const
The data set alias for a poset with name xname.
member_record_set(const sheaf_file &xfile, int xbuffer_ub, const poset_scaffold &xscaffold, const dof_tuple_record_set &xdof_tuple_records)
Creates an instance attached to the record_set with name xname in the file xfile, using record packet...
implicit_crg_interval * implicit_member(pod_index_type xid) const
The implicit interval for the member with index xid. Returns null, if no implicit interval exists...
pod_type pod() const
The current id in the iteration.
void read_record(const record_index &xext_id)
Read and internalizes all the records.
virtual bool invariant() const
Class invariant.
virtual ~member_record_set()
Destructor.
A client handle for a general, abstract partially order set.
int record_buffer_ct() const
The number of active records in record buffer.
void extend_dataset(const hsize_t *xdims, int xdims_ub)
Extends the dataset dimensions to at least the dimensions given xdims, an array of length xdims_ub...
const scoped_index & index() const
The current item in the subset.
void explicit_down_set_members(const implicit_crg_interval &xinterval, std::set< pod_index_type > &result) const
The explicit members in the downset of the interval xinterval.
void internalize(hvl_t *xhdf_buffer, interval_index_space_handle &xid_space)
Converts the record from external to internal form.
const index_space_family & member_id_spaces(bool xauto_access) const
Collection of member id spaces for this (const version).
void clear()
Delete all ids.
virtual bool contains_member(pod_index_type xmbr_hub_id) const
True if this poset contains poset member with hub id xmbr_hub_id.
int _record_buffer_ub
The maximum number of records the buffer can hold.
bool record_buffer_is_empty() const
True if there are no active records in the buffer.
bool is_open() const
True if this record_set is open.
const member_record & record() const
The current member record.
pod_index_type begin() const
The beginning of the member interval; this emulates members in the interval [begin(), end()), includes interval member.
void new_equivalence_iterator()
Create the equivalence iterator.
virtual void next()=0
Makes id() the next id in the iteration.
void clear_cover(bool xlower)
Clears the lower (xlower true) or upper (xlower false) cover set of this.
abstract_poset_member & bottom()
The bottom member of the poset (mutable version)
dof_tuple_record_set & dof_tuple_records()
The dof tuple record set associated with this.
implicit_crg_interval * interval() const
The implicit interval object for the current member, if any.
const hub_index_space_handle & hub_id_space() const
The hub id space.
virtual index_space_iterator & get_iterator() const
Allocates an id space iterator from the iterator pool.
hid_t int_data_type_hdf_id()
The HDF internal data type id for this record set.
virtual hid_t create_dataset()
Creates the HDF dataset associated with this.
std::string alias() const
The standard alias for this data set.
Abstract implementation of crg_interval for an interval of implicit cover relation graph members...
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
void next()
Makes item the next member of the subset.
const scoped_index & index() const
The index of the current member of the iteration.
void write_selection()
Write the records specified by the selection into the file.
hid_t _hdf_id
The HDF id for this record set.
pod_type interval_begin(const scoped_index &xid) const
The beginning of the interval containing xid.hub_pod(). synonym for internval_begin(xid.hub_pod()).
Abstract base class with useful features for all objects.
std::string _alias
The standard alias for this record_set.
A record_set containing records of type member_record.
hid_t _ext_data_type_hdf_id
The HDF external data type id for this record set.
A record buffer for transferring member data between the kernel and the i/o subsystem.
const bool NOT_STRICT
Iteration strictness control.
const bool DOWN
Iteration directions.
virtual member_record_set * clone() const
Virtual constructor; makes a new instance of the same type as this.
bool is_done() const
True if iteration is finished.
hid_t _int_data_type_hdf_id
The HDF internal data type id for this record set.
pod_index_type end() const
The end of the member interval.
void insert_interval(pod_type xbegin, pod_type xend, const scoped_index &xhub_begin, const scoped_index &xhub_end)
Make the closed interval [xbegin, xend] equivalent to [xbegin.hub_pod(), xhub_end.hub_pod()]. synonym for insert_interval(xbegin, xend, xhub_begin.hub_pod(), xhub_end.hub_pod()).
bool is_open() const
True if this file is open.
size_type external_size(const scoped_index &xmbr_id)
The size of the member record in external form.
void externalize(const scoped_index &xmbr_id, hvl_t *xhdf_buffer)
Converts the record from internal to external form.
std::string name() const
Name of this space.
std::string _name
The name of this record_set.
void initialize_dof_tuple_id_space()
Initializes dof_tuple_id_space().
hid_t hdf_id()
The HDF id for this record set.
pod_index_type interval_member() const
The index of the interval member itself; synonym for begin().
An index within the external ("client") scope of a given id space.
int record_buffer_ub() const
The maximum number of records the buffer can hold.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
virtual void insert_member(pod_index_type xmbr_hub_id)
Inserts the member of host() with hub id xmbr_hub_id.
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.
void internalize(pod_index_type xmax_row_int_id)
Internalize the members of scafold().structure() from disk.
virtual void create_int_data_type()
Creates a new HDF internal data type.
virtual bool contains_member(pod_index_type xmbr_hub_id, bool xauto_access=true) const
True if some version of this poset contains poset member with hub id xmbr_hub_id. ...
const bool UPPER
Selector for upper cover.
void insert(pod_type xid, const scoped_index &xhub_id)
Make id xid in this id space equivalent to xhub_id in the hub id space. synonym for insert(xid...
virtual void begin_jim_edit_mode(bool xauto_access=true)
Allow editing of jims and jim order relation.
poset_scaffold & scaffold()
Scaffold for constructing poset associated with this record set (mutable version).
virtual std::string name() const
The name of this poset.
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
virtual const scoped_index & hub_id() const
A id in the hub id space for components of this type; intended for copying to initialize ids to the h...
abstract_poset_member * clone(bool xnew_state, bool xauto_access=true) const
Virtual constructor; makes a new handle of the same type as this, attached to a new state (xnew_state...
A record_set which contains dof tuple records. Supports both record selection and record restriction ...
poset_state_handle & structure()
The handle for the poset being transferred. (Name chosen to void name conflict with class poset...
void externalize(hvl_t *xhdf_buffer, const interval_index_space_handle &xid_space)
Converts the record from internal to external form.
void delete_space(pod_type xid)
Delete the id space with index xid.
member_index_space_type & member_id_space()
External to internal member index space for structure() (mutable version).
Iterates over the subset of Zn defined by the characteristic function host().
virtual void detach_from_state()
Detach this handle from its state, if any.
std::string name() const
The name of this data set.
pod_type hub_pod(pod_type xid) const
The pod index in the unglued hub id space equivalent to xid in this id space; synonym for unglued_hub...
void next()
Makes this the next member of the subset.
poset_crg_state & crg() const
The cover relation graph.
void inc_record_buffer_ct()
The increment the number of active records in record buffer.
const sheaf_file & file() const
The file this record_set belongs to.
int_type pod_index_type
The plain old data index type.
bool is_done() const
True if iteration finished.
poset_data_type_map & type_map()
Data type map for records in this record set (mutable version)
void externalize(pod_index_type xmax_row_int_id)
Externalize the members of scafold().structure() to disk.
virtual pod_type end() const
Ending id of this space.
A poset specific collection of data converters, various buffers and other data used while transferrin...
virtual void end_jim_edit_mode(bool xensure_lattice_invariant=true, bool xauto_access=true)
Prevent editing of jims and jim order relation.
void attach_to_state(const namespace_poset *xns, const poset_path &xpath, bool xauto_access=true)
Attach to the state specified by path xpath in the namespace xns.
virtual void release_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
void make_internal_dataspace()
Create the internal dataspace.
virtual void get_read_access() const
Get read access to the state associated with this.
An abstract client handle for a member of a poset.
subposet & resident()
The resident subposet for structure() (mutable version).
void read_selection()
Read the records specified by the selection into the record buffer.
index_iterator member_iterator() const
void internalize(hvl_t *xhdf_buffer, const scoped_index &xmbr_id)
Converts the record from external to internal form.
void clean_cover(bool xlower, pod_index_type xmbr_index)
Removes members of the cover that are no longer members of the crg.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
void truncate()
Makes this the next member of the subset which is not less than old this, i.e. the depth-first descen...
hid_t _ext_dataspace_hdf_id
The HDF id for the external dataspace of this record set.
virtual const std::string & suffix() const
The name suffix for this data set.
Specialization of the filtered depth-first iterator which exposes the PREVISIT_ACTION to the client...
static pod_index_type first_member_record()
The first record used for members; the record following the id space records.
int _record_buffer_ct
The number of active records in record buffer.
static interval_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent, bool xmerge_mode)
Create a new interval id space in the id space family xid_space with name xname, persistence xis_pers...
hid_t _int_dataspace_hdf_id
The hdf5 id of the dataspace associated with the record buffer.
virtual const scoped_index & member_id(bool xauto_access) const
An id in the member hub id space; intended for copying to initialize ids to the member id space...
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
bool is_resident() const
True if and only if member represented by this record is fully resident after read.
void print_map_rep(std::ostream &xos) const
Inserts the map representation into ostream xos.