Class UnsafeOneToManyIndex<K,V>

java.lang.Object
com.atlassian.bamboo.plan.cache.index.util.unsafe.UnsafeOneToManyIndex<K,V>

@Internal public class UnsafeOneToManyIndex<K,V> extends Object
A class that allows to index any key <-> value, one-to-many relationship. The key characteristics of this class is that, unlike Multimap<K,V>, it doesn't require linear scan when removing by value. Both K and V must have hashCode() and equals() correctly defined.

The class is _not_ thread safe.

  • Constructor Details

    • UnsafeOneToManyIndex

      public UnsafeOneToManyIndex()
  • Method Details

    • addToIndex

      public void addToIndex(@NotNull K key, @NotNull V value)
      To be used when you can be sure no prior mapping exists for the value.
    • index

      public void index(@NotNull K key, @NotNull V value)
    • reindex

      public void reindex(@NotNull K key, @NotNull V value)
      Replace key value pair with a new value. This is useful if value object can change content without changing identity.
    • reindexSet

      @Nullable public @Nullable Set<V> reindexSet(@NotNull K key, @NotNull @NotNull Set<V> values)
      Replace complete value set for a key.
      Returns:
      the old set
    • getForwardMapping

      @NotNull public @NotNull Map<K,Set<V>> getForwardMapping()
    • getBackwardMapping

      @NotNull public @NotNull Map<V,K> getBackwardMapping()
    • removeByKey

      @Nullable public @Nullable Set<V> removeByKey(@NotNull K key)
    • removeByValue

      @Nullable public K removeByValue(@NotNull V value)
    • removeMatchingValuesForKey

      public void removeMatchingValuesForKey(@NotNull K key, @NotNull @NotNull Predicate<V> predicate)
    • getByKey

      @NotNull public @NotNull Set<V> getByKey(@NotNull K key)
    • getByKeyUnsafe

      @NotNull public @NotNull Set<V> getByKeyUnsafe(@NotNull K key)
      Does not perform a copy, can only be used in context that are thread safe from perspective of this object
    • getByValue

      @Nullable public K getByValue(@NotNull V value)
    • clear

      public void clear()