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