20 #ifndef GAIA_SEARCHSPACE_H 21 #define GAIA_SEARCHSPACE_H 25 #include "frozendataset.h" 26 #include "parser/filter.h" 32 typedef QPair<QString, Real> Result;
33 typedef QList<Result> SearchResults;
35 yaml::Node toYaml(
const SearchResults& results);
41 #define Vector std::vector 53 bool operator<(
const SearchPoint& x)
const {
return dist < x.dist; }
90 template <
typename SearchPo
intType,
typename DataSetType>
120 int unfilteredSize()
const;
132 SearchResults
get(
int n,
int offset = 0);
146 void thresholdLimit(
float maxDist);
148 const Filter* filter() {
return _filter; }
149 void setFilter(
const Filter* filter,
bool ownsFilter =
false);
171 void addPoints(
const DataSetType* dataset,
const QList<QString>& ids);
176 void removePoints(
const QList<QString>& ids);
201 QString pointName(
const SearchPointType& p)
const;
202 const Point* refPoint(
const SearchPointType& p)
const;
204 bool validPoint(
const SearchPointType& p)
const {
205 return _filter->isTrue(refPoint(p));
211 const QList<QString>& pointNames);
218 template <
typename Po
intType,
typename DistanceType>
219 void computeDistance(
const PointType& query,
const DistanceType* dist);
225 void setDataSet(
const DataSetType* dataset) { _dataset = dataset; }
226 const DataSetType* dataSet()
const {
return _dataset; }
235 void filterAndSort(
int n = 1000);
237 void cleanSearchSpace();
240 const DataSetType* _dataset;
243 int _sortedUpTo, _filteredUpTo;
246 template <
typename SearchPo
intType2,
typename DataSetType2>
253 int validUpTo()
const {
return qMin(_sortedUpTo, _filteredUpTo); }
270 inline QString SearchSpace::pointName(
const SearchPoint& p)
const {
279 return _dataset->referenceDataSet()->at(p.idx);
284 return _dataset->pointName(p.idx);
290 template <
typename SearchPo
intType,
typename DataSetType>
305 template <
typename SearchPo
intType,
typename DataSetType>
317 SearchResults
get(
int n,
int offset = 0);
319 int size()
const {
return _d->sspace->size(); }
338 void addPoints(
const DataSetType* dataset,
const QList<QString>& ids);
339 void removePoints(
const QList<QString>& ids);
345 QExplicitlySharedDataPointer<SearchSpaceWrapper<SearchPointType, DataSetType> > _d;
351 #include "searchspace_impl.h" 364 #endif // GAIA_SEARCHSPACE_H Definition: frozendistance.h:33
Definition: searchspace.h:57
The QueryOptimizer class tries to optimize a query by reducing the SearchSpace on which it is suppose...
Definition: parsertypes.h:30
void invalidate()
Mark this SearchSpace as neither sorted nor filtered.
Definition: searchspace.h:154
The Filter class allows to check whether a predicate is true for a given Point.
Definition: filter.h:73
Main Gaia namespace, which contains all the library functions.
Definition: addfield.cpp:22
QString name() const
Returns the point name, which also acts as its unique identifier.
Definition: point.h:115
Definition: distancefunction.h:37
Definition: searchspace.h:291
A SearchSpace is a structure dedicated to the task of storing pointers to Point with an associated di...
Definition: searchspace.h:91
Definition: searchspace.h:44
This class serves as a ref-counted wrapper for a SearchSpace, which is much more convenient to deal w...
Definition: searchspace.h:306
int validUpTo() const
Index in the search space up to which points are actually filtered and sorted.
Definition: searchspace.h:253
BaseResultSet thresholdLimit(float maxDist)
This method limits the number of results contained in this ResultSet.
Definition: searchspace.h:335
BaseResultSet limit(int n)
This function limits the number of results contained in this ResultSet.
Definition: searchspace.h:327