Fix for #87 - v4 - Remove Query setBackgroundFetchAfter() feature

This commit is contained in:
Rob Bygrave
2014-04-20 19:30:40 +12:00
parent 18d9c53ce3
commit fc628d336d
29 changed files with 54 additions and 575 deletions
@@ -185,15 +185,8 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
*/
private final ElPropertyValue manyPropertyEl;
private final int backgroundFetchAfter;
private final int maxRowsLimit;
/**
* Flag set when backgroundFetchAfter limit is hit.
*/
private boolean hasHitBackgroundFetchAfter;
private final PersistenceContext persistenceContext;
private DataReader dataReader;
@@ -272,12 +265,8 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
this.logWhereSql = queryPlan.getLogWhereSql();
this.desc = request.getBeanDescriptor();
this.predicates = predicates;
this.persistenceContext = request.getPersistenceContext();
this.maxRowsLimit = query.getMaxRows() > 0 ? query.getMaxRows() : GLOBAL_ROW_LIMIT;
this.backgroundFetchAfter = query.getBackgroundFetchAfter() > 0 ? query.getBackgroundFetchAfter() : Integer.MAX_VALUE;
this.help = createHelp(request);
this.collection = (BeanCollection<T>) (help != null ? help.createEmpty(false) : null);
}
@@ -535,26 +524,20 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
public boolean readBean() throws SQLException {
boolean result = readBeanInternal(true);
boolean result = readBeanInternal();
updateExecutionStatistics();
return result;
}
private boolean readBeanInternal(boolean inForeground) throws SQLException {
private boolean readBeanInternal() throws SQLException {
if (loadedBeanCount >= maxRowsLimit) {
collection.setHasMoreRows(hasMoreRows());
return false;
}
if (inForeground && loadedBeanCount >= backgroundFetchAfter) {
hasHitBackgroundFetchAfter = true;
collection.setFinishedFetch(false);
return false;
}
if (!manyIncluded) {
// simple query... no details...
return readRow();
@@ -629,15 +612,9 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
}
}
public BeanCollection<T> continueFetchingInBackground() throws SQLException {
readTheRows(false);
collection.setFinishedFetch(true);
return collection;
}
public BeanCollection<T> readCollection() throws SQLException {
readTheRows(true);
readTheRows();
updateExecutionStatistics();
@@ -670,17 +647,16 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
}
}
@SuppressWarnings("unchecked")
private void readTheRows(boolean inForeground) throws SQLException {
while (hasNextBean(inForeground)) {
private void readTheRows() throws SQLException {
while (hasNextBean()) {
// add to the list/set/map
help.add(collection, getLoadedBean());
}
}
protected boolean hasNextBean(boolean inForeground) throws SQLException {
protected boolean hasNextBean() throws SQLException {
if (!readBeanInternal(inForeground)) {
if (!readBeanInternal()) {
return false;
} else {
@@ -709,10 +685,6 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
request.getGraphContext().register(path, bc);
}
public boolean useBackgroundToContinueFetch() {
return hasHitBackgroundFetchAfter;
}
/**
* Return the query name.
*/