Package io.siddhi.core.table.record
Class AbstractRecordTable
- java.lang.Object
-
- io.siddhi.core.table.Table
-
- io.siddhi.core.table.record.AbstractRecordTable
-
- All Implemented Interfaces:
FindableProcessor,MemoryCalculable
- Direct Known Subclasses:
AbstractQueryableRecordTable
public abstract class AbstractRecordTable extends Table
An abstract implementation of table. Abstract implementation will handleComplexEventChunkso that developer can directly work with event data.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.siddhi.core.table.Table
Table.OnErrorAction
-
-
Field Summary
Fields Modifier and Type Field Description protected RecordTableHandlerrecordTableHandlerprotected StreamEventFactorystoreEventPool-
Fields inherited from class io.siddhi.core.table.Table
siddhiAppContext, tableDefinition, tableMap
-
-
Constructor Summary
Constructors Constructor Description AbstractRecordTable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(ComplexEventChunk<StreamEvent> addingEventChunk)protected abstract voidadd(List<Object[]> records)Add records to the Tableprotected abstract CompiledConditioncompileCondition(ExpressionBuilder expressionBuilder)Compile the matching expressionCompiledConditioncompileCondition(io.siddhi.query.api.expression.Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String,Table> tableMap, SiddhiQueryContext siddhiQueryContext)To construct a finder having the capability of finding events at the processor that corresponds to the incoming matchingEvent and the given matching expression logic.protected abstract CompiledExpressioncompileSetAttribute(ExpressionBuilder expressionBuilder)Compiles the expression in a set clauseCompiledUpdateSetcompileUpdateSet(io.siddhi.query.api.execution.query.output.stream.UpdateSet updateSet, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String,Table> tableMap, SiddhiQueryContext siddhiQueryContext)Builds the "compiled" set clause of an update query.protected abstract voidconnect()protected voidconnectAndLoadCache()booleancontains(StateEvent matchingEvent, CompiledCondition compiledCondition)protected abstract booleancontains(Map<String,Object> containsConditionParameterMap, CompiledCondition compiledCondition)Check if matching record existvoiddelete(ComplexEventChunk<StateEvent> deletingEventChunk, CompiledCondition compiledCondition)protected abstract voiddelete(List<Map<String,Object>> deleteConditionParameterMaps, CompiledCondition compiledCondition)Delete all matching recordsStreamEventfind(CompiledCondition compiledCondition, StateEvent matchingEvent)protected abstract RecordIterator<Object[]>find(Map<String,Object> findConditionParameterMap, CompiledCondition compiledCondition)Find records matching the compiled conditionio.siddhi.query.api.definition.TableDefinitiongetTableDefinition()voidinit(io.siddhi.query.api.definition.TableDefinition tableDefinition, StreamEventFactory storeEventPool, StreamEventCloner storeEventCloner, ConfigReader configReader, SiddhiAppContext siddhiAppContext, RecordTableHandler recordTableHandler)protected abstract voidinit(io.siddhi.query.api.definition.TableDefinition tableDefinition, ConfigReader configReader)Initializing the Record Tableprotected voidinitCache(io.siddhi.query.api.definition.TableDefinition tableDefinition, SiddhiAppContext siddhiAppContext, StreamEventCloner storeEventCloner, ConfigReader configReader)booleanisStateful()voidupdate(ComplexEventChunk<StateEvent> updatingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet)protected abstract voidupdate(CompiledCondition updateCondition, List<Map<String,Object>> updateConditionParameterMaps, Map<String,CompiledExpression> updateSetExpressions, List<Map<String,Object>> updateSetParameterMaps)Update all matching recordsvoidupdateOrAdd(ComplexEventChunk<StateEvent> updateOrAddingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor)protected abstract voidupdateOrAdd(CompiledCondition updateCondition, List<Map<String,Object>> updateConditionParameterMaps, Map<String,CompiledExpression> updateSetExpressions, List<Map<String,Object>> updateSetParameterMaps, List<Object[]> addingRecords)Try updating the records if they exist else add the records-
Methods inherited from class io.siddhi.core.table.Table
addEvents, connectWithRetry, containsEvent, deleteEvents, destroy, disconnect, find, getHandler, getIsConnected, getIsTryingToConnect, initTable, onAddError, onDeleteError, onUpdateError, onUpdateOrAddError, setIsConnectedToFalse, shutdown, updateEvents, updateOrAddEvents, waitWhileConnect
-
-
-
-
Field Detail
-
storeEventPool
protected StreamEventFactory storeEventPool
-
recordTableHandler
protected RecordTableHandler recordTableHandler
-
-
Method Detail
-
init
public void init(io.siddhi.query.api.definition.TableDefinition tableDefinition, StreamEventFactory storeEventPool, StreamEventCloner storeEventCloner, ConfigReader configReader, SiddhiAppContext siddhiAppContext, RecordTableHandler recordTableHandler)
-
initCache
protected void initCache(io.siddhi.query.api.definition.TableDefinition tableDefinition, SiddhiAppContext siddhiAppContext, StreamEventCloner storeEventCloner, ConfigReader configReader)
-
init
protected abstract void init(io.siddhi.query.api.definition.TableDefinition tableDefinition, ConfigReader configReader)Initializing the Record Table- Parameters:
tableDefinition- definition of the table with annotations if anyconfigReader- this hold theAbstractRecordTableconfiguration reader.
-
getTableDefinition
public io.siddhi.query.api.definition.TableDefinition getTableDefinition()
- Overrides:
getTableDefinitionin classTable
-
add
public void add(ComplexEventChunk<StreamEvent> addingEventChunk)
-
add
protected abstract void add(List<Object[]> records) throws ConnectionUnavailableException
Add records to the Table- Parameters:
records- records that need to be added to the table, each Object[] represent a record and it will match the attributes of the Table Definition.- Throws:
ConnectionUnavailableException
-
find
public StreamEvent find(CompiledCondition compiledCondition, StateEvent matchingEvent) throws ConnectionUnavailableException
- Specified by:
findin classTable- Throws:
ConnectionUnavailableException
-
find
protected abstract RecordIterator<Object[]> find(Map<String,Object> findConditionParameterMap, CompiledCondition compiledCondition) throws ConnectionUnavailableException
Find records matching the compiled condition- Parameters:
findConditionParameterMap- map of matching StreamVariable Ids and their values corresponding to the compiled conditioncompiledCondition- the compiledCondition against which records should be matched- Returns:
- RecordIterator of matching records
- Throws:
ConnectionUnavailableException
-
contains
public boolean contains(StateEvent matchingEvent, CompiledCondition compiledCondition) throws ConnectionUnavailableException
- Specified by:
containsin classTable- Throws:
ConnectionUnavailableException
-
contains
protected abstract boolean contains(Map<String,Object> containsConditionParameterMap, CompiledCondition compiledCondition) throws ConnectionUnavailableException
Check if matching record exist- Parameters:
containsConditionParameterMap- map of matching StreamVariable Ids and their values corresponding to the compiled conditioncompiledCondition- the compiledCondition against which records should be matched- Returns:
- if matching record found or not
- Throws:
ConnectionUnavailableException
-
delete
public void delete(ComplexEventChunk<StateEvent> deletingEventChunk, CompiledCondition compiledCondition)
-
connectAndLoadCache
protected void connectAndLoadCache() throws ConnectionUnavailableException- Specified by:
connectAndLoadCachein classTable- Throws:
ConnectionUnavailableException
-
connect
protected abstract void connect() throws ConnectionUnavailableException- Throws:
ConnectionUnavailableException
-
delete
protected abstract void delete(List<Map<String,Object>> deleteConditionParameterMaps, CompiledCondition compiledCondition) throws ConnectionUnavailableException
Delete all matching records- Parameters:
deleteConditionParameterMaps- map of matching StreamVariable Ids and their values corresponding to the compiled conditioncompiledCondition- the compiledCondition against which records should be matched for deletion- Throws:
ConnectionUnavailableException
-
update
public void update(ComplexEventChunk<StateEvent> updatingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet)
-
update
protected abstract void update(CompiledCondition updateCondition, List<Map<String,Object>> updateConditionParameterMaps, Map<String,CompiledExpression> updateSetExpressions, List<Map<String,Object>> updateSetParameterMaps) throws ConnectionUnavailableException
Update all matching records- Parameters:
updateCondition- the compiledCondition against which records should be matched for updateupdateConditionParameterMaps- map of matching StreamVariable Ids and their values corresponding to the compiled condition based on which the records will be updatedupdateSetExpressions- the set of updates mappings and related complied expressionsupdateSetParameterMaps- map of matching StreamVariable Ids and their values corresponding to the- Throws:
ConnectionUnavailableException
-
updateOrAdd
public void updateOrAdd(ComplexEventChunk<StateEvent> updateOrAddingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor)
- Specified by:
updateOrAddin classTable
-
updateOrAdd
protected abstract void updateOrAdd(CompiledCondition updateCondition, List<Map<String,Object>> updateConditionParameterMaps, Map<String,CompiledExpression> updateSetExpressions, List<Map<String,Object>> updateSetParameterMaps, List<Object[]> addingRecords) throws ConnectionUnavailableException
Try updating the records if they exist else add the records- Parameters:
updateCondition- the compiledCondition against which records should be matched for updateupdateConditionParameterMaps- map of matching StreamVariable Ids and their values corresponding to the compiled condition based on which the records will be updatedupdateSetExpressions- the set of updates mappings and related complied expressionsupdateSetParameterMaps- map of matching StreamVariable Ids and their values corresponding to the update setaddingRecords- the values for adding new records if the update condition did not match- Throws:
ConnectionUnavailableException
-
compileCondition
public CompiledCondition compileCondition(io.siddhi.query.api.expression.Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String,Table> tableMap, SiddhiQueryContext siddhiQueryContext)
Description copied from interface:FindableProcessorTo construct a finder having the capability of finding events at the processor that corresponds to the incoming matchingEvent and the given matching expression logic.- Parameters:
condition- the matching conditionmatchingMetaInfoHolder- the meta structure of the incoming matchingEventvariableExpressionExecutors- the list of variable ExpressionExecutors already createdtableMap- map of event tablessiddhiQueryContext- current siddhi query context- Returns:
- compiled Condition having the capability of matching events against the incoming matchingEvent
-
compileUpdateSet
public CompiledUpdateSet compileUpdateSet(io.siddhi.query.api.execution.query.output.stream.UpdateSet updateSet, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String,Table> tableMap, SiddhiQueryContext siddhiQueryContext)
Description copied from class:TableBuilds the "compiled" set clause of an update query. Here, all the pre-processing that can be done prior to receiving the update event is done, so that such pre-processing work will not be done at each update-event-arrival.- Specified by:
compileUpdateSetin classTable- Parameters:
updateSet- the set of assignment expressions, each containing the table column to be updated and the expression to be assigned.matchingMetaInfoHolder- the meta structure of the incoming matchingEventvariableExpressionExecutors- the list of variable ExpressionExecutors already createdtableMap- map of event tablessiddhiQueryContext- current siddhi query context- Returns:
- CompiledUpdateSet
-
compileCondition
protected abstract CompiledCondition compileCondition(ExpressionBuilder expressionBuilder)
Compile the matching expression- Parameters:
expressionBuilder- helps visiting the conditions in order to compile the condition- Returns:
- compiled expression that can be used for matching events in find, contains, delete, update and updateOrAdd
-
compileSetAttribute
protected abstract CompiledExpression compileSetAttribute(ExpressionBuilder expressionBuilder)
Compiles the expression in a set clause- Parameters:
expressionBuilder- helps visiting the conditions in order to compile the condition- Returns:
- compiled expression that can be used for matching events in find, contains, delete, update and updateOrAdd
-
isStateful
public boolean isStateful()
- Specified by:
isStatefulin classTable
-
-