checkTable(table);
Tracer trace = Trace.trace("query - setup", Trace.param("table", table), Trace.param("blurQuery", blurQuery));
String cluster = _clusterStatus.getCluster(true, table);
_queryChecker.checkQuery(blurQuery);
checkSelectorFetchSize(blurQuery.getSelector());
TableDescriptor tableDescriptor = _clusterStatus.getTableDescriptor(true, cluster, table);
int shardCount = tableDescriptor.getShardCount();
if (blurQuery.getUuid() == null) {
blurQuery.setUuid(UUID.randomUUID().toString());
}
BlurUtil.setStartTime(blurQuery);
trace.done();
BlurUtil.setStartTime(blurQuery);
OUTER: for (int retries = 0; retries < _maxDefaultRetries; retries++) {
Tracer selectorTrace = Trace.trace("selector - setup", Trace.param("retries", retries));
final AtomicLongArray facetCounts = BlurUtil.getAtomicLongArraySameLengthAsList(blurQuery.facets);
Selector selector = blurQuery.getSelector();
if (selector == null) {
selector = new Selector();
selector.setColumnFamiliesToFetch(EMPTY_SET);
selector.setColumnsToFetch(EMPTY_MAP);
if (!blurQuery.query.rowQuery) {
selector.setRecordOnly(true);
}
} else {
HighlightOptions highlightOptions = selector.getHighlightOptions();
if (highlightOptions != null && highlightOptions.getQuery() == null) {
highlightOptions.setQuery(blurQuery.getQuery());
}
}
blurQuery.setSelector(null);
selectorTrace.done();
BlurCommand<BlurResultIterable> command = new BlurCommand<BlurResultIterable>() {
@Override
public BlurResultIterable call(Client client, Connection connection) throws BlurException, TException {
return new BlurResultIterableClient(connection, client, table, blurQuery, facetCounts, _remoteFetchCount);
}
@Override
public BlurResultIterable call(Client client) throws BlurException, TException {
throw new RuntimeException("Won't be called.");
}
};
command.setDetachClient(true);
MergerBlurResultIterable merger = new MergerBlurResultIterable(blurQuery);
BlurResultIterable hitsIterable = null;
try {
String rowId = blurQuery.getRowId();
if (rowId == null) {
Tracer scatterGatherTrace = Trace.trace("query - scatterGather", Trace.param("retries", retries));
try {
hitsIterable = scatterGather(tableDescriptor.getCluster(), command, merger);
} finally {
scatterGatherTrace.done();
}
} else {
String clientHostnamePort = getNode(table, rowId);