Class BitmapBackedSelection

java.lang.Object
tech.tablesaw.selection.BitmapBackedSelection
All Implemented Interfaces:
it.unimi.dsi.fastutil.ints.IntIterable, Iterable<Integer>, Selection

public class BitmapBackedSelection extends Object implements Selection
A Selection implemented using bitmaps
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty Selection
    Returns a selection initialized from 0 to the given size, which cane be used for queries that exclude certain items, by first selecting the items to exclude, then flipping the bits.
    Constructs a selection containing the elements in the given array
    BitmapBackedSelection(org.roaringbitmap.RoaringBitmap bitmap)
    Constructs a selection containing the elements in the given bitmap
  • Method Summary

    Modifier and Type
    Method
    Description
    add(int... ints)
    Adds the given integers to the Selection if it is not already present, and does nothing otherwise
    addRange(int start, int end)
    Adds to the current bitmap all integers in [rangeStart,rangeEnd)
    and(Selection otherSelection)
    Intersects the receiver and otherSelection, updating the receiver
    andNot(Selection otherSelection)
    Implements the set difference operation between the receiver and otherSelection, after updating the receiver
    Returns this selection with all its values cleared
    boolean
    contains(int i)
    Returns true if the index i is selected in this object
    boolean
     
    flip(int rangeStart, int rangeEnd)
    Returns a selection with the bits from this selection flipped over the given range
    int
    get(int i)
    Returns the value of the ith element.
    int
     
    boolean
    Returns true if this selection has no values, and false otherwise
    it.unimi.dsi.fastutil.ints.IntIterator
    Returns a fastUtil intIterator that wraps a bitmap intIterator
    or(Selection otherSelection)
    Implements the union of the receiver and otherSelection, updating the receiver
    removeRange(long start, long end)
    Removes from the current bitmap from all integers in [rangeStart,rangeEnd)
    protected static Selection
    selectNRowsAtRandom(int n, int max)
    Returns an randomly generated selection of size N where Max is the largest possible value
    int
    Returns the number of integers represented by this Selection
    int[]
    Returns the elements of this selection as an array of ints
     
    protected static Selection
    with(int... rows)
    Returns a Selection containing all indexes in the array
    protected static Selection
    withoutRange(int totalRangeStart, int totalRangeEnd, int excludedRangeStart, int excludedRangeEnd)
    Returns a Selection containing all values from totalRangeStart to totalRangeEnd, except for those in the range from excludedRangeStart to excludedRangeEnd.
    protected static Selection
    withRange(int start, int end)
    Returns a Selection containing all indexes in the range start (inclusive) to end (exclusive),

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface it.unimi.dsi.fastutil.ints.IntIterable

    forEach, forEach, forEach, intIterator, intSpliterator, spliterator
  • Constructor Details

    • BitmapBackedSelection

      public BitmapBackedSelection(int size)
      Returns a selection initialized from 0 to the given size, which cane be used for queries that exclude certain items, by first selecting the items to exclude, then flipping the bits.
      Parameters:
      size - The size The end point, exclusive
    • BitmapBackedSelection

      public BitmapBackedSelection(int[] arr)
      Constructs a selection containing the elements in the given array
    • BitmapBackedSelection

      public BitmapBackedSelection(org.roaringbitmap.RoaringBitmap bitmap)
      Constructs a selection containing the elements in the given bitmap
    • BitmapBackedSelection

      public BitmapBackedSelection()
      Constructs an empty Selection
  • Method Details

    • removeRange

      public Selection removeRange(long start, long end)
      Removes from the current bitmap from all integers in [rangeStart,rangeEnd)
      Specified by:
      removeRange in interface Selection
      Parameters:
      start - inclusive beginning of range
      end - exclusive ending of range
    • flip

      public Selection flip(int rangeStart, int rangeEnd)
      Returns a selection with the bits from this selection flipped over the given range
      Specified by:
      flip in interface Selection
    • add

      public Selection add(int... ints)
      Adds the given integers to the Selection if it is not already present, and does nothing otherwise
      Specified by:
      add in interface Selection
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • size

      public int size()
      Returns the number of integers represented by this Selection
      Specified by:
      size in interface Selection
    • toArray

      public int[] toArray()
      Returns the elements of this selection as an array of ints
      Specified by:
      toArray in interface Selection
    • and

      public Selection and(Selection otherSelection)
      Intersects the receiver and otherSelection, updating the receiver
      Specified by:
      and in interface Selection
    • or

      public Selection or(Selection otherSelection)
      Implements the union of the receiver and otherSelection, updating the receiver
      Specified by:
      or in interface Selection
    • andNot

      public Selection andNot(Selection otherSelection)
      Implements the set difference operation between the receiver and otherSelection, after updating the receiver
      Specified by:
      andNot in interface Selection
    • isEmpty

      public boolean isEmpty()
      Returns true if this selection has no values, and false otherwise
      Specified by:
      isEmpty in interface Selection
    • clear

      public Selection clear()
      Returns this selection with all its values cleared
      Specified by:
      clear in interface Selection
    • contains

      public boolean contains(int i)
      Returns true if the index i is selected in this object
      Specified by:
      contains in interface Selection
    • addRange

      public Selection addRange(int start, int end)
      Adds to the current bitmap all integers in [rangeStart,rangeEnd)
      Specified by:
      addRange in interface Selection
      Parameters:
      start - inclusive beginning of range
      end - exclusive ending of range
    • get

      public int get(int i)
      Returns the value of the ith element. For example, if there are three ints {4, 32, 71} in the selection, get(0) returns 4, get(1) returns 32, and get(2) returns 71

      It can be useful if you need to iterate over the data, although there is also an iterator

      Specified by:
      get in interface Selection
    • equals

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

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

      public it.unimi.dsi.fastutil.ints.IntIterator iterator()
      Returns a fastUtil intIterator that wraps a bitmap intIterator
      Specified by:
      iterator in interface it.unimi.dsi.fastutil.ints.IntIterable
      Specified by:
      iterator in interface Iterable<Integer>
    • with

      protected static Selection with(int... rows)
      Returns a Selection containing all indexes in the array
    • withRange

      protected static Selection withRange(int start, int end)
      Returns a Selection containing all indexes in the range start (inclusive) to end (exclusive),
    • withoutRange

      protected static Selection withoutRange(int totalRangeStart, int totalRangeEnd, int excludedRangeStart, int excludedRangeEnd)
      Returns a Selection containing all values from totalRangeStart to totalRangeEnd, except for those in the range from excludedRangeStart to excludedRangeEnd. Start values are inclusive, end values exclusive.
    • selectNRowsAtRandom

      protected static Selection selectNRowsAtRandom(int n, int max)
      Returns an randomly generated selection of size N where Max is the largest possible value