Package com.j_spaces.jdbc.executor
Class AbstractQueryExecutor
java.lang.Object
com.j_spaces.jdbc.executor.AbstractQueryExecutor
- All Implemented Interfaces:
IQueryExecutor,Externalizable,Serializable
- Direct Known Subclasses:
CollocatedJoinedQueryExecutor,JoinedQueryExecutor,QueryExecutor
- Since:
- 7.0
- Author:
- anna
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classThis private class implements the Comparator and is used to sort. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.slf4j.Loggerprotected AbstractDMLQuery -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaggregate(IQueryResultSet<IEntryPacket> entries) Execute SQL function that processes the result entries and calculates one value - sum,average,min,maxavg(SelectColumn funcColumn, IQueryResultSet<IEntryPacket> entries) Calculate the average value of the given column for all entries .intclear(QueryTemplatePacket template, ISpaceProxy space, Transaction txn, int modifiers) Execute clearConverts the list of ExternaEntries to 2 dimensional array that contains the values of the entries.intcount(QueryTemplatePacket template, ISpaceProxy space, Transaction txn, int readModifier) voidexecute(InnerQueryNode innerQueryNode, ISpaceProxy space, Transaction txn, int readModifier, int max) Executes an inner queryexecuteTemplate(QueryTemplatePacket template, ISpaceProxy space, Transaction txn, int readModifier, int max) extractResults(ExpNode node) filterDistinctEntries(IQueryResultSet<IEntryPacket> entries) Removes duplicate entries from the result set.getGroupByComparator(IQueryResultSet<IEntryPacket> queryResult, List<SelectColumn> groupColumns) protected HashMap<ExpNode,IQueryResultSet<IEntryPacket>> getOrderByComparator(IQueryResultSet<IEntryPacket> entries, List<OrderColumn> orderColumns) getQuery()groupBy(IQueryResultSet<IEntryPacket> entries, List<SelectColumn> groupColumns) Group the results according to the group by clauseminMax(SelectColumn funcColumn, IQueryResultSet<IEntryPacket> entries, boolean isMax) Finds the minimum/maximum value of given columnvoidorderBy(IQueryResultSet<IEntryPacket> entries, List<OrderColumn> orderColumns) Order the results according to the order by clausereadAll(ISpaceProxy space, Transaction txn) voidvoidsetResults(ExpNode node, IQueryResultSet<IEntryPacket> results) sum(SelectColumn funcColumn, IQueryResultSet<IEntryPacket> entries) Calculate the sum value of the given column for all entriesprotected IQueryResultSet<IEntryPacket>traverseExpressionTree(ExpNode root, ISpaceProxy space, Transaction txn, int readModifier, int max) Traverse the binary expression tree non-recursively using a custom stack The tree has to be traversed in postorder - the parent is traversed after its children.void
-
Field Details
-
_logger
protected static final org.slf4j.Logger _logger -
query
-
-
Constructor Details
-
AbstractQueryExecutor
public AbstractQueryExecutor() -
AbstractQueryExecutor
-
-
Method Details
-
clear
public int clear(QueryTemplatePacket template, ISpaceProxy space, Transaction txn, int modifiers) throws RemoteException, TransactionException, UnusableEntryException Description copied from interface:IQueryExecutorExecute clear- Specified by:
clearin interfaceIQueryExecutor- Returns:
- int
- Throws:
RemoteExceptionTransactionExceptionUnusableEntryException
-
count
public int count(QueryTemplatePacket template, ISpaceProxy space, Transaction txn, int readModifier) throws SQLException - Specified by:
countin interfaceIQueryExecutor- Throws:
SQLException
-
getQuery
-
extractResults
-
setResults
-
traverseExpressionTree
protected IQueryResultSet<IEntryPacket> traverseExpressionTree(ExpNode root, ISpaceProxy space, Transaction txn, int readModifier, int max) throws SQLException Traverse the binary expression tree non-recursively using a custom stack The tree has to be traversed in postorder - the parent is traversed after its children.- Throws:
SQLException
-
readAll
- Specified by:
readAllin interfaceIQueryExecutor- Throws:
SQLException
-
executeTemplate
public IQueryResultSet<IEntryPacket> executeTemplate(QueryTemplatePacket template, ISpaceProxy space, Transaction txn, int readModifier, int max) throws SQLException - Throws:
SQLException
-
getIntermediateResults
-
aggregate
Execute SQL function that processes the result entries and calculates one value - sum,average,min,max- Specified by:
aggregatein interfaceIQueryExecutor- Returns:
- The result of sum,average,min,max
- Throws:
SQLException
-
groupBy
public IQueryResultSet<IEntryPacket> groupBy(IQueryResultSet<IEntryPacket> entries, List<SelectColumn> groupColumns) throws SQLException Group the results according to the group by clause- Specified by:
groupByin interfaceIQueryExecutor- Returns:
- IQuery result set
- Throws:
SQLException
-
getGroupByComparator
public Comparator<IEntryPacket> getGroupByComparator(IQueryResultSet<IEntryPacket> queryResult, List<SelectColumn> groupColumns) -
orderBy
public void orderBy(IQueryResultSet<IEntryPacket> entries, List<OrderColumn> orderColumns) throws SQLException Order the results according to the order by clause- Specified by:
orderByin interfaceIQueryExecutor- Throws:
SQLException
-
getOrderByComparator
public Comparator<IEntryPacket> getOrderByComparator(IQueryResultSet<IEntryPacket> entries, List<OrderColumn> orderColumns) -
minMax
Finds the minimum/maximum value of given column- Returns:
- minimum/maximum value of given column
-
avg
public Number avg(SelectColumn funcColumn, IQueryResultSet<IEntryPacket> entries) throws SQLException Calculate the average value of the given column for all entries . Average is calculated using Double precision- Returns:
- the sum value of the field
- Throws:
SQLException
-
sum
public Number sum(SelectColumn funcColumn, IQueryResultSet<IEntryPacket> entries) throws SQLException Calculate the sum value of the given column for all entries- Returns:
- the sum value of the field
- Throws:
SQLException
-
filterDistinctEntries
Removes duplicate entries from the result set. The rows are inserted into a TreeSet and only the rows that were successfully added, are considered distinct. Note: TreeSet is used and not HashSet to avoid creating hashCode for all fields.- Specified by:
filterDistinctEntriesin interfaceIQueryExecutor- Returns:
- new IQueryResultSet with distinct entries
-
convertEntriesToResultArrays
Converts the list of ExternaEntries to 2 dimensional array that contains the values of the entries. Each row matches specific IEntryPacket. The conversion is necessary for entries ordering.- Specified by:
convertEntriesToResultArraysin interfaceIQueryExecutor
-
execute
public void execute(InnerQueryNode innerQueryNode, ISpaceProxy space, Transaction txn, int readModifier, int max) throws SQLException Executes an inner query- Specified by:
executein interfaceIQueryExecutor- Throws:
SQLException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-