SheafSystem  0.0.0.0
record_set.h
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 // Interface for class record_set
19 
20 #ifndef RECORD_SET_H
21 #define RECORD_SET_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef ANY_H
28 #include "SheafSystem/any.h"
29 #endif
30 
31 #ifndef POSET_SCAFFOLD_H
32 #include "SheafSystem/poset_scaffold.h"
33 #endif
34 
35 #ifndef RECORD_INDEX_H
36 #include "SheafSystem/record_index.h"
37 #endif
38 
39 #ifndef STD_HDF5_H
40 #include "SheafSystem/std_hdf5.h"
41 #endif
42 
43 #ifndef STD_STRING_H
44 #include "SheafSystem/std_string.h"
45 #endif
46 
47 namespace sheaf
48 {
49 
50 class sheaf_file;
51 class record;
52 class poset_data_type_map;
53 
105 
106 // The hdf buffer is allocated in
107 // the record set, while the external buffer is currently
108 // allocated individually in each record, after the length of
109 // the data has been determined. (This process can and should be
110 // optimized by some sort of pool allocation scheme for the
111 // actual data.)
112 //
113 // The process for externalizing any of these record sets is the same:
114 // allocate the hvl_t buffer in the constructor
115 // for each record:
116 // transfer the poset info to the internal buffer
117 // initialize the external buffer
118 // convert the internal buffer to the external buffer
119 // transfer the external buffer to hdf (i.e. set the hvl_t)
120 //
121 // The process for internalizing is essentially the reverse :
122 // allocate the hvl_t buffer in the constructor
123 // for each record:
124 // transfer the hdf buffer to the external buffer
125 // (i.e. make the external buffer point at the
126 // memory allocated by hdf)
127 // convert the external buffer to the internal buffer
128 // transfer the internal buffer to the poset
129 //
130 //
131 // The dof_tuple_record_set is different for three reasons:
132 // 1. Restriction requires random access to individual dofs, not
133 // just entire dof tuples. Hence, the dof_tuple_record_set must
134 // contain a dataspace of rank 2, the 2 indices being dof_tuple_id
135 // and dof id.
136 // 2. While in general the dofs are of inhomogeneous
137 // type and must be implemented as variable length of char, the
138 // homogeneous case is an important optimization which must be supported.
139 // The data type is thus either variable length of char or some
140 // specific primitive type, depending on the case.
141 // 3. There is no separate internal buffer. The dof tuple itself
142 // is used as the internal buffer.
143 //
144 //
150 class SHEAF_DLL_SPEC record_set : public any
151 {
152 
153 public:
154 
155  // =============================================================================
156  // ANY FACET
157  // =============================================================================
158 
164  virtual record_set* clone() const;
165 
169  virtual bool invariant() const;
170 
174  virtual bool is_ancestor_of(const any* other) const;
175 
176 
177  // =============================================================================
178  // RECORD_SET FACET
179  // =============================================================================
180 
187  record_set(const sheaf_file& xfile, int xrecord_buffer_ub, const poset_scaffold& xscaffold);
188 
193  record_set(const record_set& xother);
194 
198  virtual ~record_set();
199 
203  const sheaf_file& file() const;
204 
208  std::string name() const;
209 
213  std::string alias() const;
214 
218  static const std::string& name_space_alias();
219 
223  static const std::string& name_space_prefix();
224 
228  virtual const std::string& suffix() const;
229 
233  std::string data_set_name(const std::string& xname) const;
234 
238  std::string data_set_alias(const std::string& xname) const;
239 
244  std::string poset_name() const;
245 
249  poset_scaffold& scaffold();
250 
254  const poset_scaffold& scaffold() const;
255 
259  poset_data_type_map& type_map();
260 
264  const poset_data_type_map& type_map() const;
265 
269  virtual void open();
270 
274  bool is_open() const;
275 
279  virtual void close();
280 
284  int record_buffer_ct() const;
285 
289  void inc_record_buffer_ct();
290 
294  void reset_record_buffer_ct();
295 
299  int record_buffer_ub() const;
300 
304  bool record_buffer_is_empty() const;
305 
309  bool record_buffer_is_full() const;
310 
311 protected:
312 
317  virtual hid_t create_dataset() = 0;
318 
323  virtual void create_int_data_type() = 0;
324 
329  void extend_dataset(const hsize_t* xdims, int xdims_ub);
330 
334  void create_alias();
335 
339  void set_name_from_alias();
340 
341 
345  hid_t hdf_id();
346 
350  hid_t ext_dataspace_hdf_id();
351 
355  hid_t ext_data_type_hdf_id();
356 
360  int ext_dataspace_rank();
361 
365  hsize_t ext_dataspace_dim(int xi);
366 
371  hid_t int_dataspace_hdf_id();
372 
376  hid_t int_data_type_hdf_id();
377 
378  // Default constructor;
379  // not supported because can not initialize reference data members
380  // record_set();
381 
386 
390  std::string _name;
391 
395  std::string _alias;
396 
401 
405  hid_t _hdf_id;
406 
411 
416 
421 
426 
431  static const hid_t NOT_AN_HDF_ID;
432 
437 
442 
448 
453 
458  virtual void read_dataset_attributes();
459 
464  virtual void write_dataset_attributes();
465 
469  void read_attribute(const char*& xatt_values,
470  size_type& xatt_ct,
471  const data_converter* xatt_conv,
472  const std::string& xatt_name);
476  void write_attribute(const void* xatt_values,
477  size_type xatt_ct,
478  const data_converter* xatt_conv,
479  const std::string& xatt_name);
480 
481 
482 };
483 
484 } // namespace sheaf
485 
486 #endif // ifndef RECORD_SET_H
487 
488 
489 
490 
491 
492 
An encapsulation of an HDF file containing sheaf data.
Definition: sheaf_file.h:49
sheaf_file & _file
The file this record_set belongs to.
Definition: record_set.h:385
int _ext_dataspace_rank
The rank of the dataspace for the record_set.
Definition: record_set.h:420
hsize_t * _ext_dataspace_dims
The current dimensions of the external dataspace.
Definition: record_set.h:425
int _record_buffer_ub
The maximum number of records the buffer can hold.
Definition: record_set.h:441
poset_scaffold & _scaffold
The poset scaffold associated with this.
Definition: record_set.h:400
hid_t _hdf_id
The HDF id for this record set.
Definition: record_set.h:405
Abstract base class with useful features for all objects.
Definition: any.h:39
std::string _alias
The standard alias for this record_set.
Definition: record_set.h:395
hid_t _ext_data_type_hdf_id
The HDF external data type id for this record set.
Definition: record_set.h:415
A poset specific collection of data converters, various buffers and other data used while transferrin...
hid_t _int_data_type_hdf_id
The HDF internal data type id for this record set.
Definition: record_set.h:452
std::string _name
The name of this record_set.
Definition: record_set.h:390
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
An abstract, indexed collection of records on secondary storage.
Definition: record_set.h:150
Function object to convert between internal and external data formats.
Namespace for the sheaves component of the sheaf system.
A poset specific collection of data converters, various buffers and other data used while transferrin...
static const hid_t NOT_AN_HDF_ID
Value indicating an invalid HDf object id. /.
Definition: record_set.h:431
hid_t _ext_dataspace_hdf_id
The HDF id for the external dataspace of this record set.
Definition: record_set.h:410
int _record_buffer_ct
The number of active records in record buffer.
Definition: record_set.h:436
hid_t _int_dataspace_hdf_id
The hdf5 id of the dataspace associated with the record buffer.
Definition: record_set.h:447