Iterator<InputSplit> splitIt = splits.iterator();
while (splitIt.hasNext()) {
try {
orderedArraySet_afterMin.clear();
MongoInputSplit mongoSplit = (MongoInputSplit)splitIt.next();
BasicDBObject min = (BasicDBObject) mongoSplit.getQuerySpec().get("$min");
BasicDBObject max = (BasicDBObject) mongoSplit.getQuerySpec().get("$max");
//DEBUG
//_logger.info("+----------------- NEW SPLIT ----------------: " + min + " /" + max);
//System.out.println("+----------------- NEW SPLIT ----------------: " + min + " /" + max);
if (null != min) { // How does the min fit in with the general query
try {
if (compareFields(-1, originalQuery, min, max, orderedArraySet, orderedArraySet_afterMin) < 0) {
splitIt.remove();
continue;
}
}
catch (Exception e) {} // do nothing probably just some comparable issue
}//TESTED
if (null != max) { // How does the min fit in with the general query
try {
if (compareFields(1, originalQuery, max, min, orderedArraySet, orderedArraySet_afterMin) > 0) {
splitIt.remove();
continue;
}
}
catch (Exception e) {} // do nothing probably just some comparable issue
}//TESTED
//DEBUG
//_logger.info("(retained split)");
//System.out.println("(retained split)");
// (don't worry about edge cases, won't happen very often and will just result in a spurious empty mapper)
////////////////////////////////
// Now some infinit.e specific processing...
if (newShardScheme) {
@SuppressWarnings("rawtypes")
TreeSet<Comparable> sourceKeyOrderedArray = orderedArraySet.get(DocumentPojo.sourceKey_);
if ((null != sourceKeyOrderedArray) && !sourceKeyOrderedArray.isEmpty()) {
@SuppressWarnings("rawtypes")
Comparable minSourceKey = null;
Object minSourceKeyObj = (null == min) ? null : min.get(DocumentPojo.sourceKey_);
if (minSourceKeyObj instanceof String) {
minSourceKey = (String)minSourceKeyObj;
}
if (null == minSourceKey) {
minSourceKey = sourceKeyOrderedArray.first();
}//TESTED
@SuppressWarnings("rawtypes")
Comparable maxSourceKey = null;
Object maxSourceKeyObj = (null == max) ? null : max.get(DocumentPojo.sourceKey_);
if (maxSourceKeyObj instanceof String) {
maxSourceKey = (String)maxSourceKeyObj;
}
if (null == maxSourceKey) {
maxSourceKey = sourceKeyOrderedArray.last();
}//TESTED
DBObject splitQuery = mongoSplit.getQuerySpec();
BasicDBObject splitQueryQuery = new BasicDBObject((BasicBSONObject) splitQuery.get("$query"));
if (0 == minSourceKey.compareTo(maxSourceKey)) { // single matching sourceKEy
splitQueryQuery.put(DocumentPojo.sourceKey_, maxSourceKey);
}//TESTED (array of sources, only one matches)
else { // multiple matching source keys
splitQueryQuery.put(DocumentPojo.sourceKey_,
new BasicDBObject(DbManager.in_, sourceKeyOrderedArray.subSet(minSourceKey, true, maxSourceKey, true)));
}//TESTED (array of sources, multiple match)
newsplits.add(new InfiniteMongoInputSplit(mongoSplit, splitQueryQuery, conf.isNoTimeout()));
}
else { // original query is of sufficient simplicity
newsplits.add(new InfiniteMongoInputSplit(mongoSplit, originalQuery, conf.isNoTimeout()));
}//TESTED (no change to existing source)
}//TESTED
else { // old sharding scheme, remove min/max and replace with normal _id based query where possible
DBObject splitQuery = mongoSplit.getQuerySpec();
// Step 1: create a query range for _id:
BasicDBObject idRange = null;
Object idMin = (min == null) ? null : min.get(DocumentPojo._id_);
Object idMax = (max == null) ? null : max.get(DocumentPojo._id_);
if (!(idMin instanceof ObjectId))