casacore
BaseTable.h
Go to the documentation of this file.
1 //# BaseTable.h: Abstract base class for tables
2 //# Copyright (C) 1994,1995,1996,1997,1998,2000,2001,2002,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef TABLES_BASETABLE_H
29 #define TABLES_BASETABLE_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/Tables/TableInfo.h>
35 #include <casacore/tables/Tables/TableDesc.h>
36 #include <casacore/tables/Tables/StorageOption.h>
37 #include <casacore/casa/Utilities/Compare.h>
38 #include <casacore/casa/Utilities/CountedPtr.h>
39 #include <casacore/casa/BasicSL/String.h>
40 #include <casacore/casa/IO/FileLocker.h>
41 #include <casacore/casa/Arrays/ArrayFwd.h>
42 
43 #ifdef HAVE_MPI
44 #include <mpi.h>
45 #endif
46 
47 namespace casacore { //# NAMESPACE CASACORE - BEGIN
48 
49 //# Forward Declarations
50 class RefTable;
51 // class TableDesc; !Forward declaration not recognized SGI compiler
52 class TableLock;
53 class BaseColumn;
54 class ColumnDesc;
55 class TableRecord;
56 class Record;
57 class TableExprNode;
58 class BaseTableIterator;
59 class DataManager;
60 class IPosition;
61 template<class T> class Block;
62 template<class T> class PtrBlock;
63 class AipsIO;
64 
65 
66 // <summary>
67 // Abstract base class for tables
68 // </summary>
69 
70 // <use visibility=local>
71 
72 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
73 // </reviewed>
74 
75 // <prerequisite>
76 //# Classes you should understand before using this one.
77 // <li> Table
78 // <li> Sort
79 // <li> TableExprNode
80 // </prerequisite>
81 
82 // <etymology>
83 // BaseTable is the (abstract) base class for different kind of tables.
84 // </etymology>
85 
86 // <synopsis>
87 // BaseTables defines many virtual functions, which are actually
88 // implemented in the underlying table classes like PlainTable and
89 // RefTable. Other functions like sort and select are implemented
90 // in BaseTable itself.
91 //
92 // The functions in BaseTable and its derived classes can only be
93 // used by the table system classes. All user access is via the
94 // envelope class Table, which references (counted) BaseTable.
95 // </synopsis>
96 
97 // <todo asof="$DATE:$">
98 //# A List of bugs, limitations, extensions or planned refinements.
99 // <li> Implement function renameColumn, removeColumn.
100 // </todo>
101 
102 
104 {
105 public:
106 
107  // Initialize the object.
109 
110 #ifdef HAVE_MPI
111  // MPI version of the constructor
112  BaseTable (MPI_Comm mpiComm, const String& tableName, int tableOption, rownr_t nrrow);
113 #endif
114 
115  // Common code shared by the MPI constructor and non-MPI constructor
117 
118  virtual ~BaseTable();
119 
120  // Link to this BaseTable object (i.e. increase reference count).
121  void link();
122 
123  // Unlink from a BaseTable.
124  // Delete it if no more references.
125  static void unlink (BaseTable*);
126 
127  // Is the table a null table?
128  // By default it is not.
129  virtual Bool isNull() const;
130 
131  // Reopen the table for read/write.
132  virtual void reopenRW() = 0;
133 
134  // Is the table stored in big or little endian format?
135  virtual Bool asBigEndian() const = 0;
136 
137  // Get the storage option used for the table.
138  virtual const StorageOption& storageOption() const = 0;
139 
140  // Is the table in use (i.e. open) in another process?
141  // If <src>checkSubTables</src> is set, it is also checked if
142  // a subtable is used in another process.
143  virtual Bool isMultiUsed(Bool checkSubTables) const = 0;
144 
145  // Get the locking info.
146  virtual const TableLock& lockOptions() const = 0;
147 
148  // Merge the given lock info with the existing one.
149  virtual void mergeLock (const TableLock& lockOptions) = 0;
150 
151  // Has this process the read or write lock, thus can the table
152  // be read or written safely?
153  virtual Bool hasLock (FileLocker::LockType) const = 0;
154 
155  // Try to lock the table for read or write access.
156  virtual Bool lock (FileLocker::LockType, uInt nattempts) = 0;
157 
158  // Unlock the table. This will also synchronize the table data,
159  // thus force the data to be written to disk.
160  virtual void unlock() = 0;
161 
162  // Flush the table, i.e. write it to disk.
163  virtual void flush (Bool fsync, Bool recursive) = 0;
164 
165  // Resync the Table object with the table file.
166  virtual void resync() = 0;
167 
168  // Get the modify counter.
169  virtual uInt getModifyCounter() const = 0;
170 
171  // Set the table to being changed. By default it does nothing.
172  virtual void setTableChanged();
173 
174  // Do not write the table (used in in case of exceptions).
175  void doNotWrite()
176  { noWrite_p = True; }
177 
178  // Test if this table is writable.
179  // This tells if values can be put into a column.
180  virtual Bool isWritable() const = 0;
181 
182  // Test if the given column is writable.
183  // <group>
184  Bool isColumnWritable (const String& columnName) const;
185  Bool isColumnWritable (uInt columnIndex) const;
186  // </group>
187 
188  // Test if the given column is stored (otherwise it is virtual).
189  // <group>
190  Bool isColumnStored (const String& columnName) const;
191  Bool isColumnStored (uInt columnIndex) const;
192  // </group>
193 
194  // Get the table name.
195  const String& tableName() const
196  { return name_p; }
197 
198  // Get the names of the tables this table consists of.
199  // The default implementation adds the name of this table to the block.
200  virtual void getPartNames (Block<String>& names, Bool recursive) const;
201 
202  // Rename the table.
203  // The following options can be given:
204  // <dl>
205  // <dt> Table::Update
206  // <dd> A table with this name must already exists, which will be
207  // overwritten. When succesfully renamed, the table is unmarked
208  // for delete (if necessary).
209  // <dt> Table::New
210  // <dd> When a table with this name exists, it will be overwritten.
211  // When succesfully renamed, the table is unmarked
212  // for delete (if necessary).
213  // <dt> Table::NewNoReplace
214  // <dd> When a table with this name already exists, an exception
215  // is thrown. When succesfully renamed, the table
216  // is unmarked for delete (if necessary).
217  // <dt> Table::Scratch
218  // <dd> Same as Table::New, but followed by markForDelete().
219  // </dl>
220  // The rename function in this base class renames the table file.
221  // In a derived class (e.g. PlainTable) the function should also
222  // be implemented to rename subtables in its keywords.
223  virtual void rename (const String& newName, int tableOption);
224 
225  // Copy the table and all its subtables.
226  // The default implementation of deepCopy is to call copy.
227  // The following options can be given:
228  // <dl>
229  // <dt> Table::New
230  // <dd> When a table with this name exists, it will be overwritten.
231  // <dt> Table::NewNoReplace
232  // <dd> When a table with this name already exists, an exception
233  // is thrown.
234  // <dt> Table::Scratch
235  // <dd> Same as Table::New, but followed by markForDelete().
236  // </dl>
237  // <group>
238  virtual void copy (const String& newName, int tableOption) const;
239  virtual void deepCopy (const String& newName,
240  const Record& dataManagerInfo,
241  const StorageOption&,
242  int tableOption,
243  Bool valueCopy,
244  int endianFormat,
245  Bool noRows) const;
246  // </group>
247 
248  // Get the table type.
249  // By default it returns Table::Plain.
250  virtual int tableType() const;
251 
252  // Get the table option.
253  int tableOption() const
254  { return option_p; }
255 
256  // Mark the table for delete.
257  // This means that the underlying table gets deleted when it is
258  // actually destructed.
259  // The scratchCallback function is called when needed.
260  void markForDelete (Bool callback, const String& oldName);
261 
262  // Unmark the table for delete.
263  // This means the underlying table does not get deleted when destructed.
264  // The scratchCallback function is called when needed.
265  void unmarkForDelete (Bool callback, const String& oldName);
266 
267  // Test if the table is marked for delete.
269  { return delete_p; }
270 
271  // Get the table description.
272  const TableDesc& tableDesc() const
273  { return (tdescPtr_p.null() ? makeEmptyTableDesc() : *tdescPtr_p); }
274 
275  // Get the actual table description.
276  virtual TableDesc actualTableDesc() const = 0;
277 
278  // Get the data manager info.
279  virtual Record dataManagerInfo() const = 0;
280 
281  // Show the table structure (implementation of Table::showStructure).
282  void showStructure (std::ostream&,
283  Bool showDataMan,
284  Bool showColumns,
285  Bool showSubTables,
286  Bool sortColumns,
287  Bool cOrder);
288 
289  // Get readonly access to the table keyword set.
290  virtual TableRecord& keywordSet() = 0;
291 
292  // Get read/write access to the table keyword set.
293  // This requires that the table is locked (or it gets locked
294  // when using AutoLocking mode).
295  virtual TableRecord& rwKeywordSet() = 0;
296 
297  // Get access to the TableInfo object.
299  { return info_p; }
300 
301  // Get the table info of the table with the given name.
302  // An empty object is returned when the table is unknown.
304 
305  // Write the TableInfo object.
306  virtual void flushTableInfo();
307 
308  // Get number of rows.
309  rownr_t nrow() const
310  { return nrrow_p; }
311 
312  // Get a column object using its index.
313  virtual BaseColumn* getColumn (uInt columnIndex) const = 0;
314 
315  // Get a column object using its name.
316  virtual BaseColumn* getColumn (const String& columnName) const = 0;
317 
318  // Test if it is possible to add a row to this table.
319  virtual Bool canAddRow() const;
320 
321  // Add one or more rows and possibly initialize them.
322  // This will fail for tables not supporting addition of rows.
323  virtual void addRow (rownr_t nrrow = 1, Bool initialize = True);
324 
325  // Test if it is possible to remove a row from this table.
326  virtual Bool canRemoveRow() const;
327 
328  // Remove rows.
329  // This will fail for tables not supporting removal of rows.
330  // <note role=tip>
331  // The following code fragments do NOT have the same result:
332  // <srcblock>
333  // tab.removeRow (10); // remove row 10
334  // tab.removeRow (20); // remove row 20, which was 21
335  //
336  // Vector<rownr_t> vec(2);
337  // vec(0) = 10;
338  // vec(1) = 20;
339  // tab.removeRow (vec); // remove row 10 and 20
340  // </srcblock>
341  // because in the first fragment removing row 10 turns the former
342  // row 21 into row 20.
343  // </note>
344  // <group>
345  virtual void removeRow (rownr_t rownr);
346  void removeRow (const Vector<rownr_t>& rownrs);
347  void removeRow (const Vector<uInt>& rownrs);
348  // </group>
349 
350  // Find the data manager with the given name or for the given column.
351  virtual DataManager* findDataManager (const String& name,
352  Bool byColumn) const = 0;
353 
354  // Select rows using the given expression (which can be null).
355  // Skip first <src>offset</src> matching rows.
356  // Return at most <src>maxRow</src> matching rows.
357  BaseTable* select (const TableExprNode&, rownr_t maxRow, rownr_t offset);
358 
359  // Select maxRow rows and skip first offset rows. maxRow=0 means all.
360  BaseTable* select (rownr_t maxRow, rownr_t offset);
361 
362  // Select rows using a vector of row numbers.
363  BaseTable* select (const Vector<rownr_t>& rownrs);
364 
365  // Select rows using a mask block.
366  // The length of the block must match the number of rows in the table.
367  // If True, the corresponding row will be selected.
369 
370  // Project the given columns (i.e. select the columns).
371  BaseTable* project (const Block<String>& columnNames);
372 
373  //# Virtually concatenate all tables in this column.
374  //# The column cells must contain tables with the same description.
375 //#// BaseTable* concatenate (const String& columnName);
376 
377  // Do logical operations on a table.
378  // <group>
379  // intersection with another table
381  // union with another table
383  // subtract another table
385  // xor with another table
387  // take complement
389  // </group>
390 
391  // Sort a table on one or more columns of scalars.
392  BaseTable* sort (const Block<String>& columnNames,
393  const Block<CountedPtr<BaseCompare> >& compareObjects,
394  const Block<Int>& sortOrder, int sortOption);
395 
396  // Create an iterator.
399  const Block<Int>& orders, int option);
400 
401  // Add one or more columns to the table.
402  // The default implementation throws an "invalid operation" exception.
403  // <group>
404  virtual void addColumn (const ColumnDesc& columnDesc, Bool addToParent);
405  virtual void addColumn (const ColumnDesc& columnDesc,
406  const String& dataManager, Bool byName,
407  Bool addToParent);
408  virtual void addColumn (const ColumnDesc& columnDesc,
409  const DataManager& dataManager, Bool addToParent);
410  virtual void addColumn (const TableDesc& tableDesc,
411  const DataManager& dataManager, Bool addToParent);
412  // </group>
413 
414  // Add one or more columns to the table.
415  // The data manager to use is described in the record.
416  void addColumns (const TableDesc& tableDesc, const Record& dmInfo,
417  Bool addToParent);
418 
419  // Test if columns can be removed.
420  virtual Bool canRemoveColumn (const Vector<String>& columnNames) const = 0;
421 
422  // Remove columns.
423  virtual void removeColumn (const Vector<String>& columnNames) = 0;
424 
425  // Check if the set of columns can be removed.
426  // It checks if columns have not been specified twice and it
427  // checks if they exist.
428  // If the flag is set an exception is thrown if errors are found.
429  Bool checkRemoveColumn (const Vector<String>& columnNames,
430  Bool throwException) const;
431 
432  // Test if a column can be renamed.
433  virtual Bool canRenameColumn (const String& columnName) const = 0;
434 
435  // Rename a column.
436  virtual void renameColumn (const String& newName,
437  const String& oldName) = 0;
438 
439  // Rename a hypercolumn.
440  virtual void renameHypercolumn (const String& newName,
441  const String& oldName) = 0;
442 
443  // Get a vector of row numbers.
444  // By default it returns the row numbers 0..nrrow()-1.
445  // It needs to be implemented for RefTable only.
446  virtual Vector<rownr_t> rowNumbers() const;
447 
448  // Get pointer to root table (i.e. parent of a RefTable).
449  // Default it is this table.
450  // It is meant for the reference tables after a select or sort which
451  // can then still name their parent as the root.
452  virtual BaseTable* root();
453 
454  // Tell if the table is in row order.
455  // By default it is, since normally a table is always in row order.
456  // It is meant for RefTable-s, where the rows can be in
457  // another (sorted) order.
458  virtual Bool rowOrder() const;
459 
460  // By the default the table cannot return the storage of rownrs.
461  // That can only be done by a RefTable, where it is implemented.
463 
464  // Adjust the row numbers to be the actual row numbers in the
465  // root table. This is, for instance, used when a RefTable is sorted.
466  // Optionally it also determines if the resulting rows are in order.
467  virtual Bool adjustRownrs (rownr_t nrrow, Vector<rownr_t>& rownrs,
468  Bool determineOrder) const;
469 
470  // Do the actual sort.
471  // The default implementation is suitable for almost all cases.
472  // Only in RefTable a smarter implementation is provided.
475  const Block<Int>& sortOrder,
476  int sortOption);
477 
478  // Create a RefTable object.
480 
481  // Check if the row number is valid.
482  // It throws an exception if out of range.
483  void checkRowNumber (rownr_t rownr) const
484  { if (rownr >= nrrow_p + nrrowToAdd_p) checkRowNumberThrow (rownr); }
485 
486  // Get the table's trace-id.
487  int traceId() const
488  { return itsTraceId; }
489 
490 
491 protected:
492  uInt nrlink_p; //# #references to this table
493  rownr_t nrrow_p; //# #rows in this table
494  rownr_t nrrowToAdd_p; //# #rows to be added
495  CountedPtr<TableDesc> tdescPtr_p; //# Pointer to table description
496  String name_p; //# table name
497  int option_p; //# Table constructor option
498  Bool noWrite_p; //# False = do not write the table
499  Bool delete_p; //# True = delete when destructed
500  TableInfo info_p; //# Table information (type, etc.)
501  Bool madeDir_p; //# True = table dir has been created
502  int itsTraceId; //# table-id for TableTrace tracing
503 
504 
505  // Do the callback for scratch tables (if callback is set).
506  void scratchCallback (Bool isScratch, const String& oldName) const;
507 
508  // Create the table directory when needed (and possible).
509  // When the file already exists, check if it is a directory.
510  // It returns True when it actually created the directory.
512 
513  // Make a true deep copy of the table.
514  void trueDeepCopy (const String& newName,
515  const Record& dataManagerInfo,
516  const StorageOption&,
517  int tableOption,
518  int endianFormat,
519  Bool noRows) const;
520 
521  // Prepare for copying or renaming a table.
522  // It checks if the target table already exists and removes it
523  // when necessary.
524  void prepareCopyRename (const String& newName, int tableOption) const;
525 
526  // Rename the subtables (used by rename function).
527  virtual void renameSubTables (const String& newName,
528  const String& oldName);
529 
530  // Check if the table already exists.
531  // Throw an exception if so.
533 
534  // Test if the table is opened for write.
536 
537  // Start writing a table. It does a putstart and writes <src>nrrow_p</src>.
538  // It should be ended by calling <src>writeEnd</src>.
539  void writeStart (AipsIO&, Bool bigEndian);
540 
541  // End writing a table.
542  void writeEnd (AipsIO&);
543 
544  // Should the table be written.
545  // This flag is False if an exception was thrown.
547  { return noWrite_p; }
548 
549  // Read the TableInfo object.
550  void getTableInfo();
551 
552 private:
553  // Copy constructor is forbidden, because copying a table requires
554  // some more knowledge (like table name of result).
555  // Declaring it private, makes it unusable.
557 
558  // Assignment is forbidden, because copying a table requires
559  // some more knowledge (like table name of result).
560  // Declaring it private, makes it unusable.
562 
563  // Show a possible extra table structure header.
564  // It is used by e.g. RefTable to show which table is referenced.
565  virtual void showStructureExtra (std::ostream&) const;
566 
567  // Show the info of the given columns.
568  // Sort the columns if needed.
569  void showColumnInfo (ostream& os, const TableDesc&, uInt maxNameLength,
570  const Array<String>& columnNames, Bool sort,
571  Bool cOrder) const;
572 
573  // Throw an exception for checkRowNumber.
574  void checkRowNumberThrow (rownr_t rownr) const;
575 
576  // Check if the tables combined in a logical operation have the
577  // same root.
578  void logicCheck (BaseTable* that);
579 
580  // Get the rownrs of the table in ascending order to be
581  // used in the logical operation on the table.
582  rownr_t logicRows (rownr_t*& rownrs, Bool& allocated);
583 
584  // Make an empty table description.
585  // This is used if one asks for the description of a NullTable.
586  // Creating an empty TableDesc in the NullTable takes too much time.
587  // Furthermore it causes static initialization order problems.
589 
590  // Make the name absolute.
591  // It first checks if the name contains valid characters (not only . and /).
592  String makeAbsoluteName (const String& name) const;
593 
594 #ifdef HAVE_MPI
595  // MPI communicator for parallel I/O
596  // Set the default to MPI_COMM_WORLD to keep the compatibility for
597  // non-MPI apps to work with the MPI-enabled casacore build.
598  MPI_Comm itsMpiComm = MPI_COMM_WORLD;
599 #endif
600 };
601 
602 
603 
604 
605 } //# NAMESPACE CASACORE - END
606 
607 #endif
BaseTable * tabNot()
take complement
virtual void addColumn(const ColumnDesc &columnDesc, const String &dataManager, Bool byName, Bool addToParent)
BaseTableIterator * makeIterator(const Block< String > &columnNames, const Block< CountedPtr< BaseCompare > > &, const Block< Int > &orders, int option)
Create an iterator.
virtual Bool adjustRownrs(rownr_t nrrow, Vector< rownr_t > &rownrs, Bool determineOrder) const
Adjust the row numbers to be the actual row numbers in the root table.
BaseTable * select(const Block< Bool > &mask)
Select rows using a mask block.
void BaseTableCommon(const String &tableName, int tableOption, rownr_t nrrow)
Common code shared by the MPI constructor and non-MPI constructor.
virtual BaseColumn * getColumn(const String &columnName) const =0
Get a column object using its name.
Bool openedForWrite() const
Test if the table is opened for write.
virtual void renameHypercolumn(const String &newName, const String &oldName)=0
Rename a hypercolumn.
virtual void flushTableInfo()
Write the TableInfo object.
void removeRow(const Vector< uInt > &rownrs)
virtual const TableLock & lockOptions() const =0
Get the locking info.
void unmarkForDelete(Bool callback, const String &oldName)
Unmark the table for delete.
BaseTable * tabOr(BaseTable *)
union with another table
virtual void reopenRW()=0
Reopen the table for read/write.
Bool isColumnStored(uInt columnIndex) const
virtual Bool isNull() const
Is the table a null table? By default it is not.
virtual void renameColumn(const String &newName, const String &oldName)=0
Rename a column.
static void unlink(BaseTable *)
Unlink from a BaseTable.
BaseTable * select(const TableExprNode &, rownr_t maxRow, rownr_t offset)
Select rows using the given expression (which can be null).
BaseTable(MPI_Comm mpiComm, const String &tableName, int tableOption, rownr_t nrrow)
MPI version of the constructor.
void showColumnInfo(ostream &os, const TableDesc &, uInt maxNameLength, const Array< String > &columnNames, Bool sort, Bool cOrder) const
Show the info of the given columns.
void throwIfTableExists()
Check if the table already exists.
Bool isMarkedForDelete() const
Test if the table is marked for delete.
Definition: BaseTable.h:268
virtual void copy(const String &newName, int tableOption) const
Copy the table and all its subtables.
virtual Bool asBigEndian() const =0
Is the table stored in big or little endian format?
const TableDesc & tableDesc() const
Get the table description.
Definition: BaseTable.h:272
CountedPtr< TableDesc > tdescPtr_p
Definition: BaseTable.h:495
Bool makeTableDir()
Create the table directory when needed (and possible).
virtual Vector< rownr_t > * rowStorage()
By the default the table cannot return the storage of rownrs.
TableInfo & tableInfo()
Get access to the TableInfo object.
Definition: BaseTable.h:298
RefTable * makeRefTable(Bool rowOrder, rownr_t initialNrrow)
Create a RefTable object.
virtual Bool lock(FileLocker::LockType, uInt nattempts)=0
Try to lock the table for read or write access.
Bool isColumnWritable(const String &columnName) const
Test if the given column is writable.
void writeStart(AipsIO &, Bool bigEndian)
Start writing a table.
virtual Bool canRemoveColumn(const Vector< String > &columnNames) const =0
Test if columns can be removed.
virtual Vector< rownr_t > rowNumbers() const
Get a vector of row numbers.
void removeRow(const Vector< rownr_t > &rownrs)
virtual void addColumn(const ColumnDesc &columnDesc, Bool addToParent)
Add one or more columns to the table.
rownr_t logicRows(rownr_t *&rownrs, Bool &allocated)
Get the rownrs of the table in ascending order to be used in the logical operation on the table.
virtual void getPartNames(Block< String > &names, Bool recursive) const
Get the names of the tables this table consists of.
BaseTable(const String &tableName, int tableOption, rownr_t nrrow)
Initialize the object.
virtual void showStructureExtra(std::ostream &) const
Show a possible extra table structure header.
BaseTable * tabAnd(BaseTable *)
Do logical operations on a table.
virtual void removeColumn(const Vector< String > &columnNames)=0
Remove columns.
void writeEnd(AipsIO &)
End writing a table.
virtual BaseColumn * getColumn(uInt columnIndex) const =0
Get a column object using its index.
BaseTable * select(rownr_t maxRow, rownr_t offset)
Select maxRow rows and skip first offset rows.
virtual TableRecord & keywordSet()=0
Get readonly access to the table keyword set.
virtual void removeRow(rownr_t rownr)
Remove rows.
virtual void addRow(rownr_t nrrow=1, Bool initialize=True)
Add one or more rows and possibly initialize them.
void checkRowNumberThrow(rownr_t rownr) const
Throw an exception for checkRowNumber.
TableInfo info_p
Definition: BaseTable.h:500
const TableDesc & makeEmptyTableDesc() const
Make an empty table description.
virtual Bool isMultiUsed(Bool checkSubTables) const =0
Is the table in use (i.e.
void doNotWrite()
Do not write the table (used in in case of exceptions).
Definition: BaseTable.h:175
void link()
Link to this BaseTable object (i.e.
void prepareCopyRename(const String &newName, int tableOption) const
Prepare for copying or renaming a table.
const String & tableName() const
Get the table name.
Definition: BaseTable.h:195
virtual Bool canRenameColumn(const String &columnName) const =0
Test if a column can be renamed.
Bool isColumnStored(const String &columnName) const
Test if the given column is stored (otherwise it is virtual).
BaseTable & operator=(const BaseTable &)
Assignment is forbidden, because copying a table requires some more knowledge (like table name of res...
BaseTable * select(const Vector< rownr_t > &rownrs)
Select rows using a vector of row numbers.
virtual Bool isWritable() const =0
Test if this table is writable.
void trueDeepCopy(const String &newName, const Record &dataManagerInfo, const StorageOption &, int tableOption, int endianFormat, Bool noRows) const
Make a true deep copy of the table.
virtual void resync()=0
Resync the Table object with the table file.
virtual void rename(const String &newName, int tableOption)
Rename the table.
virtual Bool canAddRow() const
Test if it is possible to add a row to this table.
rownr_t nrow() const
Get number of rows.
Definition: BaseTable.h:309
rownr_t nrrowToAdd_p
Definition: BaseTable.h:494
MPI_Comm itsMpiComm
MPI communicator for parallel I/O Set the default to MPI_COMM_WORLD to keep the compatibility for non...
Definition: BaseTable.h:598
virtual Bool rowOrder() const
Tell if the table is in row order.
virtual uInt getModifyCounter() const =0
Get the modify counter.
int tableOption() const
Get the table option.
Definition: BaseTable.h:253
virtual void unlock()=0
Unlock the table.
int traceId() const
Get the table's trace-id.
Definition: BaseTable.h:487
BaseTable * sort(const Block< String > &columnNames, const Block< CountedPtr< BaseCompare > > &compareObjects, const Block< Int > &sortOrder, int sortOption)
Sort a table on one or more columns of scalars.
void markForDelete(Bool callback, const String &oldName)
Mark the table for delete.
virtual BaseTable * root()
Get pointer to root table (i.e.
virtual TableDesc actualTableDesc() const =0
Get the actual table description.
virtual void mergeLock(const TableLock &lockOptions)=0
Merge the given lock info with the existing one.
void scratchCallback(Bool isScratch, const String &oldName) const
Do the callback for scratch tables (if callback is set).
virtual Bool canRemoveRow() const
Test if it is possible to remove a row from this table.
virtual Record dataManagerInfo() const =0
Get the data manager info.
virtual void addColumn(const ColumnDesc &columnDesc, const DataManager &dataManager, Bool addToParent)
BaseTable * project(const Block< String > &columnNames)
Project the given columns (i.e.
virtual Bool hasLock(FileLocker::LockType) const =0
Has this process the read or write lock, thus can the table be read or written safely?
void addColumns(const TableDesc &tableDesc, const Record &dmInfo, Bool addToParent)
Add one or more columns to the table.
virtual void flush(Bool fsync, Bool recursive)=0
Flush the table, i.e.
virtual int tableType() const
Get the table type.
void checkRowNumber(rownr_t rownr) const
Check if the row number is valid.
Definition: BaseTable.h:483
virtual DataManager * findDataManager(const String &name, Bool byColumn) const =0
Find the data manager with the given name or for the given column.
Bool checkRemoveColumn(const Vector< String > &columnNames, Bool throwException) const
Check if the set of columns can be removed.
virtual void addColumn(const TableDesc &tableDesc, const DataManager &dataManager, Bool addToParent)
virtual TableRecord & rwKeywordSet()=0
Get read/write access to the table keyword set.
virtual const StorageOption & storageOption() const =0
Get the storage option used for the table.
virtual void deepCopy(const String &newName, const Record &dataManagerInfo, const StorageOption &, int tableOption, Bool valueCopy, int endianFormat, Bool noRows) const
BaseTable * tabSub(BaseTable *)
subtract another table
String makeAbsoluteName(const String &name) const
Make the name absolute.
BaseTable * tabXor(BaseTable *)
xor with another table
void getTableInfo()
Read the TableInfo object.
BaseTable(const BaseTable &)
Copy constructor is forbidden, because copying a table requires some more knowledge (like table name ...
Bool isColumnWritable(uInt columnIndex) const
static TableInfo tableInfo(const String &tableName)
Get the table info of the table with the given name.
Bool shouldNotWrite() const
Should the table be written.
Definition: BaseTable.h:546
virtual BaseTable * doSort(PtrBlock< BaseColumn * > &, const Block< CountedPtr< BaseCompare > > &, const Block< Int > &sortOrder, int sortOption)
Do the actual sort.
void logicCheck(BaseTable *that)
Check if the tables combined in a logical operation have the same root.
virtual void renameSubTables(const String &newName, const String &oldName)
Rename the subtables (used by rename function).
void showStructure(std::ostream &, Bool showDataMan, Bool showColumns, Bool showSubTables, Bool sortColumns, Bool cOrder)
Show the table structure (implementation of Table::showStructure).
virtual void setTableChanged()
Set the table to being changed.
simple 1-D array
Definition: Block.h:200
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
Abstract base class for a data manager.
Definition: DataManager.h:218
LockType
Define the possible lock types.
Definition: FileLocker.h:95
A drop-in replacement for Block<T*>.
Definition: Block.h:814
String: the storage and methods of handling collections of characters.
Definition: String.h:223
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46