Package io.permazen.kv.util
Class KVNavigableSet
java.lang.Object
- All Implemented Interfaces:
Iterable<ByteData>,Collection<ByteData>,NavigableSet<ByteData>,Set<ByteData>,SortedSet<ByteData>
-
Field Summary
Fields inherited from class io.permazen.kv.util.AbstractKVNavigableSet
keyFilter, keyRange, kv, prefixMode, reversedFields inherited from class io.permazen.util.AbstractNavigableSet
bounds -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor for when there are no range restrictions.protectedKVNavigableSet(KVStore kv, boolean reversed, KeyRange keyRange, KeyFilter keyFilter) Primary constructor.KVNavigableSet(KVStore kv, ByteData prefix) Constructor for when the range of visibleKVStorekeys is all keys sharing a givenbyte[]prefix. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()protected NavigableSet<ByteData>createSubSet(boolean newReversed, KeyRange newKeyRange, KeyFilter newKeyFilter, Bounds<ByteData> newBounds) Create a (possibly reversed) view of this instance with (possibly) tighter lower and/or upper bounds and the givenKeyFilter, if any.protected ByteDatadecode(ByteData.Reader reader) Decode an element from abyte[]key.protected voidencode(ByteData.Writer writer, Object obj) Encode the given object into abyte[]key.booleanRemoves the given element from this set if it is present.Methods inherited from class io.permazen.kv.util.AbstractKVNavigableSet
contains, createSubSet, encodeVisible, filterKeys, first, isEmpty, isVisible, isWithinLowerBound, isWithinUpperBound, iterator, last, pollFirst, pollLastMethods inherited from class io.permazen.util.AbstractNavigableSet
buildSpliterator, ceiling, descendingIterator, descendingSet, floor, getBounds, getComparator, headSet, headSet, higher, lower, searchAbove, searchBelow, subSet, subSet, tailSet, tailSetMethods inherited from class io.permazen.util.AbstractIterationSet
equals, hashCode, size, spliterator, stream, toArray, toArrayMethods inherited from class java.util.AbstractSet
removeAllMethods inherited from class java.util.AbstractCollection
add, addAll, containsAll, retainAll, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
add, addAll, containsAll, equals, hashCode, removeAll, retainAll, size, toArray, toArrayMethods inherited from interface java.util.SortedSet
spliterator
-
Constructor Details
-
KVNavigableSet
Constructor for when there are no range restrictions.- Parameters:
kv- underlyingKVStore
-
KVNavigableSet
Constructor for when the range of visibleKVStorekeys is all keys sharing a givenbyte[]prefix.- Parameters:
kv- underlyingKVStoreprefix- prefix defining minimum and maximum keys- Throws:
NullPointerException- ifprefixis null
-
KVNavigableSet
Primary constructor.- Parameters:
kv- underlyingKVStorereversed- whether ordering is reversedkeyRange- key range restriction, or null for nonekeyFilter- key filter, or null for none- Throws:
IllegalArgumentException- ifkvis null
-
-
Method Details
-
comparator
-
remove
Description copied from class:AbstractNavigableSetRemoves the given element from this set if it is present.The implementation in
AbstractNavigableSetalways throwsUnsupportedOperationException.- Specified by:
removein interfaceCollection<ByteData>- Specified by:
removein interfaceSet<ByteData>- Overrides:
removein classAbstractNavigableSet<ByteData>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<ByteData>- Specified by:
clearin interfaceSet<ByteData>- Overrides:
clearin classAbstractCollection<ByteData>
-
encode
Description copied from class:AbstractKVNavigableSetEncode the given object into abyte[]key. Note that this method must throwIllegalArgumentException, notClassCastExceptionorNullPointerException, ifobjdoes not have the correct type or is an illegal null value.- Specified by:
encodein classAbstractKVNavigableSet<ByteData>- Parameters:
writer- output for encodedbyte[]key corresponding toobjobj- set element
-
decode
Description copied from class:AbstractKVNavigableSetDecode an element from abyte[]key.If not in prefix mode, all of
readermust be consumed; otherwise, the consumed portion is the prefix and any following keys with the same prefix are ignored.- Specified by:
decodein classAbstractKVNavigableSet<ByteData>- Parameters:
reader- input for encoded bytes- Returns:
- decoded set element
-
createSubSet
protected NavigableSet<ByteData> createSubSet(boolean newReversed, KeyRange newKeyRange, KeyFilter newKeyFilter, Bounds<ByteData> newBounds) Description copied from class:AbstractKVNavigableSetCreate a (possibly reversed) view of this instance with (possibly) tighter lower and/or upper bounds and the givenKeyFilter, if any. The bounds are consistent with the reversed ordering (i.e., reversed ifreverseis true) and have already been range-checked against this instance's bounds.- Specified by:
createSubSetin classAbstractKVNavigableSet<ByteData>- Parameters:
newReversed- whether the new set's ordering should be reversed (impliesnewBoundsare also inverted, but notkeyRange); note: means "absolutely" reversed, not relative to this instancenewKeyRange- new key range, or null for none; will be consistent withbounds, if anynewKeyFilter- new key filter, or null for nonenewBounds- new bounds- Returns:
- restricted and/or filtered view of this instance
-