Class IndexLongFieldRange

java.lang.Object
org.elasticsearch.index.shard.IndexLongFieldRange
All Implemented Interfaces:
Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment

public class IndexLongFieldRange extends Object implements Writeable, org.elasticsearch.common.xcontent.ToXContentFragment
Class representing an (inclusive) range of long values in a field in an index which may comprise multiple shards. This information is accumulated shard-by-shard, and we keep track of which shards are represented in this value. Only once all shards are represented should this information be considered accurate for the index.
  • Field Details

    • NO_SHARDS

      public static final IndexLongFieldRange NO_SHARDS
      Sentinel value indicating that no information is currently available, for instance because the index has just been created.
    • EMPTY

      public static final IndexLongFieldRange EMPTY
      Sentinel value indicating an empty range, for instance because the field is missing or has no values in any shard.
    • UNKNOWN

      public static final IndexLongFieldRange UNKNOWN
      Sentinel value indicating the actual range is unknown, for instance because more docs may be added in future.
  • Method Details

    • isComplete

      public boolean isComplete()
      Returns:
      whether this range includes information from all shards yet.
    • containsAllShardRanges

      public boolean containsAllShardRanges()
      Returns:
      whether this range includes information from all shards and can be used meaningfully.
    • getMin

      public long getMin()
      Returns:
      the (inclusive) minimum of this range.
    • getMax

      public long getMax()
      Returns:
      the (inclusive) maximum of this range.
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • readFrom

      public static IndexLongFieldRange readFrom(StreamInput in) throws IOException
      Throws:
      IOException
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      IOException
    • fromXContent

      public static IndexLongFieldRange fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException
      Throws:
      IOException
    • extendWithShardRange

      public IndexLongFieldRange extendWithShardRange(int shardId, int shardCount, ShardLongFieldRange shardFieldRange)
    • toString

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

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

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

      public IndexLongFieldRange removeShard(int shardId, int numberOfShards)
      Remove the given shard from the set of known shards, possibly without adjusting the min and max. Used when allocating a stale primary which may have a different range from the original, so we must allow the range to grow. Note that this doesn't usually allow the range to shrink, so we may in theory hit this shard more than needed after allocating a stale primary.