|
Gaia
|
A SearchSpace is a structure dedicated to the task of storing pointers to Point with an associated distance and is the structure on which the nearest-neighbours queries are performed. More...
#include <searchspace.h>
Public Member Functions | |
| BaseSearchSpace (const Filter *filter=0, bool ownsFilter=false) | |
| BaseSearchSpace (const BaseSearchSpace< SearchPointType, DataSetType > &other) | |
| Copy constructor. More... | |
| void | copyPointsFrom (const BaseSearchSpace< SearchPointType, DataSetType > &other) |
| Copy all the points from the other SearchSpace into this one. More... | |
| int | size () const |
| Returns the total number of points contained in this SearchSpace. | |
| int | unfilteredSize () const |
| Returns the size of this SearchSpace, before filtering the points. More... | |
| void | clear () |
| Clears the whole SearchSpace. | |
| SearchResults | get (int n, int offset=0) |
| Returns the list of search results, which are pairs of (pointName, distance). More... | |
| void | limit (int n) |
| This method limits the number of results contained in this SearchSpace. More... | |
| void | thresholdLimit (float maxDist) |
| This method limits the bymber of results contained in this SearchSpace. More... | |
| const Filter * | filter () |
| void | setFilter (const Filter *filter, bool ownsFilter=false) |
| void | invalidate () |
| Mark this SearchSpace as neither sorted nor filtered. | |
| void | filterAll () |
| Filters all points so that the remaining points at the end all comply to the Filter. | |
| void | pointerSort () |
| Sorts the SearchPoints contained into this SearchSpace by order of their pointer address. | |
| void | addPoints (const DataSetType *dataset, const QList< QString > &ids) |
| Add the points from the dataset with the given IDs to this SearchSpace. | |
| void | removePoints (const QList< QString > &ids) |
| Remove the points with the given IDs from this SearchSpace. | |
| void | setIntersection (const BaseSearchSpace< SearchPointType, DataSetType > *other) |
| This computes the intersection of this SearchSpace with the other one. More... | |
| void | setUnion (const BaseSearchSpace< SearchPointType, DataSetType > *other) |
| This computes the union of this SearchSpace with the other one. More... | |
| void | setDifference (const BaseSearchSpace< SearchPointType, DataSetType > *other) |
| This computes the difference of this SearchSpace and the other one (ie: this - other). More... | |
| QString | pointName (const SearchPointType &p) const |
| const Point * | refPoint (const SearchPointType &p) const |
| bool | validPoint (const SearchPointType &p) const |
| template<typename PointType , typename DistanceType > | |
| void | computeDistance (const PointType &query, const DistanceType *dist) |
| Compute the distance from the given query point to all those contained in this SearchSpace, and presort a few points to have near instant access to them. | |
| void | setDataSet (const DataSetType *dataset) |
| const DataSetType * | dataSet () const |
| void | filterAndSort (int n=1000) |
| Filters the points in this SearchSpace using the given Filter and sort them by increasing distance. More... | |
| void | cleanSearchSpace () |
Static Public Member Functions | |
| static BaseSearchSpace< SearchPointType, DataSetType > * | createFromDataSet (const DataSetType *dataset) |
| static BaseSearchSpace< SearchPointType, DataSetType > * | createFromPoints (const DataSetType *dataset, const QList< QString > &pointNames) |
Protected Member Functions | |
| int | validUpTo () const |
| Index in the search space up to which points are actually filtered and sorted. | |
| void | sortAll () |
Protected Attributes | |
| const DataSetType * | _dataset |
| const Filter * | _filter |
| bool | _ownsFilter |
| int | _sortedUpTo |
| int | _filteredUpTo |
Friends | |
| template<typename SearchPointType2 , typename DataSetType2 > | |
| class | BaseQueryOptimizer |
A SearchSpace is a structure dedicated to the task of storing pointers to Point with an associated distance and is the structure on which the nearest-neighbours queries are performed.
It is also what is returned by the view as a search result, and allows to get any number of points with a given offset if desired.
Some pre-indexed SearchSpace instances will reside in a SearchSpace pool which is owned by a specific View. It acts as an index, and the pool has a way to either add more of those, or return a given subset that satisfies certain conditions. As such, when a View needs to be revalidated, it will also revalidate all linked SearchSpace.
WARNING: As we make copies of SearchSpace to perform queries, it is perfectly safe to make multithreaded queries. However, it is NOT safe to add or remove points while there is still a query being processed, or a SearchSpace returned from a previous query still in use (ie: View instances revalidate themselves automatically when a DataSet changes, but SearchSpace ones don't)
| BaseSearchSpace::BaseSearchSpace | ( | const BaseSearchSpace< SearchPointType, DataSetType > & | other | ) |
Copy constructor.
WARNING: this does not copy the filter nor any other member variables, only the points contained in the SearchSpace.
| void BaseSearchSpace::copyPointsFrom | ( | const BaseSearchSpace< SearchPointType, DataSetType > & | other | ) |
Copy all the points from the other SearchSpace into this one.
WARNING: this does not copy the filter nor any other member variables, only the points contained in the SearchSpace.
Referenced by gaia2::BaseView< DataSetType, PointType, SearchPointType, DistanceType >::getSearchSpace().
| void BaseSearchSpace::filterAndSort | ( | int | n = 1000 | ) |
Filters the points in this SearchSpace using the given Filter and sort them by increasing distance.
| n | only filter and sort the n points with the smallest distance, this has the advantage of being much faster than sorting all the points. If n <= 0, then all the points will be sorted. |
Referenced by gaia2::BaseView< DataSetType, PointType, SearchPointType, DistanceType >::nnSearch().
| SearchResults BaseSearchSpace::get | ( | int | n, |
| int | offset = 0 |
||
| ) |
Returns the list of search results, which are pairs of (pointName, distance).
| n | the number of desired results |
| offset | the start offset |
| void BaseSearchSpace::limit | ( | int | n | ) |
This method limits the number of results contained in this SearchSpace.
If there were fewer points before than the given number, the SearchSpace is left untouched, otherwise it will have a maximum of n points after the call.
| void BaseSearchSpace::setDifference | ( | const BaseSearchSpace< SearchPointType, DataSetType > * | other | ) |
This computes the difference of this SearchSpace and the other one (ie: this - other).
NB: This function assumes that both SearchSpaces have their points ordered by pointer address.
| void BaseSearchSpace::setIntersection | ( | const BaseSearchSpace< SearchPointType, DataSetType > * | other | ) |
This computes the intersection of this SearchSpace with the other one.
NB: This function assumes that both SearchSpaces have their points ordered by pointer address.
Referenced by gaia2::BaseQueryOptimizer< SearchPointType, DataSetType >::optimize().
| void BaseSearchSpace::setUnion | ( | const BaseSearchSpace< SearchPointType, DataSetType > * | other | ) |
This computes the union of this SearchSpace with the other one.
NB: This function assumes that both SearchSpaces have their points ordered by pointer address.
Referenced by gaia2::BaseQueryOptimizer< SearchPointType, DataSetType >::optimize().
| void BaseSearchSpace::thresholdLimit | ( | float | maxDist | ) |
This method limits the bymber of results contained in this SearchSpace.
All the results which have a distance higher than the specified maxDist will be discarded from this SearchSpace.
| int BaseSearchSpace::unfilteredSize | ( | ) | const |
Returns the size of this SearchSpace, before filtering the points.
WARNING: use with care, this value might not be consistent with what you expect.