validatedExprNodes = desc.getChildEvals();
}
public EventTable[][] poll(EventBean[][] lookupEventsPerStream, PollResultIndexingStrategy indexingStrategy, ExprEvaluatorContext exprEvaluatorContext)
{
DataCache localDataCache = dataCacheThreadLocal.get();
boolean strategyStarted = false;
EventTable[][] resultPerInputRow = new EventTable[lookupEventsPerStream.length][];
// Get input parameters for each row
for (int row = 0; row < lookupEventsPerStream.length; row++)
{
Object[] lookupValues = new Object[inputParameters.size()];
// Build lookup keys
for (int valueNum = 0; valueNum < inputParameters.size(); valueNum++)
{
Object parameterValue = validatedExprNodes[valueNum].evaluate(lookupEventsPerStream[row], true, exprEvaluatorContext);
lookupValues[valueNum] = parameterValue;
}
EventTable[] result = null;
// try the threadlocal iteration cache, if set
if (localDataCache != null)
{
result = localDataCache.getCached(lookupValues);
}
// try the connection cache
if (result == null)
{
result = dataCache.getCached(lookupValues);
if ((result != null) && (localDataCache != null))
{
localDataCache.put(lookupValues, result);
}
}
if (result != null) // found in cache
{
resultPerInputRow[row] = result;
}
else // not found in cache, get from actual polling (db query)
{
try
{
if (!strategyStarted)
{
pollExecStrategy.start();
strategyStarted = true;
}
// Poll using the polling execution strategy and lookup values
List<EventBean> pollResult = pollExecStrategy.poll(lookupValues);
// index the result, if required, using an indexing strategy
EventTable[] indexTable = indexingStrategy.index(pollResult, dataCache.isActive());
// assign to row
resultPerInputRow[row] = indexTable;
// save in cache
dataCache.put(lookupValues, indexTable);
if (localDataCache != null)
{
localDataCache.put(lookupValues, indexTable);
}
}
catch (EPException ex)
{
if (strategyStarted)