Package ca.uqac.lif.cep.tuples
Class TupleFixed
java.lang.Object
ca.uqac.lif.cep.tuples.Tuple
ca.uqac.lif.cep.tuples.TupleFixed
Implementation of a named tuple. Contrarily to a
TupleMap,
a fixed tuple assumes stronger hypotheses on its use in order to
reduce memory usage and decrease response time.
- After its instantiation, the object is immutable: all
its fields are declared
private finaland no method can ever change their value. (As a matter of fact, all its methods are alsofinal.) This entails that methods that normally should be able to modify the contents of a Map (e.g.put()orclear()here have no effect. - Internally, the tuple uses plain arrays (instead of a
HashMap) for storing keys and values. For tuples with, a small number of keys, this should actually provide faster access than a HashMap. In all cases, arrays use up less memory than a HashMap. - Because of this, one can also ask for the index of a key/value pair, and obtain a value based on its index (rather than its key). Assuming that all tuples in a stream have their key/value pairs arranged in the same order, this means one can ask for the index of a key a first time, and from that point on query the remaining tuples by directly providing the index.
The process can be further optimized by using the
FixedTupleBuilder class to build a stream of tuples that all follow
the same schema.
Note that if these constraints are not suitable for your processing,
you should use the "regular" TupleMap class that gives you
much more flexibility (possibly at the expense of some overhead).
- Author:
- Sylvain Hallé
-
Nested Class Summary
Nested classes/interfaces inherited from class ca.uqac.lif.cep.tuples.Tuple
Tuple.MapEntry<K,V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclear()final booleancontainsKey(Object key) final booleancontainsValue(Object value) duplicate(boolean with_state) entrySet()booleanfinal Objectfinal intgetIndexOf(String s) final ObjectgetValue(int index) inthashCode()final booleanisEmpty()keySet()final Tuplefinal voidfinal Tuplefinal intsize()toString()final Collection<Object> values()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ca.uqac.lif.cep.Duplicable
duplicateMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
TupleFixed
-
-
Method Details
-
clear
public final void clear() -
containsKey
- Specified by:
containsKeyin interfaceMap<String,Object>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,Object>
-
entrySet
-
get
-
getValue
-
getIndexOf
-
isEmpty
public final boolean isEmpty() -
keySet
-
put
-
putAll
-
remove
-
size
public final int size() -
values
-
toString
-
duplicate
-
equals
-
hashCode
public int hashCode()
-