Google Cloud Dataflow SDK for Java, version 1.9.1
com.google.cloud.dataflow.sdk.coders
Class StringUtf8Coder
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.coders.StandardCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.AtomicCoder<String>
-
- com.google.cloud.dataflow.sdk.coders.StringUtf8Coder
-
- All Implemented Interfaces:
- Coder<String>, Serializable
public class StringUtf8Coder extends AtomicCoder<String>
ACoder
that encodesStrings
in UTF-8 encoding. If in a nested context, prefixes the string with an integer length field, encoded via aVarIntCoder
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.cloud.dataflow.sdk.coders.Coder
Coder.Context, Coder.NonDeterministicException
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean
consistentWithEquals()
String
decode(InputStream inStream, Coder.Context context)
Decodes a value of typeT
from the given input stream in the given context.void
encode(String value, OutputStream outStream, Coder.Context context)
Encodes the given value of typeT
onto the given output stream in the given context.protected long
getEncodedElementByteSize(String value, Coder.Context context)
Returns the size in bytes of the encoded value using this coder.static StringUtf8Coder
of()
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.AtomicCoder
getCoderArguments, getInstanceComponents
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder
verifyDeterministic
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.StandardCoder
asCloudObject, equals, getAllowedEncodings, getComponents, getEncodingId, hashCode, isRegisterByteSizeObserverCheap, registerByteSizeObserver, structuralValue, toString, verifyDeterministic, verifyDeterministic
-
-
-
-
Method Detail
-
of
public static StringUtf8Coder of()
-
encode
public void encode(String value, OutputStream outStream, Coder.Context context) throws IOException
Description copied from interface:Coder
Encodes the given value of typeT
onto the given output stream in the given context.- Throws:
IOException
- if writing to theOutputStream
fails for some reasonCoderException
- if the value could not be encoded for some reason
-
decode
public String decode(InputStream inStream, Coder.Context context) throws IOException
Description copied from interface:Coder
Decodes a value of typeT
from the given input stream in the given context. Returns the decoded value.- Throws:
IOException
- if reading from theInputStream
fails for some reasonCoderException
- if the value could not be decoded for some reason
-
consistentWithEquals
public boolean consistentWithEquals()
Returnstrue
if thisCoder
is injective with respect toObject.equals(java.lang.Object)
.Whenever the encoded bytes of two values are equal, then the original values are equal according to
Objects.equals()
. Note that this is well-defined fornull
.This condition is most notably false for arrays. More generally, this condition is false whenever
equals()
compares object identity, rather than performing a semantic/structural comparison.- Specified by:
consistentWithEquals
in interfaceCoder<String>
- Overrides:
consistentWithEquals
in classStandardCoder<String>
- Returns:
true
. This coder is injective.
-
getEncodedElementByteSize
protected long getEncodedElementByteSize(String value, Coder.Context context) throws Exception
Returns the size in bytes of the encoded value using this coder.- Overrides:
getEncodedElementByteSize
in classStandardCoder<String>
- Returns:
- the byte size of the UTF-8 encoding of the a string or, in a nested context, the byte size of the encoding plus the encoded length prefix.
- Throws:
Exception
-
-