* @return events
*/
public Collection<EventBean> snapshot(FilterSpecCompiled optionalFilter, Annotation[] annotations) {
// Determine virtual data window
VirtualDWView virtualDataWindow = null;
if (isVirtualDataWindow()) {
virtualDataWindow = getVirtualDataWindow();
}
if (optionalFilter == null || optionalFilter.getParameters().length == 0) {
if (virtualDataWindow != null) {
Pair<IndexMultiKey,EventTable> pair = virtualDataWindow.getFireAndForgetDesc(Collections.<String>emptySet(), Collections.<String>emptySet());
return virtualDataWindow.getFireAndForgetData(pair.getSecond(), new Object[0], new RangeIndexLookupValue[0], annotations);
}
return null;
}
// Determine what straight-equals keys and which ranges are available.
// Widening/Coercion is part of filter spec compile.
Set<String> keysAvailable = new HashSet<String>();
Set<String> rangesAvailable = new HashSet<String>();
for (FilterSpecParam param : optionalFilter.getParameters()) {
if (!(param instanceof FilterSpecParamConstant ||
param instanceof FilterSpecParamRange ||
param instanceof FilterSpecParamIn)) {
continue;
}
if (param.getFilterOperator() == FilterOperator.EQUAL ||
param.getFilterOperator() == FilterOperator.IS ||
param.getFilterOperator() == FilterOperator.IN_LIST_OF_VALUES) {
keysAvailable.add(param.getLookupable().getExpression());
}
else if (param.getFilterOperator().isRangeOperator() ||
param.getFilterOperator().isInvertedRangeOperator() ||
param.getFilterOperator().isComparisonOperator()) {
rangesAvailable.add(param.getLookupable().getExpression());
}
else if (param.getFilterOperator().isRangeOperator()) {
rangesAvailable.add(param.getLookupable().getExpression());
}
}
// Find an index that matches the needs
Pair<IndexMultiKey, EventTableAndNamePair> tablePair;
if (virtualDataWindow != null) {
Pair<IndexMultiKey, EventTable> tablePairNoName = virtualDataWindow.getFireAndForgetDesc(keysAvailable, rangesAvailable);
tablePair = new Pair<IndexMultiKey, EventTableAndNamePair>(tablePairNoName.getFirst(), new EventTableAndNamePair(tablePairNoName.getSecond(), null));
}
else {
IndexHint indexHint = IndexHint.getIndexHint(annotations);
tablePair = indexRepository.findTable(keysAvailable, rangesAvailable, explicitIndexes, indexHint);