use of org.apache.cassandra.index.IndexNotAvailableException in project cassandra by apache.
the class ReadCommand method executeLocally.
/**
* Executes this command on the local host.
*
* @param executionController the execution controller spanning this command
*
* @return an iterator over the result of executing this command locally.
*/
// The result iterator is closed upon exceptions (we know it's fine to potentially not close the intermediary
@SuppressWarnings("resource")
public // iterators created inside the try as long as we do close the original resultIterator), or by closing the result.
UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController) {
long startTimeNanos = System.nanoTime();
ColumnFamilyStore cfs = Keyspace.openAndGetStore(metadata());
Index index = getIndex(cfs);
Index.Searcher searcher = null;
if (index != null) {
if (!cfs.indexManager.isIndexQueryable(index))
throw new IndexNotAvailableException(index);
searcher = index.searcherFor(this);
Tracing.trace("Executing read on {}.{} using index {}", cfs.metadata.keyspace, cfs.metadata.name, index.getIndexMetadata().name);
}
UnfilteredPartitionIterator resultIterator = searcher == null ? queryStorage(cfs, executionController) : searcher.search(executionController);
try {
resultIterator = withStateTracking(resultIterator);
resultIterator = withMetricsRecording(withoutPurgeableTombstones(resultIterator, cfs), cfs.metric, startTimeNanos);
// If we've used a 2ndary index, we know the result already satisfy the primary expression used, so
// no point in checking it again.
RowFilter updatedFilter = searcher == null ? rowFilter() : index.getPostIndexQueryFilter(rowFilter());
// processing we do on it).
return limits().filter(updatedFilter.filter(resultIterator, nowInSec()), nowInSec());
} catch (RuntimeException | Error e) {
resultIterator.close();
throw e;
}
}
Aggregations