use of org.wso2.siddhi.core.exception.ConnectionUnavailableException in project siddhi by wso2.
the class AbstractRecordTable method add.
@Override
public void add(ComplexEventChunk<StreamEvent> addingEventChunk) throws ConnectionUnavailableException {
List<Object[]> records = new ArrayList<>();
addingEventChunk.reset();
long timestamp = 0L;
while (addingEventChunk.hasNext()) {
StreamEvent event = addingEventChunk.next();
records.add(event.getOutputData());
timestamp = event.getTimestamp();
}
if (recordTableHandler != null) {
recordTableHandler.add(timestamp, records);
} else {
add(records);
}
}
use of org.wso2.siddhi.core.exception.ConnectionUnavailableException in project siddhi by wso2.
the class AbstractRecordTable method update.
@Override
public void update(ComplexEventChunk<StateEvent> updatingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet) throws ConnectionUnavailableException {
RecordStoreCompiledCondition recordStoreCompiledCondition = ((RecordStoreCompiledCondition) compiledCondition);
RecordTableCompiledUpdateSet recordTableCompiledUpdateSet = (RecordTableCompiledUpdateSet) compiledUpdateSet;
List<Map<String, Object>> updateConditionParameterMaps = new ArrayList<>();
List<Map<String, Object>> updateSetParameterMaps = new ArrayList<>();
updatingEventChunk.reset();
long timestamp = 0L;
while (updatingEventChunk.hasNext()) {
StateEvent stateEvent = updatingEventChunk.next();
Map<String, Object> variableMap = new HashMap<>();
for (Map.Entry<String, ExpressionExecutor> entry : recordStoreCompiledCondition.variableExpressionExecutorMap.entrySet()) {
variableMap.put(entry.getKey(), entry.getValue().execute(stateEvent));
}
updateConditionParameterMaps.add(variableMap);
Map<String, Object> variableMapForUpdateSet = new HashMap<>();
for (Map.Entry<String, ExpressionExecutor> entry : recordTableCompiledUpdateSet.getExpressionExecutorMap().entrySet()) {
variableMapForUpdateSet.put(entry.getKey(), entry.getValue().execute(stateEvent));
}
updateSetParameterMaps.add(variableMapForUpdateSet);
timestamp = stateEvent.getTimestamp();
}
if (recordTableHandler != null) {
recordTableHandler.update(timestamp, recordStoreCompiledCondition.compiledCondition, updateConditionParameterMaps, recordTableCompiledUpdateSet.getUpdateSetMap(), updateSetParameterMaps);
} else {
update(recordStoreCompiledCondition.compiledCondition, updateConditionParameterMaps, recordTableCompiledUpdateSet.getUpdateSetMap(), updateSetParameterMaps);
}
}
use of org.wso2.siddhi.core.exception.ConnectionUnavailableException in project siddhi by wso2.
the class AbstractRecordTable method updateOrAdd.
@Override
public void updateOrAdd(ComplexEventChunk<StateEvent> updateOrAddingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor) throws ConnectionUnavailableException {
RecordStoreCompiledCondition recordStoreCompiledCondition = ((RecordStoreCompiledCondition) compiledCondition);
RecordTableCompiledUpdateSet recordTableCompiledUpdateSet = (RecordTableCompiledUpdateSet) compiledUpdateSet;
List<Map<String, Object>> updateConditionParameterMaps = new ArrayList<>();
List<Map<String, Object>> updateSetParameterMaps = new ArrayList<>();
List<Object[]> addingRecords = new ArrayList<>();
updateOrAddingEventChunk.reset();
long timestamp = 0L;
while (updateOrAddingEventChunk.hasNext()) {
StateEvent stateEvent = updateOrAddingEventChunk.next();
Map<String, Object> variableMap = new HashMap<>();
for (Map.Entry<String, ExpressionExecutor> entry : recordStoreCompiledCondition.variableExpressionExecutorMap.entrySet()) {
variableMap.put(entry.getKey(), entry.getValue().execute(stateEvent));
}
updateConditionParameterMaps.add(variableMap);
Map<String, Object> variableMapForUpdateSet = new HashMap<>();
for (Map.Entry<String, ExpressionExecutor> entry : recordTableCompiledUpdateSet.getExpressionExecutorMap().entrySet()) {
variableMapForUpdateSet.put(entry.getKey(), entry.getValue().execute(stateEvent));
}
updateSetParameterMaps.add(variableMapForUpdateSet);
addingRecords.add(stateEvent.getStreamEvent(0).getOutputData());
timestamp = stateEvent.getTimestamp();
}
if (recordTableHandler != null) {
recordTableHandler.updateOrAdd(timestamp, recordStoreCompiledCondition.compiledCondition, updateConditionParameterMaps, recordTableCompiledUpdateSet.getUpdateSetMap(), updateSetParameterMaps, addingRecords);
} else {
updateOrAdd(recordStoreCompiledCondition.compiledCondition, updateConditionParameterMaps, recordTableCompiledUpdateSet.getUpdateSetMap(), updateSetParameterMaps, addingRecords);
}
}
use of org.wso2.siddhi.core.exception.ConnectionUnavailableException in project siddhi by wso2.
the class AbstractRecordTable method delete.
@Override
public void delete(ComplexEventChunk<StateEvent> deletingEventChunk, CompiledCondition compiledCondition) throws ConnectionUnavailableException {
RecordStoreCompiledCondition recordStoreCompiledCondition = ((RecordStoreCompiledCondition) compiledCondition);
List<Map<String, Object>> deleteConditionParameterMaps = new ArrayList<>();
deletingEventChunk.reset();
long timestamp = 0L;
while (deletingEventChunk.hasNext()) {
StateEvent stateEvent = deletingEventChunk.next();
Map<String, Object> variableMap = new HashMap<>();
for (Map.Entry<String, ExpressionExecutor> entry : recordStoreCompiledCondition.variableExpressionExecutorMap.entrySet()) {
variableMap.put(entry.getKey(), entry.getValue().execute(stateEvent));
}
deleteConditionParameterMaps.add(variableMap);
timestamp = stateEvent.getTimestamp();
}
if (recordTableHandler != null) {
recordTableHandler.delete(timestamp, deleteConditionParameterMaps, recordStoreCompiledCondition.compiledCondition);
} else {
delete(deleteConditionParameterMaps, recordStoreCompiledCondition.compiledCondition);
}
}
Aggregations