Class GlobalId

java.lang.Object
com.yahoo.document.GlobalId
All Implemented Interfaces:
Comparable<GlobalId>

public class GlobalId extends Object implements Comparable<GlobalId>
Implements an incredibly light-weight version of the document global id. There is a lot of functionality in the C++ version of this that is missing. However, this should be sufficient for now. This is immutable (by contract - not enforcable due to exposing the raw byte array).
Author:
Simon Thoresen Hult
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The number of bytes in a global id.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GlobalId(byte[] raw)
    Constructs a new global id by copying the content of the given raw byte array.
    Constructs a new global id from a document id string.
    GlobalId(com.yahoo.vespa.objects.Deserializer buf)
    Constructs a global id by deserializing content from the given byte buffer.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
     
    byte[]
    Returns the raw byte array that constitutes this global id.
    int
     
    void
    serialize(com.yahoo.vespa.objects.Serializer buf)
    Serializes the content of this global id into the given byte buffer.
     
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • LENGTH

      public static final int LENGTH
      The number of bytes in a global id. This must match the C++ constant in "document/base/globalid.h".
      See Also:
  • Constructor Details

    • GlobalId

      public GlobalId(byte[] raw)
      Constructs a new global id by copying the content of the given raw byte array.
      Parameters:
      raw - The array to copy.
    • GlobalId

      public GlobalId(IdString id)
      Constructs a new global id from a document id string.
      Parameters:
      id - the document id to derive from
    • GlobalId

      public GlobalId(com.yahoo.vespa.objects.Deserializer buf)
      Constructs a global id by deserializing content from the given byte buffer.
      Parameters:
      buf - the buffer to deserialize from
  • Method Details

    • serialize

      public void serialize(com.yahoo.vespa.objects.Serializer buf)
      Serializes the content of this global id into the given byte buffer.
      Parameters:
      buf - the buffer to serialize to
    • getRawId

      public byte[] getRawId()
      Returns the raw byte array that constitutes this global id. The returned value MUST NOT be modified.
    • hashCode

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

      public BucketId toBucketId()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(GlobalId other)
      Specified by:
      compareTo in interface Comparable<GlobalId>
    • toString

      public String toString()
      Overrides:
      toString in class Object