Class KVNavigableSet

All Implemented Interfaces:
Iterable<byte[]>, Collection<byte[]>, NavigableSet<byte[]>, Set<byte[]>, SortedSet<byte[]>

public class KVNavigableSet extends AbstractKVNavigableSet<byte[]>
A NavigableSet view of the keys in a KVStore.

Instances are mutable, with these exceptions:

  • Constructor Details

    • KVNavigableSet

      public KVNavigableSet(KVStore kv)
      Constructor for when there are no range restrictions.
      Parameters:
      kv - underlying KVStore
    • KVNavigableSet

      public KVNavigableSet(KVStore kv, byte[] prefix)
      Constructor for when the range of visible KVStore keys is all keys sharing a given byte[] prefix.
      Parameters:
      kv - underlying KVStore
      prefix - prefix defining minimum and maximum keys
      Throws:
      NullPointerException - if prefix is null
    • KVNavigableSet

      protected KVNavigableSet(KVStore kv, boolean reversed, KeyRange keyRange, KeyFilter keyFilter)
      Primary constructor.
      Parameters:
      kv - underlying KVStore
      reversed - whether ordering is reversed
      keyRange - key range restriction, or null for none
      keyFilter - key filter, or null for none
      Throws:
      IllegalArgumentException - if kv is null
  • Method Details

    • comparator

      public Comparator<byte[]> comparator()
    • remove

      public boolean remove(Object obj)
      Description copied from class: AbstractNavigableSet
      Removes the given element from this set if it is present.

      The implementation in AbstractNavigableSet always throws UnsupportedOperationException.

      Specified by:
      remove in interface Collection<byte[]>
      Specified by:
      remove in interface Set<byte[]>
      Overrides:
      remove in class AbstractNavigableSet<byte[]>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<byte[]>
      Specified by:
      clear in interface Set<byte[]>
      Overrides:
      clear in class AbstractCollection<byte[]>
    • encode

      protected void encode(ByteWriter writer, Object obj)
      Description copied from class: AbstractKVNavigableSet
      Encode the given object into a byte[] key. Note that this method must throw IllegalArgumentException, not ClassCastException or NullPointerException, if obj does not have the correct type or is an illegal null value.
      Specified by:
      encode in class AbstractKVNavigableSet<byte[]>
      Parameters:
      writer - output for encoded byte[] key corresponding to obj
      obj - set element
    • decode

      protected byte[] decode(ByteReader reader)
      Description copied from class: AbstractKVNavigableSet
      Decode an element from a byte[] key.

      If not in prefix mode, all of reader must be consumed; otherwise, the consumed portion is the prefix and any following keys with the same prefix are ignored.

      Specified by:
      decode in class AbstractKVNavigableSet<byte[]>
      Parameters:
      reader - input for encoded bytes
      Returns:
      decoded set element
    • createSubSet

      protected NavigableSet<byte[]> createSubSet(boolean newReversed, KeyRange newKeyRange, KeyFilter newKeyFilter, Bounds<byte[]> newBounds)
      Description copied from class: AbstractKVNavigableSet
      Create a (possibly reversed) view of this instance with (possibly) tighter lower and/or upper bounds and the given KeyFilter, if any. The bounds are consistent with the reversed ordering (i.e., reversed if reverse is true) and have already been range-checked against this instance's bounds.
      Specified by:
      createSubSet in class AbstractKVNavigableSet<byte[]>
      Parameters:
      newReversed - whether the new set's ordering should be reversed (implies newBounds are also inverted, but not keyRange); note: means "absolutely" reversed, not relative to this instance
      newKeyRange - new key range, or null for none; will be consistent with bounds, if any
      newKeyFilter - new key filter, or null for none
      newBounds - new bounds
      Returns:
      restricted and/or filtered view of this instance