Loading...
Searching...
No Matches
MSTableIndex.h
Go to the documentation of this file.
//# MSTableIndex: index into a MeasurementSet sub-table
//# Copyright (C) 2000,2001,2002
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: casa-feedback@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
#ifndef MS_MSTABLEINDEX_H
#define MS_MSTABLEINDEX_H
#include <casacore/casa/aips.h>
#include <casacore/casa/Arrays/Vector.h>
#include <casacore/casa/Containers/Block.h>
#include <casacore/casa/Containers/RecordField.h>
#include <casacore/tables/Tables/Table.h>
#include <casacore/tables/Tables/ScalarColumn.h>
#include <casacore/tables/Tables/ColumnsIndex.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
//# Forward declarations
class Record;
// class ColumnsIndex;
class String;
// <summary>
// </summary>
// <use visibility=export>
// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
// </reviewed>
// <prerequisite>
// <li> MeasurementSet
// <li> ColumnsIndex
// </prerequisite>
//
// <etymology>
// </etymology>
//
// <synopsis>
// </synopsis>
//
// <example>
// </example>
//
// <motivation>
// </motivation>
//
// <thrown>
// <li>
// <li>
// </thrown>
//
// <todo>
// <li> Make the searches smarter - for TIME sorted tables, if the time to search is
// past the last seach, there's no need to search any earlier times.
// <li> Need to handle the INTERVAL=-1 case fully
// </todo>
class MSTableIndex
{
public:
// no index attached, use the attach function or assignment operator to change that
MSTableIndex();
// construct one using the indicated subtable which is part of the parent MS
// using the indicated index columns. All index columns must be scalar integer
// columns. TIME and INTERVAL will be used when present. A compare function
// can be provided to over-ride literal matching of column values.
MSTableIndex(const Table &subTable, const Vector<String> &indexCols,
ColumnsIndex::Compare *compareFunction = 0);
// construct one from another
MSTableIndex(const MSTableIndex &other);
virtual ~MSTableIndex();
// assignment operator, refernce semantics
MSTableIndex &operator=(const MSTableIndex &other);
// attach this to a subtable using indexCols
void attach(const Table &subTable, const Vector<String> &indexCols,
ColumnsIndex::Compare *compareFunction = 0);
// Call this when an index in an existing row has changed. There is no need to
// call this when new rows are added to the table
virtual void setChanged();
// access the record of index (integer) keys
virtual Record &accessKey() {return *key_p;}
// access the TIME to use in the search (seconds)
virtual Double &time() {return time_p;}
// access the INTERVAL to use in the search (seconds), must be >= 0
virtual Double &interval() {return interval_p;}
// get all of the rows in the subTable which have data during the indicated time and
// interval values. For now, this code will miss the case where the subtable has
// interval = -1 and the start time is outside of the time range implied by the time
// and interval. If the table has changed and the time is >
virtual RowNumbers getRowNumbers();
// get the row number which falls in the interval and has the time nearest to the
// center of the interval (time()). This also has the same problem as the previous function.
virtual Int64 getNearestRow(Bool &found);
// is this attached to a null table
virtual Bool isNull() { return tab_p.isNull();}
// return the subtable being indexed
virtual Table &table() {return tab_p;}
private:
// the subtable
Table tab_p;
ScalarColumn<Double> timeColumn_p, intervalColumn_p;
Vector<Double> timeVec_p, intervalVec_p;
const Double *timeVals_p, *intervalVals_p;
Bool deleteItTime_p, deleteItInterval_p;
// Internal keys - set by user
Record *key_p;
Block<RecordFieldPtr<Int> > intKeys_p;
Double time_p, interval_p;
// last known integer key values
Vector<Int> lastKeys_p;
// last known time and interval
Double lastTime_p, lastInterval_p;
// last search result - matching integer keys
RowNumbers lastSearch_p;
// last nearest
Int64 lastNearest_p;
Bool nearestFound_p, nearestReady_p;
// last known sub-table size
rownr_t nrows_p;
Bool hasChanged_p;
ColumnsIndex *index_p;
Block<RecordFieldPtr<Int> > indexKeys_p;
Bool hasTime_p, hasInterval_p;
void clear();
void makeKeys();
Bool keysChanged();
void getInternals();
void nearestTime();
};
} //# NAMESPACE CASACORE - END
#endif
casacore::Block
Definition Block.h:140
casacore::ColumnsIndex
Definition ColumnsIndex.h:226
casacore::ColumnsIndex::Compare
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:237
casacore::MSTableIndex::makeKeys
void makeKeys()
casacore::MSTableIndex::interval
virtual Double & interval()
access the INTERVAL to use in the search (seconds), must be >= 0
Definition MSTableIndex.h:115
casacore::MSTableIndex::MSTableIndex
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...
casacore::MSTableIndex::nearestFound_p
Bool nearestFound_p
Definition MSTableIndex.h:156
casacore::MSTableIndex::nearestTime
void nearestTime()
casacore::MSTableIndex::getInternals
void getInternals()
casacore::MSTableIndex::time
virtual Double & time()
access the TIME to use in the search (seconds)
Definition MSTableIndex.h:112
casacore::MSTableIndex::index_p
ColumnsIndex * index_p
Definition MSTableIndex.h:163
casacore::MSTableIndex::setChanged
virtual void setChanged()
Call this when an index in an existing row has changed.
casacore::MSTableIndex::interval_p
Double interval_p
Definition MSTableIndex.h:144
casacore::MSTableIndex::time_p
Double time_p
Definition MSTableIndex.h:144
casacore::MSTableIndex::hasTime_p
Bool hasTime_p
Definition MSTableIndex.h:165
casacore::MSTableIndex::timeColumn_p
ScalarColumn< Double > timeColumn_p
Definition MSTableIndex.h:136
casacore::MSTableIndex::lastNearest_p
Int64 lastNearest_p
last nearest
Definition MSTableIndex.h:155
casacore::MSTableIndex::key_p
Record * key_p
Internal keys - set by user.
Definition MSTableIndex.h:142
casacore::MSTableIndex::lastKeys_p
Vector< Int > lastKeys_p
last known integer key values
Definition MSTableIndex.h:147
casacore::MSTableIndex::operator=
MSTableIndex & operator=(const MSTableIndex &other)
assignment operator, refernce semantics
casacore::MSTableIndex::keysChanged
Bool keysChanged()
casacore::MSTableIndex::intKeys_p
Block< RecordFieldPtr< Int > > intKeys_p
Definition MSTableIndex.h:143
casacore::MSTableIndex::lastSearch_p
RowNumbers lastSearch_p
last search result - matching integer keys
Definition MSTableIndex.h:152
casacore::MSTableIndex::lastInterval_p
Double lastInterval_p
Definition MSTableIndex.h:149
casacore::MSTableIndex::intervalVec_p
Vector< Double > intervalVec_p
Definition MSTableIndex.h:137
casacore::MSTableIndex::timeVec_p
Vector< Double > timeVec_p
Definition MSTableIndex.h:137
casacore::MSTableIndex::intervalColumn_p
ScalarColumn< Double > intervalColumn_p
Definition MSTableIndex.h:136
casacore::MSTableIndex::table
virtual Table & table()
return the subtable being indexed
Definition MSTableIndex.h:131
casacore::MSTableIndex::MSTableIndex
MSTableIndex()
no index attached, use the attach function or assignment operator to change that
casacore::MSTableIndex::intervalVals_p
const Double * intervalVals_p
Definition MSTableIndex.h:138
casacore::MSTableIndex::nearestReady_p
Bool nearestReady_p
Definition MSTableIndex.h:156
casacore::MSTableIndex::tab_p
Table tab_p
the subtable
Definition MSTableIndex.h:134
casacore::MSTableIndex::lastTime_p
Double lastTime_p
last known time and interval
Definition MSTableIndex.h:149
casacore::MSTableIndex::isNull
virtual Bool isNull()
is this attached to a null table
Definition MSTableIndex.h:128
casacore::MSTableIndex::hasChanged_p
Bool hasChanged_p
Definition MSTableIndex.h:161
casacore::MSTableIndex::getNearestRow
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...
casacore::MSTableIndex::getRowNumbers
virtual RowNumbers getRowNumbers()
get all of the rows in the subTable which have data during the indicated time and interval values.
casacore::MSTableIndex::MSTableIndex
MSTableIndex(const MSTableIndex &other)
construct one from another
casacore::MSTableIndex::nrows_p
rownr_t nrows_p
last known sub-table size
Definition MSTableIndex.h:159
casacore::MSTableIndex::accessKey
virtual Record & accessKey()
access the record of index (integer) keys
Definition MSTableIndex.h:109
casacore::MSTableIndex::clear
void clear()
casacore::MSTableIndex::timeVals_p
const Double * timeVals_p
Definition MSTableIndex.h:138
casacore::MSTableIndex::deleteItInterval_p
Bool deleteItInterval_p
Definition MSTableIndex.h:139
casacore::MSTableIndex::~MSTableIndex
virtual ~MSTableIndex()
casacore::MSTableIndex::deleteItTime_p
Bool deleteItTime_p
Definition MSTableIndex.h:139
casacore::MSTableIndex::indexKeys_p
Block< RecordFieldPtr< Int > > indexKeys_p
Definition MSTableIndex.h:164
casacore::MSTableIndex::attach
void attach(const Table &subTable, const Vector< String > &indexCols, ColumnsIndex::Compare *compareFunction=0)
attach this to a subtable using indexCols
casacore::MSTableIndex::hasInterval_p
Bool hasInterval_p
Definition MSTableIndex.h:165
casacore::RowNumbers
Definition RowNumbers.h:36
casacore::ScalarColumn
Definition ScalarColumn.h:83
casacore::String
String: the storage and methods of handling collections of characters.
Definition String.h:223
casacore::Table
Definition Table.h:157
casacore::Vector
Definition Vector.h:82
casacore::Record
Record()
casacore
this file contains all the compiler specific defines
Definition mainpage.dox:28
casacore::Int64
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
casacore::Double
double Double
Definition aipstype.h:53
casacore::rownr_t
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44