Class GroupShardsIterator<ShardIt extends Comparable<ShardIt> & Countable>

All Implemented Interfaces:

public final class GroupShardsIterator<ShardIt extends Comparable<ShardIt> & Countable> extends Object implements Iterable<ShardIt>
This class implements a compilation of ShardIterators. Each ShardIterator iterated by this Iterable represents a group of shards. ShardsIterators are always returned in ascending order independently of their order at construction time. The incoming iterators are sorted to ensure consistent iteration behavior across Nodes / JVMs.
  • Constructor Details

    • GroupShardsIterator

      public GroupShardsIterator(List<ShardIt> iterators)
      Constructs a new GroupShardsIterator from the given list.
  • Method Details

    • sortAndCreate

      public static <ShardIt extends Comparable<ShardIt> & Countable> GroupShardsIterator<ShardIt> sortAndCreate(List<ShardIt> iterators)
      Constructs a new sorted GroupShardsIterator from the given list. Items are sorted based on their natural ordering.
      See Also:
    • totalSize

      public int totalSize()
      Returns the total number of shards within all groups
      total number of shards
    • totalSizeWith1ForEmpty

      public int totalSizeWith1ForEmpty()
      Returns the total number of shards plus the number of empty groups
      number of shards and empty groups
    • size

      public int size()
      Return the number of groups
      number of groups
    • iterator

      public Iterator<ShardIt> iterator()
      Specified by:
      iterator in interface Iterable<ShardIt extends Comparable<ShardIt> & Countable>
    • get

      public ShardIt get(int index)