Class AbstractGroupingBuilder

java.lang.Object
com.illumon.iris.db.v2.dataindex.AbstractGroupingBuilder
All Implemented Interfaces:
GroupingBuilder

public abstract class AbstractGroupingBuilder extends Object implements GroupingBuilder
The base implementation for GroupingBuilder provides fields and methods that are common to all implementations.
  • Field Details

    • regionMutators

      protected final List<Function<Table,Table>> regionMutators
    • indexOfInterest

      protected ReadOnlyIndex indexOfInterest
    • strictIntersect

      protected boolean strictIntersect
    • sortByFirstKey

      protected boolean sortByFirstKey
    • inverter

      protected ReadOnlyIndex inverter
    • matchCase

      protected boolean matchCase
    • invert

      protected boolean invert
    • groupKeys

      protected Object[] groupKeys
  • Constructor Details

    • AbstractGroupingBuilder

      public AbstractGroupingBuilder()
  • Method Details

    • addRegionMutator

      @NotNull public GroupingBuilder addRegionMutator(@NotNull Function<Table,Table> mutator)
      Description copied from interface: GroupingBuilder
      Add a method that will process tables per region. If the mutator returns a null or empty table, it will not be passed to the following mutators.
      Specified by:
      addRegionMutator in interface GroupingBuilder
      Parameters:
      mutator - a function to process the input tables.
      Returns:
      this GroupingBuilder
    • sortByFirstKey

      @NotNull public GroupingBuilder sortByFirstKey()
      Description copied from interface: GroupingBuilder
      Sort the final grouping table by the first key within each group. This can be useful to maintain visitation order.
      Specified by:
      sortByFirstKey in interface GroupingBuilder
      Returns:
      this GroupingBuilder
    • matching

      @NotNull public GroupingBuilder matching(boolean matchCase, boolean invert, Object... groupKeys)
      Description copied from interface: GroupingBuilder
      Only include keys in the resultant grouping that match the specified set of grouping keys, optionally ignoring case or inverting the match. The grouping keys must not be empty.
      Specified by:
      matching in interface GroupingBuilder
      Parameters:
      matchCase - if matches should consider case
      invert - if the match should be inverted
      groupKeys - the set of keys to match
      Returns:
      this GroupingBuilder
    • clampToIndex

      @NotNull public GroupingBuilder clampToIndex(@NotNull ReadOnlyIndex indexOfInterest, boolean strictIntersect)
      Description copied from interface: GroupingBuilder
      Clamp the returned table of indices to the specified range. In strict mode, guarantees that the indices returned for each group include ony indices in the specified index.
      Specified by:
      clampToIndex in interface GroupingBuilder
      Parameters:
      indexOfInterest - the index of interest
      strictIntersect - when true, the final table will contain only indices that are part of 'index'
      Returns:
      this GroupingBuilder
    • positionally

      public GroupingBuilder positionally(@NotNull ReadOnlyIndex inverter)
      Description copied from interface: GroupingBuilder
      Construct groupings as positions, as if the source index were flat.
      Specified by:
      positionally in interface GroupingBuilder
      Returns:
      this GroupingBuilder
    • buildGroupingMap

      @Nullable public <T> Map<T,ReadOnlyIndex> buildGroupingMap()
      Description copied from interface: GroupingBuilder
      Build a Map of the Grouping values based on the current configuration of this builder. Note that the returned map will respect the table order of the final table.
      Specified by:
      buildGroupingMap in interface GroupingBuilder
      Returns:
      a properly ordered Map of key to read only index.
    • convertToMap

      @NotNull protected <DATA_TYPE> Map<DATA_TYPE,ReadOnlyIndex> convertToMap(@Nullable Table groupingTable)
      Convert the final table into a Map of key.
      Type Parameters:
      DATA_TYPE - the type of the key
      Parameters:
      groupingTable - the table to convert
      Returns:
      the grouping table converted into a Map
    • applyIntersectAndInvert

      protected Table applyIntersectAndInvert(@NotNull Table groupingTable)
      Apply strict intersection and invert operations as required by the current builder state.
      Parameters:
      groupingTable - the table to apply the operations to.
      Returns:
      the table with intersections and inversions applied.
    • maybeSortByFirsKey

      protected Table maybeSortByFirsKey(@NotNull Table grouping)
      If requested, sort the input table by the first key of it's index column.
      Parameters:
      grouping - the input grouping.
      Returns:
      the table sorted by first key, if requested.
    • maybeApplyMatch

      protected Table maybeApplyMatch(@NotNull Table baseTable)
      If matching was requested, apply it to the parameter table.
      Parameters:
      baseTable - the table to apply to
      Returns:
      the table with matching applied if required.
    • condenseGrouping

      protected Table condenseGrouping(@NotNull Table baseTable)
    • makeMemoKey

      protected GroupingMemoKey makeMemoKey()
      Create a GroupingMemoKey for the current builder state.
      Returns:
      a memo key
    • isMemoizable

      protected boolean isMemoizable()
      Check if the current configuration is memoizable.
      Returns:
      true if it is memoizable