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