Class TupleFixed

java.lang.Object
ca.uqac.lif.cep.tuples.Tuple
ca.uqac.lif.cep.tuples.TupleFixed
All Implemented Interfaces:
ca.uqac.lif.cep.Duplicable, Map<String,Object>

public final class TupleFixed extends Tuple implements ca.uqac.lif.cep.Duplicable
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 final and no method can ever change their value. (As a matter of fact, all its methods are also final.) This entails that methods that normally should be able to modify the contents of a Map (e.g. put() or clear() 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é