casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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
86  MSTableIndex();
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
101  MSTableIndex &operator=(const MSTableIndex &other);
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 >
124  virtual RowNumbers getRowNumbers();
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();
172  Bool keysChanged();
173  void getInternals();
174  void nearestTime();
175 };
176 
177 
178 } //# NAMESPACE CASACORE - END
179 
180 #endif
181 
Index to one or more columns in a table.
Definition: ColumnsIndex.h:227
A 1-D Specialization of the Array class.
Definition: ArrayFwd.h:9
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
Vector< Double > timeVec_p
Definition: MSTableIndex.h:140
Main interface class to a read/write table.
Definition: Table.h:157
virtual RowNumbers getRowNumbers()
get all of the rows in the subTable which have data during the indicated time and interval values...
rownr_t nrows_p
last known sub-table size
Definition: MSTableIndex.h:162
Vector< Int > lastKeys_p
last known integer key values
Definition: MSTableIndex.h:150
void attach(const Table &subTable, const Vector< String > &indexCols, ColumnsIndex::Compare *compareFunction=0)
attach this to a subtable using indexCols
Int64 lastNearest_p
last nearest
Definition: MSTableIndex.h:158
Record * key_p
Internal keys - set by user.
Definition: MSTableIndex.h:145
virtual Double & time()
access the TIME to use in the search (seconds)
Definition: MSTableIndex.h:115
virtual void setChanged()
Call this when an index in an existing row has changed.
ScalarColumn< Double > timeColumn_p
Definition: MSTableIndex.h:139
double Double
Definition: aipstype.h:55
RowNumbers lastSearch_p
last search result - matching integer keys
Definition: MSTableIndex.h:155
Block< RecordFieldPtr< Int > > indexKeys_p
Definition: MSTableIndex.h:167
Block< RecordFieldPtr< Int > > intKeys_p
Definition: MSTableIndex.h:146
ColumnsIndex * index_p
Definition: MSTableIndex.h:166
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
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...
simple 1-D array
Definition: Allocator.h:210
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
Double lastTime_p
last known time and interval
Definition: MSTableIndex.h:152
Bool isNull() const
Test if the object is null, i.e.
Definition: Table.h:477
ScalarColumn< Double > intervalColumn_p
Definition: MSTableIndex.h:139
Table tab_p
the subtable
Definition: MSTableIndex.h:137
virtual Double & interval()
access the INTERVAL to use in the search (seconds), must be &gt;= 0
Definition: MSTableIndex.h:118
const Double * intervalVals_p
Definition: MSTableIndex.h:141
virtual Table & table()
return the subtable being indexed
Definition: MSTableIndex.h:134
virtual Record & accessKey()
access the record of index (integer) keys
Definition: MSTableIndex.h:112
MSTableIndex()
no index attached, use the attach function or assignment operator to change that
MSTableIndex & operator=(const MSTableIndex &other)
assignment operator, refernce semantics
const Double * timeVals_p
Definition: MSTableIndex.h:141
Vector< Double > intervalVec_p
Definition: MSTableIndex.h:140
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