for (int i = 0; i < numSplits; i++) {
q = _query.clone();
long lowLimit = min + (i * splitInterval);
long highLimit = lowLimit + splitInterval;
FilterItem lowerThanFilter = new FilterItem(new SelectItem(column), OperatorType.LESS_THAN, highLimit);
FilterItem higherThanFilter = new FilterItem(new SelectItem(column), OperatorType.GREATER_THAN,
lowLimit);
FilterItem equalsFilter = new FilterItem(new SelectItem(column), OperatorType.EQUALS_TO, lowLimit);
if (i == 0) {
// This is the first split query: no higherThan filter and
// include
// IS NULL
FilterItem nullFilter = new FilterItem(new SelectItem(column), OperatorType.EQUALS_TO, null);
FilterItem orFilterItem = new FilterItem(lowerThanFilter, nullFilter);
q.where(orFilterItem);
} else if (i + 1 == numSplits) {
// This is the lats split query: no lowerThan filter,
FilterItem orFilterItem = new FilterItem(higherThanFilter, equalsFilter);
q.where(orFilterItem);
} else {
higherThanFilter = new FilterItem(higherThanFilter, equalsFilter);
lowerThanFilter = new FilterItem(lowerThanFilter, equalsFilter);
q.where(higherThanFilter);
q.where(lowerThanFilter);
}
result.add(q);
}