java.lang.Object
org.elasticsearch.common.compress.CompressedXContent
- All Implemented Interfaces:
Writeable
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Constructor Summary
ConstructorsConstructorDescriptionCompressedXContent
(byte[] data) CompressedXContent
(String str) CompressedXContent
(Map<String, Object> map) Create aCompressedXContent
out of a serializedToXContent
that may already be compressed.CompressedXContent
(ToXContent xcontent) CompressedXContent
(ToXContent xcontent, ToXContent.Params params) Create aCompressedXContent
out of aToXContent
instance. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Return the compressed bytes.Return the compressed bytes as aBytesReference
.void
copyTo
(XContentBuilder builder) Copies the x-content in this instance to the given builder token by token.boolean
static CompressedXContent
Parses the given JSON string and then serializes it back in compressed form without any whitespaces.int
hashCode()
static CompressedXContent
string()
toString()
Return the uncompressed bytes.void
writeTo
(StreamOutput out) Write this into the StreamOutput.
-
Constructor Details
-
CompressedXContent
- Throws:
IOException
-
CompressedXContent
- Throws:
IOException
-
CompressedXContent
Create aCompressedXContent
out of aToXContent
instance.- Throws:
IOException
-
CompressedXContent
Create aCompressedXContent
out of a serializedToXContent
that may already be compressed.- Throws:
IOException
-
CompressedXContent
- Throws:
IOException
-
CompressedXContent
- Throws:
IOException
-
-
Method Details
-
fromJSON
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
Return the compressed bytes as aBytesReference
. -
uncompressed
Return the uncompressed bytes. -
string
-
getSha256
-
readCompressedString
- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
equals
-
copyTo
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 givenXContentBuilder
functionally but is much more efficient.- Parameters:
builder
- builder to copy to- Throws:
IOException
- on failure
-
hashCode
public int hashCode() -
toString
-