org.apache.metamodel.jdbc
Class QuerySplitter

java.lang.Object
  extended by org.apache.metamodel.jdbc.QuerySplitter

public final class QuerySplitter
extends Object

The QuerySplitter class makes it possible to split up queries that are expected to yield a huge result set which may cause performance problems like OutOfMemoryError's or very long processing periods. The resulting queries will in union produce the same result, but in smaller bits (resultsets with less rows). Note that there is an initial performance-penalty associated with splitting the query since some queries will be executed in order to determine reasonable intervals to use for the resulting queries WHERE clauses.

See Also:
Query, DataContext

Field Summary
static long DEFAULT_MAX_ROWS
           
 
Constructor Summary
QuerySplitter(DataContext dc, Query q)
           
 
Method Summary
 DataSet executeQueries()
           
 DataSet executeQueries(List<Query> splitQueries)
           
 long getRowCount()
           
static boolean isSplittable(Query q)
           
 QuerySplitter setMaxRows(long maxRows)
          Sets the desired maximum result set row count.
 List<Query> splitQuery()
          Splits the query into several queries that will together yield the same result set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_ROWS

public static final long DEFAULT_MAX_ROWS
See Also:
Constant Field Values
Constructor Detail

QuerySplitter

public QuerySplitter(DataContext dc,
                     Query q)
Method Detail

splitQuery

public List<Query> splitQuery()
Splits the query into several queries that will together yield the same result set

Returns:
a list of queries that can be executed to yield the same collective result as this QuerySplitter's query

isSplittable

public static boolean isSplittable(Query q)

getRowCount

public long getRowCount()
Returns:
the total number of rows expected from executing the query.

setMaxRows

public QuerySplitter setMaxRows(long maxRows)
Sets the desired maximum result set row count. Note that this size cannot be guaranteed, but will serve as an indicator for determining the split-size

Parameters:
maxRows -

executeQueries

public DataSet executeQueries()

executeQueries

public DataSet executeQueries(List<Query> splitQueries)


Copyright © 2007-2014 The Apache Software Foundation. All Rights Reserved.