SheafSystem  0.0.0.0
storage_agent.cc
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Implementation for class storage_agent
19 
20 #include "SheafSystem/storage_agent.h"
21 #include "SheafSystem/assert_contract.h"
22 
23 #include "SheafSystem/array_poset_dof_map.h"
24 #include "SheafSystem/attributes_record_set.h"
25 #include "SheafSystem/dof_tuple_record_set.h"
26 #include "SheafSystem/error_message.h"
27 #include "SheafSystem/interval_index_space_state.h"
28 #include "SheafSystem/member_names_record.h"
29 #include "SheafSystem/member_record.h"
30 #include "SheafSystem/member_record_set.h"
31 #include "SheafSystem/namespace_poset.h"
32 #include "SheafSystem/namespace_poset_member.h"
33 #include "SheafSystem/poset.h"
34 #include "SheafSystem/poset_bounds.h"
35 #include "SheafSystem/poset_bounds_descriptor.h"
36 #include "SheafSystem/poset_data_type_map.h"
37 #include "SheafSystem/poset_general_record.h"
38 #include "SheafSystem/poset_handle_factory.h"
39 #include "SheafSystem/poset_state_handle.h"
40 #include "SheafSystem/postorder_itr.h"
41 #include "SheafSystem/preorder_itr.h"
42 #include "SheafSystem/schema_poset_member.h"
43 #include "SheafSystem/subposet_names_record.h"
44 #include "SheafSystem/total_poset_member.h"
45 
46 #include "SheafSystem/index_equivalence_iterator.h"
47 
48 using namespace std;
49 
50 //#define DIAGNOSTIC_OUTPUT
51 //#undef DIAGNOSTIC_OUTPUT
52 
53 namespace
54 {
55  //
56  // The default number of records allocated in a
57  // member record buffer during a transaction.
58  //
59  const int DEFAULT_MEMBER_RECORD_BUFFER_UB = 1000;
60 
61  //
62  // OBSOLETE: no longer used. The default number of bytes in a dof_tuple record.
63  //
64  const size_t DEFAULT_DOF_TUPLE_RECORD_SIZE = 1024;
65 
66  //
67  // The default number of records allocated in a
68  // dof_tuple record buffer during a transaction.
69  //
70  const int DEFAULT_DOF_TUPLE_RECORD_BUFFER_UB = 4;
71 }
72 
73 
74 
75 // PUBLIC MEMBER FUNCTIONS
76 
77 // CANONICAL MEMBERS
78 
82 {
83 
84  // Preconditions:
85 
86 
87  // Body:
88 
89  _member_record_buffer_ub = DEFAULT_MEMBER_RECORD_BUFFER_UB;
90  _dof_tuple_record_size = DEFAULT_DOF_TUPLE_RECORD_SIZE;
91  _dof_tuple_record_buffer_ub = DEFAULT_DOF_TUPLE_RECORD_BUFFER_UB;
92 
93  // Reset the start time.
94 
95  reset_time();
96 
97  // Postconditions:
98 
99  ensure(invariant());
100  ensure(transaction_ct() == 0);
101  ensure(member_record_buffer_ub() == DEFAULT_MEMBER_RECORD_BUFFER_UB);
102  ensure(dof_tuple_record_size() == DEFAULT_DOF_TUPLE_RECORD_SIZE);
103  ensure(dof_tuple_record_buffer_ub() == DEFAULT_DOF_TUPLE_RECORD_BUFFER_UB);
104 
105  // Postconditions:
106 
107  ensure(invariant());
108 
109  // Exit:
110 
111  return;
112 }
113 
114 
118 {
119 
120  // Preconditions:
121 
122  // Body:
123 
124  not_implemented();
125 
126  // postconditions:
127 
128  ensure(invariant());
129 }
130 
131 
132 
136 clone() const
137 {
138  storage_agent* result =0;
139  // Initialized only to silence compiler warnings
140  // until implemented.
141 
142  // Preconditions:
143 
144 
145  // Body:
146 
147  not_implemented();
148 
149  // Postconditions:
150 
151  ensure(result != 0);
152  ensure(is_same_type(result));
153 
154  // Exit:
155 
156  return result;
157 }
158 
159 
163 {
164 
165  // Preconditions:
166 
167  // Body:
168 
169  // Close the file if it is open
170 
171  if(_file.is_open())
172  {
173  _file.close();
174  }
175 
176  // Postconditions:
177 
178  // Exit:
179 
180  return;
181 }
182 
183 
185 bool
187 invariant() const
188 {
189  bool result = true;
190 
191  // Preconditions:
192 
193  // Body:
194 
196 
197  // Must satisfy base class invariant
198 
199  result = result && any::invariant();
200 
201  if(invariant_check())
202  {
203  // Prevent recursive calls to invariant
204 
205  disable_invariant_check();
206 
207  // Finished, turn invariant checking back on.
208 
209  enable_invariant_check();
210  }
211 
212  // Postconditions:
213 
214  // Exit
215 
216  return result;
217 }
218 
220 bool
222 is_ancestor_of(const any* other) const
223 {
224 
225  // Preconditions:
226 
227  require(other != 0);
228 
229  // Body:
230 
231  // True if other conforms to this
232 
233  bool result = dynamic_cast<const storage_agent*>(other) != 0;
234 
235  // Postconditions:
236 
237  return result;
238 
239 }
240 
241 
242 
243 // STORAGE_AGENT INTERFACE
244 
245 
246 
249 storage_agent(const std::string& xfile_name,
251  bool xclobber,
252  bool xenable_error_report)
253 {
254 
255  // Preconditions:
256 
257  require(!xfile_name.empty());
258  require(xfile_name.substr(xfile_name.size() - 4) == ".hdf");
259 
260  // Body:
261 
262  _member_record_buffer_ub = DEFAULT_MEMBER_RECORD_BUFFER_UB;
263  _dof_tuple_record_size = DEFAULT_DOF_TUPLE_RECORD_SIZE;
264  _dof_tuple_record_buffer_ub = DEFAULT_DOF_TUPLE_RECORD_BUFFER_UB;
265 
266  if(xenable_error_report)
267  {
268  // Turn on the standard HDF error reporting.
269 
270  H5Eset_auto1(reinterpret_cast<herr_t (*)(void*)>(H5Eprint), stderr);
271  }
272  else
273  {
274  // Turn off HDF error reporting.
275 
276  H5Eset_auto1(NULL, NULL);
277  }
278 
279  // Open the file.
280 
281  _file.open(xfile_name, xmode, xclobber);
282 
283  // Set the file id space name.
284 
285  string::size_type lpos = xfile_name.find_last_of('/');
286  lpos = (lpos == string::npos) ? 0 : lpos+1;
287  string lname = xfile_name.substr(lpos);
288 
289  _file_id_space_name = poset_path::reserved_prefix() + lname;
290 
291  // Reset the start time.
292 
293  reset_time();
294 
295  // Postconditions:
296 
297  ensure(invariant());
298  ensure(transaction_ct() == 0);
299  ensure(member_record_buffer_ub() == DEFAULT_MEMBER_RECORD_BUFFER_UB);
300  ensure(dof_tuple_record_size() == DEFAULT_DOF_TUPLE_RECORD_SIZE);
301  ensure(dof_tuple_record_buffer_ub() == DEFAULT_DOF_TUPLE_RECORD_BUFFER_UB);
302  ensure(file().is_open());
303 }
304 
308 {
309  return _file;
310 }
311 
312 
313 
315 const sheaf::sheaf_file&
317 file() const
318 {
319  return _file;
320 }
321 
322 
323 
325 bool
328 {
329  bool result;
330 
331  // Preconditions:
332 
333  // Body:
334 
335  result = file().is_open();
336 
337  // Postconditions:
338 
339  ensure(result == file().is_open());
340 
341  // Exit
342 
343  return result;
344 }
345 
346 
347 
349 bool
352 {
353  bool result;
354 
355  // Preconditions:
356 
357  // Body:
358 
359  result = (file().mode() == sheaf_file::READ_ONLY);
360 
361  // Postconditions:
362 
363  ensure(result == (file().mode() == sheaf_file::READ_ONLY));
364 
365  // Exit
366 
367  return result;
368 }
369 
370 
371 
373 bool
376 {
377  bool result;
378 
379  // Preconditions:
380 
381  // Body:
382 
383  result = (file().mode() == sheaf_file::READ_WRITE);
384 
385  // Postconditions:
386 
387  ensure(result == (file().mode() == sheaf_file::READ_WRITE));
388 
389  // Exit
390 
391  return result;
392 }
393 
394 const std::string&
397 {
398  return _file_id_space_name;
399 }
400 
401 void
404 {
405  // Preconditions:
406 
407  // Body:
408 
409  _start_time = clock();
410 
411  // Postconditions:
412 
413  // Exit:
414 }
415 
416 
417 
419 clock_t
421 time() const
422 {
423  // Preconditions:
424 
425  // Body:
426 
427  clock_t result = clock() - _start_time;
428 
429  // Postconditions:
430 
431  // Exit:
432 
433  return result;
434 }
435 
436 
437 // CONSTANTS FOR ACCESS ROUTINE ARGUMENTS
438 
439 const bool sheaf::storage_agent::COMMIT = true;
440 const bool sheaf::storage_agent::ABORT = false;
441 const bool sheaf::storage_agent::RETAIN_READ = true;
442 const bool sheaf::storage_agent::RELEASE_ALL = false;
443 
444 
445 // ===========================================================
446 // NAMESPACE_POSET FACET
447 // ===========================================================
448 
450 void
453 {
454 
455  // Preconditions:
456 
457  require(xns.state_is_read_write_accessible());
458  require(!transaction_is_active(xns));
459 
460  // Body:
461 
462  define_old_variable(int old_access_request_depth = xns.access_request_depth());
463 
464  // Read the namespace itself
465 
466  read(xns);
467 
468  // Read all the posets in it that have not already been read.
469 
470  read_remainder(xns);
471 
472  // Postconditions:
473 
474  ensure(!transaction_is_active(xns));
475  ensure(xns.access_request_depth() == old_access_request_depth);
476  ensure(unexecutable("for all members m of xns: !m.is_external()"));
477 
478  // Exit
479 
480  return;
481 }
482 
483 
485 void
488 {
489 
490  // Preconditions:
491 
492  require(xns.state_is_read_write_accessible());
493  require(!transaction_is_active(xns));
494 
495  // Body:
496 
497  define_old_variable(int old_access_request_depth = xns.access_request_depth());
498 
499  // Read all the posets in the namespace that have not already been read.
500 
501  zn_to_bool_postorder_itr itr(xns.top(), "jims", DOWN, NOT_STRICT);
502  while(!itr.is_done())
503  {
504 
505 #ifdef DIAGNOSTIC_OUTPUT
506  cout << "testing is_external for poset " << xns.member_name(itr.index()) << endl;
507 #endif
508 
509  poset_state_handle& p = xns.member_poset(itr.index());
510  if(p.is_external())
511  {
512  read(p);
513  }
514  itr.next();
515  }
516 
517  // Postconditions:
518 
519  ensure(!transaction_is_active(xns));
520  ensure(xns.access_request_depth() == old_access_request_depth);
521  ensure(unexecutable("for all members m of xns: !m.is_external()"));
522 
523  // Exit
524 
525  return;
526 }
527 
529 void
532 {
533 
534  // Preconditions:
535 
536  require(xns.state_is_read_write_accessible());
537  require(!transaction_is_active(xns));
538 
539  // Body:
540 
541  define_old_variable(int old_access_request_depth = xns.access_request_depth());
542 
543  begin_read_transaction(xns);
544  end_transaction(xns, ABORT);
545 
546 #ifdef DIAGNOSTIC_OUTPUT
547  cout << static_cast<poset_state_handle&>(xns) << endl;
548 #endif
549 
550  // Postconditions:
551 
552  ensure(!transaction_is_active(xns));
553  ensure(xns.access_request_depth() == old_access_request_depth);
554 
555  // Exit
556 
557  return;
558 }
559 
561 void
564 {
565 
566  // Preconditions:
567 
568  require(file_is_read_write_accessible());
569  require(xns.is_attached());
570  require(xns.state_is_read_write_accessible());
571  require(!xns.index().is_valid());
572  require(!transaction_is_active(xns));
573 
574  // Body:
575 
576  initialize_namespace_id_spaces_for_write(xns);
577 
578  // Begin the transaction.
579 
580  begin_write_transaction(xns);
581 
582  // Commit and end the transaction
583 
584  end_transaction(xns, COMMIT);
585 
586  // Postconditions:
587 
588  ensure(state_is_consistent(xns));
589  ensure(!transaction_is_active(xns));
590 
591  // Exit
592 
593  return;
594 }
595 
597 void
600 {
601 
602  // Preconditions:
603 
604  require(file_is_read_write_accessible());
605  require(xns.is_attached());
606  require(xns.state_is_read_write_accessible());
607  require(!transaction_is_active(xns));
608  require(unexecutable("for all members m of xns( !transaction_is_active(m))"));
609 
610  // Body:
611 
612  // Write the name space itself
613 
614  write(xns);
615 
616  // Write all the posets in it.
617 
618  write_remainder(xns);
619 
620  // Postconditions:
621 
622  ensure(state_is_consistent(xns));
623  ensure(!transaction_is_active(xns));
624  ensure(unexecutable("for all members m of xns(state_is_consistent(m))"));
625  ensure(unexecutable("for all members m of xns( !transaction_is_active(m))"));
626 
627  // Exit
628 
629  return;
630 }
631 
633 void
636 {
637 
638  // Preconditions:
639 
640  require(file_is_read_write_accessible());
641  require(xns.is_attached());
642  require(xns.state_is_read_accessible());
643 
645 
646  require(unexecutable("xns itself has already been written"));
647  require(unexecutable("for all members p of xns(!p.is_external())"));
648  require(!transaction_is_active(xns));
649  require(unexecutable("for all members p of xns(!transaction_is_active(p))"));
650 
651  // Body:
652 
653  // Write all the posets in the namespace that
654  // have not been written since the last time hey were changed.
655 
656  zn_to_bool_postorder_itr itr(xns.top(), "jims", DOWN, NOT_STRICT);
657  while(!itr.is_done())
658  {
659  poset_state_handle& p = xns.member_poset(itr.index());
660 
661  assertion(!p.is_external());
662 
663  p.get_read_access();
664  if(!state_is_consistent(p))
665  {
666  write(p);
667  }
668  p.release_access();
669 
670  itr.next();
671  }
672 
673  // Postconditions:
674 
675  ensure(state_is_consistent(xns));
676  ensure(!transaction_is_active(xns));
677  ensure(unexecutable("for all members m of xns(state_is_consistent(m))"));
678  ensure(unexecutable("for all members m of xns(!transaction_is_active(m))"));
679 
680  // Exit
681 
682  return;
683 }
684 
685 
686 // ===========================================================
687 // GENERAL POSET FACET
688 // ===========================================================
689 
691 void
694  const poset_bounds_descriptor& xrow_bounds,
695  const poset_bounds_descriptor& xcol_bounds)
696 {
697 
698  // Preconditions:
699 
701  require(!transaction_is_active(xposet));
702 
703  // Body:
704 
705  int old_access_request_depth = xposet.is_external() ? 0 : xposet.access_request_depth();
706 
707  begin_read_transaction(xposet, xrow_bounds, xcol_bounds);
708  end_transaction(xposet, ABORT);
709 
710  // Postconditions:
711 
712  ensure(!xposet.is_external());
713  ensure(xposet.access_request_depth() == old_access_request_depth);
714 
715  // Exit
716 
717  return;
718 }
719 
721 void
724 {
725 
726  // Preconditions:
727 
728  require(xposet.is_external());
729  require(!transaction_is_active(xposet));
730 
731  // Body:
732 
733  poset_bounds_descriptor lrow_bounds(poset_bounds_descriptor::SUBPOSET_MEMBER,
734  TOC_INDEX,
735  TOP_INDEX);
736 
737  read(xposet, lrow_bounds);
738 
739  // Postconditions:
740 
741  ensure(!xposet.is_external());
742  ensure(xposet.access_request_depth() == 0);
743 
744  // Exit
745 
746  return;
747 }
748 
750 void
753 {
754 
755  // Preconditions:
756 
757  require(xposet.is_external());
758  require(!transaction_is_active(xposet));
759 
760  // Body:
761 
762  read(xposet,
763  poset_bounds_descriptor::BOTTOM_TOP,
764  poset_bounds_descriptor::BOTTOM_BOTTOM);
765 
766  // Postconditions:
767 
768  ensure(!xposet.is_external());
769  ensure(xposet.access_request_depth() == 0);
770 
771  // Exit
772 
773  return;
774 }
775 
777 void
780  const scoped_index& xdecomp_id)
781 {
782 
783  // Preconditions:
784 
788 
789  require(unexecutable("Have already read the table of contents"));
790  require(!transaction_is_active(xposet));
791 
792  // Body:
793 
794  int old_access_request_depth = xposet.is_external() ? 0 : xposet.access_request_depth();
795 
796  poset_bounds_descriptor lrow_bounds(poset_bounds_descriptor::MEMBER_SUBPOSET,
797  BOTTOM_INDEX,
798  xdecomp_id.hub_pod());
799 
800  read(xposet, lrow_bounds);
801 
802  // Postconditions:
803 
804  ensure(!xposet.is_external());
805  ensure(xposet.access_request_depth() == old_access_request_depth);
806 
807  // Exit
808 
809  return;
810 }
811 
813 void
816  const poset_bounds_descriptor& xrow_bounds,
817  const poset_bounds_descriptor& xcol_bounds,
818  bool xretain_read_access)
819 {
820 
821 #ifdef DIAGNOSTIC_OUTPUT
822  cout << endl << SOURCE_CODE_LOCATION;
823  cout << "writing poset " << xposet.name() << " index: " << xposet.index() << endl;
824 #endif
825 
826  // Preconditions:
827 
828  require(file_is_read_write_accessible());
829  require(xposet.is_attached());
830  require(xposet.state_is_read_accessible());
831  require(xposet.index().is_valid());
832  require(!transaction_is_active(xposet));
833  require(xcol_bounds.ub_member_is_not_top() ?
834  xposet.schema().ge(xcol_bounds.ub_id()) :
835  true);
836 
840 
841  require(unexecutable("if xposet is a section space, col bound is base space decomposition or same fiber as xposet"));
842 
843 
844  // Body:
845 
846  // Begin the transaction.
847 
848  begin_write_transaction(xposet, xrow_bounds, xcol_bounds);
849 
850  if(xretain_read_access)
851  {
852  // Commit the transaction.
853 
854  commit_transaction(xposet);
855 
856  // Release write access but not read access.
857 
858  active_transaction(xposet).is_write_transaction = false;
859  }
860  else
861  {
862  // Commit and end the transaction
863 
864  end_transaction(xposet, COMMIT);
865  }
866 
867  // Postconditions:
868 
869  ensure(state_is_consistent(xposet));
870  ensure(!write_transaction_is_active(xposet));
871  ensure(read_transaction_is_active(xposet) == xretain_read_access);
872 
873  // Exit
874 
875  return;
876 }
877 
879 void
881 write_toc(poset_state_handle& xposet, const scoped_index& xtoc_id)
882 {
883 
884  // Preconditions:
885 
886  require(file_is_read_write_accessible());
887  require(xposet.is_attached());
888  require(xposet.state_is_read_accessible());
889  require(!transaction_is_active(xposet));
890  require(xposet.includes_subposet(xtoc_id));
891 
892  // Body:
893 
894  poset_bounds_descriptor lrow_bounds(poset_bounds_descriptor::SUBPOSET_MEMBER,
895  xtoc_id.hub_pod(),
896  TOP_INDEX);
897 
898  write(xposet, lrow_bounds);
899 
900  // Postconditions:
901 
902  ensure(state_is_consistent(xposet));
903  ensure(!transaction_is_active(xposet));
904 
905  // Exit
906 
907  return;
908 }
909 
911 void
914  const scoped_index& xdecomp_id)
915 {
916 
917  // Preconditions:
918 
919  require(file_is_read_write_accessible());
920  require(xposet.is_attached());
921  require(xposet.state_is_read_accessible());
922  require(!transaction_is_active(xposet));
923  require(xposet.includes_subposet(xdecomp_id));
924 
925  // Body:
926 
927  poset_bounds_descriptor lrow_bounds(poset_bounds_descriptor::MEMBER_SUBPOSET,
928  BOTTOM_INDEX,
929  xdecomp_id.hub_pod());
930 
931  write(xposet, lrow_bounds);
932 
933  // Postconditions:
934 
935  ensure(state_is_consistent(xposet));
936  ensure(!transaction_is_active(xposet));
937 
938  // Exit
939 
940  return;
941 }
942 
944 void
947  const scoped_index& xrow_id,
948  const scoped_index& xdecomp_id)
949 {
950 
951  // Preconditions:
952 
953  require(file_is_read_write_accessible());
954  require(xposet.is_attached());
955  require(xposet.state_is_read_accessible());
956  require(!transaction_is_active(xposet));
957 
963 
964  // Body:
965 
966  poset_bounds_descriptor lrow_bounds(poset_bounds_descriptor::MEMBER_MEMBER,
967  xrow_id,
968  xrow_id);
969 
970  poset_bounds_descriptor lcol_bounds(poset_bounds_descriptor::MEMBER_SUBPOSET,
971  BOTTOM_INDEX,
972  xdecomp_id.hub_pod());
973 
974  write(xposet, lrow_bounds, lcol_bounds);
975 
976  // Postconditions:
977 
978  // ensure(state_is_consistent(xposet));
979  ensure(!transaction_is_active(xposet));
980 
981  // Exit
982 
983  return;
984 }
985 
986 // ===========================================================
987 // DOF_TUPLE FACET
988 // ===========================================================
989 
991 void
994  const scoped_index& xcol_ub_id,
995  const scoped_index& xdecomp_id)
996 {
997 
998  // Preconditions:
999 
1000  require(file_is_read_write_accessible());
1001  require(xmbr.state_is_read_accessible());
1002  require(!transaction_is_active(*(xmbr.host())));
1003 
1009 
1010  // Body:
1011 
1012  poset_bounds_descriptor lrow_bounds(poset_bounds_descriptor::MEMBER_MEMBER,
1013  xmbr.index(),
1014  xmbr.index());
1015 
1016  poset_bounds_descriptor lcol_bounds(poset_bounds_descriptor::MEMBER_SUBPOSET,
1017  BOTTOM_INDEX,
1018  xdecomp_id.hub_pod());
1019 
1020  begin_write_transaction(*(xmbr.host()), lrow_bounds, lcol_bounds);
1021 
1022  commit_dof_tuple_transaction(xmbr, xcol_ub_id, xdecomp_id);
1023 
1024  remove_active_transaction(*(xmbr.host()));
1025 
1026  // Postconditions:
1027 
1028  // ensure(state_is_consistent(xposet));
1029  ensure(!transaction_is_active(*(xmbr.host())));
1030 
1031  // Exit
1032 
1033  return;
1034 }
1035 
1036 void
1039  const scoped_index& xcol_ub_id,
1040  const scoped_index& xdecomp_id)
1041 {
1042 
1043  // Preconditions:
1044 
1045  require(file_is_read_write_accessible());
1046  require(write_transaction_is_active(*(xmbr.host())));
1047  require(xmbr.state_is_read_write_accessible());
1048 
1049  // Body:
1050 
1051  poset_state_handle& lposet = *(xmbr.host());
1052 
1053  // Get the transaction description.
1054 
1055  const transaction& ltrans = active_transaction(lposet);
1056 
1057  // Initialize the member and dof tuple index spaces.
1058  // The index spaces maintain the association between
1059  // internal and external index spaces.
1060 
1061  initialize_poset_id_spaces_for_write(lposet);
1062 
1063  // Create the poset scaffold.
1064  // The scaffold buffers various data from when it
1065  // is computed until when it is used or written.
1066 
1067  poset_scaffold lscaffold(lposet,
1068  ltrans,
1069  file().type_map(),
1070  _file_id_space_name,
1071  true);
1072 
1073  // Write the posets on which this poset depends.
1074 
1075  write_prerequisites(lscaffold);
1076 
1077  // Write this dof tuple.
1078 
1079  // Open the dof tuple record set.
1080 
1081  dof_tuple_record_set ldof_tuple_records(file(), dof_tuple_record_size(), dof_tuple_record_buffer_ub(), lscaffold);
1082  ldof_tuple_records.open();
1083 
1084  lscaffold.evaluate_toc_alias();
1085 
1086 
1087  scoped_index lint_dof_tuple_id;
1088  xmbr.dof_tuple_id(lint_dof_tuple_id, false);
1089 
1090  // Get the external dof tuple id, if one has been assigned.
1091 
1092  scoped_index lext_dof_tuple_id =
1093  lscaffold.dof_tuple_ext_id(lint_dof_tuple_id);
1094 
1095  if(!lext_dof_tuple_id.is_valid())
1096  {
1097  // This is the first time we've encountered this dof tuple;
1098  // get an external id for it. External id will be the offset of
1099  // the beginning of the tuple in the dataset.
1100 
1101  lext_dof_tuple_id = ldof_tuple_records.compute_ext_id(lint_dof_tuple_id);
1102 
1103  // Save the dof tuple type and class name to be written in the
1104  // respective map; map must not already contain an entry for lext_dof_tuple_id.
1105 
1106  assertion(lscaffold.dof_tuple_types().find(lext_dof_tuple_id.pod()) ==
1107  lscaffold.dof_tuple_types().end());
1108 
1109  dof_tuple_type ltype_id = xmbr.dof_map().type_id();
1110  pair<pod_index_type, dof_tuple_type>
1111  lmap_pair(lext_dof_tuple_id.pod(), ltype_id);
1112 
1113  lscaffold.dof_tuple_types().insert(lmap_pair);
1114 
1115  assertion(lscaffold.dof_tuple_class_names().find(lext_dof_tuple_id.pod()) ==
1116  lscaffold.dof_tuple_class_names().end());
1117 
1118  string lclass_name = xmbr.dof_map().class_name();
1119  pair<pod_index_type, string> lname_map_pair(lext_dof_tuple_id.pod(), lclass_name);
1120 
1121  lscaffold.dof_tuple_class_names().insert(lname_map_pair);
1122  }
1123 
1124  ldof_tuple_records.externalize_domain(lext_dof_tuple_id, xcol_ub_id);
1125 
1126  // Close the record set.
1127 
1128  ldof_tuple_records.close();
1129 
1130  // Postconditions:
1131 
1132  ensure(write_transaction_is_active(lposet));
1133 
1134  // Exit
1135 
1136  return;
1137 }
1138 
1139 // ===========================================================
1140 // TRANSACTION FACET
1141 // ===========================================================
1142 
1144 void
1147 {
1148 
1149  // Preconditions:
1150 
1151  require(xns.state_is_read_write_accessible());
1152  require(!transaction_is_active(xns));
1153 
1154  // Body:
1155 
1156 #ifdef DIAGNOSTIC_OUTPUT
1157  cout << endl << SOURCE_CODE_LOCATION;
1158  cout << "reading poset " << xns.name() << endl;
1159 #endif
1160 
1161  define_old_variable(int old_access_request_depth = xns.access_request_depth());
1162 
1163  // Want to read all the rows and whatever columns are in the file.
1164  // Enter xns in the set of active read transactions
1165 
1166  transaction ltrans(READ, xns);
1167  put_active_transaction(ltrans);
1168 
1169  // Clear the namespace, except for the standard members
1170  // bottom, top, primitives, primitives schema, and primitive definitions members.
1171  // Also deletes all non-standard id spaces.
1172 
1173  xns.clear();
1174 
1175  // Initialize index spaces for members, subposets, and dof tuples
1176  // in name space and its standard posets.
1177 
1178  initialize_namespace_id_spaces_for_read(xns);
1179 
1180  // Create the poset scaffold.
1181  // The scaffold buffers various data from when it
1182  // is read until it can be used to build the poset.
1183 
1184  poset_scaffold lscaffold(xns,
1185  ltrans,
1186  file().type_map(),
1187  _file_id_space_name,
1188  false);
1189 
1190  // Read this poset
1191 
1192  // Open and read the general attributes record set.
1193  // Gets the external schema which is needed to instantiate
1194  // the dof tuple record set.
1195 
1196  attributes_record_set lattributes_records(file(), lscaffold);
1197  lattributes_records.open();
1198  lattributes_records.internalize();
1199 
1200  // The poset and its subposets have been created;
1201  // now we can attach the bounds objects.
1202 
1203  lscaffold.evaluate_toc_alias();
1204 
1205  // Open the other record sets.
1206 
1207  dof_tuple_record_set ldof_tuple_records(file(), dof_tuple_record_size(), dof_tuple_record_buffer_ub(), lscaffold);
1208  ldof_tuple_records.open();
1209 
1210  member_record_set lmember_records(file(), member_record_buffer_ub(), lscaffold, ldof_tuple_records);
1211  lmember_records.open();
1212 
1213  // Read and convert the other record sets to internal form.
1214 
1215  lmember_records.internalize(lscaffold.row_bounds().ub_id());
1216  ldof_tuple_records.internalize();
1217 
1218  // Close the record sets.
1219 
1220  lmember_records.close();
1221  ldof_tuple_records.close();
1222  lattributes_records.close();
1223 
1224  // Tranfser member names from scaffold to poset.
1225  // Have to do this after member_names_record in attribute record set
1226  // has been internalized and after all members have been internalized.
1227 
1228  lscaffold.put_member_names_to_poset();
1229 
1230  //
1231  // Reset the namespace name from whatever the client
1232  // chose initially to the name in the file.
1233  //
1234  string lns_name = lattributes_records.poset_name();
1235  xns.put_name(lns_name);
1236 
1237  // The non-standard dof tuples all have void pointers in them.
1238  // Allocate external handles instead.
1239 
1240  namespace_poset_member lns_mbr(xns.top());
1241  zn_to_bool_postorder_itr itr(lns_mbr, DOWN, NOT_STRICT);
1242  while(!itr.is_done())
1243  {
1244  lns_mbr.attach_to_state(&xns, itr.index());
1245 
1246  if(lns_mbr.is_jim() && lns_mbr.index().pod() >= xns.standard_member_ct())
1247  {
1248  // The current member is not a standard member;
1249  // create an external handle for it.
1250  // Handle pointer is inserted in namespace dof tuple by
1251  // attach_to_state.
1252  // Do not delete the handle!
1253 
1254  poset_state_handle* lmbr_poset =
1255  poset_state_handle::new_poset_handle(lns_mbr.poset_class(), lns_mbr.poset_type_id());
1256 
1257  lmbr_poset->attach_to_state(&lns_mbr);
1258 
1262 
1263  lns_mbr.dof_map().extend_to_top();
1264  }
1265 
1266  itr.next();
1267  }
1268 
1269 
1270  lns_mbr.detach_from_state();
1271 
1272  // Postconditions:
1273 
1274  ensure(read_transaction_is_active(xns));
1275  ensure(xns.access_request_depth() == old_access_request_depth);
1276 
1277  // Exit
1278 
1279  return;
1280 }
1281 
1283 void
1286  const poset_bounds_descriptor& xrow_bounds,
1287  const poset_bounds_descriptor& xcol_bounds)
1288 {
1289 
1290  // Preconditions:
1291 
1292 #ifdef DIAGNOSTIC_OUTPUT
1293  cout << endl << SOURCE_CODE_LOCATION;
1294  cout << "reading poset: " << xposet.name() << " index: " << xposet.index() << endl;
1295 #endif
1296 
1297  require(!transaction_is_active(xposet));
1298 
1299  // Body:
1300 
1301  int old_access_request_depth =
1302  xposet.is_external() ? 0 : xposet.access_request_depth();
1303 
1304  // Enter xposet in the set of active read transactions
1305 
1306  transaction ltrans(READ, xposet, xrow_bounds, xcol_bounds);
1307  put_active_transaction(ltrans);
1308 
1309  // Read all the posets this poset depends on.
1310 
1311  read_prerequisites(xposet, xcol_bounds);
1312 
1313  // Read this poset:
1314 
1315  // Deal with the "pointer bug":
1316  // Make sure we use the handle that is held by the namespace for all operations.
1317  // Ensures that states, members, and subposets don't hold pointers to
1318  // handles that will later disappear.
1319 
1320  poset_state_handle& lposet = xposet.name_space()->member_poset(xposet.index());
1321 
1322  // Create the poset scaffold.
1323  // The scaffold buffers various data from when it
1324  // is read until it can be used to build the poset.
1325 
1326  poset_scaffold lscaffold(lposet,
1327  ltrans,
1328  file().type_map(),
1329  _file_id_space_name,
1330  false);
1331 
1332  // Open and read the general attributes record set.
1333  // Gets the external schema and instantiates the poset state;
1334  // see poset_general_record::transfer_internal_buffer_to_poset.
1335 
1336 #ifdef DIAGNOSTIC_OUTPUT
1337 
1338  cout << endl << SOURCE_CODE_LOCATION;
1339  cout << "opening record sets for poset " << lposet.name() << endl;
1340 #endif
1341 
1342  attributes_record_set lattributes_records(file(), lscaffold);
1343  lattributes_records.open();
1344  lattributes_records.internalize();
1345 
1346  // The poset and its subposets have been created;
1347  // now we can attach the bounds objects.
1348 
1349  lscaffold.evaluate_toc_alias();
1350 
1351  // Open the other record sets.
1352 
1353  dof_tuple_record_set ldof_tuple_records(file(),
1354  dof_tuple_record_size(),
1355  dof_tuple_record_buffer_ub(),
1356  lscaffold);
1357  ldof_tuple_records.open();
1358 
1359  member_record_set lmember_records(file(),
1360  member_record_buffer_ub(),
1361  lscaffold,
1362  ldof_tuple_records);
1363  lmember_records.open();
1364 
1365  // Read and convert the other record sets to internal form.
1366 
1367  index_iterator* lrow_itr = lposet.bound_iterator(lscaffold.row_bounds(), true);
1368 
1369  while(!lrow_itr->is_done())
1370  {
1371  lmember_records.internalize(lrow_itr->index());
1372 
1373  ldof_tuple_records.internalize();
1374  lrow_itr->next();
1375  }
1376  delete lrow_itr;
1377 
1378  // Finished with the bounds; detach them.
1379 
1380  // Close the record sets.
1381 
1382  lmember_records.close();
1383  ldof_tuple_records.close();
1384  lattributes_records.close();
1385 
1386 #ifdef DIAGNOSTIC_OUTPUT
1387 
1388  cout << endl << SOURCE_CODE_LOCATION;
1389  cout << "closed record sets for poset " << lposet.name() << endl;
1390 #endif
1391 
1392  // Tranfser member names from scaffold to poset.
1393  // Have to do this after member_names_record in attribute record set
1394  // has been internalized and after all members have been internalized.
1395 
1396  lscaffold.put_member_names_to_poset();
1397 
1398  // Make sure client handle is attached to
1399  // new state created by read.
1400 
1401  if(xposet.is_external())
1402  {
1403  xposet.attach_to_state(&lposet);
1404  }
1405 
1406  // Release any access acquired by the read process.
1409 
1410  while(lposet.access_request_depth() > old_access_request_depth)
1411  {
1412  lposet.release_access();
1413  }
1414 
1415 #ifdef DIAGNOSTIC_OUTPUT
1416  cout << lposet << endl;
1417 #endif
1418 
1419  // Postconditions:
1420 
1421  ensure(!xposet.is_external());
1422  ensure(xposet.access_request_depth() == old_access_request_depth);
1423  ensure(read_transaction_is_active(xposet));
1424 
1425  // Exit
1426 
1427  return;
1428 }
1429 
1431 void
1434  const poset_bounds_descriptor& xrow_bounds,
1435  const poset_bounds_descriptor& xcol_bounds)
1436 {
1437 
1438  // Preconditions:
1439 
1440  require(!transaction_is_active(xposet));
1441 
1442  // Body:
1443 
1444  begin_read_transaction(xposet, xrow_bounds, xcol_bounds);
1445 
1446  // Mark transaction as write transaction;
1447 
1448  // // have to remove, modify, and reinsert the transaction.
1449 
1450  // transaction ltrans(active_transaction(xposet));
1451  // remove_active_transaction(xposet);
1452  // ltrans.is_write_transaction = true;
1453  // put_active_transaction(ltrans);
1454 
1455  active_transaction(xposet).is_write_transaction = true;
1456 
1457 
1458  // Postconditions:
1459 
1460  ensure(read_transaction_is_active(xposet));
1461  ensure(write_transaction_is_active(xposet));
1462 
1463  // Exit
1464 
1465  return;
1466 }
1467 
1468 void
1471 {
1472 
1473  // Preconditions:
1474 
1475  require(file_is_read_write_accessible());
1476  require(xns.state_is_read_write_accessible());
1477  require(!transaction_is_active(xns));
1478 
1479  // Body:
1480 
1481  // Enter xns in the set of active write transactions
1482 
1483  poset_bounds_descriptor lcol_bounds(poset_bounds_descriptor::MEMBER_MEMBER,
1484  BOTTOM_INDEX,
1485  IO_INDEX);
1486 
1487  transaction ltrans(WRITE, xns, poset_bounds_descriptor::BOTTOM_TOP, lcol_bounds);
1488  put_active_transaction(ltrans);
1489 
1490  // Postconditions:
1491 
1492  ensure(write_transaction_is_active(xns));
1493 
1494  // Exit
1495 
1496  return;
1497 }
1498 
1500 void
1503  const poset_bounds_descriptor& xrow_bounds,
1504  const poset_bounds_descriptor& xcol_bounds)
1505 {
1506 
1507  // Preconditions:
1508 
1509  require(file_is_read_write_accessible());
1510  require(xposet.is_attached());
1511  require(xposet.state_is_read_accessible());
1512  require(!transaction_is_active(xposet));
1513  require(xcol_bounds.ub_member_is_not_top() ?
1514  xposet.schema().ge(xcol_bounds.ub_id()) :
1515  true);
1516 
1517  // Body:
1518 
1519  // Enter xposet in the set of active write transactions
1520 
1521  transaction ltrans(WRITE, xposet, xrow_bounds, xcol_bounds);
1522  put_active_transaction(ltrans);
1523 
1524  // Postconditions:
1525 
1526  ensure(write_transaction_is_active(xposet));
1527 
1528  // Exit
1529 
1530  return;
1531 }
1532 
1534 void
1537 {
1538 
1539  // Preconditions:
1540 
1541  require(file_is_read_write_accessible());
1542  require(write_transaction_is_active(xposet));
1543 
1547 
1548  require(xposet.state_is_read_accessible());
1549 
1550  // Body:
1551 
1552  // Get the transaction description.
1553 
1554  const transaction& ltrans = active_transaction(xposet);
1555 
1556  // Initialize the member and dof tuple index spaces.
1557  // The index spaces maintain the association between
1558  // internal and external index spaces.
1559 
1560  initialize_poset_id_spaces_for_write(xposet);
1561 
1562  // Create the poset scaffold.
1563  // The scaffold buffers various data from when it
1564  // is computed until when it is used or written.
1565 
1566  poset_scaffold lscaffold(xposet,
1567  ltrans,
1568  file().type_map(),
1569  _file_id_space_name,
1570  true);
1571 
1572  // Write the posets on which this poset depends.
1573 
1574  write_prerequisites(lscaffold);
1575 
1576  // Write this poset
1577 
1578 #ifdef DIAGNOSTIC_OUTPUT
1579  cout << endl << SOURCE_CODE_LOCATION;
1580  cout << "opening record sets for poset " << xposet.name() << endl;
1581 #endif
1582 
1583  // Transfeer member names from poset to scaffold.
1584  // Have to do this before attributes records are externalized,
1585  // but now is a good a time as any.
1586 
1587  lscaffold.get_member_names_from_poset();
1588 
1589  // Open all the record sets.
1590 
1591  dof_tuple_record_set ldof_tuple_records(file(),
1592  dof_tuple_record_size(),
1593  dof_tuple_record_buffer_ub(),
1594  lscaffold);
1595  ldof_tuple_records.open();
1596 
1597 
1598  member_record_set lmember_records(file(),
1599  member_record_buffer_ub(),
1600  lscaffold,
1601  ldof_tuple_records);
1602  lmember_records.open();
1603  // lmember_records.initialize_external_ids();
1604 
1605  attributes_record_set lattributes_records(file(), lscaffold);
1606  lattributes_records.open();
1607 
1608  // Write the record sets.
1609 
1610  lscaffold.evaluate_toc_alias();
1611 
1612  index_iterator* lrow_itr = xposet.bound_iterator(lscaffold.row_bounds(), true);
1613 
1614  while(!lrow_itr->is_done())
1615  {
1616  lmember_records.externalize(lrow_itr->index());
1617 
1618  ldof_tuple_records.externalize();
1619 
1620  lrow_itr->next();
1621  }
1622  delete lrow_itr;
1623 
1624  lattributes_records.externalize();
1625 
1626  // Close the record sets.
1627 
1628  lmember_records.close();
1629  ldof_tuple_records.close();
1630  lattributes_records.close();
1631 
1632 #ifdef DIAGNOSTIC_OUTPUT
1633  cout << endl << SOURCE_CODE_LOCATION;
1634  cout << "closed record sets for poset " << xposet.name() << endl;
1635 #endif
1636 
1637  // Now the state is consistent.
1638 
1639  put_state_is_consistent(xposet);
1640 
1641  // Postconditions:
1642 
1643  ensure(write_transaction_is_active(xposet));
1644  ensure(state_is_consistent(xposet));
1645 
1646  // Exit
1647 
1648  return;
1649 }
1650 
1652 void
1654 end_transaction(poset_state_handle& xposet, bool xcommit)
1655 {
1656 
1657  // Preconditions:
1658 
1659  require(transaction_is_active(xposet));
1660  require(xcommit ? file_is_read_write_accessible() : true);
1661  require(xcommit ? write_transaction_is_active(xposet) : true);
1662 
1663  // Body:
1664 
1665  define_old_variable(int old_access_request_depth = xposet.access_request_depth());
1666 
1667  if(xcommit)
1668  commit_transaction(xposet);
1669 
1670  // Remove the xposet from the set of active transactions
1671 
1672  remove_active_transaction(xposet);
1673 
1674  // Postconditions:
1675 
1676  ensure(!transaction_is_active(xposet));
1677  ensure( xcommit ? state_is_consistent(xposet) : true );
1678  ensure(xposet.access_request_depth() == old_access_request_depth);
1679 
1680  // Exit
1681 
1682  return;
1683 }
1684 
1685 
1686 // ===========================================================
1687 // BUFFER SIZE CONTROL FACET
1688 // ===========================================================
1689 
1690 
1691 
1693 int
1696 {
1697  return _member_record_buffer_ub;
1698 }
1699 
1700 
1702 void
1705 {
1706  // Preconditions:
1707 
1708  require(xub > 0);
1709 
1710  // Body:
1711 
1712  _member_record_buffer_ub = xub;
1713 
1714  // Postconditions:
1715 
1716  ensure(member_record_buffer_ub() == xub);
1717 
1718  // Exit
1719 
1720  return;
1721 }
1722 
1724 size_t
1727 {
1728  return _dof_tuple_record_size;
1729 }
1730 
1732 void
1735 {
1736  // Preconditions:
1737 
1738  // Body:
1739 
1740  _dof_tuple_record_size = xsize;
1741 
1742  // Postconditions:
1743 
1744  ensure(dof_tuple_record_size() == xsize);
1745 
1746  // Exit
1747 
1748  return;
1749 }
1750 
1752 int
1755 {
1756  return _dof_tuple_record_buffer_ub;
1757 }
1758 
1760 void
1763 {
1764  // Preconditions:
1765 
1766  require(xub > 0);
1767 
1768  // Body:
1769 
1770  _dof_tuple_record_buffer_ub = xub;
1771 
1772  // Postconditions:
1773 
1774  ensure(dof_tuple_record_buffer_ub() == xub);
1775 
1776  // Exit
1777 
1778  return;
1779 }
1780 
1781 // TRANSACTION STATUS FACET
1782 
1784 int
1787 {
1788  int result;
1789 
1790  // Preconditions:
1791 
1792  // Body:
1793 
1794  result = _active_transactions.size();
1795 
1796  // Postconditions:
1797 
1798  ensure(result >= 0);
1799 
1800  // Exit
1801 
1802  return result;
1803 }
1804 
1805 
1806 
1808 bool
1811 {
1812  bool result;
1813 
1814  // Preconditions:
1815 
1816  // Body:
1817 
1818  transaction ltrans(xindex);
1819  set<transaction>::const_iterator itr = _active_transactions.find(ltrans);
1820 
1821  result = itr != _active_transactions.end();
1822 
1823  // Postconditions:
1824 
1825  // Exit
1826 
1827  return result;
1828 }
1829 
1830 
1831 
1833 bool
1836 {
1837  bool result;
1838 
1839  // Preconditions:
1840 
1841  // Body:
1842 
1843  transaction ltrans(READ, xposet); // type doesn't matter here.
1844  set<transaction>::const_iterator itr = _active_transactions.find(ltrans);
1845 
1846  result = itr != _active_transactions.end();
1847 
1848  // Postconditions:
1849 
1850  // Exit
1851 
1852  return result;
1853 }
1854 
1855 
1856 
1858 bool
1861 {
1862  bool result;
1863 
1864  // Preconditions:
1865 
1866  // Body:
1867 
1868  transaction ltrans(READ, xposet); // type doesn't matter here.
1869  set<transaction>::const_iterator itr = _active_transactions.find(ltrans);
1870 
1871  result = (itr != _active_transactions.end()) && itr->is_read_transaction;
1872 
1873  // Postconditions:
1874 
1875  // Exit
1876 
1877  return result;
1878 }
1879 
1880 
1881 
1883 bool
1886 {
1887  bool result;
1888 
1889  // Preconditions:
1890 
1891  // Body:
1892 
1893  transaction ltrans(WRITE, xposet); // type doesn't actually matter here.
1894  set<transaction>::const_iterator itr = _active_transactions.find(ltrans);
1895 
1896  result = (itr != _active_transactions.end()) && itr->is_write_transaction;
1897 
1898  // Postconditions:
1899 
1900  // Exit
1901 
1902  return result;
1903 }
1904 
1905 
1906 
1908 bool
1911 {
1912  bool result;
1913 
1914  // Preconditions:
1915 
1916  // Body:
1917 
1918 
1919  result = read_transaction_is_active(xposet) &&
1920  write_transaction_is_active(xposet);
1921 
1922  // Postconditions:
1923 
1924  // Exit
1925 
1926  return result;
1927 }
1928 
1929 
1930 
1932 bool
1935 {
1936  bool result;
1937 
1938  // Preconditions:
1939 
1940  require(xposet.is_attached() ? xposet.state_is_read_accessible() : true);
1941 
1942  // Body:
1943 
1944  // The definition of this condition is:
1945  // internal state exists and
1946  // external state exists and
1947  // internal hasn't been modified since external was written.
1948 
1949  // internal state exists = xposet.is_attached();
1950  // external state exists = member index space exists
1951  // not modified = !xposet.state_is_modified()
1952  //
1953  // Note that is_attached() is a precondition for evaluating the
1954  // other two conditions.
1955 
1963 
1964  result = xposet.is_attached();
1965 
1966  result =
1967  result &&
1968  xposet.member_id_spaces(false).contains(_file_id_space_name) &&
1969  !xposet.member_id_spaces(false).is_empty(_file_id_space_name);
1970 
1971  result =
1972  result &&
1973  xposet.subposet_id_spaces(false).contains(_file_id_space_name) &&
1974  !xposet.subposet_id_spaces(false).is_empty(_file_id_space_name);
1975 
1976  result =
1977  result &&
1978  xposet.dof_tuple_id_spaces(false).contains(_file_id_space_name);
1979 
1980  result = result && !xposet.state_is_modified();
1981 
1982  // Postconditions:
1983 
1984  // Exit
1985 
1986  return result;
1987 }
1988 
1989 
1990 // PROTECTED MEMBER FUNCTIONS
1991 
1992 void
1995 {
1996  // Preconditions:
1997 
1998  require(xposet.is_attached());
1999 
2000  // Body:
2001 
2002  xposet.clear_state_is_modified();
2003 
2004  // Postconditions:
2005 
2006  // Exit
2007 
2008  return;
2009 }
2010 
2011 // ROUTINES TO SUPPORT INDEPENDENT ACCESS
2012 
2014 void
2017  const poset_bounds_descriptor& xcol_bounds)
2018 {
2019 
2020  // Preconditions:
2021 
2022  require(xposet.name_space()->state_is_read_write_accessible());
2023 
2024  // Body:
2025 
2026  namespace_poset* lns = xposet.name_space();
2027 
2028  // Read the posets on which this poset depends:
2029  // Get a handle to the name space member for xposet.
2030 
2031  namespace_poset_member lname_space_mbr(xposet.name_space(), xposet.index());
2032 
2033 #ifdef DIAGNOSTIC_OUTPUT
2034  cout << "Inspecting prerequisites of poset " << lname_space_mbr.name() << endl;
2035 #endif
2036 
2037  // Read prerequisites.
2038 
2039  for(int i=0; i<PREREQ_IDS_UB; ++i)
2040  {
2041  pod_index_type lprereq_id = lname_space_mbr.poset_prereq_id(i);
2042 
2043 #ifdef DIAGNOSTIC_OUTPUT
2044  cout << "\tprereq_id = " << lprereq_id << endl;
2045 #endif
2046 
2047  if(is_valid(lprereq_id))
2048  {
2049  // Get the poset associated with the member; has to be non-null
2050 
2051  poset_state_handle& lposet = lns->member_poset(lprereq_id);
2052 
2053  if(lposet.is_external())
2054  {
2055  // Prerequisite has not been read in; read it.
2056 
2057  begin_read_transaction(lposet);
2058  }
2059 
2060  // We'll need read access to the
2061  // prerequisite to read the poset.
2062  // Released in table_dof_tuple_record::release_prerequisites()
2063  // after we've actually created the poset state.
2064 
2065  lposet.get_read_access();
2066 
2067 #ifdef DIAGNOSTIC_OUTPUT
2068  cout << "prereq name: " << lposet.name() << endl;
2069 #endif
2070 
2071  // lposet is handle from namespace - do not detach or delete it!
2072  }
2073  }
2074 
2075  // Clean up
2076 
2077  lname_space_mbr.detach_from_state();
2078 
2079  // Postconditions:
2080 
2081  ensure(unexecutable(all prerequisites have been internalized));
2082 
2083  // Exit
2084 
2085  return;
2086 }
2087 
2089 void
2092 {
2093 
2094  // Preconditions:
2095 
2096  require(!xscaffold.structure().is_external());
2097  require(xscaffold.name_space()->state_is_read_accessible());
2098 
2099  // Body:
2100 
2101  // Make sure the posets on which this poset depends have been written to the file:
2102 
2103  namespace_poset* lns = xscaffold.name_space();
2104  if(xscaffold.structure_is_namespace())
2105  {
2106  // This poset is the namespace.
2107  // It's prerequisite is the namespace schema poset.
2108 
2109  if(!state_is_consistent(lns->namespace_schema()))
2110  {
2111  write(lns->namespace_schema());
2112  }
2113  }
2114  else
2115  {
2116  // This poset is an ordinary poset.
2117 
2118  // Prerequisites are represented by the name space order.
2119  // Get a handle to the name space member for xposet.
2120 
2121  namespace_poset_member lname_space_mbr(lns, xscaffold.index());
2122 
2123 #ifdef DIAGNOSTIC_OUTPUT
2124  cout << "Inspecting prerequisites of poset " << lname_space_mbr.name() << endl;
2125 #endif
2126 
2127  for(int i=0; i<PREREQ_IDS_UB; ++i)
2128  {
2129  pod_index_type lprereq_id = lname_space_mbr.poset_prereq_id(i);
2130 
2131 #ifdef DIAGNOSTIC_OUTPUT
2132  cout << "\tprereq_id = " << lprereq_id << endl;
2133 #endif
2134 
2135  if(is_valid(lprereq_id))
2136  {
2137  // Get the poset associated with the member
2138 
2139  poset_state_handle& lposet = lns->member_poset(lprereq_id);
2140 
2141  lposet.get_read_access();
2142 
2143 #ifdef DIAGNOSTIC_OUTPUT
2144  cout << "prereq name: " << lposet.name() << endl;
2145 #endif
2146 
2147  if(!state_is_consistent(lposet))
2148  {
2149  // Prerequisite has been modified since last written to file; write it out.
2150  // Note that this writes the entire prerequisite poset out, not just some part
2151  // of it. In particular, it will write out an entire schema, not just the
2152  // down set of the schema member of the poset that triggered this write.
2153 
2154  write(lposet);
2155 
2158  }
2159 
2160  lposet.release_access();
2161 
2162  // lposet is handle from namespace - do not detach or delete it!
2163  }
2164  }
2165 
2166  // Clean up
2167 
2168  lname_space_mbr.detach_from_state();
2169  }
2170 
2171 
2172  // Postconditions:
2173 
2175 
2176  ensure(unexecutable("for all prerequisites p: state_is_consistent(p)"));
2177 
2178  // Exit
2179 
2180  return;
2181 }
2182 
2183 void
2186 {
2187  // Preconditions:
2188 
2192 
2193  require(xposet.state_is_read_accessible());
2194 
2195  // Body:
2196 
2197  // Make sure the member id space exists.
2198  // Don't clear the id space or initialize scratch ids;
2199  // may need entries from previous partial read or write.
2200 
2201  if(!xposet.member_id_spaces(false).contains(_file_id_space_name))
2202  {
2203  // Doesn't exist; create it.
2204 
2205  interval_index_space_handle::new_space(xposet.member_id_spaces(false),
2206  _file_id_space_name, false, false);
2207  }
2208 
2209  // Get a subposet index id space for this poset; create it if needed or
2210  // clear the id space; entries get reconstructed on each read or write.
2211 
2212  if(!xposet.subposet_id_spaces(false).contains(_file_id_space_name))
2213  {
2214  // Doesn't exist; create it.
2215 
2216  interval_index_space_handle::new_space(xposet.subposet_id_spaces(false),
2217  _file_id_space_name, false, false);
2218  }
2219  else
2220  {
2222  xposet.subposet_id_spaces(false).
2223  get_id_space<scattered_insertion_index_space_handle>(_file_id_space_name);
2224  lid_space.clear();
2225  lid_space.release_id_space();
2226  }
2227 
2228  // Get a dof tuple index id space for this poset; create it if needed.
2229  // Don't clear the id space, may need entries from previous partial read or write.
2230 
2231  if(!xposet.dof_tuple_id_spaces(false).contains(_file_id_space_name))
2232  {
2233  // Doesn't exist; create it.
2234 
2235  interval_index_space_handle::new_space(xposet.dof_tuple_id_spaces(false),
2236  _file_id_space_name, false, false);
2237  }
2238 
2239  // Postconditions:
2240 
2241  ensure(xposet.member_id_spaces(false).contains(file_id_space_name()));
2242  ensure(xposet.subposet_id_spaces(false).contains(file_id_space_name()));
2243  ensure(xposet.dof_tuple_id_spaces(false).contains(file_id_space_name()));
2244 
2245  // Exit
2246 
2247  return;
2248 }
2249 
2251 void
2254 {
2255  // Preconditions:
2256 
2257  require(xns.state_is_read_write_accessible());
2258 
2260 
2261  // Body:
2262 
2263  // Clear the member file id spaces for the name space
2264  // and every poset in it.
2265 
2267 
2268  zn_to_bool_postorder_itr itr0(xns.top(), "jims", DOWN, NOT_STRICT);
2269  while(!itr0.is_done())
2270  {
2271  poset_state_handle& lmbr_poset = xns.member_poset(itr0.index());
2272  if(!lmbr_poset.is_external())
2273  {
2274  lmbr_poset.get_read_write_access(true);
2275  if(lmbr_poset.member_id_spaces(false).contains(_file_id_space_name))
2276  {
2277  lid_space.attach_to(lmbr_poset.member_id_spaces(false), _file_id_space_name);
2278  lid_space.clear();
2279  }
2280 
2281  poset_powerset_state& lmbr_powerset = lmbr_poset.powerset();
2282  if(lmbr_poset.subposet_id_spaces(false).contains(_file_id_space_name))
2283  {
2284  lid_space.attach_to(lmbr_poset.subposet_id_spaces(false), _file_id_space_name);
2285  lid_space.clear();
2286  }
2287 
2288  poset_table_state& lmbr_table = lmbr_poset.table();
2289  if(lmbr_poset.dof_tuple_id_spaces(false).contains(_file_id_space_name))
2290  {
2291  lid_space.attach_to(lmbr_poset.dof_tuple_id_spaces(false), _file_id_space_name);
2292  lid_space.clear();
2293  }
2294 
2295  lmbr_poset.release_access();
2296  }
2297 
2298  itr0.next();
2299  }
2300 
2301  if(xns.member_id_spaces(false).contains(_file_id_space_name))
2302  {
2303  lid_space.attach_to(xns.member_id_spaces(false), _file_id_space_name);
2304  lid_space.clear();
2305  }
2306 
2307  if(xns.subposet_id_spaces(false).contains(_file_id_space_name))
2308  {
2309  lid_space.attach_to(xns.subposet_id_spaces(false), _file_id_space_name);
2310  lid_space.clear();
2311  }
2312 
2313  if(xns.dof_tuple_id_spaces(false).contains(_file_id_space_name))
2314  {
2315  lid_space.attach_to(xns.dof_tuple_id_spaces(false), _file_id_space_name);
2316  lid_space.clear();
2317  }
2318 
2319  // Postconditions:
2320 
2321 
2322  // Exit:
2323 
2324  return;
2325 }
2326 
2328 void
2331 {
2332  // Preconditions:
2333 
2334  require(xns.state_is_read_write_accessible());
2335 
2336  // Body:
2337 
2338  // Clear all the index spaces.
2339  // Will clear all the file id spaces too, but there shouldn't be any
2340  // at this point.
2341 
2342  clear_all_id_spaces(xns);
2343 
2344  // Index spaces for the namespace poset itself will be
2345  // initialized when the namespace is read.
2346 
2347  // Initialize the subposet, dof_tuple and member index spaces
2348  // for the standard posets. These posets will not be read in
2349  // but the spaces need to exist for consistency.
2350 
2351  pod_index_type lfirst_member = member_record_set::first_member_record();
2352 
2353  interval_index_space_handle lid_space =
2354  interval_index_space_handle::new_space(xns.primitives().member_id_spaces(false),
2355  _file_id_space_name, false, false);
2356 
2357  // then assign record ids sequentially.
2358 
2359  pod_index_type lprim_ct = xns.primitives().standard_member_ct();
2360  lid_space.insert_interval(lfirst_member, lfirst_member+lprim_ct, 0, lprim_ct);
2361 
2362  // Initialize primitives schema space.
2363 
2364  lid_space =
2365  interval_index_space_handle::new_space(xns.primitives_schema().member_id_spaces(false),
2366  _file_id_space_name, false, false);
2367 
2368  // Reserve 0-th record for id space,
2369  // then assign record ids sequentially.
2370 
2371  pod_index_type lprim_schema_ct =
2373  lid_space.insert_interval(lfirst_member, lfirst_member+lprim_schema_ct,
2374  0, lprim_schema_ct);
2375 
2376  // Initialize namespaces schema space.
2377 
2378  lid_space =
2379  interval_index_space_handle::new_space(xns.namespace_schema().member_id_spaces(false),
2380  _file_id_space_name, false, false);
2381 
2382  // Reserve 0-th record for id space,
2383  // then assign record ids sequentially.
2384 
2385  pod_index_type lnamespace_schema_ct =
2387  lid_space.insert_interval(lfirst_member, lfirst_member+lnamespace_schema_ct,
2388  0, lnamespace_schema_ct);
2389 
2390  // Postconditions:
2391 
2392 
2393  // Exit:
2394 
2395  return;
2396 }
2397 
2399 void
2402 {
2403  // Preconditions:
2404 
2405  require(xns.state_is_read_write_accessible());
2406 
2407  // Body:
2408 
2409  // Clear all the file id spaces.
2410  // Necessary because non-existent or empty file id space
2411  // used by state_is_consistent
2412  // to determine if external state exists.
2413 
2414  clear_all_id_spaces(xns);
2415 
2416  // The id spaces will be recreated and populated as needed
2417  // when the posets are written.
2418 
2419  // Postconditions:
2420 
2421 
2422  // Exit:
2423 
2424  return;
2425 }
2426 
2427 // PRIVATE MEMBER FUNCTIONS
2428 
2432 const string _name_space_ext_name("__name_space");
2433 
2435 bool
2437 operator<(const transaction& xother) const
2438 {
2439  return (target < xother.target);
2440 }
2441 
2445 {
2446  // Preconditions:
2447 
2448  // Body:
2449 
2450  // Postconditions:
2451 
2452  // Exit
2453 
2454  return;
2455 }
2456 
2460  : row_bounds(poset_bounds_descriptor::BOTTOM_TOP),
2461  col_bounds(poset_bounds_descriptor::BOTTOM_TOP)
2462 {
2463  // Preconditions:
2464 
2465  // Body:
2466 
2468 
2469  is_read_transaction = false;
2470  is_write_transaction = false;
2471 
2472  // Postconditions:
2473 
2474  ensure(!is_valid(target));
2475  ensure(!is_read_transaction);
2476  ensure(!is_write_transaction);
2479 
2480  // Exit
2481 
2482  return;
2483 }
2484 
2488  : row_bounds(poset_bounds_descriptor::BOTTOM_TOP),
2489  col_bounds(poset_bounds_descriptor::BOTTOM_TOP)
2490 {
2491  // Preconditions:
2492 
2493  // Body:
2494 
2495  target = xindex;
2496  is_read_transaction = false;
2497  is_write_transaction = false;
2498 
2499  // Postconditions:
2500 
2501  ensure(target == xindex);
2502  ensure(!is_read_transaction);
2503  ensure(!is_write_transaction);
2506 
2507  // Exit
2508 
2509  return;
2510 }
2511 
2515  const poset_state_handle& xposet,
2516  const poset_bounds_descriptor& xrow_bounds,
2517  const poset_bounds_descriptor& xcol_bounds)
2518  : row_bounds(xrow_bounds),
2519  col_bounds(xcol_bounds)
2520 {
2521  // Preconditions:
2522 
2523  // Body:
2524 
2525  target = xposet.index().pod();
2526  switch(xtype)
2527  {
2528  case READ:
2529  is_read_transaction = true;
2530  is_write_transaction = false;
2531  break;
2532 
2533  case WRITE:
2534  is_read_transaction = false;
2535  is_write_transaction = true;
2536  break;
2537 
2538  case READ_WRITE:
2539  is_read_transaction = false;
2540  is_write_transaction = true;
2541  break;
2542  }
2543 
2544  // Postconditions:
2545 
2546  ensure(target == xposet.index().pod());
2547  ensure(is_read_transaction == ((xtype == READ) || (xtype == READ_WRITE)));
2548  ensure(is_write_transaction == ((xtype == WRITE) || (xtype == READ_WRITE)));
2549  ensure(row_bounds == xrow_bounds);
2550  ensure(col_bounds == xcol_bounds);
2551 
2552  // Exit
2553 
2554  return;
2555 }
2556 
2557 
2560 sheaf::storage_agent::
2561 active_transaction(const poset_state_handle& xposet)
2562 {
2563  // Preconditions:
2564 
2565  require(transaction_is_active(xposet));
2566 
2567  // Body:
2568 
2569  transaction ltrans(READ, xposet); // type doesn't matter
2570  set<transaction>::iterator itr = _active_transactions.find(ltrans);
2571 
2572  const transaction& result = *itr;
2573 
2574  // Postconditions:
2575 
2576  // Exit
2577 
2578  return result;
2579 }
2580 
2581 
2583 void
2584 sheaf::storage_agent::
2585 put_active_transaction(transaction& xtransaction)
2586 {
2587  // Preconditions:
2588 
2589  require(!transaction_is_active(xtransaction.target));
2590 
2591  // Body:
2592 
2593  _active_transactions.insert(xtransaction);
2594 
2595  // Postconditions:
2596 
2597  ensure(transaction_is_active(xtransaction.target));
2598 
2599  // Exit
2600 
2601  return;
2602 }
2603 
2605 void
2606 sheaf::storage_agent::
2607 remove_active_transaction(const poset_state_handle& xposet)
2608 {
2609  transaction result;
2610 
2611  // Preconditions:
2612 
2613  // Body:
2614 
2615  transaction ltrans(READ, xposet); // Type doesn't matter.
2616  (void)_active_transactions.erase(ltrans);
2617 
2618  // Postconditions:
2619 
2620  ensure(!transaction_is_active(xposet));
2621 
2622  // Exit
2623 
2624  return;
2625 }
2626 
2627 
2628 
2629 
2630 
2631 
An implementation of class scattered_insertion_index_space_handle that has a interval id space state...
bool is_read_transaction
True if read transaction.
An encapsulation of an HDF file containing sheaf data.
Definition: sheaf_file.h:49
poset_table_state & table() const
The table of dof tuples of this poset.
void read_prerequisites(const poset_state_handle &xposet, const poset_bounds_descriptor &xcol_bounds)
Reads all posets that xposet depends on.
virtual void get_read_write_access(bool xrelease_read_only_access=false)
Get read write access to the state associated with this. If release_read_only_access is requested...
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_...
pod_index_type ub_id() const
The index of the upper bound member, if the upper bound contains a single member. ...
void read_entire(namespace_poset &xns)
Reads the namespace xns and all the posets in it.
poset_state_handle * host() const
The poset which this is a handle to a component of.
void put_state_is_consistent(poset_state_handle &xposet)
Sets the state_is_consistent flag for xposet to true.
virtual void open()
Opens the record_set.
Definition: record_set.cc:450
bool is_valid() const
True if this is a valid id.
Definition: scoped_index.h:832
pod_index_type dof_tuple_id(bool xauto_access) const
The dof tuple index of this member.
void evaluate_toc_alias()
If row bounds lower bound is an alias for the toc bounds, substitutes the toc bounds into the row bou...
namespace_poset * name_space() const
The name space of this poset.
bool is_write_transaction
True if write transaction.
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.
virtual ~storage_agent()
Destructor.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
void put_name(const std::string &xname)
Sets name() to xname. Intended for use only by storage_agent::begin_read_transaction(namespace_poset&...
virtual void close()
Closes the record_set.
Definition: record_set.cc:588
namespace_poset_schema & namespace_schema()
The namespace poset schema within this namespace (mutable version)
const scoped_index & index() const
The member index of this poset within the namespace host()
bool state_is_consistent(const poset_state_handle &xposet) const
True if uncommitted state is consistent with committed state.
dof_tuple_types_type & dof_tuple_types()
Dof tuple type ids (mutable version).
const std::string & file_id_space_name() const
The name of the id spaces associated with this file in each poset.
void internalize()
Internalize the members of scafold().structure() from disk.
std::string poset_name() const
The name of the poset this represents, extracted from the name of the dataset.
Definition: record_set.cc:373
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
void put_member_record_buffer_ub(int xub)
Sets the number of records allocated in a member record buffer during a transaction.
scoped_index dof_tuple_ext_id(const scoped_index &xid) const
An id in the dof tuple external id space with pod mapped from xid.
A client handle for a general, abstract partially order set.
access_mode
File access modes.
Definition: sheaf_file.h:111
virtual bool includes_subposet(pod_index_type xsubposet_hub_id, bool xauto_access=true) const
True if this poset includes subposet with hub id xsubposet_hub_id.
const index_space_family & dof_tuple_id_spaces(bool xauto_access) const
Collection of dof tuple id spaces for this (const version).
int transaction_ct() const
The number of active transactions.
primitives_poset & primitives()
The poset of primitives for this namespace (mutable version)
const scoped_index & index() const
The current item in the subset.
void put_dof_tuple_record_size(size_t xsize)
OBSOLETE: no longer used. Sets the number of bytes in a dof_tuple record.
const index_space_family & member_id_spaces(bool xauto_access) const
Collection of member id spaces for this (const version).
STL namespace.
Specialization of the filtered depth-first iterator which exposes the POSTVISIT_ACTION to the client...
Definition: postorder_itr.h:40
virtual void release_id_space() const
Returns this id space handle to the handle pool.
pod_index_type ub_id() const
The index of the upper bound member, if the upper bound contains a single member. ...
poset_state_handle & member_poset(pod_index_type xhub_id, bool xauto_access=true) const
The poset_state_handle object referred to by hub id xhub_id.
void initialize_poset_id_spaces_for_write(poset_state_handle &xposet)
Initializes the subposet and dof tuple index spaces for poset xposet.
poset_bounds_descriptor col_bounds
Bounds for the columns accessed in this transaction.
const scoped_index & index() const
The index of the component state this handle is attached to.
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.
sheaf_file & file()
The file this is attached to.
std::string name() const
A name for this.
virtual bool invariant() const
Class invariant.
dof_tuple_class_names_type & dof_tuple_class_names()
Dof tuple class names (mutable version).
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.
bool file_is_read_accessible() const
True if file is open.
bool read_transaction_is_active(const poset_state_handle &xposet) const
True if there is an active read transaction for poset xposet.
primitives_poset_schema & primitives_schema()
The schema poset for the primitives poset (mutable version)
void next()
Makes item the next member of the subset.
A client handle for a member of a namespace poset.
transaction()
Default constructor.
void clear_all_id_spaces(namespace_poset &xns)
Clears all dof tuple index spaces.
void commit_transaction(poset_state_handle &xposet)
Commits the uncommitted state, but does not end the transaction or release read access.
void read_toc(poset_state_handle &xposet)
Reads the table of contents portion of poset xposet.
Abstract base class with useful features for all objects.
Definition: any.h:39
A record_set containing records of type member_record.
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 ident...
const bool NOT_STRICT
Iteration strictness control.
Definition: sheaf.h:102
const bool DOWN
Iteration directions.
Definition: sheaf.h:77
virtual int standard_member_ct() const
The number of standard members automatically allocated by the constructor.
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 ...
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 aut...
void clear_state_is_modified()
Sets the state_is_modified floag to false.
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
void end_transaction(poset_state_handle &xposet, bool xcommit=true)
Ends an independent access transaction.
pod_index_type target
The index of the target poset of the transaction.
namespace_poset_member & top()
The top member of the poset (mutable version)
bool ub_member_is_not_top() const
True if ub_is_member() and ub_id() is not sheaf_constants::TOP_INDEX.
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()).
void reset_time()
Reset the start time. Set the start time to the CPU time when this function is called.
bool is_external() const
True if this has a corresponding member in a name space, but is not yet attached to a state...
bool state_is_read_write_accessible() const
True if this is attached and if the state is accessible for read and write or access control is disab...
void get_member_names_from_poset()
Transfers the enitre poset member name map to the scaffold name map.
poset_bounds_descriptor row_bounds
Bounds for the rows accessed in this transaction.
void write(namespace_poset &xns)
Writes the namespace xns.
void write_remainder(const namespace_poset &xns)
Writes all the posets in namespace xns that have not already been written.
transaction_type
Type of access associated with a transaction.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
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...
void read(namespace_poset &xns)
Reads the namespace xns.
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...
bool state_is_modified() const
True if write access has been granted and released since the last call to clear_state_is_modified().
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...
void internalize(pod_index_type xmax_row_int_id)
Internalize the members of scafold().structure() from disk.
void read_index(poset_state_handle &xposet)
Reads the index of poset xposet; that is, it does not read the dof tuples.
bool transaction_is_active(pod_index_type xindex) const
True if either a read or write transaction is active for poset with index xindex. ...
poset_bounds & row_bounds()
The bounds for the rows in this transaction (mutable version).
virtual std::string member_name(pod_index_type xmbr_hub_id, bool xauto_access=false) const
A name for the member with hub id xmbr_hub_id.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
void internalize()
Internalize the record set from disk.
void clear()
Removes all members except the standard members.
static const poset_bounds_descriptor & BOTTOM_TOP
An instance with lb() == {bottom} and ub() == {top}.
void externalize_domain(const scoped_index &xtuple_ext_id, const scoped_index &xschema_id)
Externalize the domain specified by the schema member with index xschema_id.
bool structure_is_namespace() const
True if the poset being transferred is the name space poset.
dof_tuple_type
Identifiers for dof tuple types.
void attach_to_state(const poset_state_handle *xother)
Attach this handle to the same state as xother.
virtual std::string name() const
The name of this poset.
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 ...
const index_space_family & subposet_id_spaces(bool xauto_access) const
Collection of subposet id spaces for this (const version).
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...
void begin_write_transaction(namespace_poset &xns)
Begins an independent write transaction for the namespace xns.
virtual storage_agent * clone() const
Virtual constructor; makes a new instance of the same type as this.
void externalize()
Externalize the members of scafold().structure() to disk.
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...
Iterates over the subset of Zn defined by the characteristic function host().
bool file_is_read_write_accessible() const
True if file is open with READ_WRITE.
namespace_poset * name_space() const
The namespace this poset resides in.
bool ge(pod_index_type xother_index) const
True if this is greater than or equal to the member with index xother_index.
virtual bool is_attached() const
True if this is attached to a state.
A record set for storing various poset attributes.
A description of a (lower, upper) bounds pair for a poset. Specifies a portion of a poset for a bound...
void externalize()
Externalize the reccord set to disk.
bool is_empty(const std::string &xname) const
True if there are no ids in the space with name xname.
static const bool ABORT
Value to indicate transaction should not be committed.
index_iterator * bound_iterator(const poset_bounds &xbnd_id, bool xis_ub) const
An iterator for the upper bound (xis_ub == true) or the lower bound (xis_ub == false) for xbounds...
static const bool RETAIN_READ
Value to indicate read access should be retained.
int access_request_depth() const
The number of times access has been requested and granted without being released. ...
pod_index_type compute_ext_id(const scoped_index &xtuple_id)
Computes the external id for the dof tuple dof tuple with id xtuple_id.
virtual std::string name() const
The name of this poset.
void read_remainder(namespace_poset &xns)
Reads all members of the namespace that have not already been read.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
static const bool RELEASE_ALL
Value to indicate read access should not be retained.
bool is_done() const
True if iteration finished.
bool file_is_read_only_accessible() const
True if file is open with READ_ONLY access.
scoped_index index() const
The name space index of this poset.
static const bool COMMIT
Value to indicate transaction should be committed.
A handle for a scattered_insertion_index_space_state.
void externalize(pod_index_type xmax_row_int_id)
Externalize the members of scafold().structure() to disk.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
A poset specific collection of data converters, various buffers and other data used while transferrin...
virtual void open()
Opens the record_set.
int member_record_buffer_ub() const
The number of records allocated in a member record buffer during a transaction.
void begin_read_transaction(namespace_poset &xns)
Begins an independent read transaction for the namespace xposet.
virtual dof_tuple_type type_id() const =0
An identifer for the type of dof tuple this is.
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...
void write_entire(namespace_poset &xns)
Writes the namespace xns and all the posets in it. Rewrites any posets that have already been written...
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.
virtual poset_dof_map & dof_map(bool xrequire_write_access=false)
The map from schema member ids or client ids to dof values for this poset member (mutable version) ...
bool read_write_transaction_is_active(poset_state_handle &xposet) const
True if both a read-write transaction is active.
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.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
Definition: pod_types.cc:37
virtual const std::string & class_name() const
The name of the actual (possibly derived) class of this instance.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
Definition: pod_types.cc:31
The set of subsets of a poset.
clock_t time() const
Return the CPU time between when reset_time() was last called and when this function is called...
void write_prerequisites(const poset_scaffold &xscaffold)
Writes all posets that xposet depends on.
bool operator<(const transaction &xother) const
True if this.target < xother.target.
void put_member_names_to_poset()
Transfers all entries in scaffold name map that refer members that exist in the poset.
The data structure representing the table containing the dof tuples of the members of a poset...
poset_powerset_state & powerset() const
The set of subposets of this poset.
storage_agent()
Default constructor.
Agent responsible for importing and exporting posets from an external name space which resides on dis...
Definition: storage_agent.h:74
const int PREREQ_IDS_UB
Number of prerequisites ids. Must be consistent with PREREQ_ID_*_INDEX below.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710