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
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/tables/Tables/Table.h>
33#include <casacore/casa/Containers/Record.h>
34#include <casacore/casa/Arrays/Vector.h>
35#include <vector>
36
37
38//# Forward Declarations
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 class ValueHolder;
41 class RecordFieldId;
42 class Table;
43 class TableLock;
44 class ColumnDesc;
45 class TableExprNode;
46 class Slicer;
47
48
49// <summary>
50// High-level interface to tables
51// </summary>
52
53// <use visibility=export>
54
55// <reviewed reviewer="Paul Shannon" date="1995/09/15" tests="ttable.py" demos="">
56// </reviewed>
57
58// <prerequisite>
59//# Classes you should understand before using this one.
60// <li> class Table
61// <li> python script table.py
62// </prerequisite>
63
64// <etymology>
65// TableProxy is a proxy for access to tables from any script.
66// </etymology>
67
68// <synopsis>
69// TableProxy gives access to most of the functionality in the Table System.
70// It is primarily meant to be used in classes that wrap access to it
71// from scripting languages (like Glish and Python).
72// However, it can also be used directly from other C++ code.
73//
74// It has functions to open, create, read, write, and query tables.
75// Accompying proxy classes give access to other functionality. They are:
76// <ul>
77// <li> <linkto class=TableIterProxy>TableIterProxy</linkto> for iteration
78// through a table using class
79// <linkto class=TableIterator>TableIterator</linkto>.
80// <li> <linkto class=TableRowProxy>TableRowProxy</linkto> for access to
81// table rows using class <linkto class=TableRow>TableRow</linkto>.
82// <li> <linkto class=TableIndexProxy>TableIterProxy</linkto> for faster
83// indexed access to using classes
84// <linkto class=ColumnsIndex>ColumnsIndex</linkto> and
85// <linkto class=ColumnsIndexArray>ColumnsIndexArray</linkto>.
86// </ul>
87//
88// TableProxy does not have the TableRecord type in its interface, because
89// such a type cannot be handled by e.g. Glish or Python. Instead it
90// converts TableRecords to/from Records. If a TableRecord contains a field
91// with a Table object, it is represented in the Record as a string
92// with the value "Table: NAME" where NAME is the table name.
93// </synopsis>
94
95// <motivation>
96// TableProxy is the Tasking-independent high-level table interface.
97// Different front-ends (e.g. GlishTableProxy) can be put on top of it.
98// </motivation>
99
101{
102public:
103 // Default constructor initializes to not open.
104 // This constructor is only needed for containers.
106
107 // Create the object from an existing table (used by some methods).
109 : table_p (table) {}
110
111 // Open the table with a given name.
113 const Record& lockOptions,
114 int option);
115
116 // Create a table with given name and description, etc.
118 const Record& lockOptions,
119 const String& endianFormat,
120 const String& memType,
121 Int64 nrow,
122 const Record& tableDesc,
123 const Record& dmInfo);
124
125 // Create a table object to concatenate a number of similar tables.
126 // The keyword set of the first table is take as the keyword set of the
127 // entire concatenation. However, it can be specified which subtables
128 // have to be concatenated as well which means that for each subtable name
129 // the subtable in the keywordsets are concatenated.
130 // <note>For Boost-Python the constructors must have different nr of arguments.
131 // Hence some dummy arguments are added.
132 //</note>
133 // <group>
134 TableProxy (const Vector<String>& tableNames,
135 const Vector<String>& concatenateSubTableNames,
136 const Record& lockOptions,
137 int option);
138 TableProxy (const std::vector<TableProxy>& tables,
139 const Vector<String>& concatenateSubTableNames,
140 int dummy1=0, int dummy2=0, int dummy3=0);
141 // </group>
142
143 // Create a table object from a table command (as defined in TableGram).
144 // <br>If a CALC command was given, the resulting values are stored in
145 // the a record and a null TableProxy object is returned.
146 // The result can be obtained using getCalcResult.
147 // <note>
148 // If the command string contains no GIVING part, the resulting
149 // table is temporary and its name is blank.
150 // </note>
151 TableProxy (const String& command,
152 const std::vector<TableProxy>& tables);
153
154 // Create a table from an Ascii file.
155 // It fills a string containing the names and types
156 // of the columns (in the form COL1=R, COL2=D, ...).
157 // The string can be obtained using getAsciiFormat.
158 TableProxy (const String& fileName,
159 const String& headerName,
160 const String& tableName,
161 Bool autoHeader,
162 const IPosition& autoShape,
163 const String& separator,
164 const String& commentMarker,
165 Int64 firstLine,
166 Int64 lastLine,
168 const Vector<String>& dataTypes = Vector<String>());
169
170 // Copy constructor.
172
173 // Close the table.
175
176 // Assignment.
178
179 // Select the given rows from the table and create a new (reference) table.
180 // If outName is not empty, the new table is made persistent with that name.
182 const String& outName);
183
184 // Reopen the table for read/write.
185 void reopenRW();
186
187 // Resync the table.
188 void resync();
189
190 // Flush the table and optionally all its subtables.
191 void flush (Bool recursive);
192
193 // Flush and close the table and all its subtables.
194 void close();
195
196 // Get the endian format of the table.
197 // It fills the result with value "big" or "little".
199
200 // Acquire a (read or write) lock on the table.
201 void lock (Bool mode, Int nattempts);
202
203 // Release a lock on the table.
204 void unlock();
205
206 // Determine if data in the table has changed.
208
209 // Determine if the process has a read or write lock on the table.
211
212 // Get the lock options of the table.
213 // It fills the record with the fields option, interval and maxwait.
215
216 // Determine if the table (and optionally its subtables) are in use
217 // in another process.
218 Bool isMultiUsed (Bool checkSubTables);
219
220 // Write the table to an ASCII file
221 // (approximately the inverse of the from-ASCII-contructor).
222 // If <src>headerFile</src> is empty or equal to <src>asciiFile</src>, the
223 // headers are written in the same file as the data, otherwise in a separate
224 // file.
225 // If no columns are given (or if the first column name is empty), all
226 // table columns are written. Columns containing records are also printed
227 // (enclosed in {}), but a warning message is returned.
228 // <br>Argument <src>sep</src> is used as separator between columns and
229 // array values. If it is empty, a blank is used.
230 // <br>For each column the precision can be given. It is only used for
231 // columns containing floating point numbers. A value <=0 means using the
232 // default which is 9 for single and 18 for double precision.
233 // <br>If <src>useBrackets=True</src>, arrays are enclosed in [] (for each
234 // dimension), so variable shaped arrays can be read back unambiguously.
235 // The type in the header will be something like D[4,64]. If the column is
236 // variable shaped, the type is like D[].
237 // If <src>useBracket=False</src>, arrays are written linearly where a
238 // shape [4,64] is given in the header like D4,64. If the column is variable
239 // shaped, the shape of the first cell is used and a warning message is
240 // returned.
241 String toAscii (const String& asciiFile,
242 const String& headerFile,
243 const Vector<String>& columns,
244 const String& sep,
245 const Vector<Int>& precision,
246 Bool useBrackets);
247
248 // Rename the table
249 void rename (const String& newTableName);
250
251 // Copy the table (possibly a deep copy).
252 // If noRows=True, an empty table is created.
253 TableProxy copy (const String& newTableName,
254 Bool toMemoryTable,
255 Bool deepCopy,
256 Bool valueCopy,
257 const String& endianFormat,
258 const Record& dminfo,
259 Bool noRows);
260
261 // Copy rows from one table to another.
262 // If startOut<0, it is set to the end of the output table.
264 Int64 startIn,
265 Int64 startOut,
266 Int64 nrow);
267
268 // Close and delete the table.
269 void deleteTable (Bool checkSubTables);
270
271 // Get the table info of the table.
273
274 // Put the table info of the table.
275 void putTableInfo (const Record& value);
276
277 // Add a line to the TableInfo readme.
278 void addReadmeLine (const String& line);
279
280 // Test if a table is readable.
282
283 // Test if a table is writable.
285
286 // Set the maximum cache size for the given column in the table.
287 void setMaximumCacheSize (const String& columnName,
288 Int nbytes);
289
290 // Add one or more columns to the table.
291 void addColumns (const Record& tableDesc,
292 const Record& dminfo,
293 Bool addToParent);
294
295 // Rename a column in the table.
296 void renameColumn (const String& nameOld,
297 const String& nameNew);
298
299 // Remove one or more columns from the table.
301
302 // Add rows to the table.
303 void addRow (Int64 nrow);
304
305 // Remove rows from the table.
306 void removeRow (const Vector<Int64>& rownrs);
307
308 // Get some or all values from a column in the table.
309 // row is the starting row number (0-relative).
310 // nrow=-1 means until the end of the table.
311 // incr is the step in row number.
312 // <group>
313 ValueHolder getColumn (const String& columnName,
314 Int64 row,
315 Int64 nrow,
316 Int64 incr);
317 void getColumnVH (const String& columnName,
318 Int64 row,
319 Int64 nrow,
320 Int64 incr,
321 const ValueHolder& vh);
322 Record getVarColumn (const String& columnName,
323 Int64 row,
324 Int64 nrow,
325 Int64 incr);
326 // </group>
327
328 // Get some or all value slices from a column in the table.
329 // If the inc vector is empty, it defaults to all 1.
330 // <group>
332 Int64 row,
333 Int64 nrow,
334 Int64 incr,
335 const Vector<Int>& blc,
336 const Vector<Int>& trc,
337 const Vector<Int>& inc);
339 const IPosition& blc,
340 const IPosition& trc,
341 const IPosition& inc,
342 Int64 row,
343 Int64 nrow,
344 Int64 incr);
345 void getColumnSliceVH (const String& columnName,
346 Int64 row,
347 Int64 nrow,
348 Int64 incr,
349 const Vector<Int>& blc,
350 const Vector<Int>& trc,
351 const Vector<Int>& inc,
352 const ValueHolder& vh);
353 void getColumnSliceVHIP (const String& columnName,
354 const IPosition& blc,
355 const IPosition& trc,
356 const IPosition& inc,
357 Int64 row,
358 Int64 nrow,
359 Int64 incr,
360 const ValueHolder& vh);
361 // </group>
362
363 // Put some or all values into a column in the table.
364 // row is the starting row number (0-relative).
365 // nrow=-1 means until the end of the table.
366 // incr is the step in row number.
367 // <group>
368 void putColumn (const String& columnName,
369 Int64 row,
370 Int64 nrow,
371 Int64 incr,
372 const ValueHolder&);
373 void putVarColumn (const String& columnName,
374 Int64 row,
375 Int64 nrow,
376 Int64 incr,
377 const Record& values);
378 // </group>
379
380 // Put some or all value slices into a column in the table.
381 // <group>
382 void putColumnSlice (const String& columnName,
383 Int64 row,
384 Int64 nrow,
385 Int64 incr,
386 const Vector<Int>& blc,
387 const Vector<Int>& trc,
388 const Vector<Int>& inc,
389 const ValueHolder&);
390 void putColumnSliceIP (const String& columnName,
391 const ValueHolder&,
392 const IPosition& blc,
393 const IPosition& trc,
394 const IPosition& inc,
395 Int64 row,
396 Int64 nrow,
397 Int64 incr);
398 // </group>
399
400 // Tests if the contents of a cell are defined.
401 // Only a column with variable shaped arrays can have an empty cell.
402 Bool cellContentsDefined (const String& columnName,
403 Int64 rownr);
404
405 // Get a value from a column in the table.
406 ValueHolder getCell (const String& columnName,
407 Int64 row);
408 void getCellVH (const String& columnName,
409 Int64 row, const ValueHolder& vh);
410
411 // Get a value slice from a column in the table.
412 // If the inc vector is empty, it defaults to all 1.
413 // <group>
414 ValueHolder getCellSlice (const String& columnName,
415 Int64 row,
416 const Vector<Int>& blc,
417 const Vector<Int>& trc,
418 const Vector<Int>& inc);
420 Int64 row,
421 const IPosition& blc,
422 const IPosition& trc,
423 const IPosition& inc);
424 void getCellSliceVH (const String& columnName,
425 Int64 row,
426 const Vector<Int>& blc,
427 const Vector<Int>& trc,
428 const Vector<Int>& inc,
429 const ValueHolder& vh);
430 void getCellSliceVHIP (const String& columnName,
431 Int64 row,
432 const IPosition& blc,
433 const IPosition& trc,
434 const IPosition& inc,
435 const ValueHolder& vh);
436 // </group>
437
438 // Put a value into a column in the table.
439 void putCell (const String& columnName,
440 const Vector<Int64>& rownrs,
441 const ValueHolder&);
442
443 // Put a value slice into a column in the table.
444 // If the inc vector is empty, it defaults to all 1.
445 // <group>
446 void putCellSlice (const String& columnName,
447 Int64 row,
448 const Vector<Int>& blc,
449 const Vector<Int>& trc,
450 const Vector<Int>& inc,
451 const ValueHolder&);
452 void putCellSliceIP (const String& columnName,
453 Int64 row,
454 const ValueHolder&,
455 const IPosition& blc,
456 const IPosition& trc,
457 const IPosition& inc);
458 // </group>
459
460 // Get the shape of one or more cells in a column as a vector of Strings
461 // containing the shapes as [a,b,c].
462 // If the shape is fixed, a single String is returned.
464 Int64 rownr,
465 Int64 nrow,
466 Int64 incr,
467 Bool cOrder = False);
468
469 // Get a table or column keyword value in the table.
470 // If the columnName is empty, a given keyword is a table keyword.
471 // The keyword can be given as a name or a 0-based index.
472 ValueHolder getKeyword (const String& columnName,
473 const String& keywordName,
474 Int keywordIndex);
475
476 // Get the table or column keyword values in the table.
477 // If the columnName is empty, the table keyword values are returned.
478 Record getKeywordSet (const String& columnName);
479
480 // Define a table or column keyword in the table.
481 // If the column name is empty, a table keyword is defined.
482 // The keyword can be given as a name or a 0-based number.
483 // The value should be a record containing the value of the keyword.
484 // The value can be any type (including a record).
485 void putKeyword (const String& columnName,
486 const String& keywordName,
487 Int keywordIndex,
488 Bool makeSubRecord,
489 const ValueHolder&);
490
491 // Define multiple table or column keywords in the table.
492 // If the column name is empty, a table keywords are defined.
493 // The value should be a record containing the values of the keywords.
494 // The values can be any type (including a record).
495 // The field names are the keyword names.
496 void putKeywordSet (const String& columnName,
497 const Record& valueSet);
498
499 // Remove a table or column keyword from the table.
500 // If the column name is empty, a table keyword is removed.
501 void removeKeyword (const String& columnName,
502 const String& keywordName,
503 Int keywordIndex);
504
505 // Get the names of all field in a record in the table.
506 // If the column name is empty, the table keywords are used.
507 // If the keyword name is empty, the names of all keywords are returned.
508 // Otherwise the names of all fields in the keyword value are returned.
509 // In that case the value has to be a record.
511 const String& keywordName,
512 Int keywordIndex);
513
514 // Get table name.
516
517 // Get the names of the parts the table consists of (e.g. for a ConcatTable).
519
520 // Get #columns of the table.
522
523 // Get #rows of the table.
525
526 // Get the shape (#columns, #rows) of the table.
528
529 // Get the row numbers of the table.
531
532 // Get all column names in the table.
534
535 // Return in result if the column contains scalars.
536 Bool isScalarColumn (const String& columnName);
537
538 // Return the data type of the column as:
539 // Bool, UChar, Short, UShort, Int, UInt, Int64,
540 // Float, Double, Complex, DComplex, String, Table, or unknown.
541 String columnDataType (const String& columnName);
542
543 // Return the type of array in the column as:
544 // Direct
545 // Undefined
546 // FixedShape
547 // Direct,Undefined
548 // Direct,FixedShape
549 // Undefined,FixedShape
550 // Direct,Undefined,FixedShape
551 // or Error -- unexpected column type
552 String columnArrayType (const String& columnName);
553
554 // Get the data manager info of the table.
556
557 // Get the properties of a data manager given by column or data manager name.
558 Record getProperties (const String& name, Bool byColumn);
559
560 // Set the properties of a data manager given by column or data manager name.
561 void setProperties (const String& name, const Record& properties,
562 Bool byColumn);
563
564 // Get the table description of the table.
565 // It returns a record containing the description.
566 Record getTableDescription (Bool actual, //# use actual description?
567 Bool cOrder=False);
568
569 // Create a Record table description from a TableDesc object
570 static Record getTableDesc(const TableDesc & tabdesc, Bool cOrder=False);
571
572 // Get the column description of a column in the table.
573 // It returns a record containing the description.
575 Bool actual, //# use actual description?
576 Bool cOrder=False);
577
578 // Get ascii format string.
580
581 // Get result of possible CALC statement.
583
584 // Show the structure of a table.
585 String showStructure (Bool showDataMan=True, Bool showColumns=True,
586 Bool showSubTables=False, Bool sortColumns=False) const;
587
588 // Return the table object.
589 // <group>
591 { return table_p; }
592 const Table& table() const
593 { return table_p; }
594 // </group>
595
596 // Get or put the values of all keywords.
597 // Thus convert from TableRecord to/from Record.
598 // Keywords containing a table are converted to a string containing
599 // the table name preceeded by 'Table: '.
600 // <group>
601 static Record getKeyValues (const TableRecord& keySet);
602 static void putKeyValues (TableRecord& keySet, const Record& valueSet);
603 // </group>
604
605 // Get the lock options from the fields in the record.
606 // If the record or lockoption is invalid, an exception is thrown.
607 static TableLock makeLockOptions (const Record& options);
608
609 // Turn the string into the endian format option.
610 // An exception is thrown if the string is invalid.
612
613 // Make hypercolumn definitions for the given hypercolumns.
614 static Bool makeHC (const Record& gdesc, TableDesc& tabdesc,
615 String& message);
616
617 // Get the value of a keyword.
618 static ValueHolder getKeyValue (const TableRecord& keySet,
619 const RecordFieldId& fieldId);
620
621 // Put the value of a keyword.
622 static void putKeyValue (TableRecord& keySet,
623 const RecordFieldId& fieldId,
624 const ValueHolder& value);
625
626 // Make a real table description from a table description in a record.
627 // An exception is thrown if the record table description is invalid.
628 // A record table description is a Record object as returned by
629 // getDesc.
630 static Bool makeTableDesc (const Record& gdesc, TableDesc& tabdesc,
631 String& message);
632
633 // Add an array column description to the table description.
634 // It is used by the function makeDesc.
636 const String& valueType,
637 const String& columnName,
638 const String& comment,
639 const String& dataManagerType,
640 const String& dataManagerGroup,
641 int options,
642 Int ndim, const Vector<Int64>& shape,
643 Bool cOrder,
644 String& message);
645
646 // Make a record containing the column description.
647 static Record recordColumnDesc (const ColumnDesc&, Bool cOrder);
648
649 // Make a record containing the description of all hypercolumns.
650 static Record recordHCDesc (const TableDesc& tableDesc);
651
652 // Calculate the values of a CALC expression and store them in field
653 // 'values' in rec.
654 static void calcValues (Record& rec, const TableExprNode& expr);
655
656 // Get the type string as used externally (in e.g. glish).
657 static String getTypeStr (DataType);
658
659 // Optionally reverse the axes.
660 static IPosition fillAxes (const IPosition&, Bool cOrder);
661
662 // Check if the new shape is still the same.
663 // <br> same: 0=first time; 1=still the same; 2=different
664 static void stillSameShape (Int& same, IPosition& shape,
665 const IPosition& newShape);
666
667 // Copy the array contents of the record fields to a single array.
668 // This can only be done if the shape is constant.
669 template<typename T>
670 static Array<T> record2Array (const Record& rec)
671 {
672 if (rec.empty()) {
673 return Array<T>();
674 }
675 Array<T> tmp;
676 rec.get (0, tmp);
677 IPosition shp(tmp.shape());
678 shp.append (IPosition(1, rec.size()));
679 Array<T> arr(shp);
680 ArrayIterator<T> iter(arr, tmp.ndim());
681 for (uInt i=0; i<rec.size(); ++i, iter.next()) {
682 rec.get (i, iter.array());
683 }
684 return arr;
685 }
686
687protected:
688
689 // Get the column info for toAscii.
690 Bool getColInfo (const String& colName, Bool useBrackets,
691 String& type, String& message);
692
693 // Print the data in a table cell for toAscii.
694 // <group>
695 void printValueHolder (const ValueHolder& vh, ostream& os,
696 const String& sep, Int prec, Bool useBrackets) const;
697 template<typename T>
698 void printArray (const Array<T>& arr, ostream& os,
699 const String& sep) const;
700 void printArrayValue (ostream& os, Bool v, const String&) const
701 {os << v;}
702 void printArrayValue (ostream& os, Int v, const String&) const
703 {os << v;}
704 void printArrayValue (ostream& os, Int64 v, const String&) const
705 {os << v;}
706 void printArrayValue (ostream& os, Double v, const String&) const
707 {os << v;}
708 void printArrayValue (ostream& os, const DComplex& v, const String&) const
709 {os << v;}
710 void printArrayValue (ostream& os, const String& v, const String&) const
711 {os << '"' << v << '"';}
712 // </group>
713
714 // Sync table to get correct nr of rows and check the row number.
715 // It returns the nr of table rows.
716 Int64 getRowsCheck (const String& columnName,
717 Int64 row, Int64 nrow, Int64 incr,
718 const String& caller);
719
720 // Sync table to get correct nr of rows and check the row number.
721 // Fill the slicer with the possibly expanded blc,trc,inc.
722 // It returns the nr of table rows.
724 const String& columnName,
725 Int64 row, Int64 nrow, Int64 incr,
726 const IPosition& blc,
727 const IPosition& trc,
728 const IPosition& inc,
729 const String& caller);
730
731 // Check if the column name and row numbers are valid.
732 // Return the recalculated nrow so that it does not exceed #rows.
734 const String& colName,
735 Int64 rownr, Int64 nrow, Int64 incr,
736 const String& caller);
737
738 // Make an empty array (with 1 axis) of the correct datatype.
739 ValueHolder makeEmptyArray (DataType dtype);
740
741 // Get values from the column.
742 // Nrow<0 means till the end of the column.
744 Int64 rownr, Int64 nrow, Int64 incr,
745 Bool isCell);
746 void getValueFromTable (const String& colName,
747 Int64 rownr, Int64 nrow, Int64 incr,
748 Bool isCell, const ValueHolder& vh);
749
750 // Get value slices from the column.
751 // Nrow<0 means till the end of the column.
753 const Slicer& slicer,
754 Int64 rownr, Int64 nrow, Int64 incr,
755 Bool isCell);
756 void getValueSliceFromTable(const String& colName,
757 const Slicer& slicer,
758 Int64 rownr, Int64 nrow, Int64 incr,
759 Bool isCell, const ValueHolder& vh);
760
761 // Put values into the column.
762 // Nrow<0 means till the end of the column.
763 void putValueInTable (const String& colName,
764 Int64 rownr, Int64 nrow, Int64 incr,
765 Bool isCell, const ValueHolder&);
766
767 // Put value slices into the column.
768 // Nrow<0 means till the end of the column.
769 void putValueSliceInTable (const String& colName,
770 const Slicer& slicer,
771 Int64 rownr, Int64 nrow, Int64 incr,
772 Bool isCell, const ValueHolder&);
773
774 // Split the keyname into its separate parts (separator is .).
775 // Check if each part exists and is a subrecord (except last part).
776 // When putting, subrecords are created if undefined and if
777 // makeSubRecord is set.
778 // On return it fills in the fieldid with the latest keyword part.
779 // KeySet is set to the last subrecord.
780 // <group>
781 void findKeyId (RecordFieldId& fieldid,
782 const TableRecord*& keySet,
783 const String& keyname,
784 const String& column);
785 void findKeyId (RecordFieldId& fieldid,
786 TableRecord*& keySet,
787 const String& keyname,
788 const String& column,
789 Bool mustExist, Bool change, Bool makeSubRecord);
790 // </group>
791
792 // Replace the user-given default value (<0) by the default value
793 // used by Slicer (i.e. by Slicer::MimicSource).
795
796 // Synchronize table if readlocking is in effect.
797 // In this way the number of rows is up-to-date.
799
800 //# The data members.
804};
805
806} //# NAMESPACE CASACORE - END
807
808#endif
size_t ndim() const
The dimensionality of this array.
Definition ArrayBase.h:96
const IPosition & shape() const
The length of each axis.
Definition ArrayBase.h:123
Array< T > & array()
Return the cursor.
Definition ArrayIter.h:113
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).
bool empty() const
Is the record empty?
void get(const RecordFieldId &, Bool &value) const
Get the value of the given field.
String: the storage and methods of handling collections of characters.
Definition String.h:223
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:706
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:704
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:700
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:708
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:108
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:590
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:710
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:592
void printArrayValue(ostream &os, Int v, const String &) const
Definition TableProxy.h:702
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:670
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:195
this file contains all the compiler specific defines
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
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53