Gaia
gaia2::BaseQueryOptimizer< SearchPointType, DataSetType > Class Template Reference

The QueryOptimizer class tries to optimize a query by reducing the SearchSpace on which it is supposed to operate, mostly by the means of the associated filter. More...

#include <queryoptimizer.h>

Public Types

typedef BaseSearchSpacePool< SearchPointType, DataSetType > SearchSpacePoolType
 
typedef BaseSearchSpace< SearchPointType, DataSetType > SearchSpaceType
 

Public Member Functions

 BaseQueryOptimizer (SearchSpacePoolType *spool)
 
SearchSpaceTypeoptimize (Filter *filter)
 Ownership of the SearchSpace is yielded to the caller of the function. More...
 

Protected Member Functions

SearchSpaceTypeoptimize (parser::Predicate *pred)
 

Static Protected Member Functions

static parser::PredLabelIsInfindPointID (parser::Predicate *pred)
 
template<typename PredicateType >
static PredicateType * findPredicate (parser::Predicate *pred)
 
static bool swapPredicate (Filter *filter, parser::Predicate *swapOut, parser::Predicate *swapIn)
 Swaps predicate swapOut inside of filter for predicate swapIn. More...
 
static bool swapPredicate (parser::Predicate *parent, parser::Predicate *swapOut, parser::Predicate *swapIn)
 Swaps predicate swapOut (starting with given parent predicate) for predicate swapIn. More...
 
static void deletePredicate (Filter *filter, parser::Predicate *pred)
 Deletes given predicate inside filter (replaces it with the always true predicate).
 
static void reduceFilter (Filter *filter)
 Tries to apply simplification on the filter, such as replacing "X and True" by "X", etc... More...
 
static parser::PredicatereducePredicate (parser::Predicate *pred)
 Tries to apply simplification on the predicate, such as replacing "X and True" by "X", etc... More...
 

Protected Attributes

SearchSpacePoolType_spool
 

Detailed Description

template<typename SearchPointType, typename DataSetType>
class gaia2::BaseQueryOptimizer< SearchPointType, DataSetType >

The QueryOptimizer class tries to optimize a query by reducing the SearchSpace on which it is supposed to operate, mostly by the means of the associated filter.

It should tap into a SearchSpace pool and return the final SearchSpace, as well as the possibly modified Filter (contained inside the SearchSpace), on which to perform the query.

Member Function Documentation

template<typename SearchPointType , typename DataSetType >
BaseSearchSpace< SearchPointType, DataSetType > * gaia2::BaseQueryOptimizer< SearchPointType, DataSetType >::optimize ( Filter filter)

Ownership of the SearchSpace is yielded to the caller of the function.

Ownership of the filter is given to this function (either it will be destroyed and replaced by an optimized filter inside the SearchSpace, or it will put directly into the SearchSpace. In any case, you shouldn't try to delete it after having called this function).

References gaia2::isAlwaysFalse(), gaia2::isAlwaysTrue(), gaia2::Filter::parse(), gaia2::BaseSearchSpace< SearchPointType, DataSetType >::setIntersection(), and gaia2::BaseSearchSpace< SearchPointType, DataSetType >::setUnion().

Referenced by gaia2::BaseView< DataSetType, PointType, SearchPointType, DistanceType >::getSearchSpace().

template<typename SearchPointType , typename DataSetType >
void gaia2::BaseQueryOptimizer< SearchPointType, DataSetType >::reduceFilter ( Filter filter)
staticprotected

Tries to apply simplification on the filter, such as replacing "X and True" by "X", etc...

without changing the return value of it. The filter is modified in-place.

template<typename SearchPointType , typename DataSetType >
parser::Predicate * gaia2::BaseQueryOptimizer< SearchPointType, DataSetType >::reducePredicate ( parser::Predicate pred)
staticprotected

Tries to apply simplification on the predicate, such as replacing "X and True" by "X", etc...

without changing the return value of it.

Returns
the modified predicate if any simplification could be made, null pointer otherwise.
template<typename SearchPointType , typename DataSetType >
bool gaia2::BaseQueryOptimizer< SearchPointType, DataSetType >::swapPredicate ( Filter filter,
parser::Predicate swapOut,
parser::Predicate swapIn 
)
staticprotected

Swaps predicate swapOut inside of filter for predicate swapIn.

Returns
true if it succeeded, false if we couldn't find swapOut inside of filter.
template<typename SearchPointType , typename DataSetType >
bool gaia2::BaseQueryOptimizer< SearchPointType, DataSetType >::swapPredicate ( parser::Predicate parent,
parser::Predicate swapOut,
parser::Predicate swapIn 
)
staticprotected

Swaps predicate swapOut (starting with given parent predicate) for predicate swapIn.

Returns
true if it succeeded, false if we couldn't find swapOut.

The documentation for this class was generated from the following files: