casacore
Loading...
Searching...
No Matches
TableProxy.h
Go to the documentation of this file.
1// # TableProxy.h: High-level interface to tables
2// # Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2005
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_TABLEPROXY_H
27#define TABLES_TABLEPROXY_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/Tables/Table.h>
32#include <casacore/casa/Containers/Record.h>
33#include <casacore/casa/Arrays/Vector.h>
34#include <vector>
35
36// # Forward Declarations
37namespace casacore { // # NAMESPACE CASACORE - BEGIN
38class ValueHolder;
39class RecordFieldId;
40class Table;
41class TableLock;
42class ColumnDesc;
43class TableExprNode;
44class Slicer;
45
46// <summary>
47// High-level interface to tables
48// </summary>
49
50// <use visibility=export>
51
52// <reviewed reviewer="Paul Shannon" date="1995/09/15" tests="ttable.py" demos="">
53// </reviewed>
54
55// <prerequisite>
56// # Classes you should understand before using this one.
57// <li> class Table
58// <li> python script table.py
59// </prerequisite>
60
61// <etymology>
62// TableProxy is a proxy for access to tables from any script.
63// </etymology>
64
65// <synopsis>
66// TableProxy gives access to most of the functionality in the Table System.
67// It is primarily meant to be used in classes that wrap access to it
68// from scripting languages (like Glish and Python).
69// However, it can also be used directly from other C++ code.
70//
71// It has functions to open, create, read, write, and query tables.
72// Accompying proxy classes give access to other functionality. They are:
73// <ul>
74// <li> <linkto class=TableIterProxy>TableIterProxy</linkto> for iteration
75// through a table using class
76// <linkto class=TableIterator>TableIterator</linkto>.
77// <li> <linkto class=TableRowProxy>TableRowProxy</linkto> for access to
78// table rows using class <linkto class=TableRow>TableRow</linkto>.
79// <li> <linkto class=TableIndexProxy>TableIterProxy</linkto> for faster
80// indexed access to using classes
81// <linkto class=ColumnsIndex>ColumnsIndex</linkto> and
82// <linkto class=ColumnsIndexArray>ColumnsIndexArray</linkto>.
83// </ul>
84//
85// TableProxy does not have the TableRecord type in its interface, because
86// such a type cannot be handled by e.g. Glish or Python. Instead it
87// converts TableRecords to/from Records. If a TableRecord contains a field
88// with a Table object, it is represented in the Record as a string
89// with the value "Table: NAME" where NAME is the table name.
90// </synopsis>
91
92// <motivation>
93// TableProxy is the Tasking-independent high-level table interface.
94// Different front-ends (e.g. GlishTableProxy) can be put on top of it.
95// </motivation>
96
98 public:
99 // Default constructor initializes to not open.
100 // This constructor is only needed for containers.
102
103 // Create the object from an existing table (used by some methods).
105
106 // Open the table with a given name.
107 TableProxy(const String& tableName, const Record& lockOptions, int option);
108
109 // Create a table with given name and description, etc.
111 const String& memType, Int64 nrow, const Record& tableDesc, const Record& dmInfo);
112
113 // Create a table object to concatenate a number of similar tables.
114 // The keyword set of the first table is take as the keyword set of the
115 // entire concatenation. However, it can be specified which subtables
116 // have to be concatenated as well which means that for each subtable name
117 // the subtable in the keywordsets are concatenated.
118 // <note>For Boost-Python the constructors must have different nr of arguments.
119 // Hence some dummy arguments are added.
120 //</note>
121 // <group>
122 TableProxy(const Vector<String>& tableNames, const Vector<String>& concatenateSubTableNames,
123 const Record& lockOptions, int option);
124 TableProxy(const std::vector<TableProxy>& tables, const Vector<String>& concatenateSubTableNames,
125 int dummy1 = 0, int dummy2 = 0, int dummy3 = 0);
126 // </group>
127
128 // Create a table object from a table command (as defined in TableGram).
129 // <br>If a CALC command was given, the resulting values are stored in
130 // the a record and a null TableProxy object is returned.
131 // The result can be obtained using getCalcResult.
132 // <note>
133 // If the command string contains no GIVING part, the resulting
134 // table is temporary and its name is blank.
135 // </note>
136 TableProxy(const String& command, const std::vector<TableProxy>& tables);
137
138 // Create a table from an Ascii file.
139 // It fills a string containing the names and types
140 // of the columns (in the form COL1=R, COL2=D, ...).
141 // The string can be obtained using getAsciiFormat.
142 TableProxy(const String& fileName, const String& headerName, const String& tableName,
143 Bool autoHeader, const IPosition& autoShape, const String& separator,
144 const String& commentMarker, Int64 firstLine, Int64 lastLine,
146 const Vector<String>& dataTypes = Vector<String>());
147
148 // Copy constructor.
150
151 // Close the table.
153
154 // Assignment.
156
157 // Select the given rows from the table and create a new (reference) table.
158 // If outName is not empty, the new table is made persistent with that name.
159 TableProxy selectRows(const Vector<Int64>& rownrs, const String& outName);
160
161 // Reopen the table for read/write.
162 void reopenRW();
163
164 // Resync the table.
165 void resync();
166
167 // Flush the table and optionally all its subtables.
168 void flush(Bool recursive);
169
170 // Flush and close the table and all its subtables.
171 void close();
172
173 // Get the endian format of the table.
174 // It fills the result with value "big" or "little".
176
177 // Acquire a (read or write) lock on the table.
178 void lock(Bool mode, Int nattempts);
179
180 // Release a lock on the table.
181 void unlock();
182
183 // Determine if data in the table has changed.
185
186 // Determine if the process has a read or write lock on the table.
188
189 // Get the lock options of the table.
190 // It fills the record with the fields option, interval and maxwait.
192
193 // Determine if the table (and optionally its subtables) are in use
194 // in another process.
195 Bool isMultiUsed(Bool checkSubTables);
196
197 // Write the table to an ASCII file
198 // (approximately the inverse of the from-ASCII-contructor).
199 // If <src>headerFile</src> is empty or equal to <src>asciiFile</src>, the
200 // headers are written in the same file as the data, otherwise in a separate
201 // file.
202 // If no columns are given (or if the first column name is empty), all
203 // table columns are written. Columns containing records are also printed
204 // (enclosed in {}), but a warning message is returned.
205 // <br>Argument <src>sep</src> is used as separator between columns and
206 // array values. If it is empty, a blank is used.
207 // <br>For each column the precision can be given. It is only used for
208 // columns containing floating point numbers. A value <=0 means using the
209 // default which is 9 for single and 18 for double precision.
210 // <br>If <src>useBrackets=True</src>, arrays are enclosed in [] (for each
211 // dimension), so variable shaped arrays can be read back unambiguously.
212 // The type in the header will be something like D[4,64]. If the column is
213 // variable shaped, the type is like D[].
214 // If <src>useBracket=False</src>, arrays are written linearly where a
215 // shape [4,64] is given in the header like D4,64. If the column is variable
216 // shaped, the shape of the first cell is used and a warning message is
217 // returned.
218 String toAscii(const String& asciiFile, const String& headerFile, const Vector<String>& columns,
219 const String& sep, const Vector<Int>& precision, Bool useBrackets);
220
221 // Rename the table
222 void rename(const String& newTableName);
223
224 // Copy the table (possibly a deep copy).
225 // If noRows=True, an empty table is created.
226 TableProxy copy(const String& newTableName, Bool toMemoryTable, Bool deepCopy, Bool valueCopy,
227 const String& endianFormat, const Record& dminfo, Bool noRows);
228
229 // Copy rows from one table to another.
230 // If startOut<0, it is set to the end of the output table.
231 void copyRows(TableProxy& out, Int64 startIn, Int64 startOut, Int64 nrow);
232
233 // Close and delete the table.
234 void deleteTable(Bool checkSubTables);
235
236 // Get the table info of the table.
238
239 // Put the table info of the table.
241
242 // Add a line to the TableInfo readme.
243 void addReadmeLine(const String& line);
244
245 // Test if a table is readable.
247
248 // Test if a table is writable.
250
251 // Set the maximum cache size for the given column in the table.
252 void setMaximumCacheSize(const String& columnName, Int nbytes);
253
254 // Add one or more columns to the table.
255 void addColumns(const Record& tableDesc, const Record& dminfo, Bool addToParent);
256
257 // Rename a column in the table.
258 void renameColumn(const String& nameOld, const String& nameNew);
259
260 // Remove one or more columns from the table.
262
263 // Add rows to the table.
264 void addRow(Int64 nrow);
265
266 // Remove rows from the table.
267 void removeRow(const Vector<Int64>& rownrs);
268
269 // Get some or all values from a column in the table.
270 // row is the starting row number (0-relative).
271 // nrow=-1 means until the end of the table.
272 // incr is the step in row number.
273 // <group>
274 ValueHolder getColumn(const String& columnName, Int64 row, Int64 nrow, Int64 incr);
275 void getColumnVH(const String& columnName, Int64 row, Int64 nrow, Int64 incr,
276 const ValueHolder& vh);
277 Record getVarColumn(const String& columnName, Int64 row, Int64 nrow, Int64 incr);
278 // </group>
279
280 // Get some or all value slices from a column in the table.
281 // If the inc vector is empty, it defaults to all 1.
282 // <group>
283 ValueHolder getColumnSlice(const String& columnName, Int64 row, Int64 nrow, Int64 incr,
284 const Vector<Int>& blc, const Vector<Int>& trc,
285 const Vector<Int>& inc);
286 ValueHolder getColumnSliceIP(const String& columnName, const IPosition& blc, const IPosition& trc,
287 const IPosition& inc, Int64 row, Int64 nrow, Int64 incr);
288 void getColumnSliceVH(const String& columnName, Int64 row, Int64 nrow, Int64 incr,
289 const Vector<Int>& blc, const Vector<Int>& trc, const Vector<Int>& inc,
290 const ValueHolder& vh);
291 void getColumnSliceVHIP(const String& columnName, const IPosition& blc, const IPosition& trc,
292 const IPosition& inc, Int64 row, Int64 nrow, Int64 incr,
293 const ValueHolder& vh);
294 // </group>
295
296 // Put some or all values into a column in the table.
297 // row is the starting row number (0-relative).
298 // nrow=-1 means until the end of the table.
299 // incr is the step in row number.
300 // <group>
301 void putColumn(const String& columnName, Int64 row, Int64 nrow, Int64 incr, const ValueHolder&);
302 void putVarColumn(const String& columnName, Int64 row, Int64 nrow, Int64 incr,
303 const Record& values);
304 // </group>
305
306 // Put some or all value slices into a column in the table.
307 // <group>
308 void putColumnSlice(const String& columnName, Int64 row, Int64 nrow, Int64 incr,
309 const Vector<Int>& blc, const Vector<Int>& trc, const Vector<Int>& inc,
310 const ValueHolder&);
311 void putColumnSliceIP(const String& columnName, const ValueHolder&, const IPosition& blc,
312 const IPosition& trc, const IPosition& inc, Int64 row, Int64 nrow,
313 Int64 incr);
314 // </group>
315
316 // Tests if the contents of a cell are defined.
317 // Only a column with variable shaped arrays can have an empty cell.
318 Bool cellContentsDefined(const String& columnName, Int64 rownr);
319
320 // Get a value from a column in the table.
321 ValueHolder getCell(const String& columnName, Int64 row);
322 void getCellVH(const String& columnName, Int64 row, const ValueHolder& vh);
323
324 // Get a value slice from a column in the table.
325 // If the inc vector is empty, it defaults to all 1.
326 // <group>
327 ValueHolder getCellSlice(const String& columnName, Int64 row, const Vector<Int>& blc,
328 const Vector<Int>& trc, const Vector<Int>& inc);
329 ValueHolder getCellSliceIP(const String& columnName, Int64 row, const IPosition& blc,
330 const IPosition& trc, const IPosition& inc);
331 void getCellSliceVH(const String& columnName, Int64 row, const Vector<Int>& blc,
332 const Vector<Int>& trc, const Vector<Int>& inc, const ValueHolder& vh);
333 void getCellSliceVHIP(const String& columnName, Int64 row, const IPosition& blc,
334 const IPosition& trc, const IPosition& inc, const ValueHolder& vh);
335 // </group>
336
337 // Put a value into a column in the table.
338 void putCell(const String& columnName, const Vector<Int64>& rownrs, const ValueHolder&);
339
340 // Put a value slice into a column in the table.
341 // If the inc vector is empty, it defaults to all 1.
342 // <group>
343 void putCellSlice(const String& columnName, Int64 row, const Vector<Int>& blc,
344 const Vector<Int>& trc, const Vector<Int>& inc, const ValueHolder&);
345 void putCellSliceIP(const String& columnName, Int64 row, const ValueHolder&, const IPosition& blc,
346 const IPosition& trc, const IPosition& inc);
347 // </group>
348
349 // Get the shape of one or more cells in a column as a vector of Strings
350 // containing the shapes as [a,b,c].
351 // If the shape is fixed, a single String is returned.
352 Vector<String> getColumnShapeString(const String& columnName, Int64 rownr, Int64 nrow, Int64 incr,
353 Bool cOrder = False);
354
355 // Get a table or column keyword value in the table.
356 // If the columnName is empty, a given keyword is a table keyword.
357 // The keyword can be given as a name or a 0-based index.
358 ValueHolder getKeyword(const String& columnName, const String& keywordName, Int keywordIndex);
359
360 // Get the table or column keyword values in the table.
361 // If the columnName is empty, the table keyword values are returned.
362 Record getKeywordSet(const String& columnName);
363
364 // Define a table or column keyword in the table.
365 // If the column name is empty, a table keyword is defined.
366 // The keyword can be given as a name or a 0-based number.
367 // The value should be a record containing the value of the keyword.
368 // The value can be any type (including a record).
369 void putKeyword(const String& columnName, const String& keywordName, Int keywordIndex,
370 Bool makeSubRecord, const ValueHolder&);
371
372 // Define multiple table or column keywords in the table.
373 // If the column name is empty, a table keywords are defined.
374 // The value should be a record containing the values of the keywords.
375 // The values can be any type (including a record).
376 // The field names are the keyword names.
377 void putKeywordSet(const String& columnName, const Record& valueSet);
378
379 // Remove a table or column keyword from the table.
380 // If the column name is empty, a table keyword is removed.
381 void removeKeyword(const String& columnName, const String& keywordName, Int keywordIndex);
382
383 // Get the names of all field in a record in the table.
384 // If the column name is empty, the table keywords are used.
385 // If the keyword name is empty, the names of all keywords are returned.
386 // Otherwise the names of all fields in the keyword value are returned.
387 // In that case the value has to be a record.
388 Vector<String> getFieldNames(const String& columnName, const String& keywordName,
389 Int keywordIndex);
390
391 // Get table name.
393
394 // Get the names of the parts the table consists of (e.g. for a ConcatTable).
396
397 // Get #columns of the table.
399
400 // Get #rows of the table.
402
403 // Get the shape (#columns, #rows) of the table.
405
406 // Get the row numbers of the table.
408
409 // Get all column names in the table.
411
412 // Return in result if the column contains scalars.
413 Bool isScalarColumn(const String& columnName);
414
415 // Return the data type of the column as:
416 // Bool, UChar, Short, UShort, Int, UInt, Int64,
417 // Float, Double, Complex, DComplex, String, Table, or unknown.
418 String columnDataType(const String& columnName);
419
420 // Return the type of array in the column as:
421 // Direct
422 // Undefined
423 // FixedShape
424 // Direct,Undefined
425 // Direct,FixedShape
426 // Undefined,FixedShape
427 // Direct,Undefined,FixedShape
428 // or Error -- unexpected column type
429 String columnArrayType(const String& columnName);
430
431 // Get the data manager info of the table.
433
434 // Get the properties of a data manager given by column or data manager name.
436
437 // Set the properties of a data manager given by column or data manager name.
438 void setProperties(const String& name, const Record& properties, Bool byColumn);
439
440 // Get the table description of the table.
441 // It returns a record containing the description.
442 Record getTableDescription(Bool actual, // # use actual description?
443 Bool cOrder = False);
444
445 // Create a Record table description from a TableDesc object
446 static Record getTableDesc(const TableDesc& tabdesc, Bool cOrder = False);
447
448 // Get the column description of a column in the table.
449 // It returns a record containing the description.
451 Bool actual, // # use actual description?
452 Bool cOrder = False);
453
454 // Get ascii format string.
456
457 // Get result of possible CALC statement.
459
460 // Show the structure of a table.
461 String showStructure(Bool showDataMan = True, Bool showColumns = True, Bool showSubTables = False,
462 Bool sortColumns = False) const;
463
464 // Return the table object.
465 // <group>
466 Table& table() { return table_p; }
467 const Table& table() const { return table_p; }
468 // </group>
469
470 // Get or put the values of all keywords.
471 // Thus convert from TableRecord to/from Record.
472 // Keywords containing a table are converted to a string containing
473 // the table name preceeded by 'Table: '.
474 // <group>
475 static Record getKeyValues(const TableRecord& keySet);
476 static void putKeyValues(TableRecord& keySet, const Record& valueSet);
477 // </group>
478
479 // Get the lock options from the fields in the record.
480 // If the record or lockoption is invalid, an exception is thrown.
481 static TableLock makeLockOptions(const Record& options);
482
483 // Turn the string into the endian format option.
484 // An exception is thrown if the string is invalid.
486
487 // Make hypercolumn definitions for the given hypercolumns.
488 static Bool makeHC(const Record& gdesc, TableDesc& tabdesc, String& message);
489
490 // Get the value of a keyword.
491 static ValueHolder getKeyValue(const TableRecord& keySet, const RecordFieldId& fieldId);
492
493 // Put the value of a keyword.
494 static void putKeyValue(TableRecord& keySet, const RecordFieldId& fieldId,
495 const ValueHolder& value);
496
497 // Make a real table description from a table description in a record.
498 // An exception is thrown if the record table description is invalid.
499 // A record table description is a Record object as returned by
500 // getDesc.
501 static Bool makeTableDesc(const Record& gdesc, TableDesc& tabdesc, String& message);
502
503 // Add an array column description to the table description.
504 // It is used by the function makeDesc.
505 static Bool addArrayColumnDesc(TableDesc& tableDesc, const String& valueType,
506 const String& columnName, const String& comment,
507 const String& dataManagerType, const String& dataManagerGroup,
508 int options, Int ndim, const Vector<Int64>& shape, Bool cOrder,
509 String& message);
510
511 // Make a record containing the column description.
512 static Record recordColumnDesc(const ColumnDesc&, Bool cOrder);
513
514 // Make a record containing the description of all hypercolumns.
515 static Record recordHCDesc(const TableDesc& tableDesc);
516
517 // Calculate the values of a CALC expression and store them in field
518 // 'values' in rec.
519 static void calcValues(Record& rec, const TableExprNode& expr);
520
521 // Get the type string as used externally (in e.g. glish).
522 static String getTypeStr(DataType);
523
524 // Optionally reverse the axes.
525 static IPosition fillAxes(const IPosition&, Bool cOrder);
526
527 // Check if the new shape is still the same.
528 // <br> same: 0=first time; 1=still the same; 2=different
529 static void stillSameShape(Int& same, IPosition& shape, const IPosition& newShape);
530
531 // Copy the array contents of the record fields to a single array.
532 // This can only be done if the shape is constant.
533 template <typename T>
534 static Array<T> record2Array(const Record& rec) {
535 if (rec.empty()) {
536 return Array<T>();
537 }
538 Array<T> tmp;
539 rec.get(0, tmp);
540 IPosition shp(tmp.shape());
541 shp.append(IPosition(1, rec.size()));
542 Array<T> arr(shp);
543 ArrayIterator<T> iter(arr, tmp.ndim());
544 for (uInt i = 0; i < rec.size(); ++i, iter.next()) {
545 rec.get(i, iter.array());
546 }
547 return arr;
548 }
549
550 protected:
551 // Get the column info for toAscii.
552 Bool getColInfo(const String& colName, Bool useBrackets, String& type, String& message);
553
554 // Print the data in a table cell for toAscii.
555 // <group>
556 void printValueHolder(const ValueHolder& vh, ostream& os, const String& sep, Int prec,
557 Bool useBrackets) const;
558 template <typename T>
559 void printArray(const Array<T>& arr, ostream& os, const String& sep) const;
560 void printArrayValue(ostream& os, Bool v, const String&) const { os << v; }
561 void printArrayValue(ostream& os, Int v, const String&) const { os << v; }
562 void printArrayValue(ostream& os, Int64 v, const String&) const { os << v; }
563 void printArrayValue(ostream& os, Double v, const String&) const { os << v; }
564 void printArrayValue(ostream& os, const DComplex& v, const String&) const { os << v; }
565 void printArrayValue(ostream& os, const String& v, const String&) const { os << '"' << v << '"'; }
566 // </group>
567
568 // Sync table to get correct nr of rows and check the row number.
569 // It returns the nr of table rows.
570 Int64 getRowsCheck(const String& columnName, Int64 row, Int64 nrow, Int64 incr,
571 const String& caller);
572
573 // Sync table to get correct nr of rows and check the row number.
574 // Fill the slicer with the possibly expanded blc,trc,inc.
575 // It returns the nr of table rows.
576 Int64 getRowsSliceCheck(Slicer& slicer, const String& columnName, Int64 row, Int64 nrow,
577 Int64 incr, const IPosition& blc, const IPosition& trc,
578 const IPosition& inc, const String& caller);
579
580 // Check if the column name and row numbers are valid.
581 // Return the recalculated nrow so that it does not exceed #rows.
582 Int64 checkRowColumn(Table& table, const String& colName, Int64 rownr, Int64 nrow, Int64 incr,
583 const String& caller);
584
585 // Make an empty array (with 1 axis) of the correct datatype.
587
588 // Get values from the column.
589 // Nrow<0 means till the end of the column.
590 ValueHolder getValueFromTable(const String& colName, Int64 rownr, Int64 nrow, Int64 incr,
591 Bool isCell);
592 void getValueFromTable(const String& colName, Int64 rownr, Int64 nrow, Int64 incr, Bool isCell,
593 const ValueHolder& vh);
594
595 // Get value slices from the column.
596 // Nrow<0 means till the end of the column.
597 ValueHolder getValueSliceFromTable(const String& colName, const Slicer& slicer, Int64 rownr,
598 Int64 nrow, Int64 incr, Bool isCell);
599 void getValueSliceFromTable(const String& colName, const Slicer& slicer, Int64 rownr, Int64 nrow,
600 Int64 incr, Bool isCell, const ValueHolder& vh);
601
602 // Put values into the column.
603 // Nrow<0 means till the end of the column.
604 void putValueInTable(const String& colName, Int64 rownr, Int64 nrow, Int64 incr, Bool isCell,
605 const ValueHolder&);
606
607 // Put value slices into the column.
608 // Nrow<0 means till the end of the column.
609 void putValueSliceInTable(const String& colName, const Slicer& slicer, Int64 rownr, Int64 nrow,
610 Int64 incr, Bool isCell, const ValueHolder&);
611
612 // Split the keyname into its separate parts (separator is .).
613 // Check if each part exists and is a subrecord (except last part).
614 // When putting, subrecords are created if undefined and if
615 // makeSubRecord is set.
616 // On return it fills in the fieldid with the latest keyword part.
617 // KeySet is set to the last subrecord.
618 // <group>
619 void findKeyId(RecordFieldId& fieldid, const TableRecord*& keySet, const String& keyname,
620 const String& column);
621 void findKeyId(RecordFieldId& fieldid, TableRecord*& keySet, const String& keyname,
622 const String& column, Bool mustExist, Bool change, Bool makeSubRecord);
623 // </group>
624
625 // Replace the user-given default value (<0) by the default value
626 // used by Slicer (i.e. by Slicer::MimicSource).
628
629 // Synchronize table if readlocking is in effect.
630 // In this way the number of rows is up-to-date.
632
633 // # The data members.
637};
638
639} // namespace casacore
640
641#endif
size_t ndim() const
The dimensionality of this array.
Definition ArrayBase.h:94
const IPosition & shape() const
The length of each axis.
Definition ArrayBase.h:116
Array< T > & array()
Return the cursor.
Definition ArrayIter.h:111
virtual void next() override
Move the cursor to the next position.
void append(const IPosition &other)
Append this IPosition with another one (causing a resize).
String: the storage and methods of handling collections of characters.
Definition String.h:355
ValueHolder getColumn(const String &columnName, Int64 row, Int64 nrow, Int64 incr)
Get some or all values from a column in the table.
void removeKeyword(const String &columnName, const String &keywordName, Int keywordIndex)
Remove a table or column keyword from the table.
static Record getTableDesc(const TableDesc &tabdesc, Bool cOrder=False)
Create a Record table description from a TableDesc object.
static void putKeyValue(TableRecord &keySet, const RecordFieldId &fieldId, const ValueHolder &value)
Put the value of a keyword.
String columnDataType(const String &columnName)
Return the data type of the column as: Bool, UChar, Short, UShort, Int, UInt, Int64,...
TableProxy copy(const String &newTableName, Bool toMemoryTable, Bool deepCopy, Bool valueCopy, const String &endianFormat, const Record &dminfo, Bool noRows)
Copy the table (possibly a deep copy).
Int64 checkRowColumn(Table &table, const String &colName, Int64 rownr, Int64 nrow, Int64 incr, const String &caller)
Check if the column name and row numbers are valid.
void printArrayValue(ostream &os, Double v, const String &) const
Definition TableProxy.h:563
void putCellSliceIP(const String &columnName, Int64 row, const ValueHolder &, const IPosition &blc, const IPosition &trc, const IPosition &inc)
TableProxy(const String &command, const std::vector< TableProxy > &tables)
Create a table object from a table command (as defined in TableGram).
void setMaximumCacheSize(const String &columnName, Int nbytes)
Set the maximum cache size for the given column in the table.
TableProxy(const String &tableName, const Record &lockOptions, int option)
Open the table with a given name.
ValueHolder getCellSliceIP(const String &columnName, Int64 row, const IPosition &blc, const IPosition &trc, const IPosition &inc)
String getAsciiFormat() const
Get ascii format string.
ValueHolder getColumnSliceIP(const String &columnName, const IPosition &blc, const IPosition &trc, const IPosition &inc, Int64 row, Int64 nrow, Int64 incr)
void getColumnSliceVH(const String &columnName, Int64 row, Int64 nrow, Int64 incr, const Vector< Int > &blc, const Vector< Int > &trc, const Vector< Int > &inc, const ValueHolder &vh)
String columnArrayType(const String &columnName)
Return the type of array in the column as: Direct Undefined FixedShape Direct,Undefined Direct,...
void putTableInfo(const Record &value)
Put the table info of the table.
Record getColumnDescription(const String &columnName, Bool actual, Bool cOrder=False)
Get the column description of a column in the table.
void printArrayValue(ostream &os, Int64 v, const String &) const
Definition TableProxy.h:562
TableProxy()
Default constructor initializes to not open.
~TableProxy()
Close the table.
ValueHolder makeEmptyArray(DataType dtype)
Make an empty array (with 1 axis) of the correct datatype.
void deleteTable(Bool checkSubTables)
Close and delete the table.
Vector< String > getPartNames(Bool recursive)
Get the names of the parts the table consists of (e.g.
Int64 getRowsCheck(const String &columnName, Int64 row, Int64 nrow, Int64 incr, const String &caller)
Sync table to get correct nr of rows and check the row number.
void setProperties(const String &name, const Record &properties, Bool byColumn)
Set the properties of a data manager given by column or data manager name.
Bool hasLock(Bool mode)
Determine if the process has a read or write lock on the table.
void printArrayValue(ostream &os, Bool v, const String &) const
Definition TableProxy.h:560
void putCellSlice(const String &columnName, Int64 row, const Vector< Int > &blc, const Vector< Int > &trc, const Vector< Int > &inc, const ValueHolder &)
Put a value slice into a column in the table.
Record getKeywordSet(const String &columnName)
Get the table or column keyword values in the table.
ValueHolder getKeyword(const String &columnName, const String &keywordName, Int keywordIndex)
Get a table or column keyword value in the table.
Bool hasDataChanged()
Determine if data in the table has changed.
void getCellSliceVHIP(const String &columnName, Int64 row, const IPosition &blc, const IPosition &trc, const IPosition &inc, const ValueHolder &vh)
Vector< Int64 > shape()
Get the shape (#columns, #rows) of the table.
void reopenRW()
Reopen the table for read/write.
Bool isWritable() const
Test if a table is writable.
void putKeywordSet(const String &columnName, const Record &valueSet)
Define multiple table or column keywords in the table.
void printArrayValue(ostream &os, const DComplex &v, const String &) const
Definition TableProxy.h:564
TableProxy(const TableProxy &)
Copy constructor.
void addRow(Int64 nrow)
Add rows to the table.
static IPosition fillAxes(const IPosition &, Bool cOrder)
Optionally reverse the axes.
Int ncolumns()
Get #columns of the table.
void getColumnSliceVHIP(const String &columnName, const IPosition &blc, const IPosition &trc, const IPosition &inc, Int64 row, Int64 nrow, Int64 incr, const ValueHolder &vh)
TableProxy(const Table &table)
Create the object from an existing table (used by some methods).
Definition TableProxy.h:104
Record getDataManagerInfo()
Get the data manager info of the table.
Record getVarColumn(const String &columnName, Int64 row, Int64 nrow, Int64 incr)
Bool cellContentsDefined(const String &columnName, Int64 rownr)
Tests if the contents of a cell are defined.
Vector< Int64 > rowNumbers(TableProxy &other)
Get the row numbers of the table.
ValueHolder getValueSliceFromTable(const String &colName, const Slicer &slicer, Int64 rownr, Int64 nrow, Int64 incr, Bool isCell)
Get value slices from the column.
void putValueInTable(const String &colName, Int64 rownr, Int64 nrow, Int64 incr, Bool isCell, const ValueHolder &)
Put values into the column.
void putVarColumn(const String &columnName, Int64 row, Int64 nrow, Int64 incr, const Record &values)
static void stillSameShape(Int &same, IPosition &shape, const IPosition &newShape)
Check if the new shape is still the same.
static void calcValues(Record &rec, const TableExprNode &expr)
Calculate the values of a CALC expression and store them in field 'values' in rec.
TableProxy selectRows(const Vector< Int64 > &rownrs, const String &outName)
Select the given rows from the table and create a new (reference) table.
TableProxy(const String &tableName, const Record &lockOptions, const String &endianFormat, const String &memType, Int64 nrow, const Record &tableDesc, const Record &dmInfo)
Create a table with given name and description, etc.
Int64 getRowsSliceCheck(Slicer &slicer, const String &columnName, Int64 row, Int64 nrow, Int64 incr, const IPosition &blc, const IPosition &trc, const IPosition &inc, const String &caller)
Sync table to get correct nr of rows and check the row number.
void close()
Flush and close the table and all its subtables.
Table & table()
Return the table object.
Definition TableProxy.h:466
void putColumn(const String &columnName, Int64 row, Int64 nrow, Int64 incr, const ValueHolder &)
Put some or all values into a column in the table.
void renameColumn(const String &nameOld, const String &nameNew)
Rename a column in the table.
TableProxy(const String &fileName, const String &headerName, const String &tableName, Bool autoHeader, const IPosition &autoShape, const String &separator, const String &commentMarker, Int64 firstLine, Int64 lastLine, const Vector< String > &columnNames=Vector< String >(), const Vector< String > &dataTypes=Vector< String >())
Create a table from an Ascii file.
static Record recordHCDesc(const TableDesc &tableDesc)
Make a record containing the description of all hypercolumns.
static String getTypeStr(DataType)
Get the type string as used externally (in e.g.
void unlock()
Release a lock on the table.
static ValueHolder getKeyValue(const TableRecord &keySet, const RecordFieldId &fieldId)
Get the value of a keyword.
static Table::EndianFormat makeEndianFormat(const String &endianFormat)
Turn the string into the endian format option.
void getValueFromTable(const String &colName, Int64 rownr, Int64 nrow, Int64 incr, Bool isCell, const ValueHolder &vh)
static Record recordColumnDesc(const ColumnDesc &, Bool cOrder)
Make a record containing the column description.
Record getTableDescription(Bool actual, Bool cOrder=False)
Get the table description of the table.
ValueHolder getColumnSlice(const String &columnName, Int64 row, Int64 nrow, Int64 incr, const Vector< Int > &blc, const Vector< Int > &trc, const Vector< Int > &inc)
Get some or all value slices from a column in the table.
TableProxy & operator=(const TableProxy &)
Assignment.
String toAscii(const String &asciiFile, const String &headerFile, const Vector< String > &columns, const String &sep, const Vector< Int > &precision, Bool useBrackets)
Write the table to an ASCII file (approximately the inverse of the from-ASCII-contructor).
static Record getKeyValues(const TableRecord &keySet)
Get or put the values of all keywords.
void printArrayValue(ostream &os, const String &v, const String &) const
Definition TableProxy.h:565
TableProxy(const Vector< String > &tableNames, const Vector< String > &concatenateSubTableNames, const Record &lockOptions, int option)
Create a table object to concatenate a number of similar tables.
static Bool makeTableDesc(const Record &gdesc, TableDesc &tabdesc, String &message)
Make a real table description from a table description in a record.
Bool isReadable() const
Test if a table is readable.
void removeColumns(const Vector< String > &columnNames)
Remove one or more columns from the table.
TableProxy(const std::vector< TableProxy > &tables, const Vector< String > &concatenateSubTableNames, int dummy1=0, int dummy2=0, int dummy3=0)
Record getProperties(const String &name, Bool byColumn)
Get the properties of a data manager given by column or data manager name.
void putValueSliceInTable(const String &colName, const Slicer &slicer, Int64 rownr, Int64 nrow, Int64 incr, Bool isCell, const ValueHolder &)
Put value slices into the column.
void printValueHolder(const ValueHolder &vh, ostream &os, const String &sep, Int prec, Bool useBrackets) const
Print the data in a table cell for toAscii.
ValueHolder getCell(const String &columnName, Int64 row)
Get a value from a column in the table.
Vector< String > columnNames()
Get all column names in the table.
static TableLock makeLockOptions(const Record &options)
Get the lock options from the fields in the record.
void findKeyId(RecordFieldId &fieldid, const TableRecord *&keySet, const String &keyname, const String &column)
Split the keyname into its separate parts (separator is.).
void flush(Bool recursive)
Flush the table and optionally all its subtables.
void syncTable(Table &table)
Synchronize table if readlocking is in effect.
ValueHolder getCellSlice(const String &columnName, Int64 row, const Vector< Int > &blc, const Vector< Int > &trc, const Vector< Int > &inc)
Get a value slice from a column in the table.
ValueHolder getValueFromTable(const String &colName, Int64 rownr, Int64 nrow, Int64 incr, Bool isCell)
Get values from the column.
void setDefaultForSlicer(IPosition &vec) const
Replace the user-given default value (<0) by the default value used by Slicer (i.e.
Bool isScalarColumn(const String &columnName)
Return in result if the column contains scalars.
Record lockOptions()
Get the lock options of the table.
void putColumnSlice(const String &columnName, Int64 row, Int64 nrow, Int64 incr, const Vector< Int > &blc, const Vector< Int > &trc, const Vector< Int > &inc, const ValueHolder &)
Put some or all value slices into a column in the table.
void lock(Bool mode, Int nattempts)
Acquire a (read or write) lock on the table.
void copyRows(TableProxy &out, Int64 startIn, Int64 startOut, Int64 nrow)
Copy rows from one table to another.
void findKeyId(RecordFieldId &fieldid, TableRecord *&keySet, const String &keyname, const String &column, Bool mustExist, Bool change, Bool makeSubRecord)
Record tableInfo()
Get the table info of the table.
void addReadmeLine(const String &line)
Add a line to the TableInfo readme.
String endianFormat() const
Get the endian format of the table.
void putKeyword(const String &columnName, const String &keywordName, Int keywordIndex, Bool makeSubRecord, const ValueHolder &)
Define a table or column keyword in the table.
const Table & table() const
Definition TableProxy.h:467
void printArrayValue(ostream &os, Int v, const String &) const
Definition TableProxy.h:561
Bool getColInfo(const String &colName, Bool useBrackets, String &type, String &message)
Get the column info for toAscii.
void putCell(const String &columnName, const Vector< Int64 > &rownrs, const ValueHolder &)
Put a value into a column in the table.
static Bool addArrayColumnDesc(TableDesc &tableDesc, const String &valueType, const String &columnName, const String &comment, const String &dataManagerType, const String &dataManagerGroup, int options, Int ndim, const Vector< Int64 > &shape, Bool cOrder, String &message)
Add an array column description to the table description.
void addColumns(const Record &tableDesc, const Record &dminfo, Bool addToParent)
Add one or more columns to the table.
static Bool makeHC(const Record &gdesc, TableDesc &tabdesc, String &message)
Make hypercolumn definitions for the given hypercolumns.
static Array< T > record2Array(const Record &rec)
Copy the array contents of the record fields to a single array.
Definition TableProxy.h:534
void getColumnVH(const String &columnName, Int64 row, Int64 nrow, Int64 incr, const ValueHolder &vh)
Bool isMultiUsed(Bool checkSubTables)
Determine if the table (and optionally its subtables) are in use in another process.
void getValueSliceFromTable(const String &colName, const Slicer &slicer, Int64 rownr, Int64 nrow, Int64 incr, Bool isCell, const ValueHolder &vh)
void printArray(const Array< T > &arr, ostream &os, const String &sep) const
void resync()
Resync the table.
void rename(const String &newTableName)
Rename the table.
Vector< String > getFieldNames(const String &columnName, const String &keywordName, Int keywordIndex)
Get the names of all field in a record in the table.
Int64 nrows()
Get #rows of the table.
Record getCalcResult() const
Get result of possible CALC statement.
Vector< String > getColumnShapeString(const String &columnName, Int64 rownr, Int64 nrow, Int64 incr, Bool cOrder=False)
Get the shape of one or more cells in a column as a vector of Strings containing the shapes as [a,...
void getCellVH(const String &columnName, Int64 row, const ValueHolder &vh)
String tableName()
Get table name.
void removeRow(const Vector< Int64 > &rownrs)
Remove rows from the table.
String showStructure(Bool showDataMan=True, Bool showColumns=True, Bool showSubTables=False, Bool sortColumns=False) const
Show the structure of a table.
void getCellSliceVH(const String &columnName, Int64 row, const Vector< Int > &blc, const Vector< Int > &trc, const Vector< Int > &inc, const ValueHolder &vh)
void putColumnSliceIP(const String &columnName, const ValueHolder &, const IPosition &blc, const IPosition &trc, const IPosition &inc, Int64 row, Int64 nrow, Int64 incr)
static void putKeyValues(TableRecord &keySet, const Record &valueSet)
EndianFormat
Define the possible endian formats in which table data can be stored.
Definition Table.h:192
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
unsigned int uInt
Definition aipstype.h:49
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
String name() const
Return the name of the field.
const String & comment(const RecordFieldId &) const override
Get the comment for this field.
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:360
double Double
Definition aipstype.h:53