Interface QueryMap<K,V>

Type Parameters:
K - the type of the Map entry keys
V - the type of the Map entry values
All Superinterfaces:
Map<K,V>
All Known Subinterfaces:
NamedCache<K,V>, NamedMap<K,V>
All Known Implementing Classes:
BundlingNamedCache, ContinuousQueryCache, ConverterCollections.ConverterNamedCache, ConverterCollections.ConverterQueryMap, NearCache, ReadonlyNamedCache, VersionedNearCache, WrapperNamedCache

public interface QueryMap<K,V> extends Map<K,V>
Map with additional query features.
Author:
gg 2002.09.24, as 2014.08.05
  • Method Details

    • keySet

      Set<K> keySet(Filter filter)
      Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter.

      Unlike the Map.keySet() method, the set returned by this method may not be backed by the map, so changes to the set may not reflected in the map, and vice-versa.

      Note: The Partitioned Cache implements the QueryMap interface using the Parallel Query feature.

      Parameters:
      filter - the Filter object representing the criteria that the entries of this map should satisfy
      Returns:
      a set of keys for entries that satisfy the specified criteria
    • entrySet

      Set<Map.Entry<K,V>> entrySet(Filter filter)
      Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. Each element in the returned set is a Map.Entry.

      Unlike the Map.entrySet() method, the set returned by this method may not be backed by the map, so changes to the set may not be reflected in the map, and vice-versa.

      Note: The Partitioned Cache implements the QueryMap interface using the Parallel Query feature.

      Parameters:
      filter - the Filter object representing the criteria that the entries of this map should satisfy
      Returns:
      a set of entries that satisfy the specified criteria
    • entrySet

      Set<Map.Entry<K,V>> entrySet(Filter filter, Comparator comparator)
      Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. Each element in the returned set is a Map.Entry. It is further guaranteed that its iterator will traverse the set in such a way that the entry values come up in ascending order, sorted by the specified Comparator or according to the natural ordering (see Comparable).

      Unlike the Map.entrySet() method, the set returned by this method may not be backed by the map, so changes to the set may not be reflected in the map, and vice-versa.

      Note: The Partitioned Cache implements the QueryMap interface using the Parallel Query feature.

      Parameters:
      filter - the Filter object representing the criteria that the entries of this map should satisfy
      comparator - the Comparator object which imposes an ordering on entries in the resulting set; or null if the entries' values natural ordering should be used
      Returns:
      a set of entries that satisfy the specified criteria
      See Also:
    • values

      default Collection<V> values(Filter filter)
      Return a collection of the values contained in this map that satisfy the criteria expressed by the filter.

      Unlike the Map.values() method, the collection returned by this method may not be backed by the map, so changes to the collection may not be reflected in the map, and vice-versa.

      Note: The Partitioned Cache implements the QueryMap interface using the Parallel Query feature.

      Parameters:
      filter - the Filter object representing the criteria that the entries of this map should satisfy
      Returns:
      a collection of values for entries that satisfy the specified criteria
    • values

      default Collection<V> values(Filter filter, Comparator comparator)
      Return a collection of the values contained in this map that satisfy the criteria expressed by the filter.

      Unlike the Map.values() method, the collection returned by this method may not be backed by the map, so changes to the collection may not be reflected in the map, and vice-versa.

      Note: The Partitioned Cache implements the QueryMap interface using the Parallel Query feature.

      Parameters:
      filter - the Filter object representing the criteria that the entries of this map should satisfy
      comparator - the Comparator object which imposes an ordering on entries in the resulting set; or null if the entries' values natural ordering should be used
      Returns:
      a collection of values for entries that satisfy the specified criteria
      See Also:
    • addIndex

      <T, E> void addIndex(ValueExtractor<? super T,? extends E> extractor, boolean fOrdered, Comparator<? super E> comparator)
      Add an index to this QueryMap. This allows to correlate values stored in this indexed Map (or attributes of those values) to the corresponding keys in the indexed Map and increase the performance of methods that use Filters.

      The ordering maintained by this map (as determined by either the specified Comparator or the natural ordering of the indexed values) must be consistent with equals (see Comparable or Comparator for a precise definition of consistent with equals.)

      This method is only intended as a hint to the map implementation, and as such it may be ignored by the map if indexes are not supported or if the desired index (or a similar index) already exists. It is expected that an application will call this method to suggest an index even if the index may already exist, just so that the application is certain that index has been suggested. For example in a distributed environment, each server will likely suggest the same set of indexes when it starts, and there is no downside to the application blindly requesting those indexes regardless of whether another server has already requested the same indexes.

      Type Parameters:
      T - the type of the value to extract from
      E - the type of value that will be extracted
      Parameters:
      extractor - the ValueExtractor object that is used to extract an indexable Object from a value stored in the indexed Map. Must not be null.
      fOrdered - true iff the contents of the indexed information should be ordered; false otherwise
      comparator - the Comparator object which imposes an ordering on entries in the indexed map; or null if the entries' values natural ordering should be used
      See Also:
    • addIndex

      default <T, E> void addIndex(ValueExtractor<? super T,? extends E> extractor)
      Add an unordered index to this QueryMap. This allows to correlate values stored in this indexed Map (or attributes of those values) to the corresponding keys in the indexed Map and increase the performance of methods that use Filters.

      This method is only intended as a hint to the map implementation, and as such it may be ignored by the map if indexes are not supported or if the desired index (or a similar index) already exists. It is expected that an application will call this method to suggest an index even if the index may already exist, just so that the application is certain that index has been suggested. For example in a distributed environment, each server will likely suggest the same set of indexes when it starts, and there is no downside to the application blindly requesting those indexes regardless of whether another server has already requested the same indexes.

      Type Parameters:
      T - the type of the value to extract from
      E - the type of value that will be extracted
      Parameters:
      extractor - the ValueExtractor object that is used to extract an indexable Object from a value stored in the indexed Map. Must not be null.
      See Also:
    • removeIndex

      <T, E> void removeIndex(ValueExtractor<? super T,? extends E> extractor)
      Remove an index from this QueryMap.
      Type Parameters:
      T - the type of the value to extract from
      E - the type of value that will be extracted
      Parameters:
      extractor - the ValueExtractor object that is used to extract an indexable Object from a value stored in the Map.
    • forEach

      default void forEach(BiConsumer<? super K,? super V> action)
      Perform the given action for each entry in this map until all entries have been processed or the action throws an exception.

      Exceptions thrown by the action are relayed to the caller.

      The implementation processes each entry on the client and should only be used for read-only client-side operations (such as adding map entries to a UI widget, for example).

      Any entry mutation caused by the specified action will not be propagated to the server when this method is called on a distributed map, so it should be avoided. The mutating operations on a subset of entries should be implemented using one of InvocableMap.invokeAll(com.tangosol.util.InvocableMap.EntryProcessor<K, V, R>), Map.replaceAll(java.util.function.BiFunction<? super K, ? super V, ? extends V>), Map.compute(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>), or Map.merge(K, V, java.util.function.BiFunction<? super V, ? super V, ? extends V>) methods instead.

      Specified by:
      forEach in interface Map<K,V>
      Parameters:
      action - the action to be performed for each entry
      Since:
      12.2.1
    • forEach

      default void forEach(Filter filter, BiConsumer<? super K,? super V> action)
      Perform the given action for each entry selected by the specified filter until all entries have been processed or the action throws an exception.

      Exceptions thrown by the action are relayed to the caller.

      The implementation processes each entry on the client and should only be used for read-only client-side operations (such as adding map entries to a UI widget, for example).

      Any entry mutation caused by the specified action will not be propagated to the server when this method is called on a distributed map, so it should be avoided. The mutating operations on a subset of entries should be implemented using one of InvocableMap.invokeAll(com.tangosol.util.InvocableMap.EntryProcessor<K, V, R>), Map.replaceAll(java.util.function.BiFunction<? super K, ? super V, ? extends V>), Map.compute(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>), or Map.merge(K, V, java.util.function.BiFunction<? super V, ? super V, ? extends V>) methods instead.

      Parameters:
      filter - the filter that should be used to select entries
      action - the action to be performed for each entry
      Since:
      12.2.1