V
- Type of the valuespublic class SharedBuffer<V> extends Object
The idea of the implementation is to have a buffer for incoming events with unique ids assigned to them. This way we do not need to deserialize events during processing and we store only one copy of the event.
The entries in SharedBuffer
are SharedBufferNode
. The shared buffer node allows to store
relations between different entries. A dewey versioning scheme allows to discriminate between
different relations (e.g. preceding element).
The implementation is strongly based on the paper "Efficient Pattern Matching over Event Streams".
Constructor and Description |
---|
SharedBuffer(KeyedStateStore stateStore,
TypeSerializer<V> valueSerializer) |
Modifier and Type | Method and Description |
---|---|
void |
advanceTime(long timestamp)
Notifies shared buffer that there will be no events with timestamp <&eq; the given value.
|
List<Map<String,List<EventId>>> |
extractPatterns(NodeId nodeId,
DeweyNumber version)
Returns all elements from the previous relation starting at the given entry.
|
void |
init(Map<EventId,Lockable<V>> events,
Map<NodeId,Lockable<SharedBufferNode>> entries)
Deprecated.
Only for state migration!
|
boolean |
isEmpty()
Checks if there is no elements in the buffer.
|
void |
lockNode(NodeId node)
Increases the reference counter for the given entry so that it is not
accidentally removed.
|
Map<String,List<V>> |
materializeMatch(Map<String,List<EventId>> match) |
Map<String,List<V>> |
materializeMatch(Map<String,List<EventId>> match,
Map<EventId,V> cache) |
NodeId |
put(String stateName,
EventId eventId,
NodeId previousNodeId,
DeweyNumber version)
Stores given value (value + timestamp) under the given state.
|
EventId |
registerEvent(V value,
long timestamp)
Adds another unique event to the shared buffer and assigns a unique id for it.
|
void |
releaseEvent(EventId eventId)
Decreases the reference counter for the given event so that it can be
removed once the reference counter reaches 0.
|
void |
releaseNode(NodeId node)
Decreases the reference counter for the given entry so that it can be
removed once the reference counter reaches 0.
|
public SharedBuffer(KeyedStateStore stateStore, TypeSerializer<V> valueSerializer)
public void advanceTime(long timestamp) throws Exception
timestamp
- watermark, no earlier events will arriveException
- Thrown if the system cannot access the state.public EventId registerEvent(V value, long timestamp) throws Exception
ComputationState
s
NOTE:Should be called only once for each unique event!
value
- event to be registeredException
- Thrown if the system cannot access the state.@Deprecated public void init(Map<EventId,Lockable<V>> events, Map<NodeId,Lockable<SharedBufferNode>> entries) throws Exception
events
- map of events with assigned unique idsentries
- map of SharedBufferNodesException
- Thrown if the system cannot access the state.public NodeId put(String stateName, EventId eventId, @Nullable NodeId previousNodeId, DeweyNumber version) throws Exception
stateName
- name of the state that the event should be assigned toeventId
- unique id of event assigned by this SharedBufferpreviousNodeId
- id of previous entry (might be null if start of new run)version
- Version of the previous relationException
- Thrown if the system cannot access the state.public boolean isEmpty() throws Exception
Exception
- Thrown if the system cannot access the state.public List<Map<String,List<EventId>>> extractPatterns(NodeId nodeId, DeweyNumber version) throws Exception
nodeId
- id of the starting entryversion
- Version of the previous relation which shall be extractedException
- Thrown if the system cannot access the state.public Map<String,List<V>> materializeMatch(Map<String,List<EventId>> match, Map<EventId,V> cache)
public void lockNode(NodeId node) throws Exception
node
- id of the entryException
- Thrown if the system cannot access the state.public void releaseNode(NodeId node) throws Exception
node
- id of the entryException
- Thrown if the system cannot access the state.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.