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 java.lang.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.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent

    org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params

    Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable

    Writeable.Reader<V>, Writeable.Writer<V>
  • Field Summary

    Fields
    Modifier and Type Field Description
    static IndexLongFieldRange EMPTY
    Sentinel value indicating an empty range, for instance because the field is missing or has no values in any shard.
    static IndexLongFieldRange NO_SHARDS
    Sentinel value indicating that no information is currently available, for instance because the index has just been created.
    static IndexLongFieldRange UNKNOWN
    Sentinel value indicating the actual range is unknown, for instance because more docs may be added in future.

    Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Method Summary

    Modifier and Type Method Description
    boolean containsAllShardRanges()  
    boolean equals​(java.lang.Object o)  
    IndexLongFieldRange extendWithShardRange​(int shardId, int shardCount, ShardLongFieldRange shardFieldRange)  
    static IndexLongFieldRange fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser)  
    long getMax()  
    long getMin()  
    int hashCode()  
    boolean isComplete()  
    static IndexLongFieldRange readFrom​(StreamInput in)  
    IndexLongFieldRange removeShard​(int shardId, int numberOfShards)
    Remove the given shard from the set of known shards, possibly without adjusting the min and max.
    java.lang.String toString()  
    org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)  
    void writeTo​(StreamOutput out)
    Write this into the StreamOutput.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment

    isFragment
  • 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 java.io.IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      java.io.IOException
    • readFrom

      public static IndexLongFieldRange readFrom​(StreamInput in) throws java.io.IOException
      Throws:
      java.io.IOException
    • toXContent

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

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

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

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

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.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.