SheafSystem  0.0.0.0
sheaf::storage_agent Class Reference

Agent responsible for importing and exporting posets from an external name space which resides on disk. More...

#include <storage_agent.h>

Inheritance diagram for sheaf::storage_agent:
sheaf::any

Classes

class  transaction
 A transaction entity. More...
 

Public Types

enum  transaction_type { READ, WRITE, READ_WRITE }
 Type of access associated with a transaction. More...
 

Public Member Functions

 storage_agent ()
 Default constructor. More...
 
 storage_agent (const storage_agent &xother)
 Copy constructor. More...
 
virtual storage_agentclone () const
 Virtual constructor; makes a new instance of the same type as this. More...
 
virtual ~storage_agent ()
 Destructor. More...
 
virtual bool invariant () const
 Class invariant. More...
 
virtual bool is_ancestor_of (const any *other) const
 Conformance test; true if other conforms to this. More...
 
 storage_agent (const std::string &xfile_name, sheaf_file::access_mode xmode=sheaf_file::READ_WRITE, bool xclobber=true, bool xenable_error_report=false)
 Creates a storage_agent attached to the file with name xfile_name. Locks the file against deletion, but does not prevent access to the file by other processes. More...
 
sheaf_filefile ()
 The file this is attached to. More...
 
const sheaf_filefile () const
 The file this is attached to. More...
 
bool file_is_read_accessible () const
 True if file is open. More...
 
bool file_is_read_only_accessible () const
 True if file is open with READ_ONLY access. More...
 
bool file_is_read_write_accessible () const
 True if file is open with READ_WRITE. More...
 
const std::string & file_id_space_name () const
 The name of the id spaces associated with this file in each poset. More...
 
void reset_time ()
 Reset the start time. Set the start time to the CPU time when this function is called. More...
 
clock_t time () const
 Return the CPU time between when reset_time() was last called and when this function is called. More...
 
void read_entire (namespace_poset &xns)
 Reads the namespace xns and all the posets in it. More...
 
void read_remainder (namespace_poset &xns)
 Reads all members of the namespace that have not already been read. More...
 
void read (namespace_poset &xns)
 Reads the namespace xns. More...
 
void write (namespace_poset &xns)
 Writes the namespace xns. More...
 
void write_entire (namespace_poset &xns)
 Writes the namespace xns and all the posets in it. Rewrites any posets that have already been written. More...
 
void write_remainder (const namespace_poset &xns)
 Writes all the posets in namespace xns that have not already been written. More...
 
void read (poset_state_handle &xposet, const poset_bounds_descriptor &xrow_bounds=poset_bounds_descriptor::BOTTOM_TOP, const poset_bounds_descriptor &xcol_bounds=poset_bounds_descriptor::BOTTOM_TOP)
 Reads the portion of poset xposet specified by the row bounds xrow_bounds and the column bounds xcol_bounds. More...
 
void read_toc (poset_state_handle &xposet)
 Reads the table of contents portion of poset xposet. More...
 
void read_index (poset_state_handle &xposet)
 Reads the index of poset xposet; that is, it does not read the dof tuples. More...
 
void read_row_decomposition (poset_state_handle &xposet, const scoped_index &xdecomp_id)
 Reads poset xposet using the row decomposition identified by index xdecomp_id. More...
 
void write (poset_state_handle &xposet, const poset_bounds_descriptor &xrow_bounds=poset_bounds_descriptor::BOTTOM_TOP, const poset_bounds_descriptor &xcol_bounds=poset_bounds_descriptor::BOTTOM_TOP, bool xretain_read_access=false)
 Executes an independent write-only transaction for the portion of poset xposet defined by the down sets of max_row_member_index and max_col_member_index. If xdownset_filter !=0, deletes the members of the downset of the upper bound, filtered by xdownset_filter. More...
 
void write_toc (poset_state_handle &xposet, const scoped_index &xtoc_id)
 Writes the portion of poset xposet between the lower bound specified by the subposet with index xtoc_id and upper bound top. Registers xtoc_id as lower bounds of the table of the contents. More...
 
void write_row_decomposition (poset_state_handle &xposet, const scoped_index &xdecomp_id)
 Writes poset xposet using the row decomposition identified by index xdecomp_id. More...
 
void write_col_decomposition (poset_state_handle &xposet, const scoped_index &xrow_id, const scoped_index &xdecomp_id)
 Writes the member identified by xrow_id in poset xposet using the column decomposition identified by index xdecomp_id. More...
 
void write_dof_tuple (const abstract_poset_member &xmbr, const scoped_index &xcol_ub_id, const scoped_index &xdecomp_id)
 Writes the portion of the dof tuple of member xmbr which is in the downset of the schema member identified by xcol_ub_id, which must be a member of column decomposition xdecomp_id. More...
 
void commit_dof_tuple_transaction (const abstract_poset_member &xmbr, const scoped_index &xcol_ub_id, const scoped_index &xdecomp_id)
 Commits the dof tuple transaction associated with xmbr. More...
 
void begin_read_transaction (namespace_poset &xns)
 Begins an independent read transaction for the namespace xposet. More...
 
void begin_read_transaction (poset_state_handle &xposet, const poset_bounds_descriptor &xrow_bounds=poset_bounds_descriptor::BOTTOM_TOP, const poset_bounds_descriptor &xcol_bounds=poset_bounds_descriptor::BOTTOM_TOP)
 Begins an independent read transaction for the portion of poset xposet defined by the down sets of max_row_member_index and max_col_member_index. More...
 
void begin_read_write_transaction (poset_state_handle &xposet, const poset_bounds_descriptor &xrow_bounds=poset_bounds_descriptor::BOTTOM_TOP, const poset_bounds_descriptor &xcol_bounds=poset_bounds_descriptor::BOTTOM_TOP)
 Begins an independent read-write transaction for the portion of poset xposet defined by the down sets of max_row_member_index and max_col_member_index. Initialize the uncommited (internal) copy from the committed (external) copy of the poset state. More...
 
void begin_write_transaction (namespace_poset &xns)
 Begins an independent write transaction for the namespace xns. More...
 
void begin_write_transaction (const poset_state_handle &xposet, const poset_bounds_descriptor &xrow_bounds=poset_bounds_descriptor::BOTTOM_TOP, const poset_bounds_descriptor &xcol_bounds=poset_bounds_descriptor::BOTTOM_TOP)
 Begins an independent write-only transaction for the portion of poset xposet defined by the down sets of max_row_member_index and max_col_member_index. More...
 
void commit_transaction (poset_state_handle &xposet)
 Commits the uncommitted state, but does not end the transaction or release read access. More...
 
void end_transaction (poset_state_handle &xposet, bool xcommit=true)
 Ends an independent access transaction. More...
 
int member_record_buffer_ub () const
 The number of records allocated in a member record buffer during a transaction. More...
 
void put_member_record_buffer_ub (int xub)
 Sets the number of records allocated in a member record buffer during a transaction. More...
 
size_t dof_tuple_record_size () const
 OBSOLETE: no longer used. The number of bytes in a dof tuple record The dof tuple records are now automatically sized as follows. For ordinary posets, each record holds an entire dof tuple. For section spaces, each record holds an instance of the fiber type. More...
 
void put_dof_tuple_record_size (size_t xsize)
 OBSOLETE: no longer used. Sets the number of bytes in a dof_tuple record. More...
 
int dof_tuple_record_buffer_ub () const
 The number of records allocated in a dof_tuple record buffer during a transaction. Equal to the HDF chunk size. More...
 
void put_dof_tuple_record_buffer_ub (int xub)
 Sets the number of records allocated in a dof_tuple record buffer during a transaction and hence the HDF chunk size. More...
 
int transaction_ct () const
 The number of active transactions. More...
 
bool transaction_is_active (pod_index_type xindex) const
 True if either a read or write transaction is active for poset with index xindex. More...
 
bool transaction_is_active (const poset_state_handle &xposet) const
 True if either a read or write transaction is active for poset xposet. More...
 
bool read_transaction_is_active (const poset_state_handle &xposet) const
 True if there is an active read transaction for poset xposet. More...
 
bool write_transaction_is_active (const poset_state_handle &xposet) const
 True if there is an active write transaction involving the poset with name space index xindex. More...
 
bool read_write_transaction_is_active (poset_state_handle &xposet) const
 True if both a read-write transaction is active. More...
 
bool state_is_consistent (const poset_state_handle &xposet) const
 True if uncommitted state is consistent with committed state. More...
 
- Public Member Functions inherited from sheaf::any
bool is_same_type (const any *other) const
 True if other is the same type as this. More...
 
virtual ~any ()
 Destructor. More...
 
bool invariant_check () const
 True if invariant checking is enabled. More...
 
void enable_invariant_check () const
 Enable invariant checking. More...
 
void disable_invariant_check () const
 Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing invariant checking during multi-phase initialization. More...
 
int disable_invariance_check_request_depth () const
 Number of times disable_invariant_check has been called without matching call to enable_invariant_check. More...
 

Static Public Attributes

static const bool COMMIT = true
 Value to indicate transaction should be committed. More...
 
static const bool ABORT = false
 Value to indicate transaction should not be committed. More...
 
static const bool RETAIN_READ = true
 Value to indicate read access should be retained. More...
 
static const bool RELEASE_ALL = false
 Value to indicate read access should not be retained. More...
 

Protected Member Functions

void put_state_is_consistent (poset_state_handle &xposet)
 Sets the state_is_consistent flag for xposet to true. More...
 
void read_prerequisites (const poset_state_handle &xposet, const poset_bounds_descriptor &xcol_bounds)
 Reads all posets that xposet depends on. More...
 
void write_prerequisites (const poset_scaffold &xscaffold)
 Writes all posets that xposet depends on. More...
 
void initialize_poset_id_spaces_for_write (poset_state_handle &xposet)
 Initializes the subposet and dof tuple index spaces for poset xposet. More...
 
void initialize_namespace_id_spaces_for_read (namespace_poset &xposet)
 Ensures that the namespace and its standard posets have an empty index space for members and no index space for dof tuples. More...
 
void initialize_namespace_id_spaces_for_write (namespace_poset &xposet)
 Ensures that the namespace and its standard posets have an empty index space for members and no index space for dof tuples. More...
 
void clear_all_id_spaces (namespace_poset &xns)
 Clears all dof tuple index spaces. More...
 
- Protected Member Functions inherited from sheaf::any
 any ()
 default constructor More...
 

Friends

class poset_scaffold
 
class dof_tuple_record_set
 

Detailed Description

Agent responsible for importing and exporting posets from an external name space which resides on disk.

Definition at line 74 of file storage_agent.h.

Member Enumeration Documentation

◆ transaction_type

Type of access associated with a transaction.

Definition at line 466 of file storage_agent.h.

Constructor & Destructor Documentation

◆ storage_agent() [1/3]

sheaf::storage_agent::storage_agent ( )

Default constructor.

Postcondition

Definition at line 81 of file storage_agent.cc.

Referenced by is_ancestor_of().

◆ storage_agent() [2/3]

sheaf::storage_agent::storage_agent ( const storage_agent xother)

Copy constructor.

Not Implemented.

Postcondition

Definition at line 117 of file storage_agent.cc.

References clone().

◆ ~storage_agent()

sheaf::storage_agent::~storage_agent ( )
virtual

Destructor.

Definition at line 162 of file storage_agent.cc.

References invariant().

Referenced by clone().

◆ storage_agent() [3/3]

sheaf::storage_agent::storage_agent ( const std::string &  xfile_name,
sheaf_file::access_mode  xmode = sheaf_file::READ_WRITE,
bool  xclobber = true,
bool  xenable_error_report = false 
)

Creates a storage_agent attached to the file with name xfile_name. Locks the file against deletion, but does not prevent access to the file by other processes.

Precondition
  • !xfile_name.empty()
  • xfile_name.substr(xfile_name.size() - 4) == ".hdf"
Postcondition

Definition at line 249 of file storage_agent.cc.

References file().

Member Function Documentation

◆ begin_read_transaction() [1/2]

◆ begin_read_transaction() [2/2]

void sheaf::storage_agent::begin_read_transaction ( poset_state_handle xposet,
const poset_bounds_descriptor xrow_bounds = poset_bounds_descriptor::BOTTOM_TOP,
const poset_bounds_descriptor xcol_bounds = poset_bounds_descriptor::BOTTOM_TOP 
)

◆ begin_read_write_transaction()

void sheaf::storage_agent::begin_read_write_transaction ( poset_state_handle xposet,
const poset_bounds_descriptor xrow_bounds = poset_bounds_descriptor::BOTTOM_TOP,
const poset_bounds_descriptor xcol_bounds = poset_bounds_descriptor::BOTTOM_TOP 
)

Begins an independent read-write transaction for the portion of poset xposet defined by the down sets of max_row_member_index and max_col_member_index. Initialize the uncommited (internal) copy from the committed (external) copy of the poset state.

Precondition
  • !transaction_is_active(xposet)
Postcondition
  • read_transaction_is_active(xposet)
  • write_transaction_is_active(xposet)

Definition at line 1433 of file storage_agent.cc.

References begin_write_transaction().

Referenced by begin_read_transaction().

◆ begin_write_transaction() [1/2]

void sheaf::storage_agent::begin_write_transaction ( namespace_poset xns)

Begins an independent write transaction for the namespace xns.

Precondition
  • xns.state_is_read_write_accessible()
  • !transaction_is_active(xns)
Postcondition
  • write_transaction_is_active(xns)

Definition at line 1470 of file storage_agent.cc.

References sheaf::read_write_monitor_handle::state_is_read_write_accessible().

Referenced by begin_read_write_transaction().

◆ begin_write_transaction() [2/2]

void sheaf::storage_agent::begin_write_transaction ( const poset_state_handle xposet,
const poset_bounds_descriptor xrow_bounds = poset_bounds_descriptor::BOTTOM_TOP,
const poset_bounds_descriptor xcol_bounds = poset_bounds_descriptor::BOTTOM_TOP 
)

Begins an independent write-only transaction for the portion of poset xposet defined by the down sets of max_row_member_index and max_col_member_index.

Precondition
  • xposet.is_attached()
  • xposet.state_is_read_accessible()
  • !transaction_is_active(xposet)
  • xcol_bounds.ub_member_is_not_top() ? xposet.schema().ge(xcol_bounds.ub_id()) : true
Postcondition
  • write_transaction_is_active(xposet)

Definition at line 1502 of file storage_agent.cc.

References commit_transaction(), sheaf::abstract_poset_member::ge(), sheaf::poset_state_handle::is_attached(), sheaf::poset_state_handle::schema(), sheaf::read_write_monitor_handle::state_is_read_accessible(), sheaf::poset_bounds_descriptor::ub_id(), and sheaf::poset_bounds_descriptor::ub_member_is_not_top().

◆ clear_all_id_spaces()

◆ clone()

sheaf::storage_agent * sheaf::storage_agent::clone ( ) const
virtual

Virtual constructor; makes a new instance of the same type as this.

Not Implemented.

Postcondition
  • result != 0
  • is_same_type(result)

Reimplemented from sheaf::any.

Definition at line 136 of file storage_agent.cc.

References ~storage_agent().

Referenced by storage_agent().

◆ commit_dof_tuple_transaction()

◆ commit_transaction()

void sheaf::storage_agent::commit_transaction ( poset_state_handle xposet)

Commits the uncommitted state, but does not end the transaction or release read access.

Precondition
  • write_transaction_is_active(xposet)
Issue:
Should really be read-write accessible so that the new id space functions can require write access. However, writing only requires read access in general.
Precondition
  • xposet.state_is_read_accessible()
Postcondition
  • write_transaction_is_active(xposet)
  • state_is_consistent(xposet)

Definition at line 1536 of file storage_agent.cc.

References sheaf::poset_state_handle::bound_iterator(), sheaf::record_set::close(), end_transaction(), sheaf::poset_scaffold::evaluate_toc_alias(), sheaf::dof_tuple_record_set::externalize(), sheaf::member_record_set::externalize(), sheaf::attributes_record_set::externalize(), sheaf::poset_scaffold::get_member_names_from_poset(), sheaf::index_iterator::index(), sheaf::index_iterator::is_done(), sheaf::poset_state_handle::name(), sheaf::index_iterator::next(), sheaf::dof_tuple_record_set::open(), sheaf::record_set::open(), sheaf::poset_scaffold::row_bounds(), and sheaf::read_write_monitor_handle::state_is_read_accessible().

Referenced by begin_write_transaction().

◆ dof_tuple_record_buffer_ub()

int sheaf::storage_agent::dof_tuple_record_buffer_ub ( ) const

The number of records allocated in a dof_tuple record buffer during a transaction. Equal to the HDF chunk size.

Definition at line 1754 of file storage_agent.cc.

References put_dof_tuple_record_buffer_ub().

Referenced by put_dof_tuple_record_size().

◆ dof_tuple_record_size()

size_t sheaf::storage_agent::dof_tuple_record_size ( ) const

OBSOLETE: no longer used. The number of bytes in a dof tuple record The dof tuple records are now automatically sized as follows. For ordinary posets, each record holds an entire dof tuple. For section spaces, each record holds an instance of the fiber type.

Definition at line 1726 of file storage_agent.cc.

References put_dof_tuple_record_size().

Referenced by put_member_record_buffer_ub().

◆ end_transaction()

void sheaf::storage_agent::end_transaction ( poset_state_handle xposet,
bool  xcommit = true 
)

Ends an independent access transaction.

Precondition
  • transaction_is_active(xposet)
  • xcommit ? write_transaction_is_active(xposet) : true
Postcondition
  • !transaction_is_active(xposet)
  • xcommit ? state_is_consistent(xposet) : true
  • xposet.access_request_depth() == old_access_request_depth

Definition at line 1654 of file storage_agent.cc.

References sheaf::read_write_monitor_handle::access_request_depth(), and member_record_buffer_ub().

Referenced by commit_transaction().

◆ file() [1/2]

sheaf::sheaf_file & sheaf::storage_agent::file ( )

The file this is attached to.

Definition at line 307 of file storage_agent.cc.

Referenced by storage_agent().

◆ file() [2/2]

const sheaf::sheaf_file & sheaf::storage_agent::file ( ) const

The file this is attached to.

Definition at line 317 of file storage_agent.cc.

References file_is_read_accessible().

◆ file_id_space_name()

const std::string & sheaf::storage_agent::file_id_space_name ( ) const

The name of the id spaces associated with this file in each poset.

Definition at line 396 of file storage_agent.cc.

References reset_time().

Referenced by file_is_read_write_accessible().

◆ file_is_read_accessible()

bool sheaf::storage_agent::file_is_read_accessible ( ) const

True if file is open.

Postcondition

Definition at line 327 of file storage_agent.cc.

References file_is_read_only_accessible().

Referenced by file().

◆ file_is_read_only_accessible()

bool sheaf::storage_agent::file_is_read_only_accessible ( ) const

True if file is open with READ_ONLY access.

Postcondition
  • result == (file().mode() == sheaf_file::READ_ONLY)

Definition at line 351 of file storage_agent.cc.

References file_is_read_write_accessible().

Referenced by file_is_read_accessible().

◆ file_is_read_write_accessible()

bool sheaf::storage_agent::file_is_read_write_accessible ( ) const

True if file is open with READ_WRITE.

Postcondition
  • result == (file().mode() == sheaf_file::READ_WRITE)

Definition at line 375 of file storage_agent.cc.

References file_id_space_name().

Referenced by file_is_read_only_accessible().

◆ initialize_namespace_id_spaces_for_read()

void sheaf::storage_agent::initialize_namespace_id_spaces_for_read ( namespace_poset xposet)
protected

◆ initialize_namespace_id_spaces_for_write()

void sheaf::storage_agent::initialize_namespace_id_spaces_for_write ( namespace_poset xposet)
protected

Ensures that the namespace and its standard posets have an empty index space for members and no index space for dof tuples.

Precondition
  • xns.state_is_read_write_accessible()

Definition at line 2401 of file storage_agent.cc.

References sheaf::storage_agent::transaction::operator<(), and sheaf::read_write_monitor_handle::state_is_read_write_accessible().

Referenced by initialize_namespace_id_spaces_for_read().

◆ initialize_poset_id_spaces_for_write()

void sheaf::storage_agent::initialize_poset_id_spaces_for_write ( poset_state_handle xposet)
protected

Initializes the subposet and dof tuple index spaces for poset xposet.

Issue:
Should really be read-write accessible so that the new id space functions can require write access. However, writing only requires read access in general.
Precondition
  • xposet.state_is_read_accessible()
Postcondition
  • xposet.member_id_spaces(false).contains(file_id_space_name())
  • xposet.subposet_id_spaces(false).contains(file_id_space_name())
  • xposet.dof_tuple_id_spaces(false).contains(file_id_space_name())

Definition at line 2185 of file storage_agent.cc.

References sheaf::gathered_insertion_index_space_handle::clear(), clear_all_id_spaces(), sheaf::index_space_family::contains(), sheaf::poset_state_handle::dof_tuple_id_spaces(), sheaf::poset_state_handle::member_id_spaces(), sheaf::explicit_index_space_handle::release_id_space(), sheaf::read_write_monitor_handle::state_is_read_accessible(), and sheaf::poset_state_handle::subposet_id_spaces().

Referenced by write_prerequisites().

◆ invariant()

bool sheaf::storage_agent::invariant ( ) const
virtual

Class invariant.

Todo:
finish storage_agent::invariant

Reimplemented from sheaf::any.

Definition at line 187 of file storage_agent.cc.

References is_ancestor_of().

Referenced by ~storage_agent().

◆ is_ancestor_of()

bool sheaf::storage_agent::is_ancestor_of ( const any other) const
virtual

Conformance test; true if other conforms to this.

Precondition
  • other != 0

Reimplemented from sheaf::any.

Definition at line 222 of file storage_agent.cc.

References storage_agent().

Referenced by invariant().

◆ member_record_buffer_ub()

int sheaf::storage_agent::member_record_buffer_ub ( ) const

The number of records allocated in a member record buffer during a transaction.

Definition at line 1695 of file storage_agent.cc.

References put_member_record_buffer_ub().

Referenced by end_transaction().

◆ put_dof_tuple_record_buffer_ub()

void sheaf::storage_agent::put_dof_tuple_record_buffer_ub ( int  xub)

Sets the number of records allocated in a dof_tuple record buffer during a transaction and hence the HDF chunk size.

Precondition
  • xub > 0
Postcondition

Definition at line 1762 of file storage_agent.cc.

References transaction_ct().

Referenced by dof_tuple_record_buffer_ub().

◆ put_dof_tuple_record_size()

void sheaf::storage_agent::put_dof_tuple_record_size ( size_t  xsize)

OBSOLETE: no longer used. Sets the number of bytes in a dof_tuple record.

Postcondition

Definition at line 1734 of file storage_agent.cc.

References dof_tuple_record_buffer_ub().

Referenced by dof_tuple_record_size().

◆ put_member_record_buffer_ub()

void sheaf::storage_agent::put_member_record_buffer_ub ( int  xub)

Sets the number of records allocated in a member record buffer during a transaction.

Precondition
  • xub > 0
Postcondition

Definition at line 1704 of file storage_agent.cc.

References dof_tuple_record_size().

Referenced by member_record_buffer_ub().

◆ put_state_is_consistent()

void sheaf::storage_agent::put_state_is_consistent ( poset_state_handle xposet)
protected

Sets the state_is_consistent flag for xposet to true.

Precondition
  • xposet.is_attached()

Definition at line 1994 of file storage_agent.cc.

References sheaf::read_write_monitor_handle::clear_state_is_modified(), sheaf::poset_state_handle::is_attached(), and read_prerequisites().

Referenced by state_is_consistent().

◆ read() [1/2]

void sheaf::storage_agent::read ( namespace_poset xns)

Reads the namespace xns.

Precondition
  • xns.state_is_read_write_accessible()
  • !transaction_is_active(xns)
Postcondition
  • !transaction_is_active(xns)
  • xns.access_request_depth() == old_access_request_depth

Definition at line 531 of file storage_agent.cc.

References sheaf::read_write_monitor_handle::access_request_depth(), sheaf::read_write_monitor_handle::state_is_read_write_accessible(), and write().

Referenced by read_remainder(), and write_remainder().

◆ read() [2/2]

void sheaf::storage_agent::read ( poset_state_handle xposet,
const poset_bounds_descriptor xrow_bounds = poset_bounds_descriptor::BOTTOM_TOP,
const poset_bounds_descriptor xcol_bounds = poset_bounds_descriptor::BOTTOM_TOP 
)

Reads the portion of poset xposet specified by the row bounds xrow_bounds and the column bounds xcol_bounds.

require(xposet.is_external()); ///

Todo:
relax this requirement
Precondition
  • !transaction_is_active(xposet)
Postcondition
  • !xposet.is_external()
  • xposet.access_request_depth() == old_access_request_depth

Definition at line 693 of file storage_agent.cc.

References sheaf::read_write_monitor_handle::access_request_depth(), sheaf::poset_state_handle::is_external(), and read_toc().

◆ read_entire()

void sheaf::storage_agent::read_entire ( namespace_poset xns)

Reads the namespace xns and all the posets in it.

Precondition
  • xns.state_is_read_write_accessible()
  • !transaction_is_active(xns)
Postcondition
  • !transaction_is_active(xns)
  • xns.access_request_depth() == old_access_request_depth
  • -unexecutable( "for all members m of xns: !m.is_external()" )

Definition at line 452 of file storage_agent.cc.

References sheaf::read_write_monitor_handle::access_request_depth(), read_remainder(), and sheaf::read_write_monitor_handle::state_is_read_write_accessible().

Referenced by time().

◆ read_index()

void sheaf::storage_agent::read_index ( poset_state_handle xposet)

Reads the index of poset xposet; that is, it does not read the dof tuples.

Precondition
  • xposet.is_external()
  • !transaction_is_active(xposet)
Postcondition
  • !xposet.is_external()
  • xposet.access_request_depth() == 0

Definition at line 752 of file storage_agent.cc.

References sheaf::read_write_monitor_handle::access_request_depth(), sheaf::poset_state_handle::is_external(), and read_row_decomposition().

Referenced by read_toc().

◆ read_prerequisites()

void sheaf::storage_agent::read_prerequisites ( const poset_state_handle xposet,
const poset_bounds_descriptor xcol_bounds 
)
protected

◆ read_remainder()

void sheaf::storage_agent::read_remainder ( namespace_poset xns)

Reads all members of the namespace that have not already been read.

Precondition
  • xns.state_is_read_write_accessible()
  • !transaction_is_active(xns)
Postcondition
  • !transaction_is_active(xns)
  • xns.access_request_depth() == old_access_request_depth
  • -unexecutable( "for all members m of xns: !m.is_external()" )

Definition at line 487 of file storage_agent.cc.

References sheaf::read_write_monitor_handle::access_request_depth(), sheaf::DOWN, sheaf::poset_state_handle::is_external(), sheaf::poset_state_handle::member_name(), sheaf::namespace_poset::member_poset(), sheaf::NOT_STRICT, read(), sheaf::read_write_monitor_handle::state_is_read_write_accessible(), and sheaf::namespace_poset::top().

Referenced by read_entire().

◆ read_row_decomposition()

void sheaf::storage_agent::read_row_decomposition ( poset_state_handle xposet,
const scoped_index xdecomp_id 
)

Reads poset xposet using the row decomposition identified by index xdecomp_id.

Todo:
make the following executable.
Issue:
may want to introduce a state machine to coordinate multiple partial read/write transactions.
Precondition
  • -unexecutable( "Have already read the table of contents" )
  • !transaction_is_active(xposet)
Postcondition
  • !xposet.is_external()
  • xposet.access_request_depth() == old_access_request_depth

Definition at line 779 of file storage_agent.cc.

References sheaf::read_write_monitor_handle::access_request_depth(), sheaf::scoped_index::hub_pod(), sheaf::poset_state_handle::is_external(), and write().

Referenced by read_index().

◆ read_toc()

void sheaf::storage_agent::read_toc ( poset_state_handle xposet)

Reads the table of contents portion of poset xposet.

Precondition
  • xposet.is_external()
  • !transaction_is_active(xposet)
Postcondition
  • !xposet.is_external()
  • xposet.access_request_depth() == 0

Definition at line 723 of file storage_agent.cc.

References sheaf::read_write_monitor_handle::access_request_depth(), sheaf::poset_state_handle::is_external(), and read_index().

Referenced by read().

◆ read_transaction_is_active()

bool sheaf::storage_agent::read_transaction_is_active ( const poset_state_handle xposet) const

True if there is an active read transaction for poset xposet.

Definition at line 1860 of file storage_agent.cc.

Referenced by transaction_is_active().

◆ read_write_transaction_is_active()

bool sheaf::storage_agent::read_write_transaction_is_active ( poset_state_handle xposet) const

True if both a read-write transaction is active.

Definition at line 1910 of file storage_agent.cc.

References state_is_consistent().

◆ reset_time()

void sheaf::storage_agent::reset_time ( )

Reset the start time. Set the start time to the CPU time when this function is called.

Definition at line 403 of file storage_agent.cc.

References time().

Referenced by file_id_space_name().

◆ state_is_consistent()

bool sheaf::storage_agent::state_is_consistent ( const poset_state_handle xposet) const

True if uncommitted state is consistent with committed state.

Precondition
  • xposet.is_attached() ? xposet.state_is_read_accessible() : true
Hack:
use of member index space as test for external state is a temporary implementation. Need more formal support for this test. In order for this hack to work, we clear the index spaces in write(namespace_poset&). Furthermore, since this routine is typically called before any attempt to write a poset, the call to member_id_space below actually creates the index space.
Todo:
replace with some better mechanism.

Definition at line 1934 of file storage_agent.cc.

References sheaf::index_space_family::contains(), sheaf::poset_state_handle::dof_tuple_id_spaces(), sheaf::poset_state_handle::is_attached(), sheaf::index_space_family::is_empty(), sheaf::poset_state_handle::member_id_spaces(), put_state_is_consistent(), sheaf::read_write_monitor_handle::state_is_modified(), sheaf::read_write_monitor_handle::state_is_read_accessible(), and sheaf::poset_state_handle::subposet_id_spaces().

Referenced by read_write_transaction_is_active().

◆ time()

clock_t sheaf::storage_agent::time ( ) const

Return the CPU time between when reset_time() was last called and when this function is called.

Definition at line 421 of file storage_agent.cc.

References ABORT, COMMIT, read_entire(), RELEASE_ALL, and RETAIN_READ.

Referenced by reset_time().

◆ transaction_ct()

int sheaf::storage_agent::transaction_ct ( ) const

The number of active transactions.

Postcondition
  • result >= 0

Definition at line 1786 of file storage_agent.cc.

References transaction_is_active().

Referenced by put_dof_tuple_record_buffer_ub().

◆ transaction_is_active() [1/2]

bool sheaf::storage_agent::transaction_is_active ( pod_index_type  xindex) const

True if either a read or write transaction is active for poset with index xindex.

Definition at line 1810 of file storage_agent.cc.

Referenced by sheaf::storage_agent::transaction::transaction(), and transaction_ct().

◆ transaction_is_active() [2/2]

bool sheaf::storage_agent::transaction_is_active ( const poset_state_handle xposet) const

True if either a read or write transaction is active for poset xposet.

Definition at line 1835 of file storage_agent.cc.

References read_transaction_is_active().

◆ write() [1/2]

void sheaf::storage_agent::write ( namespace_poset xns)

Writes the namespace xns.

Precondition
  • xns.is_attached()
  • xns.state_is_read_write_accessible()
  • !transaction_is_active(xns)
Postcondition
  • state_is_consistent(xns)
  • !transaction_is_active(xns)

Definition at line 563 of file storage_agent.cc.

References sheaf::poset_state_handle::index(), sheaf::poset_state_handle::is_attached(), sheaf::scoped_index::is_valid(), sheaf::read_write_monitor_handle::state_is_read_write_accessible(), and write_entire().

Referenced by read(), and read_row_decomposition().

◆ write() [2/2]

void sheaf::storage_agent::write ( poset_state_handle xposet,
const poset_bounds_descriptor xrow_bounds = poset_bounds_descriptor::BOTTOM_TOP,
const poset_bounds_descriptor xcol_bounds = poset_bounds_descriptor::BOTTOM_TOP,
bool  xretain_read_access = false 
)

Executes an independent write-only transaction for the portion of poset xposet defined by the down sets of max_row_member_index and max_col_member_index. If xdownset_filter !=0, deletes the members of the downset of the upper bound, filtered by xdownset_filter.

Precondition
  • xposet.is_attached()
  • xposet.state_is_read_accessible()
  • !transaction_is_active(xposet)
  • xcol_bounds.ub_member_is_not_top() ? xposet.schema().ge(xcol_bounds.ub_id()) : true
Hack:
the product subposet hack, version 2. See poset_scaffold::dof_tuple_schema_int_id for the origin of the following requirement.
Precondition
  • -unexecutable( "if xposet is a section space, col bound is base space decomposition or same fiber as xposet" )
Postcondition
  • state_is_consistent(xposet)
  • !write_transaction_is_active(xposet)
  • read_transaction_is_active(xposet) == xretain_read_access

Definition at line 815 of file storage_agent.cc.

References sheaf::abstract_poset_member::ge(), sheaf::poset_state_handle::index(), sheaf::poset_state_handle::is_attached(), sheaf::scoped_index::is_valid(), sheaf::poset_state_handle::name(), sheaf::poset_state_handle::schema(), sheaf::read_write_monitor_handle::state_is_read_accessible(), sheaf::poset_bounds_descriptor::ub_id(), sheaf::poset_bounds_descriptor::ub_member_is_not_top(), and write_toc().

◆ write_col_decomposition()

void sheaf::storage_agent::write_col_decomposition ( poset_state_handle xposet,
const scoped_index xrow_id,
const scoped_index xdecomp_id 
)

Writes the member identified by xrow_id in poset xposet using the column decomposition identified by index xdecomp_id.

Precondition
  • xposet.is_attached()
  • xposet.state_is_read_accessible()
  • !transaction_is_active(xposet)
Hack:
the product subposet hack. Following precondition can not be enforced because xdecomp_id may be subposet of base space, not schema itself

require(xposet.schema().host()->includes_subposet(xdecomp_id));

Postcondition
  • !transaction_is_active(xposet)

Definition at line 946 of file storage_agent.cc.

References sheaf::scoped_index::hub_pod(), sheaf::poset_state_handle::is_attached(), sheaf::read_write_monitor_handle::state_is_read_accessible(), and write_dof_tuple().

Referenced by write_row_decomposition().

◆ write_dof_tuple()

void sheaf::storage_agent::write_dof_tuple ( const abstract_poset_member xmbr,
const scoped_index xcol_ub_id,
const scoped_index xdecomp_id 
)

Writes the portion of the dof tuple of member xmbr which is in the downset of the schema member identified by xcol_ub_id, which must be a member of column decomposition xdecomp_id.

Precondition
  • xmbr.state_is_read_accessible()
  • !transaction_is_active(*(xmbr.host()))
Hack:
the product subposet hack. Following precondition can not be enforced because xdecomp_id may be subposet of base space, not schema itself

require(xposet.schema().host()->includes_subposet(xdecomp_id));

Postcondition
  • !transaction_is_active(*(xmbr.host()))

Definition at line 993 of file storage_agent.cc.

References commit_dof_tuple_transaction(), sheaf::poset_component::host(), sheaf::scoped_index::hub_pod(), sheaf::poset_component::index(), and sheaf::read_write_monitor_handle::state_is_read_accessible().

Referenced by write_col_decomposition().

◆ write_entire()

void sheaf::storage_agent::write_entire ( namespace_poset xns)

Writes the namespace xns and all the posets in it. Rewrites any posets that have already been written.

Precondition
  • xns.is_attached()
  • xns.state_is_read_write_accessible()
  • !transaction_is_active(xns)
  • -unexecutable( "for all members m of xns( !transaction_is_active(m))" )
Postcondition
  • state_is_consistent(xns)
  • !transaction_is_active(xns)
  • -unexecutable( "for all members m of xns(state_is_consistent(m))" )
  • -unexecutable( "for all members m of xns( !transaction_is_active(m))" )

Definition at line 599 of file storage_agent.cc.

References sheaf::poset_state_handle::is_attached(), sheaf::read_write_monitor_handle::state_is_read_write_accessible(), and write_remainder().

Referenced by write().

◆ write_prerequisites()

void sheaf::storage_agent::write_prerequisites ( const poset_scaffold xscaffold)
protected

Writes all posets that xposet depends on.

Precondition
  • !xscaffold.structure().is_external()
  • xscaffold.name_space()->state_is_read_accessible()
Issue:
if we retain read access in the main write, do we need to retain read access to all the prerequisites?
Issue:
we can't actually ensure the following if we've released read access.
Postcondition
  • -unexecutable( "for all prerequisites p: state_is_consistent(p)" )

Definition at line 2091 of file storage_agent.cc.

References sheaf::poset_state_handle::get_read_access(), sheaf::poset_scaffold::index(), initialize_poset_id_spaces_for_write(), sheaf::poset_state_handle::is_external(), sheaf::is_valid(), sheaf::poset_state_handle::name(), sheaf::abstract_poset_member::name(), sheaf::poset_scaffold::name_space(), sheaf::PREREQ_IDS_UB, sheaf::poset_state_handle::release_access(), sheaf::read_write_monitor_handle::state_is_read_accessible(), sheaf::poset_scaffold::structure(), and sheaf::poset_scaffold::structure_is_namespace().

Referenced by read_prerequisites().

◆ write_remainder()

void sheaf::storage_agent::write_remainder ( const namespace_poset xns)

Writes all the posets in namespace xns that have not already been written.

Precondition
  • xns.is_attached()
  • xns.state_is_read_accessible()
Todo:
make the following executable
Precondition
  • -unexecutable( "xns itself has already been written" )
  • -unexecutable( "for all members p of xns(!p.is_external())" )
  • !transaction_is_active(xns)
  • -unexecutable( "for all members p of xns(!transaction_is_active(p))" )
Postcondition
  • state_is_consistent(xns)
  • !transaction_is_active(xns)
  • -unexecutable( "for all members m of xns(state_is_consistent(m))" )
  • -unexecutable( "for all members m of xns(!transaction_is_active(m))" )

Definition at line 635 of file storage_agent.cc.

References sheaf::DOWN, sheaf::poset_state_handle::get_read_access(), sheaf::poset_state_handle::is_attached(), sheaf::poset_state_handle::is_external(), sheaf::namespace_poset::member_poset(), sheaf::NOT_STRICT, read(), sheaf::poset_state_handle::release_access(), sheaf::read_write_monitor_handle::state_is_read_accessible(), and sheaf::namespace_poset::top().

Referenced by write_entire().

◆ write_row_decomposition()

void sheaf::storage_agent::write_row_decomposition ( poset_state_handle xposet,
const scoped_index xdecomp_id 
)

Writes poset xposet using the row decomposition identified by index xdecomp_id.

Precondition
  • xposet.is_attached()
  • xposet.state_is_read_accessible()
  • !transaction_is_active(xposet)
  • xposet.includes_subposet(xdecomp_id)
Postcondition
  • state_is_consistent(xposet)
  • !transaction_is_active(xposet)

Definition at line 913 of file storage_agent.cc.

References sheaf::scoped_index::hub_pod(), sheaf::poset_state_handle::includes_subposet(), sheaf::poset_state_handle::is_attached(), sheaf::read_write_monitor_handle::state_is_read_accessible(), and write_col_decomposition().

Referenced by write_toc().

◆ write_toc()

void sheaf::storage_agent::write_toc ( poset_state_handle xposet,
const scoped_index xtoc_id 
)

Writes the portion of poset xposet between the lower bound specified by the subposet with index xtoc_id and upper bound top. Registers xtoc_id as lower bounds of the table of the contents.

Precondition
  • xposet.is_attached()
  • xposet.state_is_read_accessible()
  • !transaction_is_active(xposet)
  • xposet.includes_subposet(xtoc_id)
Postcondition
  • state_is_consistent(xposet)
  • !transaction_is_active(xposet)

Definition at line 881 of file storage_agent.cc.

References sheaf::scoped_index::hub_pod(), sheaf::poset_state_handle::includes_subposet(), sheaf::poset_state_handle::is_attached(), sheaf::read_write_monitor_handle::state_is_read_accessible(), and write_row_decomposition().

Referenced by write().

◆ write_transaction_is_active()

bool sheaf::storage_agent::write_transaction_is_active ( const poset_state_handle xposet) const

True if there is an active write transaction involving the poset with name space index xindex.

Definition at line 1885 of file storage_agent.cc.

Member Data Documentation

◆ ABORT

const bool sheaf::storage_agent::ABORT = false
static

Value to indicate transaction should not be committed.

Definition at line 187 of file storage_agent.h.

Referenced by time().

◆ COMMIT

const bool sheaf::storage_agent::COMMIT = true
static

Value to indicate transaction should be committed.

Definition at line 182 of file storage_agent.h.

Referenced by time().

◆ RELEASE_ALL

const bool sheaf::storage_agent::RELEASE_ALL = false
static

Value to indicate read access should not be retained.

Definition at line 197 of file storage_agent.h.

Referenced by time().

◆ RETAIN_READ

const bool sheaf::storage_agent::RETAIN_READ = true
static

Value to indicate read access should be retained.

Definition at line 192 of file storage_agent.h.

Referenced by time().


The documentation for this class was generated from the following files: