casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExprNodeArray.h
Go to the documentation of this file.
1 //# ExprNodeArray.h: Classes representing an array in table select expression
2 //# Copyright (C) 1997,1999,2000,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: ExprNodeArray.h 21262 2012-09-07 12:38:36Z gervandiepen $
27 
28 #ifndef TABLES_EXPRNODEARRAY_H
29 #define TABLES_EXPRNODEARRAY_H
30 
31 //# Includes
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class TableExprNodeSet;
42 
43 
44 // <summary>
45 // Base class for arrays in table select expression
46 // </summary>
47 
48 // <use visibility=local>
49 
50 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // <li> TableExprNode
56 // <li> TableExprNodeRep
57 // <li> TableExprNodeBinary
58 // </prerequisite>
59 
60 // <synopsis>
61 // This class is the base class to represent an array.
62 // The actual storing of the array column is done by its derivations.
63 // </synopsis>
64 
66 {
67 public:
68  // Create the object.
69  // <group>
73  // </group>
74 
76 
77  // Turn a constant array with one element into a scalar.
78  // It returns a zero pointer if not possible.
79  // The default implementation returns 0.
80  virtual TENShPtr makeConstantScalar();
81 
82  // Validate the given index against the array's shape.
83  // Treat a negative as an index from the end (a la python) and replace it.
84  IPosition validateIndex (const IPosition& index,
85  const ArrayBase& arr) const;
86 
87  // Get the shape of the array in the given row.
88  // This default implementation evaluates the value and returns its shape.
89  virtual const IPosition& getShape (const TableExprId& id);
90 
91  // The default implementation of getArrayDouble does
92  // getArrayInt and converts the result.
93  virtual MArray<Double> getArrayDouble (const TableExprId& id);
94 
95  // The default implementation of getArrayDComplex does
96  // getArrayDouble and converts the result.
97  virtual MArray<DComplex> getArrayDComplex (const TableExprId& id);
98 
99  // Does a value occur in the set?
100  // <group>
101  virtual Bool hasBool (const TableExprId& id, Bool value);
102  virtual Bool hasInt (const TableExprId& id, Int64 value);
103  virtual Bool hasDouble (const TableExprId& id, Double value);
104  virtual Bool hasDComplex (const TableExprId& id, const DComplex& value);
105  virtual Bool hasString (const TableExprId& id, const String& value);
106  virtual Bool hasDate (const TableExprId& id, const MVTime& value);
107  virtual MArray<Bool> hasArrayBool (const TableExprId& id,
108  const MArray<Bool>& value);
109  virtual MArray<Bool> hasArrayInt (const TableExprId& id,
110  const MArray<Int64>& value);
111  virtual MArray<Bool> hasArrayDouble (const TableExprId& id,
112  const MArray<Double>& value);
113  virtual MArray<Bool> hasArrayDComplex (const TableExprId& id,
114  const MArray<DComplex>& value);
115  virtual MArray<Bool> hasArrayString (const TableExprId& id,
116  const MArray<String>& value);
117  virtual MArray<Bool> hasArrayDate (const TableExprId& id,
118  const MArray<MVTime>& value);
119  // </group>
120 
121  // Get a single element from the array in the given row.
122  // <group>
123  virtual Bool getElemBool (const TableExprId& id,
124  const Slicer& index);
125  virtual Int64 getElemInt (const TableExprId& id,
126  const Slicer& index);
127  virtual Double getElemDouble (const TableExprId& id,
128  const Slicer& index);
129  virtual DComplex getElemDComplex (const TableExprId& id,
130  const Slicer& index);
131  virtual String getElemString (const TableExprId& id,
132  const Slicer& index);
133  virtual MVTime getElemDate (const TableExprId& id,
134  const Slicer& index);
135  // </group>
136 
137  // Get a slice of the array in the given row.
138  // <group>
139  virtual MArray<Bool> getSliceBool (const TableExprId& id,
140  const Slicer&);
141  virtual MArray<Int64> getSliceInt (const TableExprId& id,
142  const Slicer&);
143  virtual MArray<Double> getSliceDouble (const TableExprId& id,
144  const Slicer&);
145  virtual MArray<DComplex> getSliceDComplex (const TableExprId& id,
146  const Slicer&);
147  virtual MArray<String> getSliceString (const TableExprId& id,
148  const Slicer&);
149  virtual MArray<MVTime> getSliceDate (const TableExprId& id,
150  const Slicer&);
151  // </group>
152 
153  // Get a single element for the entire column (used by sort).
154  // <group>
155  virtual Array<Bool> getElemColumnBool (const Vector<rownr_t>& rownrs,
156  const Slicer&);
157  virtual Array<uChar> getElemColumnuChar (const Vector<rownr_t>& rownrs,
158  const Slicer&);
159  virtual Array<Short> getElemColumnShort (const Vector<rownr_t>& rownrs,
160  const Slicer&);
161  virtual Array<uShort> getElemColumnuShort (const Vector<rownr_t>& rownrs,
162  const Slicer&);
163  virtual Array<Int> getElemColumnInt (const Vector<rownr_t>& rownrs,
164  const Slicer&);
165  virtual Array<uInt> getElemColumnuInt (const Vector<rownr_t>& rownrs,
166  const Slicer&);
167  virtual Array<Int64> getElemColumnInt64 (const Vector<rownr_t>& rownrs,
168  const Slicer&);
169  virtual Array<Float> getElemColumnFloat (const Vector<rownr_t>& rownrs,
170  const Slicer&);
171  virtual Array<Double> getElemColumnDouble (const Vector<rownr_t>& rownrs,
172  const Slicer&);
173  virtual Array<Complex> getElemColumnComplex (const Vector<rownr_t>& rownrs,
174  const Slicer&);
176  const Slicer&);
177  virtual Array<String> getElemColumnString (const Vector<rownr_t>& rownrs,
178  const Slicer&);
179  // </group>
180 
181  // Make an array with the given shape and fill it with the value.
182  static MArray<Int64> makeArray (const IPosition& shape, Int64 value);
183  static MArray<Double> makeArray (const IPosition& shape, Double value);
184  static MArray<DComplex> makeArray (const IPosition& shape,
185  const DComplex& value);
186 
187 protected:
189 };
190 
191 
192 
193 // <summary>
194 // Base class for Array column in table select expression
195 // </summary>
196 
197 // <use visibility=local>
198 
199 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
200 // </reviewed>
201 
202 // <prerequisite>
203 //# Classes you should understand before using this one.
204 // <li> TableExprNodeArray
205 // </prerequisite>
206 
207 // <synopsis>
208 // This class is the base class to store an array column.
209 // The actual storing of the array column is done by its derivations.
210 // </synopsis>
211 
213 {
214 public:
215  // Create the object for the given column and table.
216  TableExprNodeArrayColumn (const TableColumn& tablecol,
217  const Table& table);
218 
220 
221  // This node represents a table column.
222  virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
223 
224  // Do not apply the selection.
225  virtual void disableApplySelection();
226 
227  // Re-create the column object for a selection of rows.
228  virtual void applySelection (const Vector<rownr_t>& rownrs);
229 
230  // Get the TableColumn object.
231  const TableColumn& getColumn() const;
232 
233  // Get the shape of the array in the given row.
234  virtual const IPosition& getShape (const TableExprId& id);
235 
236  // Is the value in the given row defined?
237  virtual Bool isDefined (const TableExprId& id);
238 
239  // Get the data type of this column.
240  // It returns with a True status.
241  virtual Bool getColumnDataType (DataType&) const;
242 
243 protected:
247 };
248 
249 
250 
251 // <summary>
252 // Bool array column in table select expression
253 // </summary>
254 
255 // <use visibility=local>
256 
257 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
258 // </reviewed>
259 
260 // <prerequisite>
261 //# Classes you should understand before using this one.
262 // <li> TableExprNodeArrayColumn
263 // </prerequisite>
264 
265 // <synopsis>
266 // These classes store an array column of type X.
267 // </synopsis>
268 
270 {
271 public:
273  const Table&);
275 
276  // Re-create the column object for a selection of rows.
277  virtual void applySelection (const Vector<rownr_t>& rownrs);
278 
279  virtual Bool getElemBool (const TableExprId& id, const Slicer& index);
280  virtual MArray<Bool> getArrayBool (const TableExprId& id);
281  virtual MArray<Bool> getSliceBool (const TableExprId& id, const Slicer&);
282  virtual Array<Bool> getElemColumnBool (const Vector<rownr_t>& rownrs,
283  const Slicer&);
284 protected:
286 };
287 
288 
289 // <summary>
290 // uChar array column in table select expression
291 // </summary>
292 
293 // <use visibility=local>
294 
295 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
296 // </reviewed>
297 
298 // <prerequisite>
299 //# Classes you should understand before using this one.
300 // <li> TableExprNodeArrayColumn
301 // </prerequisite>
302 
303 // <synopsis>
304 // These classes store an array column of type X.
305 // </synopsis>
306 
308 {
309 public:
311  const Table&);
313 
314  // Re-create the column object for a selection of rows.
315  virtual void applySelection (const Vector<rownr_t>& rownrs);
316 
317  virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
318  virtual MArray<Int64> getArrayInt (const TableExprId& id);
319  virtual MArray<Int64> getSliceInt (const TableExprId& id,
320  const Slicer&);
321  virtual Array<uChar> getElemColumnuChar (const Vector<rownr_t>& rownrs,
322  const Slicer&);
323 protected:
325 };
326 
327 
328 // <summary>
329 // Short array column in table select expression
330 // </summary>
331 
332 // <use visibility=local>
333 
334 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
335 // </reviewed>
336 
337 // <prerequisite>
338 //# Classes you should understand before using this one.
339 // <li> TableExprNodeArrayColumn
340 // </prerequisite>
341 
342 // <synopsis>
343 // These classes store an array column of type X.
344 // </synopsis>
345 
347 {
348 public:
350  const Table&);
352 
353  // Re-create the column object for a selection of rows.
354  virtual void applySelection (const Vector<rownr_t>& rownrs);
355 
356  virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
357  virtual MArray<Int64> getArrayInt (const TableExprId& id);
358  virtual MArray<Int64> getSliceInt (const TableExprId& id,
359  const Slicer&);
360  virtual Array<Short> getElemColumnShort (const Vector<rownr_t>& rownrs,
361  const Slicer&);
362 protected:
364 };
365 
366 
367 // <summary>
368 // uShort array column in table select expression
369 // </summary>
370 
371 // <use visibility=local>
372 
373 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
374 // </reviewed>
375 
376 // <prerequisite>
377 //# Classes you should understand before using this one.
378 // <li> TableExprNodeArrayColumn
379 // </prerequisite>
380 
381 // <synopsis>
382 // These classes store an array column of type X.
383 // </synopsis>
384 
386 {
387 public:
389  const Table&);
391 
392  // Re-create the column object for a selection of rows.
393  virtual void applySelection (const Vector<rownr_t>& rownrs);
394 
395  virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
396  virtual MArray<Int64> getArrayInt (const TableExprId& id);
397  virtual MArray<Int64> getSliceInt (const TableExprId& id,
398  const Slicer&);
399  virtual Array<uShort> getElemColumnuShort (const Vector<rownr_t>& rownrs,
400  const Slicer&);
401 protected:
403 };
404 
405 
406 // <summary>
407 // Int array column in table select expression
408 // </summary>
409 
410 // <use visibility=local>
411 
412 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
413 // </reviewed>
414 
415 // <prerequisite>
416 //# Classes you should understand before using this one.
417 // <li> TableExprNodeArrayColumn
418 // </prerequisite>
419 
420 // <synopsis>
421 // These classes store an array column of type X.
422 // </synopsis>
423 
425 {
426 public:
428  const Table&);
430 
431  // Re-create the column object for a selection of rows.
432  virtual void applySelection (const Vector<rownr_t>& rownrs);
433 
434  virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
435  virtual MArray<Int64> getArrayInt (const TableExprId& id);
436  virtual MArray<Int64> getSliceInt (const TableExprId& id,
437  const Slicer&);
438  virtual Array<Int> getElemColumnInt (const Vector<rownr_t>& rownrs,
439  const Slicer&);
440 protected:
442 };
443 
444 
445 // <summary>
446 // uInt array column in table select expression
447 // </summary>
448 
449 // <use visibility=local>
450 
451 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
452 // </reviewed>
453 
454 // <prerequisite>
455 //# Classes you should understand before using this one.
456 // <li> TableExprNodeArrayColumn
457 // </prerequisite>
458 
459 // <synopsis>
460 // These classes store an array column of type X.
461 // </synopsis>
462 
464 {
465 public:
467  const Table&);
469 
470  // Re-create the column object for a selection of rows.
471  virtual void applySelection (const Vector<rownr_t>& rownrs);
472 
473  virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
474  virtual MArray<Int64> getArrayInt (const TableExprId& id);
475  virtual MArray<Int64> getSliceInt (const TableExprId& id,
476  const Slicer&);
477  virtual Array<uInt> getElemColumnuInt (const Vector<rownr_t>& rownrs,
478  const Slicer&);
479 protected:
481 };
482 
483 
484 // <summary>
485 // Int64 array column in table select expression
486 // </summary>
487 
488 // <use visibility=local>
489 
490 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
491 // </reviewed>
492 
493 // <prerequisite>
494 //# Classes you should understand before using this one.
495 // <li> TableExprNodeArrayColumn
496 // </prerequisite>
497 
498 // <synopsis>
499 // These classes store an array column of type X.
500 // </synopsis>
501 
503 {
504 public:
506  const Table&);
508 
509  // Re-create the column object for a selection of rows.
510  virtual void applySelection (const Vector<rownr_t>& rownrs);
511 
512  virtual Int64 getElemInt (const TableExprId& id, const Slicer& index);
513  virtual MArray<Int64> getArrayInt (const TableExprId& id);
514  virtual MArray<Int64> getSliceInt (const TableExprId& id,
515  const Slicer&);
516  virtual Array<Int64> getElemColumnInt64 (const Vector<rownr_t>& rownrs,
517  const Slicer&);
518 protected:
520 };
521 
522 
523 // <summary>
524 // Float array column in table select expression
525 // </summary>
526 
527 // <use visibility=local>
528 
529 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
530 // </reviewed>
531 
532 // <prerequisite>
533 //# Classes you should understand before using this one.
534 // <li> TableExprNodeArrayColumn
535 // </prerequisite>
536 
537 // <synopsis>
538 // These classes store an array column of type X.
539 // </synopsis>
540 
542 {
543 public:
545  const Table&);
547 
548  // Re-create the column object for a selection of rows.
549  virtual void applySelection (const Vector<rownr_t>& rownrs);
550 
551  virtual Double getElemDouble (const TableExprId& id, const Slicer& index);
552  virtual MArray<Double> getArrayDouble (const TableExprId& id);
553  virtual MArray<Double> getSliceDouble (const TableExprId& id,
554  const Slicer&);
555  virtual Array<Float> getElemColumnFloat (const Vector<rownr_t>& rownrs,
556  const Slicer&);
557 protected:
559 };
560 
561 
562 // <summary>
563 // Double array column in table select expression
564 // </summary>
565 
566 // <use visibility=local>
567 
568 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
569 // </reviewed>
570 
571 // <prerequisite>
572 //# Classes you should understand before using this one.
573 // <li> TableExprNodeArrayColumn
574 // </prerequisite>
575 
576 // <synopsis>
577 // These classes store an array column of type X.
578 // </synopsis>
579 
581 {
582 public:
584  const Table&);
586 
587  // Re-create the column object for a selection of rows.
588  virtual void applySelection (const Vector<rownr_t>& rownrs);
589 
590  virtual Double getElemDouble (const TableExprId& id, const Slicer& index);
591  virtual MArray<Double> getArrayDouble (const TableExprId& id);
592  virtual MArray<Double> getSliceDouble (const TableExprId& id,
593  const Slicer&);
594  virtual Array<Double> getElemColumnDouble (const Vector<rownr_t>& rownrs,
595  const Slicer&);
596 protected:
598 };
599 
600 
601 // <summary>
602 // Complex array column in table select expression
603 // </summary>
604 
605 // <use visibility=local>
606 
607 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
608 // </reviewed>
609 
610 // <prerequisite>
611 //# Classes you should understand before using this one.
612 // <li> TableExprNodeArrayColumn
613 // </prerequisite>
614 
615 // <synopsis>
616 // These classes store an array column of type X.
617 // </synopsis>
618 
620 {
621 public:
623  const Table&);
625 
626  // Re-create the column object for a selection of rows.
627  virtual void applySelection (const Vector<rownr_t>& rownrs);
628 
629  virtual DComplex getElemDComplex (const TableExprId& id, const Slicer& index);
630  virtual MArray<DComplex> getArrayDComplex (const TableExprId& id);
631  virtual MArray<DComplex> getSliceDComplex (const TableExprId& id,
632  const Slicer&);
633  virtual Array<Complex> getElemColumnComplex (const Vector<rownr_t>& rownrs,
634  const Slicer&);
635 protected:
637 };
638 
639 
640 // <summary>
641 // DComplex array column in table select expression
642 // </summary>
643 
644 // <use visibility=local>
645 
646 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
647 // </reviewed>
648 
649 // <prerequisite>
650 //# Classes you should understand before using this one.
651 // <li> TableExprNodeArrayColumn
652 // </prerequisite>
653 
654 // <synopsis>
655 // These classes store an array column of type X.
656 // </synopsis>
657 
659 {
660 public:
662  const Table&);
664 
665  // Re-create the column object for a selection of rows.
666  virtual void applySelection (const Vector<rownr_t>& rownrs);
667 
668  virtual DComplex getElemDComplex (const TableExprId& id, const Slicer& index);
669  virtual MArray<DComplex> getArrayDComplex (const TableExprId& id);
670  virtual MArray<DComplex> getSliceDComplex (const TableExprId& id,
671  const Slicer&);
673  const Slicer&);
674 protected:
676 };
677 
678 
679 // <summary>
680 // String array column in table select expression
681 // </summary>
682 
683 // <use visibility=local>
684 
685 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
686 // </reviewed>
687 
688 // <prerequisite>
689 //# Classes you should understand before using this one.
690 // <li> TableExprNodeArrayColumn
691 // </prerequisite>
692 
693 // <synopsis>
694 // These classes store an array column of type X.
695 // </synopsis>
696 
698 {
699 public:
701  const Table&);
703 
704  // Re-create the column object for a selection of rows.
705  virtual void applySelection (const Vector<rownr_t>& rownrs);
706 
707  virtual String getElemString (const TableExprId& id, const Slicer& index);
708  virtual MArray<String> getArrayString (const TableExprId& id);
709  virtual MArray<String> getSliceString (const TableExprId& id,
710  const Slicer&);
711  virtual Array<String> getElemColumnString (const Vector<rownr_t>& rownrs,
712  const Slicer&);
713 protected:
715 };
716 
717 
718 
719 
720 // <summary>
721 // The index of an array element in a table select expression
722 // </summary>
723 
724 // <use visibility=local>
725 
726 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
727 // </reviewed>
728 
729 // <prerequisite>
730 //# Classes you should understand before using this one.
731 // <li> TableExprNodeMulti
732 // </prerequisite>
733 
734 // <etymology>
735 // TableExprNodeIndex is used to store an index.
736 // All the operands must be Int.
737 // </etymology>
738 
739 // <synopsis>
740 // TableExprNodeIndex is a derivation of TableExprNodeMulti
741 // expression tree that represents an index.
742 // </synopsis>
743 
744 // <motivation>
745 // All operands of TableExprNodeIndex must be Int,
746 // therefore it is a derivation of TableExprNodeMulti.
747 // </motivation>
748 
749 // <todo asof="$DATE:$">
750 //# A List of bugs, limitations, extensions or planned refinements.
751 // <li> to be filled in
752 // </todo>
753 
755 {
756 public:
757  // Constructor
758  explicit TableExprNodeIndex (const TableExprNodeSet& indices,
759  const TaQLStyle& = TaQLStyle(0));
760 
761  // Destructor
762  virtual ~TableExprNodeIndex();
763 
764  // Link all the operands and check datatype.
765  // Calculate the IPosition values for the const operands.
766  void fillIndex (const TableExprNodeSet& indices);
767 
768  // Check if the index values match the dimensionality and shape
769  // of fixed-shaped array.
770  void checkIndexValues (const TENShPtr& arrayNode);
771 
772  // Get the Slicer value for a constant index.
773  const Slicer& getConstantSlicer() const;
774 
775  // Get the Slicer value for the slice.
776  const Slicer& getSlicer (const TableExprId& id);
777 
778  // Does it index a single element?
779  Bool isSingle() const;
780 
781 protected:
782  Int origin_p; //# origin 0 for C++/Python; 1 for Glish
783  Int endMinus_p; //# subtract from end (origin and endExcl)
784  Bool isCOrder_p; //# True for Python
785  IPosition start_p; //# precalculated start values
786  IPosition end_p; //# precalculated end values (<0 = till end)
787  IPosition incr_p; //# precalculated increment values
788  Slicer slicer_p; //# combined start, end, and incr
789  Block<Bool> varIndex_p; //# is the start for the axes variable?
790  Bool isSingle_p; //# Index a single value?
791 
792  // Precalculate the constant indices and store them.
793  void convertConstIndex();
794 
795  // Fill the slicer for this row.
796  void fillSlicer (const TableExprId& id);
797 
798  // Get the shape of the node involved. Reverse axes if needed.
799  IPosition getNodeShape (const TENShPtr& arrayNode) const;
800 };
801 
802 
803 
804 
805 // <summary>
806 // Array column part in table select expression
807 // </summary>
808 
809 // <use visibility=local>
810 
811 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
812 // </reviewed>
813 
814 // <prerequisite>
815 //# Classes you should understand before using this one.
816 // <li> TableExprNode
817 // <li> TableExprNodeRep
818 // <li> TableExprNodeBinary
819 // </prerequisite>
820 
821 // <synopsis>
822 // This class handles a part of an array.
823 // It uses a TableExprNodeArray to handle the array
824 // and a TableExprNodeIndex to store the index.
825 // </synopsis>
826 
828 {
829 public:
830  TableExprNodeArrayPart (const TENShPtr& arrayNode,
831  const TENShPtr& indexNode);
833 
834  // Show the node.
835  virtual void show (ostream& os, uInt indent) const;
836 
837  virtual Bool getBool (const TableExprId& id);
838  virtual Int64 getInt (const TableExprId& id);
839  virtual Double getDouble (const TableExprId& id);
840  virtual DComplex getDComplex (const TableExprId& id);
841  virtual String getString (const TableExprId& id);
842  virtual MVTime getDate (const TableExprId& id);
843 
844  virtual MArray<Bool> getArrayBool (const TableExprId& id);
845  virtual MArray<Int64> getArrayInt (const TableExprId& id);
846  virtual MArray<Double> getArrayDouble (const TableExprId& id);
847  virtual MArray<DComplex> getArrayDComplex (const TableExprId& id);
848  virtual MArray<String> getArrayString (const TableExprId& id);
849  virtual MArray<MVTime> getArrayDate (const TableExprId& id);
850 
851  // Get the data type of this column (if possible).
852  // It returns with a False status when the index is not constant
853  // (that means that the index can vary with row number).
854  virtual Bool getColumnDataType (DataType&) const;
855 
856  virtual Array<Bool> getColumnBool (const Vector<rownr_t>& rownrs);
857  virtual Array<uChar> getColumnuChar (const Vector<rownr_t>& rownrs);
858  virtual Array<Short> getColumnShort (const Vector<rownr_t>& rownrs);
859  virtual Array<uShort> getColumnuShort (const Vector<rownr_t>& rownrs);
860  virtual Array<Int> getColumnInt (const Vector<rownr_t>& rownrs);
861  virtual Array<uInt> getColumnuInt (const Vector<rownr_t>& rownrs);
862  virtual Array<Int64> getColumnInt64 (const Vector<rownr_t>& rownrs);
863  virtual Array<Float> getColumnFloat (const Vector<rownr_t>& rownrs);
864  virtual Array<Double> getColumnDouble (const Vector<rownr_t>& rownrs);
865  virtual Array<Complex> getColumnComplex (const Vector<rownr_t>& rownrs);
866  virtual Array<DComplex> getColumnDComplex (const Vector<rownr_t>& rownrs);
867  virtual Array<String> getColumnString (const Vector<rownr_t>& rownrs);
868 
869  // Get the index node.
870  const TableExprNodeIndex* getIndexNode() const;
871 
872  // Get the array column node.
873  // It returns 0 if the parent object is no array column.
875 
876 private:
879  TableExprNodeArrayColumn* colNode_p; //# 0 if arrNode is no arraycolumn
880 };
881 
882 
883 
884 
886 {
887  return isSingle_p;
888 }
890 {
891  return slicer_p;
892 }
894 {
895  if (!isConstant()) {
896  fillSlicer (id);
897  }
898  return slicer_p;
899 }
900 
902 {
903  return tabCol_p;
904 }
905 
907 {
908  return inxNode_p;
909 }
910 
911 inline const TableExprNodeArrayColumn*
913 {
914  return colNode_p;
915 }
916 
917 
918 
919 } //# NAMESPACE CASACORE - END
920 
921 #endif
922 
virtual MArray< Double > getSliceDouble(const TableExprId &id, const Slicer &)
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
virtual DComplex getElemDComplex(const TableExprId &id, const Slicer &index)
const Slicer & getSlicer(const TableExprId &id)
Get the Slicer value for the slice.
void fillIndex(const TableExprNodeSet &indices)
Link all the operands and check datatype.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
virtual MArray< DComplex > getSliceDComplex(const TableExprId &id, const Slicer &)
virtual String getElemString(const TableExprId &id, const Slicer &index)
int Int
Definition: aipstype.h:50
Bool isSingle() const
Does it index a single element?
virtual Int64 getElemInt(const TableExprId &id, const Slicer &index)
virtual DComplex getElemDComplex(const TableExprId &id, const Slicer &index)
virtual MArray< Int64 > getSliceInt(const TableExprId &id, const Slicer &)
Non-templated base class for templated Array class.
Definition: ArrayBase.h:72
void checkIndexValues(const TENShPtr &arrayNode)
Check if the index values match the dimensionality and shape of fixed-shaped array.
virtual DComplex getElemDComplex(const TableExprId &id, const Slicer &index)
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
virtual MArray< DComplex > getArrayDComplex(const TableExprId &id)
The default implementation of getArrayDComplex does getArrayDouble and converts the result...
TableExprNodeArrayColumnuShort(const TableColumn &, const Table &)
virtual Bool hasString(const TableExprId &id, const String &value)
virtual MArray< Bool > getSliceBool(const TableExprId &id, const Slicer &)
Get a slice of the array in the given row.
virtual MArray< String > getSliceString(const TableExprId &id, const Slicer &)
Main interface class to a read/write table.
Definition: Table.h:157
virtual MArray< DComplex > getArrayDComplex(const TableExprId &id)
The default implementation of getArrayDComplex does getArrayDouble and converts the result...
virtual Array< Bool > getColumnBool(const Vector< rownr_t > &rownrs)
Get the value of the expression evaluated for the entire column.
const TableColumn & getColumn() const
Get the TableColumn object.
virtual Array< DComplex > getColumnDComplex(const Vector< rownr_t > &rownrs)
virtual Array< Int > getElemColumnInt(const Vector< rownr_t > &rownrs, const Slicer &)
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
uInt array column in table select expression
virtual const IPosition & getShape(const TableExprId &id)
Get the shape of the array in the given row.
TableExprNodeArrayColumnuChar(const TableColumn &, const Table &)
TableExprNodeArrayColumnString(const TableColumn &, const Table &)
virtual Array< Float > getElemColumnFloat(const Vector< rownr_t > &rownrs, const Slicer &)
Short array column in table select expression.
TableExprNodeIndex * inxNode_p
virtual Array< Double > getColumnDouble(const Vector< rownr_t > &rownrs)
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
virtual MArray< Bool > getSliceBool(const TableExprId &id, const Slicer &)
Get a slice of the array in the given row.
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
TableExprNodeArrayColumn * colNode_p
Class to hold multiple table expression nodes.
Definition: ExprNodeSet.h:310
virtual MArray< Int64 > getSliceInt(const TableExprId &id, const Slicer &)
Double array column in table select expression.
virtual MArray< DComplex > getSliceDComplex(const TableExprId &id, const Slicer &)
virtual Array< uChar > getElemColumnuChar(const Vector< rownr_t > &rownrs, const Slicer &)
virtual MArray< Int64 > getSliceInt(const TableExprId &id, const Slicer &)
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
virtual void disableApplySelection()
Do not apply the selection.
virtual MArray< Int64 > getSliceInt(const TableExprId &id, const Slicer &)
TableExprNodeArrayColumnShort(const TableColumn &, const Table &)
TableExprNodeArrayColumnInt64(const TableColumn &, const Table &)
Base class for Array column in table select expression.
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
Bool isConstant() const
Is the expression a constant?
Definition: ExprNodeRep.h:727
virtual MArray< MVTime > getArrayDate(const TableExprId &id)
virtual Array< String > getColumnString(const Vector< rownr_t > &rownrs)
virtual Double getElemDouble(const TableExprId &id, const Slicer &index)
virtual Int64 getElemInt(const TableExprId &id, const Slicer &index)
virtual MArray< Bool > hasArrayString(const TableExprId &id, const MArray< String > &value)
virtual Array< Float > getElemColumnFloat(const Vector< rownr_t > &rownrs, const Slicer &)
virtual Int64 getElemInt(const TableExprId &id, const Slicer &index)
virtual Array< Complex > getElemColumnComplex(const Vector< rownr_t > &rownrs, const Slicer &)
virtual MArray< Int64 > getSliceInt(const TableExprId &id, const Slicer &)
virtual Double getDouble(const TableExprId &id)
virtual Bool isDefined(const TableExprId &id)
Is the value in the given row defined?
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
Base class for arrays in table select expression.
Definition: ExprNodeArray.h:65
virtual Array< String > getElemColumnString(const Vector< rownr_t > &rownrs, const Slicer &)
virtual MArray< MVTime > getSliceDate(const TableExprId &id, const Slicer &)
virtual Array< Short > getElemColumnShort(const Vector< rownr_t > &rownrs, const Slicer &)
virtual Array< Double > getElemColumnDouble(const Vector< rownr_t > &rownrs, const Slicer &)
virtual Array< Int64 > getColumnInt64(const Vector< rownr_t > &rownrs)
NodeDataType
Define the data types of a node.
Definition: ExprNodeRep.h:161
Abstract base class for a node in a table column expression tree.
Definition: ExprNodeRep.h:157
virtual String getString(const TableExprId &id)
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
virtual Array< uShort > getElemColumnuShort(const Vector< rownr_t > &rownrs, const Slicer &)
virtual MArray< Double > getArrayDouble(const TableExprId &id)
The default implementation of getArrayDouble does getArrayInt and converts the result.
virtual MArray< DComplex > getSliceDComplex(const TableExprId &id, const Slicer &)
virtual Array< Complex > getElemColumnComplex(const Vector< rownr_t > &rownrs, const Slicer &)
DComplex array column in table select expression.
virtual Array< Short > getElemColumnShort(const Vector< rownr_t > &rownrs, const Slicer &)
virtual Array< Short > getColumnShort(const Vector< rownr_t > &rownrs)
const TableExprNodeIndex * getIndexNode() const
Get the index node.
virtual MArray< String > getArrayString(const TableExprId &id)
virtual MVTime getElemDate(const TableExprId &id, const Slicer &index)
virtual const IPosition & getShape(const TableExprId &id)
Get the shape of the array in the given row.
virtual MArray< Double > getArrayDouble(const TableExprId &id)
The default implementation of getArrayDouble does getArrayInt and converts the result.
virtual MArray< Bool > hasArrayDComplex(const TableExprId &id, const MArray< DComplex > &value)
virtual MArray< Bool > hasArrayDate(const TableExprId &id, const MArray< MVTime > &value)
virtual Int64 getElemInt(const TableExprId &id, const Slicer &index)
virtual void getColumnNodes(std::vector< TableExprNodeRep * > &cols)
This node represents a table column.
virtual Bool getElemBool(const TableExprId &id, const Slicer &index)
Get a single element from the array in the given row.
TableExprNodeArrayColumnuInt(const TableColumn &, const Table &)
const TableExprNodeArrayColumn * getColumnNode() const
Get the array column node.
TableExprNodeArrayColumnComplex(const TableColumn &, const Table &)
virtual MArray< DComplex > getArrayDComplex(const TableExprId &id)
The default implementation of getArrayDComplex does getArrayDouble and converts the result...
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
IPosition validateIndex(const IPosition &index, const ArrayBase &arr) const
Validate the given index against the array&#39;s shape.
virtual Array< String > getElemColumnString(const Vector< rownr_t > &rownrs, const Slicer &)
virtual MArray< Double > getSliceDouble(const TableExprId &id, const Slicer &)
virtual Array< Int > getElemColumnInt(const Vector< rownr_t > &rownrs, const Slicer &)
TableExprNodeArrayColumnDouble(const TableColumn &, const Table &)
Abstract base class for a node having multiple child nodes.
Definition: ExprNodeRep.h:660
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
virtual Int64 getElemInt(const TableExprId &id, const Slicer &index)
double Double
Definition: aipstype.h:55
OperType
Define the operator types.
Definition: ExprNodeRep.h:187
virtual Double getElemDouble(const TableExprId &id, const Slicer &index)
virtual Array< DComplex > getElemColumnDComplex(const Vector< rownr_t > &rownrs, const Slicer &)
TableExprNodeArray * arrNode_p
Class with static members defining the TaQL style.
Definition: TaQLStyle.h:64
virtual MArray< Bool > hasArrayBool(const TableExprId &id, const MArray< Bool > &value)
Int64 array column in table select expression.
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
virtual Double getElemDouble(const TableExprId &id, const Slicer &index)
virtual Bool getBool(const TableExprId &id)
Get a scalar value for this node in the given row.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Int array column in table select expression.
String array column in table select expression.
virtual MArray< Bool > getArrayBool(const TableExprId &id)
Get an array value for this node in the given row.
virtual DComplex getDComplex(const TableExprId &id)
virtual Int64 getElemInt(const TableExprId &id, const Slicer &index)
virtual Array< Int64 > getElemColumnInt64(const Vector< rownr_t > &rownrs, const Slicer &)
Read/write access to a table column.
Definition: TableColumn.h:98
void fillSlicer(const TableExprId &id)
Fill the slicer for this row.
virtual Bool hasBool(const TableExprId &id, Bool value)
Does a value occur in the set?
virtual Array< Int > getColumnInt(const Vector< rownr_t > &rownrs)
Float array column in table select expression.
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
virtual Bool hasInt(const TableExprId &id, Int64 value)
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
virtual MArray< DComplex > getArrayDComplex(const TableExprId &id)
The default implementation of getArrayDComplex does getArrayDouble and converts the result...
virtual MVTime getDate(const TableExprId &id)
virtual Array< uChar > getColumnuChar(const Vector< rownr_t > &rownrs)
virtual Bool getColumnDataType(DataType &) const
Get the data type of this column.
virtual MArray< Double > getArrayDouble(const TableExprId &id)
The default implementation of getArrayDouble does getArrayInt and converts the result.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:288
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
virtual String getElemString(const TableExprId &id, const Slicer &index)
virtual Bool hasDate(const TableExprId &id, const MVTime &value)
virtual Int64 getElemInt(const TableExprId &id, const Slicer &index)
virtual Array< uChar > getElemColumnuChar(const Vector< rownr_t > &rownrs, const Slicer &)
TableExprNodeArrayColumn(const TableColumn &tablecol, const Table &table)
Create the object for the given column and table.
Array column part in table select expression.
virtual Bool hasDComplex(const TableExprId &id, const DComplex &value)
virtual Array< Complex > getColumnComplex(const Vector< rownr_t > &rownrs)
virtual TENShPtr makeConstantScalar()
Turn a constant array with one element into a scalar.
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
The identification of a TaQL selection subject.
Definition: TableExprId.h:97
IPosition getNodeShape(const TENShPtr &arrayNode) const
Get the shape of the node involved.
TableExprNodeArrayColumnInt(const TableColumn &, const Table &)
virtual Array< uShort > getColumnuShort(const Vector< rownr_t > &rownrs)
TableExprNodeArrayColumnDComplex(const TableColumn &, const Table &)
void convertConstIndex()
Precalculate the constant indices and store them.
TableExprNodeArray(NodeDataType, OperType)
Create the object.
virtual MArray< Double > getSliceDouble(const TableExprId &id, const Slicer &)
virtual Array< Int64 > getElemColumnInt64(const Vector< rownr_t > &rownrs, const Slicer &)
virtual Int64 getInt(const TableExprId &id)
TableExprNodeArrayColumnFloat(const TableColumn &, const Table &)
Table & table()
Get table.
Definition: ExprNodeRep.h:749
virtual Array< uShort > getElemColumnuShort(const Vector< rownr_t > &rownrs, const Slicer &)
static MArray< Int64 > makeArray(const IPosition &shape, Int64 value)
Make an array with the given shape and fill it with the value.
TableExprNodeIndex(const TableExprNodeSet &indices, const TaQLStyle &=TaQLStyle(0))
Constructor.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
virtual MArray< Int64 > getSliceInt(const TableExprId &id, const Slicer &)
virtual MArray< Bool > getArrayBool(const TableExprId &id)
Get an array value for this node in the given row.
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
virtual MArray< Bool > hasArrayInt(const TableExprId &id, const MArray< Int64 > &value)
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
virtual MArray< Bool > hasArrayDouble(const TableExprId &id, const MArray< Double > &value)
virtual Array< Float > getColumnFloat(const Vector< rownr_t > &rownrs)
virtual Array< Bool > getElemColumnBool(const Vector< rownr_t > &rownrs, const Slicer &)
Get a single element for the entire column (used by sort).
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
uShort array column in table select expression
virtual Array< uInt > getElemColumnuInt(const Vector< rownr_t > &rownrs, const Slicer &)
virtual Array< Bool > getElemColumnBool(const Vector< rownr_t > &rownrs, const Slicer &)
Get a single element for the entire column (used by sort).
uChar array column in table select expression
TableExprNodeArrayColumnBool(const TableColumn &, const Table &)
virtual MArray< Int64 > getSliceInt(const TableExprId &id, const Slicer &)
virtual Array< DComplex > getElemColumnDComplex(const Vector< rownr_t > &rownrs, const Slicer &)
virtual MArray< String > getSliceString(const TableExprId &id, const Slicer &)
virtual MArray< Double > getArrayDouble(const TableExprId &id)
The default implementation of getArrayDouble does getArrayInt and converts the result.
Class to handle date/time type conversions and I/O.
Definition: MVTime.h:270
virtual Bool getColumnDataType(DataType &) const
Get the data type of this column (if possible).
virtual Array< uInt > getElemColumnuInt(const Vector< rownr_t > &rownrs, const Slicer &)
The index of an array element in a table select expression.
virtual void show(ostream &os, uInt indent) const
Show the node.
const IPosition & shape() const
Get the fixed shape (same for all rows).
Definition: ExprNodeRep.h:745
TableExprNodeArrayPart(const TENShPtr &arrayNode, const TENShPtr &indexNode)
virtual Bool hasDouble(const TableExprId &id, Double value)
Complex array column in table select expression.
const Slicer & getConstantSlicer() const
Get the Slicer value for a constant index.
Abstract base class for a node having 0, 1, or 2 child nodes.
Definition: ExprNodeRep.h:558
virtual MArray< String > getArrayString(const TableExprId &id)
Bool array column in table select expression.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
virtual ~TableExprNodeIndex()
Destructor.
virtual Array< Double > getElemColumnDouble(const Vector< rownr_t > &rownrs, const Slicer &)
unsigned int uInt
Definition: aipstype.h:51
virtual Bool getElemBool(const TableExprId &id, const Slicer &index)
Get a single element from the array in the given row.
virtual Array< uInt > getColumnuInt(const Vector< rownr_t > &rownrs)