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