Class Indexer<T>


  • public class Indexer<T>
    extends java.lang.Object
    Indexer for values.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean includenull
      Include null values during indexing.
      protected java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.util.Set<T>>> indexedvalues
      The index of published values.
      static int INTERSECT_CUTOFF
      Cutoff value for building index set intersections.
      protected IKeyExtractor<T> keyextractor
      Service key extractor.
      protected java.util.Set<T> values
      All values.
    • Constructor Summary

      Constructors 
      Constructor Description
      Indexer​(IKeyExtractor<T> keyextractor, boolean includenull, java.lang.String... indextypes)
      Create a new ServiceIndexer.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addValue​(T value)
      Add a value to the indexer.
      void clear()
      Clears all contained values.
      java.util.Set<T> getAllValues()
      Returns all values.
      IKeyExtractor<T> getKeyExtractor()
      Gets the key extractor used by the service.
      java.util.Set<T> getValues​(java.lang.String keytype, java.lang.String key)
      Get values per type.
      java.util.Set<T> getValues​(java.util.List<Tuple3<java.lang.String,​java.lang.String[],​java.lang.Boolean>> spec)
      Get values per specification.
      java.util.Set<T> getValuesInverted​(java.util.List<Tuple2<java.lang.String,​java.lang.String[]>> spec)
      Get values per specification (multivalues considered as OR match, when queries are the values).
      boolean isIndexed​(java.lang.String indexname)
      Test if a property is indexed per name.
      static void main​(java.lang.String[] args)
      Main for testing.
      boolean match​(java.util.List<Tuple3<java.lang.String,​java.lang.String[],​java.lang.Boolean>> spec, T value)
      Tests if the search specification matches a value (spec=query).
      boolean matchOr​(java.util.List<Tuple2<java.lang.String,​java.lang.String[]>> spec, T value)
      Tests if the search specification matches a value (spec=service, value=query).
      void removeValue​(T value)
      Remove a value from the indexer.
      void updateIndex​(java.lang.String indexname)
      Update an index for all values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INTERSECT_CUTOFF

        public static final int INTERSECT_CUTOFF
        Cutoff value for building index set intersections.
        See Also:
        Constant Field Values
      • keyextractor

        protected IKeyExtractor<T> keyextractor
        Service key extractor.
      • values

        protected java.util.Set<T> values
        All values.
      • indexedvalues

        protected java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.util.Set<T>>> indexedvalues
        The index of published values. First string is the index key name.
      • includenull

        protected boolean includenull
        Include null values during indexing.
    • Constructor Detail

      • Indexer

        public Indexer​(IKeyExtractor<T> keyextractor,
                       boolean includenull,
                       java.lang.String... indextypes)
        Create a new ServiceIndexer.
    • Method Detail

      • isIndexed

        public boolean isIndexed​(java.lang.String indexname)
        Test if a property is indexed per name.
        Parameters:
        indexname - The index name.
        Returns:
        True, if is indexed.
      • getValues

        public java.util.Set<T> getValues​(java.util.List<Tuple3<java.lang.String,​java.lang.String[],​java.lang.Boolean>> spec)
        Get values per specification. 'And' relates to inter-term, i.e. example type=ICMS, tags=a,b means an object must have both fulfilled. For multi-valued intra-term values it can be 'and' or 'or' as well.
        Parameters:
        spec - The key values (first element is key name and array are values)
        Returns:
        The values matching the spec.
      • getValuesInverted

        public java.util.Set<T> getValuesInverted​(java.util.List<Tuple2<java.lang.String,​java.lang.String[]>> spec)
        Get values per specification (multivalues considered as OR match, when queries are the values).
        Parameters:
        spec - The key values (first element is key name and array are values)
        Returns:
        The values matching the spec.
      • getValues

        public java.util.Set<T> getValues​(java.lang.String keytype,
                                          java.lang.String key)
        Get values per type.
        Parameters:
        keytype - the key type.
        key - The key value.
        Returns:
        The values matching the key.
      • getAllValues

        public java.util.Set<T> getAllValues()
        Returns all values.
        Returns:
        All values.
      • addValue

        public void addValue​(T value)
        Add a value to the indexer.
        Parameters:
        value - The value.
      • removeValue

        public void removeValue​(T value)
        Remove a value from the indexer.
        Parameters:
        value - The value.
      • match

        public boolean match​(java.util.List<Tuple3<java.lang.String,​java.lang.String[],​java.lang.Boolean>> spec,
                             T value)
        Tests if the search specification matches a value (spec=query).
        Parameters:
        value - The value.
        Returns:
        True, if the value matches.
      • matchOr

        public boolean matchOr​(java.util.List<Tuple2<java.lang.String,​java.lang.String[]>> spec,
                               T value)
        Tests if the search specification matches a value (spec=service, value=query).
        Parameters:
        value - The value.
        Returns:
        True, if the value matches.
      • getKeyExtractor

        public IKeyExtractor<T> getKeyExtractor()
        Gets the key extractor used by the service.
        Returns:
        The key extractor.
      • clear

        public void clear()
        Clears all contained values.
      • updateIndex

        public void updateIndex​(java.lang.String indexname)
        Update an index for all values.
      • main

        public static void main​(java.lang.String[] args)
        Main for testing.