casacore
MSTableIndex.h
Go to the documentation of this file.
1  //# MSTableIndex: index into a MeasurementSet sub-table
2 //# Copyright (C) 2000,2001,2002
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 //#
27 //# $Id$
28 
29 #ifndef MS_MSTABLEINDEX_H
30 #define MS_MSTABLEINDEX_H
31 
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/Arrays/Vector.h>
34 #include <casacore/casa/Containers/Block.h>
35 #include <casacore/casa/Containers/RecordField.h>
36 #include <casacore/tables/Tables/Table.h>
37 #include <casacore/tables/Tables/ScalarColumn.h>
38 #include <casacore/tables/Tables/ColumnsIndex.h>
39 
40 namespace casacore { //# NAMESPACE CASACORE - BEGIN
41 
42 //# Forward declarations
43 class Record;
44 // class ColumnsIndex;
45 class String;
46 
47 // <summary>
48 // </summary>
49 
50 // <use visibility=export>
51 
52 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
53 // </reviewed>
54 
55 // <prerequisite>
56 // <li> MeasurementSet
57 // <li> ColumnsIndex
58 // </prerequisite>
59 //
60 // <etymology>
61 // </etymology>
62 //
63 // <synopsis>
64 // </synopsis>
65 //
66 // <example>
67 // </example>
68 //
69 // <motivation>
70 // </motivation>
71 //
72 // <thrown>
73 // <li>
74 // <li>
75 // </thrown>
76 //
77 // <todo>
78 // <li> Make the searches smarter - for TIME sorted tables, if the time to search is
79 // past the last seach, there's no need to search any earlier times.
80 // <li> Need to handle the INTERVAL=-1 case fully
81 // </todo>
83 {
84 public:
85  // no index attached, use the attach function or assignment operator to change that
87 
88  // construct one using the indicated subtable which is part of the parent MS
89  // using the indicated index columns. All index columns must be scalar integer
90  // columns. TIME and INTERVAL will be used when present. A compare function
91  // can be provided to over-ride literal matching of column values.
92  MSTableIndex(const Table &subTable, const Vector<String> &indexCols,
93  ColumnsIndex::Compare *compareFunction = 0);
94 
95  // construct one from another
96  MSTableIndex(const MSTableIndex &other);
97 
98  virtual ~MSTableIndex();
99 
100  // assignment operator, refernce semantics
102 
103  // attach this to a subtable using indexCols
104  void attach(const Table &subTable, const Vector<String> &indexCols,
105  ColumnsIndex::Compare *compareFunction = 0);
106 
107  // Call this when an index in an existing row has changed. There is no need to
108  // call this when new rows are added to the table
109  virtual void setChanged();
110 
111  // access the record of index (integer) keys
112  virtual Record &accessKey() {return *key_p;}
113 
114  // access the TIME to use in the search (seconds)
115  virtual Double &time() {return time_p;}
116 
117  // access the INTERVAL to use in the search (seconds), must be >= 0
118  virtual Double &interval() {return interval_p;}
119 
120  // get all of the rows in the subTable which have data during the indicated time and
121  // interval values. For now, this code will miss the case where the subtable has
122  // interval = -1 and the start time is outside of the time range implied by the time
123  // and interval. If the table has changed and the time is >
125 
126  // get the row number which falls in the interval and has the time nearest to the
127  // center of the interval (time()). This also has the same problem as the previous function.
128  virtual Int64 getNearestRow(Bool &found);
129 
130  // is this attached to a null table
131  virtual Bool isNull() { return tab_p.isNull();}
132 
133  // return the subtable being indexed
134  virtual Table &table() {return tab_p;}
135 private:
136  // the subtable
138 
143 
144  // Internal keys - set by user
148 
149  // last known integer key values
151  // last known time and interval
153 
154  // last search result - matching integer keys
156 
157  // last nearest
160 
161  // last known sub-table size
163 
165 
169 
170  void clear();
171  void makeKeys();
173  void getInternals();
174  void nearestTime();
175 };
176 
177 
178 } //# NAMESPACE CASACORE - END
179 
180 #endif
181 
simple 1-D array
Definition: Block.h:200
Int Compare(const Block< void * > &fieldPtrs, const Block< void * > &dataPtrs, const Block< Int > &dataTypes, rownr_t index)
Define the signature of a comparison function.
Definition: ColumnsIndex.h:239
MSTableIndex(const Table &subTable, const Vector< String > &indexCols, ColumnsIndex::Compare *compareFunction=0)
construct one using the indicated subtable which is part of the parent MS using the indicated index c...
ColumnsIndex * index_p
Definition: MSTableIndex.h:166
virtual void setChanged()
Call this when an index in an existing row has changed.
ScalarColumn< Double > timeColumn_p
Definition: MSTableIndex.h:139
Int64 lastNearest_p
last nearest
Definition: MSTableIndex.h:158
Record * key_p
Internal keys - set by user.
Definition: MSTableIndex.h:145
Vector< Int > lastKeys_p
last known integer key values
Definition: MSTableIndex.h:150
virtual Record & accessKey()
access the record of index (integer) keys
Definition: MSTableIndex.h:112
virtual Double & time()
access the TIME to use in the search (seconds)
Definition: MSTableIndex.h:115
Block< RecordFieldPtr< Int > > intKeys_p
Definition: MSTableIndex.h:146
RowNumbers lastSearch_p
last search result - matching integer keys
Definition: MSTableIndex.h:155
Vector< Double > intervalVec_p
Definition: MSTableIndex.h:140
Vector< Double > timeVec_p
Definition: MSTableIndex.h:140
ScalarColumn< Double > intervalColumn_p
Definition: MSTableIndex.h:139
MSTableIndex()
no index attached, use the attach function or assignment operator to change that
const Double * intervalVals_p
Definition: MSTableIndex.h:141
Table tab_p
the subtable
Definition: MSTableIndex.h:137
Double lastTime_p
last known time and interval
Definition: MSTableIndex.h:152
virtual Bool isNull()
is this attached to a null table
Definition: MSTableIndex.h:131
virtual Int64 getNearestRow(Bool &found)
get the row number which falls in the interval and has the time nearest to the center of the interval...
MSTableIndex & operator=(const MSTableIndex &other)
assignment operator, refernce semantics
virtual RowNumbers getRowNumbers()
get all of the rows in the subTable which have data during the indicated time and interval values.
MSTableIndex(const MSTableIndex &other)
construct one from another
rownr_t nrows_p
last known sub-table size
Definition: MSTableIndex.h:162
const Double * timeVals_p
Definition: MSTableIndex.h:141
virtual Double & interval()
access the INTERVAL to use in the search (seconds), must be >= 0
Definition: MSTableIndex.h:118
virtual Table & table()
return the subtable being indexed
Definition: MSTableIndex.h:134
Block< RecordFieldPtr< Int > > indexKeys_p
Definition: MSTableIndex.h:167
void attach(const Table &subTable, const Vector< String > &indexCols, ColumnsIndex::Compare *compareFunction=0)
attach this to a subtable using indexCols
Bool isNull() const
Test if the object is null, i.e.
Definition: Table.h:477
this file contains all the compiler specific defines
Definition: mainpage.dox:28
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
double Double
Definition: aipstype.h:55
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46