Class GlobalId

  • All Implemented Interfaces:
    java.lang.Comparable

    public class GlobalId
    extends java.lang.Object
    implements java.lang.Comparable
    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 int LENGTH
      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.
      GlobalId​(IdString id)
      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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(java.lang.Object o)  
      boolean equals​(java.lang.Object obj)  
      byte[] getRawId()
      Returns the raw byte array that constitutes this global id.
      int hashCode()  
      void serialize​(com.yahoo.vespa.objects.Serializer buf)
      Serializes the content of this global id into the given byte buffer.
      BucketId toBucketId()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • 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:
        Constant Field Values
    • Constructor Detail

      • 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 Detail

      • 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 java.lang.Object
      • toBucketId

        public BucketId toBucketId()
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(java.lang.Object o)
        Specified by:
        compareTo in interface java.lang.Comparable
      • toString

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