org.axiondb.engine.commands
Class AxionQueryOptimizer

java.lang.Object
  extended by org.axiondb.engine.commands.AxionQueryOptimizer

public class AxionQueryOptimizer
extends Object

Axion Query Optimizer


Constructor Summary
AxionQueryOptimizer()
           
 
Method Summary
static Selectable createOneRootFunction(Set conditions)
          Compose back the decomposed condition into a single condition tree.
static Set[] decomposeWhereConditionNodes(Set flattenConditionSet, boolean isAllInnerJoin)
          Decomose a where/join condition into three part: (1) column-column comparision function (2) column-literal conditions.
static Set deriveTableFilter(Set flattenConditions, boolean isAllInnerJoin)
          Decomposes the given WhereNodeinto a Setof nodes that were originally joined by ANDs, and adds to this set predicates that are implied by the original tree (for example, given A = 1 and A = B, we can infer B = 1.)
static Function findColumnLiteralEqualFunction(TableIdentifier tid, Table table, Set conditions, boolean mustCheckForIndex)
           
static Function findColumnLiteralFunction(TableIdentifier tid, Table table, Set conditions, boolean mustCheckForIndex)
          Find column-literal comparision function for a given table.
static ComparisonFunction findFirstColumnColumnComparisonFunction(Set columnColumnConditions, TableIdentifier tid, Table table, boolean mustCheckForIndex)
           
static EqualFunction findFirstEqualFunction(Set columnColumnConditions, TableIdentifier tid, Table table, boolean mustCheckForIndex)
           
static Set flatConditionTree(Selectable conditionTree)
          Flatten the given condition tree into an ANDed set
static Selectable getColumnRefersTable(ComparisonFunction fn, TableIdentifier tid)
           
static boolean hasTableReference(ComparisonFunction fn, TableIdentifier tid)
           
static boolean isAllInnerJoin(Object node)
           
static Function isColumnIndexed(TableIdentifier tid, Table table, Selectable condition, boolean mustCheckForIndex)
           
static boolean onlyReferencesTable(TableIdentifier table, Selectable conditionNode)
          Check if the given table is the only table refernce in the condition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AxionQueryOptimizer

public AxionQueryOptimizer()
Method Detail

createOneRootFunction

public static Selectable createOneRootFunction(Set conditions)
Compose back the decomposed condition into a single condition tree.

Parameters:
conditions - decomposed condition set
Returns:
Single condition tree composed with AndFunction

decomposeWhereConditionNodes

public static Set[] decomposeWhereConditionNodes(Set flattenConditionSet,
                                                 boolean isAllInnerJoin)
Decomose a where/join condition into three part: (1) column-column comparision function (2) column-literal conditions. column-literal conditions can be applied earlier at table level than at join level. (3) and all remaining conditions: any other function, these will be applied after join.

Parameters:
flattenConditionSet - Flatten Condition Set, created from the where/join condition, or combined where and join condition set
Returns:
Array of Set 0: column-column set, 1: column-literal set, 2: other

hasTableReference

public static boolean hasTableReference(ComparisonFunction fn,
                                        TableIdentifier tid)

getColumnRefersTable

public static Selectable getColumnRefersTable(ComparisonFunction fn,
                                              TableIdentifier tid)

deriveTableFilter

public static Set deriveTableFilter(Set flattenConditions,
                                    boolean isAllInnerJoin)
                             throws AxionException
Decomposes the given WhereNodeinto a Setof nodes that were originally joined by ANDs, and adds to this set predicates that are implied by the original tree (for example, given A = 1 and A = B, we can infer B = 1.)

Parameters:
flattenConditions -
Returns:
derived condition set
Throws:
AxionException

findColumnLiteralFunction

public static Function findColumnLiteralFunction(TableIdentifier tid,
                                                 Table table,
                                                 Set conditions,
                                                 boolean mustCheckForIndex)
Find column-literal comparision function for a given table. This function then can be applied first to restrict the number of rows returned by an iterator. We do this at the index level also. Give preference to EqualFunction

Parameters:
tid - TableIdentifier
conditions - decomposed condition set
Returns:
column-literal function if found, null if not found

findColumnLiteralEqualFunction

public static Function findColumnLiteralEqualFunction(TableIdentifier tid,
                                                      Table table,
                                                      Set conditions,
                                                      boolean mustCheckForIndex)

isColumnIndexed

public static Function isColumnIndexed(TableIdentifier tid,
                                       Table table,
                                       Selectable condition,
                                       boolean mustCheckForIndex)

findFirstColumnColumnComparisonFunction

public static ComparisonFunction findFirstColumnColumnComparisonFunction(Set columnColumnConditions,
                                                                         TableIdentifier tid,
                                                                         Table table,
                                                                         boolean mustCheckForIndex)
                                                                  throws AxionException
Throws:
AxionException

findFirstEqualFunction

public static EqualFunction findFirstEqualFunction(Set columnColumnConditions,
                                                   TableIdentifier tid,
                                                   Table table,
                                                   boolean mustCheckForIndex)
                                            throws AxionException
Throws:
AxionException

flatConditionTree

public static Set flatConditionTree(Selectable conditionTree)
Flatten the given condition tree into an ANDed set

Parameters:
conditionTree - condition tree
Returns:
flat set of functions which are anded together

onlyReferencesTable

public static boolean onlyReferencesTable(TableIdentifier table,
                                          Selectable conditionNode)
Check if the given table is the only table refernce in the condition

Parameters:
table - TableIdentifier
conditionNode -
Returns:
true if match, otherwise false.

isAllInnerJoin

public static boolean isAllInnerJoin(Object node)