K
- Type of the keysV
- Type of the valuespublic class SharedBuffer<K extends Serializable,V> extends Object implements Serializable
The idea of the implementation is to have for each key a dedicated SharedBufferPage
. Each
buffer page maintains a collection of the inserted values.
The values are wrapped in a SharedBufferEntry
. The shared buffer entry 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".
Modifier and Type | Class and Description |
---|---|
static class |
SharedBuffer.SharedBufferEdge<K,V>
Versioned edge between two shared buffer entries
|
Constructor and Description |
---|
SharedBuffer(TypeSerializer<V> valueSerializer) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(K key,
V value,
long timestamp)
Checks whether the given key, value, timestamp triple is contained in the shared buffer
|
boolean |
equals(Object obj) |
Collection<com.google.common.collect.LinkedHashMultimap<K,V>> |
extractPatterns(K key,
V value,
long timestamp,
DeweyNumber version)
Returns all elements from the previous relation starting at the given value with the
given key and timestamp.
|
int |
hashCode() |
boolean |
isEmpty() |
void |
lock(K key,
V value,
long timestamp)
Increases the reference counter for the given value, key, timestamp entry so that it is not
accidentally removed.
|
void |
prune(long pruningTimestamp)
Deletes all entries in each page which have expired with respect to given pruning timestamp.
|
void |
put(K key,
V value,
long timestamp,
DeweyNumber version)
Stores given value (value + timestamp) under the given key.
|
void |
put(K key,
V value,
long timestamp,
K previousKey,
V previousValue,
long previousTimestamp,
DeweyNumber version)
Stores given value (value + timestamp) under the given key.
|
void |
release(K key,
V value,
long timestamp)
Decreases the reference counter for the given value, key, timstamp entry so that it can be
removed once the reference counter reaches 0.
|
void |
remove(K key,
V value,
long timestamp)
Removes the given value, key, timestamp entry if its reference counter is 0.
|
String |
toString() |
public SharedBuffer(TypeSerializer<V> valueSerializer)
public void put(K key, V value, long timestamp, K previousKey, V previousValue, long previousTimestamp, DeweyNumber version)
key
- Key of the current valuevalue
- Current valuetimestamp
- Timestamp of the current value (a value requires always a timestamp to make it uniquely referable))previousKey
- Key of the value for the previous relationpreviousValue
- Value for the previous relationpreviousTimestamp
- Timestamp of the value for the previous relationversion
- Version of the previous relationpublic void put(K key, V value, long timestamp, DeweyNumber version)
key
- Key of the current valuevalue
- Current valuetimestamp
- Timestamp of the current value (a value requires always a timestamp to make it uniquely referable))version
- Version of the previous relationpublic boolean contains(K key, V value, long timestamp)
key
- Key of the valuevalue
- Valuetimestamp
- Timestamp of the valuepublic boolean isEmpty()
public void prune(long pruningTimestamp)
pruningTimestamp
- The time which is used for pruning. All elements whose timestamp is
lower than the pruning timestamp will be removed.public Collection<com.google.common.collect.LinkedHashMultimap<K,V>> extractPatterns(K key, V value, long timestamp, DeweyNumber version)
key
- Key of the starting valuevalue
- Value of the starting elementtimestamp
- Timestamp of the starting valueversion
- Version of the previous relation which shall be extractedpublic void lock(K key, V value, long timestamp)
key
- Key of the value to lockvalue
- Value to locktimestamp
- Timestamp of the value to lockpublic void release(K key, V value, long timestamp)
key
- Key of the value to releasevalue
- Value to releasetimestamp
- Timestamp of the value to releasepublic void remove(K key, V value, long timestamp)
key
- Key of the value to removevalue
- Value to removetimestamp
- Timestamp of the value to remvoeCopyright © 2014–2017 The Apache Software Foundation. All rights reserved.