org.axiondb.engine.commands

Class AxionQueryOptimizer

public class AxionQueryOptimizer extends Object

Axion Query Optimizer

Author: Rodney Waldhoff Chuck Burdick Ahimanikya Satapathy Ritesh Adval

Method Summary
static SelectablecreateOneRootFunction(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. 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.
static SetderiveTableFilter(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 FunctionfindColumnLiteralEqualFunction(TableIdentifier tid, Table table, Set conditions, boolean mustCheckForIndex)
static FunctionfindColumnLiteralFunction(TableIdentifier tid, Table table, Set conditions, boolean mustCheckForIndex)
Find column-literal comparision function for a given table.
static ComparisonFunctionfindFirstColumnColumnComparisonFunction(Set columnColumnConditions, TableIdentifier tid, Table table, boolean mustCheckForIndex)
static EqualFunctionfindFirstEqualFunction(Set columnColumnConditions, TableIdentifier tid, Table table, boolean mustCheckForIndex)
static SetflatConditionTree(Selectable conditionTree)
Flatten the given condition tree into an ANDed set
static SelectablegetColumnRefersTable(ComparisonFunction fn, TableIdentifier tid)
static booleanhasTableReference(ComparisonFunction fn, TableIdentifier tid)
static booleanisAllInnerJoin(Object node)
static FunctionisColumnIndexed(TableIdentifier tid, Table table, Selectable condition, boolean mustCheckForIndex)
static booleanonlyReferencesTable(TableIdentifier table, Selectable conditionNode)
Check if the given table is the only table refernce in the condition

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

deriveTableFilter

public 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.)

Parameters: flattenConditions

Returns: derived condition set

Throws: AxionException

findColumnLiteralEqualFunction

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

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

findFirstColumnColumnComparisonFunction

public static ComparisonFunction findFirstColumnColumnComparisonFunction(Set columnColumnConditions, TableIdentifier tid, Table table, boolean mustCheckForIndex)

findFirstEqualFunction

public static EqualFunction findFirstEqualFunction(Set columnColumnConditions, TableIdentifier tid, Table table, boolean mustCheckForIndex)

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

getColumnRefersTable

public static Selectable getColumnRefersTable(ComparisonFunction fn, TableIdentifier tid)

hasTableReference

public static boolean hasTableReference(ComparisonFunction fn, TableIdentifier tid)

isAllInnerJoin

public static boolean isAllInnerJoin(Object node)

isColumnIndexed

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

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.