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{
81public:
82 // no index attached, use the attach function or assignment operator to change that
84
85 // construct one using the indicated subtable which is part of the parent MS
86 // using the indicated index columns. All index columns must be scalar integer
87 // columns. TIME and INTERVAL will be used when present. A compare function
88 // can be provided to over-ride literal matching of column values.
89 MSTableIndex(const Table &subTable, const Vector<String> &indexCols,
90 ColumnsIndex::Compare *compareFunction = 0);
91
92 // construct one from another
94
95 virtual ~MSTableIndex();
96
97 // assignment operator, refernce semantics
99
100 // attach this to a subtable using indexCols
101 void attach(const Table &subTable, const Vector<String> &indexCols,
102 ColumnsIndex::Compare *compareFunction = 0);
103
104 // Call this when an index in an existing row has changed. There is no need to
105 // call this when new rows are added to the table
106 virtual void setChanged();
107
108 // access the record of index (integer) keys
109 virtual Record &accessKey() {return *key_p;}
110
111 // access the TIME to use in the search (seconds)
112 virtual Double &time() {return time_p;}
113
114 // access the INTERVAL to use in the search (seconds), must be >= 0
115 virtual Double &interval() {return interval_p;}
116
117 // get all of the rows in the subTable which have data during the indicated time and
118 // interval values. For now, this code will miss the case where the subtable has
119 // interval = -1 and the start time is outside of the time range implied by the time
120 // and interval. If the table has changed and the time is >
122
123 // get the row number which falls in the interval and has the time nearest to the
124 // center of the interval (time()). This also has the same problem as the previous function.
125 virtual Int64 getNearestRow(Bool &found);
126
127 // is this attached to a null table
128 virtual Bool isNull() { return tab_p.isNull();}
129
130 // return the subtable being indexed
131 virtual Table &table() {return tab_p;}
132private:
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
175} //# NAMESPACE CASACORE - END
176
177#endif
178
simple 1-D array
Definition Block.h:198
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
Bool isNull() const
Test if the object is null, i.e.
Definition Table.h:480
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: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