Class CompressedXContent

java.lang.Object
org.elasticsearch.common.compress.CompressedXContent

public final class CompressedXContent extends Object
Similar class to the String class except that it internally stores data using a compressed representation in order to require less permanent memory. Note that the compressed string might still sometimes need to be decompressed in order to perform equality checks or to compute hash codes.
  • Constructor Details

  • Method Details

    • fromJSON

      public static CompressedXContent fromJSON(String json) throws IOException
      Parses the given JSON string and then serializes it back in compressed form without any whitespaces. This is used to normalize mapping json strings for deduplication.
      Parameters:
      json - string containing valid JSON
      Returns:
      compressed x-content normalized to not contain any whitespaces
      Throws:
      IOException
    • compressed

      public byte[] compressed()
      Return the compressed bytes.
    • compressedReference

      public BytesReference compressedReference()
      Return the compressed bytes as a BytesReference.
    • uncompressed

      public BytesReference uncompressed()
      Return the uncompressed bytes.
    • string

      public String string()
    • getSha256

      public String getSha256()
    • readCompressedString

      public static CompressedXContent readCompressedString(StreamInput in) throws IOException
      Throws:
      IOException
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Throws:
      IOException
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • copyTo

      public void copyTo(org.elasticsearch.xcontent.XContentBuilder builder) throws IOException
      Copies the x-content in this instance to the given builder token by token. This operation is equivalent to parsing the contents of this instance into a map and then writing the map to the given XContentBuilder functionally but is much more efficient.
      Parameters:
      builder - builder to copy to
      Throws:
      IOException - on failure
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object