java.lang.Object
org.elasticsearch.common.lucene.BytesRefs

public class BytesRefs extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.lucene.util.BytesRef
    checkIndexableLength(org.apache.lucene.util.BytesRef input)
    Checks that the input is not longer than IndexWriter.MAX_TERM_LENGTH
    static org.apache.lucene.util.BytesRef
    Converts an object value to BytesRef.
    static org.apache.lucene.util.BytesRef
    Converts a given string to a BytesRef object with an exactly sized byte array.
    static String
    Converts a value to a string, taking special care if its a BytesRef to call BytesRef.utf8ToString().

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BytesRefs

      public BytesRefs()
  • Method Details

    • toString

      public static String toString(Object value)
      Converts a value to a string, taking special care if its a BytesRef to call BytesRef.utf8ToString().
    • toBytesRef

      public static org.apache.lucene.util.BytesRef toBytesRef(Object value)
      Converts an object value to BytesRef.
    • checkIndexableLength

      public static org.apache.lucene.util.BytesRef checkIndexableLength(org.apache.lucene.util.BytesRef input)
      Checks that the input is not longer than IndexWriter.MAX_TERM_LENGTH
      Parameters:
      input - a BytesRef
      Returns:
      the same BytesRef, if no exception has been thrown
      Throws:
      IllegalArgumentException - if the input is too long
    • toExactSizedBytesRef

      public static org.apache.lucene.util.BytesRef toExactSizedBytesRef(String s)
      Converts a given string to a BytesRef object with an exactly sized byte array.

      This method alternative method to the standard BytesRef constructor's allocates the exact byte array size needed for the string. This is done by parsing the UTF-16 string two times the first to estimate the array length and the second to copy the string value inside the array.

      Parameters:
      s - the input string to convert
      Returns:
      a BytesRef object representing the input string