Class ByteSegmentedSortedMultiset

java.lang.Object
io.deephaven.engine.table.impl.ssms.ByteSegmentedSortedMultiset
All Implemented Interfaces:
SegmentedSortedMultiSet<Byte>, LongSizedDataStructure, ByteVector, Vector<ByteVector>, Serializable, Iterable<Byte>

public final class ByteSegmentedSortedMultiset extends Object implements SegmentedSortedMultiSet<Byte>, ByteVector
See Also:
  • Constructor Details

    • ByteSegmentedSortedMultiset

      public ByteSegmentedSortedMultiset(int leafSize)
      Create a ByteSegmentedSortedArray with the given leafSize.
      Parameters:
      leafSize - the maximumSize for any leaf
  • Method Details

    • insert

      public boolean insert(WritableChunk<? extends Values> valuesToInsert, WritableIntChunk<ChunkLengths> counts)
      Description copied from interface: SegmentedSortedMultiSet
      Insert new valuesToInsert into this SSMS. The valuesToInsert to insert must be sorted, without duplicates. The valuesToInsert and counts chunks will be modified during this call, and the resulting chunks are undefined.
      Specified by:
      insert in interface SegmentedSortedMultiSet<Byte>
      Parameters:
      valuesToInsert - the valuesToInsert to insert
      counts - the number of times each value occurs
      Returns:
      true if any new values were inserted
    • remove

      public boolean remove(SegmentedSortedMultiSet.RemoveContext removeContext, WritableChunk<? extends Values> valuesToRemove, WritableIntChunk<ChunkLengths> counts)
      Remove valuesToRemove from this SSA. The valuesToRemove to remove must be sorted.
      Specified by:
      remove in interface SegmentedSortedMultiSet<Byte>
      Parameters:
      valuesToRemove - the valuesToRemove to remove
      removeContext - removalContext
      Returns:
      true if any values were removed.
    • validate

      @VisibleForTesting public void validate()
    • totalSize

      public long totalSize()
      Specified by:
      totalSize in interface SegmentedSortedMultiSet<Byte>
      Returns:
      the total size of the set in elements (i.e. if A exists twice, 2 is returned not one)
    • getNodeSize

      public int getNodeSize()
      Specified by:
      getNodeSize in interface SegmentedSortedMultiSet<Byte>
    • getMin

      public Byte getMin()
      Specified by:
      getMin in interface SegmentedSortedMultiSet<Byte>
    • getMax

      public Byte getMax()
      Specified by:
      getMax in interface SegmentedSortedMultiSet<Byte>
    • getMinByte

      public byte getMinByte()
    • getMinCount

      public long getMinCount()
      Specified by:
      getMinCount in interface SegmentedSortedMultiSet<Byte>
      Returns:
      the number of times the minimum value exists in this SSM.
    • getMaxByte

      public byte getMaxByte()
    • getMaxCount

      public long getMaxCount()
      Specified by:
      getMaxCount in interface SegmentedSortedMultiSet<Byte>
      Returns:
      the number of times the maximum value exists in this SSM.
    • moveFrontToBack

      public void moveFrontToBack(SegmentedSortedMultiSet untypedDestination, long count)
      Description copied from interface: SegmentedSortedMultiSet
      Remove count elements from the front of this SSM and add them to the back of the destination SSM.

      The minimum element of this SSM must be greater than or equal to the maximum of destination.

      Specified by:
      moveFrontToBack in interface SegmentedSortedMultiSet<Byte>
      Parameters:
      untypedDestination - the SegmentedSortedMultiSet to append count elements to
      count - how many elements to move to the destination
    • moveBackToFront

      public void moveBackToFront(SegmentedSortedMultiSet untypedDestination, long count)
      Description copied from interface: SegmentedSortedMultiSet
      Remove count elements from the back of this SSM and add them to the front of the destination SSM.

      The minimum element of this SSM must be less than or equal to the maximum of destination.

      Specified by:
      moveBackToFront in interface SegmentedSortedMultiSet<Byte>
      Parameters:
      untypedDestination - the SegmentedSortedMultiSet to prepend count elements to
      count - how many elements to move to the destination
    • keyChunk

      public WritableByteChunk<?> keyChunk()
      Specified by:
      keyChunk in interface SegmentedSortedMultiSet<Byte>
    • fillKeyChunk

      public void fillKeyChunk(WritableChunk<?> keyChunk, int offset)
      Specified by:
      fillKeyChunk in interface SegmentedSortedMultiSet<Byte>
    • countChunk

      public WritableLongChunk<?> countChunk()
      Specified by:
      countChunk in interface SegmentedSortedMultiSet<Byte>
    • setTrackDeltas

      public void setTrackDeltas(boolean shouldTrackDeltas)
      Specified by:
      setTrackDeltas in interface SegmentedSortedMultiSet<Byte>
    • clearDeltas

      public void clearDeltas()
      Specified by:
      clearDeltas in interface SegmentedSortedMultiSet<Byte>
    • getAddedSize

      public int getAddedSize()
      Specified by:
      getAddedSize in interface SegmentedSortedMultiSet<Byte>
    • getRemovedSize

      public int getRemovedSize()
      Specified by:
      getRemovedSize in interface SegmentedSortedMultiSet<Byte>
    • fillRemovedChunk

      public void fillRemovedChunk(WritableByteChunk<? extends Values> chunk, int position)
    • fillAddedChunk

      public void fillAddedChunk(WritableByteChunk<? extends Values> chunk, int position)
    • getPrevValues

      public ByteVector getPrevValues()
    • get

      public byte get(long index)
      Description copied from interface: ByteVector
      Get the element of this ByteVector at offset index. If index is not within range [0, size()), will return the null byte.
      Specified by:
      get in interface ByteVector
      Parameters:
      index - An offset into this ByteVector
      Returns:
      The element at the specified offset, or the null byte
    • subVector

      public ByteVector subVector(long fromIndexInclusive, long toIndexExclusive)
      Description copied from interface: Vector
      Get a Vector that represents a slice of this Vector.
      Specified by:
      subVector in interface ByteVector
      Specified by:
      subVector in interface Vector<ByteVector>
      Parameters:
      fromIndexInclusive - The first offset into this Vector to include in the result; if negative, the result will have a range of null values at offsets in [0, -fromIndexInclusive)
      toIndexExclusive - The first offset into this Vector to not include in the result; if larger than size(), the result will have a range of null values at the corresponding offsets
      Returns:
      The sub-Vector specified by [fromIndexInclusive, toIndexExclusive)
    • subVectorByPositions

      public ByteVector subVectorByPositions(long[] positions)
      Description copied from interface: Vector
      Get a Vector that represents a set of offset positions in this Vector.
      Specified by:
      subVectorByPositions in interface ByteVector
      Specified by:
      subVectorByPositions in interface Vector<ByteVector>
      Parameters:
      positions - The offsets to include; if not within [0, size()), the corresponding offset in the result will contain the appropriate null value
      Returns:
      The sub-Vector specified by positions
    • toArray

      public byte[] toArray()
      Description copied from interface: Vector
      Get an array representation of the elements of this Vector. Callers must not mutate the result, as implementations may choose to return their backing array in some cases.
      Specified by:
      toArray in interface ByteVector
      Specified by:
      toArray in interface Vector<ByteVector>
      Returns:
      An array representation of the elements of this Vector that must not be mutated
    • copyToArray

      public byte[] copyToArray()
      Description copied from interface: Vector
      Get an array representation of the elements of this Vector. Callers may freely mutate the result, as it is guaranteed to be freshly-allocated and belongs to the caller upon return.
      Specified by:
      copyToArray in interface ByteVector
      Specified by:
      copyToArray in interface Vector<ByteVector>
      Returns:
      An array representation of the elements of this Vector that may be freely mutated
    • size

      public long size()
      Description copied from interface: LongSizedDataStructure
      The size of this data structure.
      Specified by:
      size in interface LongSizedDataStructure
      Specified by:
      size in interface SegmentedSortedMultiSet<Byte>
      Returns:
      the size of the set (i.e. the number of unique elements).
    • getDirect

      public ByteVector getDirect()
      Specified by:
      getDirect in interface ByteVector
      Specified by:
      getDirect in interface Vector<ByteVector>
      Returns:
      A version of this Vector that is flattened out to only reference memory
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object