Package io.siddhi.core.table.record
Class AbstractQueryableRecordTable
- java.lang.Object
-
- io.siddhi.core.table.Table
-
- io.siddhi.core.table.record.AbstractRecordTable
-
- io.siddhi.core.table.record.AbstractQueryableRecordTable
-
- All Implemented Interfaces:
FindableProcessor,QueryableProcessor,MemoryCalculable
public abstract class AbstractQueryableRecordTable extends AbstractRecordTable implements QueryableProcessor
An abstract implementation of table. Abstract implementation will handleComplexEventChunkso that developer can directly work with event data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAbstractQueryableRecordTable.CompiledSelectionWithCacheclass to hold both store compile selection and cache compile selection wrappedclassAbstractQueryableRecordTable.OrderByAttributeBuilderHolder of order by attribute with order orientationclassAbstractQueryableRecordTable.SelectAttributeBuilderHolder of Selection attribute with renaming field-
Nested classes/interfaces inherited from class io.siddhi.core.table.Table
Table.OnErrorAction
-
-
Field Summary
Fields Modifier and Type Field Description protected StateEventcontainsMatchingEventprotected StateEventfindMatchingEventprotected MatchingMetaInfoHoldermatchingMetaInfoHolderForTestOnDemandQuerystatic ThreadLocal<Boolean>queryStoreWithoutCheckingCacheprotected io.siddhi.query.api.execution.query.selection.SelectorselectorForTestOnDemandQueryprotected SiddhiQueryContextsiddhiQueryContextForTestOnDemandQuery-
Fields inherited from class io.siddhi.core.table.record.AbstractRecordTable
recordTableHandler, storeEventPool
-
Fields inherited from class io.siddhi.core.table.Table
siddhiAppContext, tableDefinition, tableMap
-
-
Constructor Summary
Constructors Constructor Description AbstractQueryableRecordTable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(ComplexEventChunk<StreamEvent> addingEventChunk)CompiledConditioncompileCondition(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.CompiledSelectioncompileSelection(io.siddhi.query.api.execution.query.selection.Selector selector, List<io.siddhi.query.api.definition.Attribute> expectedOutputAttributes, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String,Table> tableMap, SiddhiQueryContext siddhiQueryContext)To construct a selection having the capability of transforming events based on given selection logic.protected abstract CompiledSelectioncompileSelection(List<AbstractQueryableRecordTable.SelectAttributeBuilder> selectAttributeBuilders, List<ExpressionBuilder> groupByExpressionBuilder, ExpressionBuilder havingExpressionBuilder, List<AbstractQueryableRecordTable.OrderByAttributeBuilder> orderByAttributeBuilders, Long limit, Long offset)Compile the query selectionCompiledUpdateSetcompileUpdateSet(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 voidconnectAndLoadCache()booleancontains(StateEvent matchingEvent, CompiledCondition compiledCondition)voiddelete(ComplexEventChunk<StateEvent> deletingEventChunk, CompiledCondition compiledCondition)StreamEventfind(CompiledCondition compiledCondition, StateEvent matchingEvent)voidhandleCacheExpiry(CompiledCondition cacheExpiryCompiledCondition, ComplexEventChunk<StateEvent> deleteEventChunk)voidinitCache(io.siddhi.query.api.definition.TableDefinition tableDefinition, SiddhiAppContext siddhiAppContext, StreamEventCloner storeEventCloner, ConfigReader configReader)StreamEventquery(StateEvent matchingEvent, CompiledCondition compiledCondition, CompiledSelection compiledSelection)To find events from the processor event pool, that the matches the matchingEvent based on finder logic and return them based on the defined selection.StreamEventquery(StateEvent matchingEvent, CompiledCondition compiledCondition, CompiledSelection compiledSelection, io.siddhi.query.api.definition.Attribute[] outputAttributes)To find events from the processor event pool, that the matches the matchingEvent based on finder logic and return them based on the defined selection.protected abstract RecordIterator<Object[]>query(Map<String,Object> parameterMap, CompiledCondition compiledCondition, CompiledSelection compiledSelection, io.siddhi.query.api.definition.Attribute[] outputAttributes)Query records matching the compiled condition and selectionvoidupdate(ComplexEventChunk<StateEvent> updatingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet)voidupdateOrAdd(ComplexEventChunk<StateEvent> updateOrAddingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor)-
Methods inherited from class io.siddhi.core.table.record.AbstractRecordTable
add, compileCondition, compileSetAttribute, connect, contains, delete, find, getTableDefinition, init, init, isStateful, update, updateOrAdd
-
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.siddhi.core.query.processor.stream.window.FindableProcessor
find
-
-
-
-
Field Detail
-
queryStoreWithoutCheckingCache
public static ThreadLocal<Boolean> queryStoreWithoutCheckingCache
-
findMatchingEvent
protected StateEvent findMatchingEvent
-
selectorForTestOnDemandQuery
protected io.siddhi.query.api.execution.query.selection.Selector selectorForTestOnDemandQuery
-
siddhiQueryContextForTestOnDemandQuery
protected SiddhiQueryContext siddhiQueryContextForTestOnDemandQuery
-
matchingMetaInfoHolderForTestOnDemandQuery
protected MatchingMetaInfoHolder matchingMetaInfoHolderForTestOnDemandQuery
-
containsMatchingEvent
protected StateEvent containsMatchingEvent
-
-
Method Detail
-
initCache
public void initCache(io.siddhi.query.api.definition.TableDefinition tableDefinition, SiddhiAppContext siddhiAppContext, StreamEventCloner storeEventCloner, ConfigReader configReader)- Overrides:
initCachein classAbstractRecordTable
-
connectAndLoadCache
protected void connectAndLoadCache() throws ConnectionUnavailableException- Overrides:
connectAndLoadCachein classAbstractRecordTable- Throws:
ConnectionUnavailableException
-
query
public StreamEvent query(StateEvent matchingEvent, CompiledCondition compiledCondition, CompiledSelection compiledSelection) throws ConnectionUnavailableException
Description copied from interface:QueryableProcessorTo find events from the processor event pool, that the matches the matchingEvent based on finder logic and return them based on the defined selection.- Specified by:
queryin interfaceQueryableProcessor- Parameters:
matchingEvent- the event to be matched with the events at the processorcompiledCondition- the execution element responsible for matching the corresponding events that matches the matchingEvent based on pool of events at ProcessorcompiledSelection- the execution element responsible for transforming the corresponding events to the given selection- Returns:
- the matched events
- Throws:
ConnectionUnavailableException
-
add
public void add(ComplexEventChunk<StreamEvent> addingEventChunk)
- Overrides:
addin classAbstractRecordTable
-
delete
public void delete(ComplexEventChunk<StateEvent> deletingEventChunk, CompiledCondition compiledCondition)
- Overrides:
deletein classAbstractRecordTable
-
update
public void update(ComplexEventChunk<StateEvent> updatingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet)
- Overrides:
updatein classAbstractRecordTable
-
contains
public boolean contains(StateEvent matchingEvent, CompiledCondition compiledCondition) throws ConnectionUnavailableException
- Overrides:
containsin classAbstractRecordTable- Throws:
ConnectionUnavailableException
-
updateOrAdd
public void updateOrAdd(ComplexEventChunk<StateEvent> updateOrAddingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor)
- Overrides:
updateOrAddin classAbstractRecordTable
-
find
public StreamEvent find(CompiledCondition compiledCondition, StateEvent matchingEvent) throws ConnectionUnavailableException
- Overrides:
findin classAbstractRecordTable- Throws:
ConnectionUnavailableException
-
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.- Overrides:
compileUpdateSetin classAbstractRecordTable- 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
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.- Specified by:
compileConditionin interfaceFindableProcessor- Overrides:
compileConditionin classAbstractRecordTable- 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
-
query
public StreamEvent query(StateEvent matchingEvent, CompiledCondition compiledCondition, CompiledSelection compiledSelection, io.siddhi.query.api.definition.Attribute[] outputAttributes) throws ConnectionUnavailableException
Description copied from interface:QueryableProcessorTo find events from the processor event pool, that the matches the matchingEvent based on finder logic and return them based on the defined selection.- Specified by:
queryin interfaceQueryableProcessor- Parameters:
matchingEvent- the event to be matched with the events at the processorcompiledCondition- the execution element responsible for matching the corresponding events that matches the matchingEvent based on pool of events at ProcessorcompiledSelection- the execution element responsible for transforming the corresponding events to the given selectionoutputAttributes- the output attributes specified in the query.- Returns:
- the matched events
- Throws:
ConnectionUnavailableException
-
query
protected abstract RecordIterator<Object[]> query(Map<String,Object> parameterMap, CompiledCondition compiledCondition, CompiledSelection compiledSelection, io.siddhi.query.api.definition.Attribute[] outputAttributes) throws ConnectionUnavailableException
Query records matching the compiled condition and selection- Parameters:
parameterMap- map of matching StreamVariable Ids and their values corresponding to the compiled condition and selectioncompiledCondition- the compiledCondition against which records should be matchedcompiledSelection- the compiledSelection that maps records based to requested format- Returns:
- RecordIterator of matching records
- Throws:
ConnectionUnavailableException
-
compileSelection
public CompiledSelection compileSelection(io.siddhi.query.api.execution.query.selection.Selector selector, List<io.siddhi.query.api.definition.Attribute> expectedOutputAttributes, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String,Table> tableMap, SiddhiQueryContext siddhiQueryContext)
Description copied from interface:QueryableProcessorTo construct a selection having the capability of transforming events based on given selection logic.- Specified by:
compileSelectionin interfaceQueryableProcessor- Parameters:
selector- the query selectormatchingMetaInfoHolder- the meta structure of the incoming matchingEventvariableExpressionExecutors- the list of variable ExpressionExecutors already createdtableMap- map of event tablessiddhiQueryContext- current siddhi query context- Returns:
- compiled Selection having the capability of transforming events based on the selection
-
compileSelection
protected abstract CompiledSelection compileSelection(List<AbstractQueryableRecordTable.SelectAttributeBuilder> selectAttributeBuilders, List<ExpressionBuilder> groupByExpressionBuilder, ExpressionBuilder havingExpressionBuilder, List<AbstractQueryableRecordTable.OrderByAttributeBuilder> orderByAttributeBuilders, Long limit, Long offset)
Compile the query selection- Parameters:
selectAttributeBuilders- helps visiting the select attributes in ordergroupByExpressionBuilder- helps visiting the group by attributes in orderhavingExpressionBuilder- helps visiting the having conditionorderByAttributeBuilders- helps visiting the order by attributes in orderlimit- defines the limit leveloffset- defines the offset level- Returns:
- compiled selection that can be used for retrieving events on a defined format
-
handleCacheExpiry
public void handleCacheExpiry(CompiledCondition cacheExpiryCompiledCondition, ComplexEventChunk<StateEvent> deleteEventChunk)
-
-