count++;
// The key that is returned by the EvaluatingIterator is not the same key that is in
// the table. The value that is returned by the EvaluatingIterator is a kryo
// serialized EventFields object.
processResults.resume();
Document d = this.createDocument(entry.getKey(), entry.getValue());
results.getResults().add(d);
processResults.suspend();
}
log.info(count + " matching entries found in optimized query.");
optimizationSucceeded = true;
processResults.stop();
} catch (TableNotFoundException e) {
log.error(this.getTableName() + "not found", e);
throw new RuntimeException(this.getIndexTableName() + "not found", e);
} finally {
if (bs != null) {
bs.close();
}
}
optimizedEventQuery.stop();
}
optimizedQuery.stop();
}
// WE should look into finding a better way to handle whether we do an optimized query or not.
// We are not setting up an else condition here because we may have aborted the logic early in the if statement.
if (!optimizationSucceeded || ((null != orTerms && orTerms.size() > 0) && (indexedTerms.size() != fields.size()) && !orsAllIndexed)) {
// if (!optimizationSucceeded || ((null != orTerms && orTerms.size() > 0) && (indexedTerms.size() != fields.size()))) {
fullScanQuery.start();
if (log.isDebugEnabled()) {
log.debug(hash + " Performing full scan query");
}
// Set up a full scan using the date ranges from the query
// Create BatchScanner, set the ranges, and setup the iterators.
BatchScanner bs = null;
try {
// The ranges are the start and end dates
Collection<Range> r = getFullScanRange(beginDate, endDate, terms);
ranges.addAll(r);
if (log.isDebugEnabled()) {
log.debug(hash + " Ranges: count: " + ranges.size() + ", " + ranges.toString());
}
bs = connector.createBatchScanner(this.getTableName(), auths, queryThreads);
bs.setRanges(ranges);
IteratorSetting si = new IteratorSetting(22, "eval", EvaluatingIterator.class);
// Create datatype regex if needed
if (null != typeFilter) {
StringBuilder buf = new StringBuilder();
String s = "";
for (String type : typeFilter) {
buf.append(s).append(type).append(".*");
s = "|";
}
if (log.isDebugEnabled())
log.debug("Setting colf regex iterator to: " + buf.toString());
IteratorSetting ri = new IteratorSetting(21, "typeFilter", RegExFilter.class);
RegExFilter.setRegexs(ri, null, buf.toString(), null, null, false);
bs.addScanIterator(ri);
}
if (log.isDebugEnabled()) {
log.debug("Setting scan option: " + EvaluatingIterator.QUERY_OPTION + " to " + queryString);
}
si.addOption(EvaluatingIterator.QUERY_OPTION, queryString);
if (null != unevaluatedExpressions) {
StringBuilder unevaluatedExpressionList = new StringBuilder();
String sep2 = "";
for (String exp : unevaluatedExpressions) {
unevaluatedExpressionList.append(sep2).append(exp);
sep2 = ",";
}
if (log.isDebugEnabled())
log.debug("Setting scan option: " + EvaluatingIterator.UNEVALUTED_EXPRESSIONS + " to " + unevaluatedExpressionList.toString());
si.addOption(EvaluatingIterator.UNEVALUTED_EXPRESSIONS, unevaluatedExpressionList.toString());
}
bs.addScanIterator(si);
long count = 0;
processResults.start();
processResults.suspend();
for (Entry<Key,Value> entry : bs) {
count++;
// The key that is returned by the EvaluatingIterator is not the same key that is in
// the partition table. The value that is returned by the EvaluatingIterator is a kryo
// serialized EventFields object.
processResults.resume();
Document d = this.createDocument(entry.getKey(), entry.getValue());
results.getResults().add(d);
processResults.suspend();
}
processResults.stop();
log.info(count + " matching entries found in full scan query.");