Interface Indexer<Tuple_ extends Tuple,​Value_>

  • Type Parameters:
    Tuple_ - For example for from(A).join(B), the tuple is UniTuple<A> xor UniTuple<B>. For example for Bi<A, B>.join(C), the tuple is BiTuple<A, B> xor UniTuple<C>.
    Value_ - For example for from(A).join(B), the value is Set<BiTuple<A, B>>. For example for Bi<A, B>.join(C), the value is Set<TriTuple<A, B, C>>.
    All Known Implementing Classes:
    EqualsAndComparisonIndexer, EqualsIndexer, NoneIndexer

    public interface Indexer<Tuple_ extends Tuple,​Value_>
    An indexer for entity or fact X, maps a property or a combination of properties of X, denoted by indexProperties, to all instances of X that 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)}, calling get(room=A) would return a map with a keySet of lesson 1 and 3.

    It returns a Map<X, V> instead of Set<X> for performance, to avoid doing the same hash lookup twice in the client. For example JoinBiNode uses the value to store a set of child tuples justified by the X instance.

    The fact X is wrapped in a Tuple, because the BavetTupleState is needed by clients of get(Object[]).

    • Method Detail

      • put

        void put​(Object[] indexProperties,
                 Tuple_ tuple,
                 Value_ value)
        Differs from Map.put(Object, Object) because it fails if the key already exists.
        Parameters:
        indexProperties - never null
        tuple - never null
        value - never null
        Throws:
        IllegalStateException - if the indexProperties-tuple key already exists
      • remove

        Value_ remove​(Object[] indexProperties,
                      Tuple_ tuple)
        Differs from Map.remove(Object) because it fails if the key does not exist.
        Parameters:
        indexProperties - never null
        tuple - never null
        Returns:
        never null
        Throws:
        IllegalStateException - if the indexProperties-tuple key didn't exist
      • get

        Map<Tuple_,​Value_> get​(Object[] indexProperties)
        Parameters:
        indexProperties - never null
        Returns:
        never null