Package org.opensearch.core.index.shard
Class ShardId
java.lang.Object
org.opensearch.core.index.shard.ShardId
- All Implemented Interfaces:
Comparable<ShardId>,Writeable,ToXContent,ToXContentFragment
@PublicApi(since="1.0.0")
public class ShardId
extends Object
implements Comparable<ShardId>, ToXContentFragment, Writeable
Allows for shard level components to be injected with the shard id.
- Opensearch.api:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.WriteableRegistry, Writeable.Writer<V> -
Field Summary
Fields inherited from interface org.opensearch.core.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCompares this ShardId with the specified ShardId.booleanstatic ShardIdfromString(String shardIdString) Parse the string representation of this shardId back to an object.longintgetId()Returns the shard id of this shard id.getIndex()Returns the index of this shard id.Returns the name of the index of this shard id.inthashCode()Returns the hash code of this shard id.intid()Return the shardId of this shard id.toString()Returns a string representation of this shard id.toXContent(XContentBuilder builder, ToXContent.Params params) voidwriteTo(StreamOutput out) Writes this shard id to a stream.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opensearch.core.xcontent.ToXContentFragment
isFragment
-
Constructor Details
-
ShardId
Constructs a new shard id.- Parameters:
index- the index nameshardId- the shard id
-
ShardId
Constructs a new shard id with the given index name, index unique identifier, and shard id.- Parameters:
index- the index nameindexUUID- the index unique identifiershardId- the shard id
-
ShardId
Constructs a new shardId from a stream.- Parameters:
in- the stream to read from- Throws:
IOException- if an error occurs while reading from the stream- See Also:
-
-
Method Details
-
getBaseRamBytesUsed
public long getBaseRamBytesUsed() -
writeTo
Writes this shard id to a stream.- Specified by:
writeToin interfaceWriteable- Parameters:
out- the stream to write to- Throws:
IOException- if an error occurs while writing to the stream
-
getIndex
Returns the index of this shard id.- Returns:
- the index of this shard id
-
getIndexName
Returns the name of the index of this shard id.- Returns:
- the name of the index of this shard id
-
id
public int id()Return the shardId of this shard id.- Returns:
- the shardId of this shard id
- See Also:
-
getId
public int getId()Returns the shard id of this shard id.- Returns:
- the shard id of this shard id
-
toString
Returns a string representation of this shard id. -
fromString
Parse the string representation of this shardId back to an object.We lose index uuid information here, but since we use toString in rest responses, this is the best we can do to reconstruct the object on the client side.
- Parameters:
shardIdString- the string representation of the shard id (Expect a string of format "[indexName][shardId]" (square brackets included))
-
equals
-
hashCode
public int hashCode()Returns the hash code of this shard id. -
compareTo
Compares this ShardId with the specified ShardId.- Specified by:
compareToin interfaceComparable<ShardId>- Parameters:
o- the ShardId to be compared.- Returns:
- a negative integer, zero, or a positive integer if this ShardId is less than, equal to, or greater than the specified ShardId
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-