Interface Indexer<Tuple_ extends Tuple,Value_>
-
- Type Parameters:
Tuple_- For example forfrom(A).join(B), the tuple isUniTuple<A>xorUniTuple<B>. For example forBi<A, B>.join(C), the tuple isBiTuple<A, B>xorUniTuple<C>.Value_- For example forfrom(A).join(B), the value isSet<BiTuple<A, B>>. For example forBi<A, B>.join(C), the value isSet<TriTuple<A, B, C>>.
public interface Indexer<Tuple_ extends Tuple,Value_>An indexer for entity or factX, maps a property or a combination of properties ofX, denoted byindexProperties, to all instances ofXthat match those properties, depending on the the indexer type (equal, lower than, ...). For example for{Lesson(id=1, room=A), Lesson(id=2, room=B), Lesson(id=3, room=A)}, callingget(room=A)would return a map with a keySet of lesson 1 and 3.It returns a
Map<X, V>instead ofSet<X>for performance, to avoid doing the same hash lookup twice in the client. For exampleJoinBiNodeuses the value to store a set of child tuples justified by the X instance.The fact X is wrapped in a Tuple, because the
BavetTupleStateis needed by clients of#visit(IndexProperties, Consumer).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanisEmpty()voidput(IndexProperties indexProperties, Tuple_ tuple, Value_ value)Differs fromMap.put(Object, Object)because it fails if the key already exists.Value_remove(IndexProperties indexProperties, Tuple_ tuple)Differs fromMap.remove(Object)because it fails if the key does not exist.voidvisit(IndexProperties indexProperties, BiConsumer<Tuple_,Value_> tupleValueMapEntryVisitor)
-
-
-
Method Detail
-
put
void put(IndexProperties indexProperties, Tuple_ tuple, Value_ value)
Differs fromMap.put(Object, Object)because it fails if the key already exists.- Parameters:
indexProperties- never nulltuple- never nullvalue- never null- Throws:
IllegalStateException- if the indexProperties-tuple key already exists
-
remove
Value_ remove(IndexProperties indexProperties, Tuple_ tuple)
Differs fromMap.remove(Object)because it fails if the key does not exist.- Parameters:
indexProperties- never nulltuple- never null- Returns:
- never null
- Throws:
IllegalStateException- if the indexProperties-tuple key didn't exist
-
visit
void visit(IndexProperties indexProperties, BiConsumer<Tuple_,Value_> tupleValueMapEntryVisitor)
- Parameters:
indexProperties- never nulltupleValueMapEntryVisitor- never null
-
isEmpty
boolean isEmpty()
-
-