Class 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
    • Constructor Detail

      • QuerySplitter

        public QuerySplitter​(org.apache.metamodel.DataContext dc,
                             org.apache.metamodel.query.Query q)
    • Method Detail

      • splitQuery

        public List<org.apache.metamodel.query.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​(org.apache.metamodel.query.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 org.apache.metamodel.data.DataSet executeQueries()
      • executeQueries

        public org.apache.metamodel.data.DataSet executeQueries​(List<org.apache.metamodel.query.Query> splitQueries)