Class IsmFormat.IsmRecordCoder<V>
- java.lang.Object
-
- org.apache.beam.sdk.coders.Coder<T>
-
- org.apache.beam.sdk.coders.CustomCoder<IsmFormat.IsmRecord<V>>
-
- org.apache.beam.runners.dataflow.internal.IsmFormat.IsmRecordCoder<V>
-
- All Implemented Interfaces:
java.io.Serializable
- Enclosing class:
- IsmFormat
public static class IsmFormat.IsmRecordCoder<V> extends org.apache.beam.sdk.coders.CustomCoder<IsmFormat.IsmRecord<V>>
ACoderforIsmFormat.IsmRecords.Note that this coder standalone will not produce an Ism file. This coder can be used to materialize a
PCollectionofIsmFormat.IsmRecords. Only when this coder is combined with anIsmSinkwill one produce an Ism file.The
IsmFormat.IsmRecordencoded format is:- encoded key component 1 using key component coder 1
- ...
- encoded key component N using key component coder N
- encoded value using value coder
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanconsistentWithEquals()IsmFormat.IsmRecord<V>decode(java.io.InputStream inStream)voidencode(IsmFormat.IsmRecord<V> value, java.io.OutputStream outStream)intencodeAndHash(java.util.List<?> keyComponents, RandomAccessData keyBytesToMutate)Computes the shard id for the given key component(s).intencodeAndHash(java.util.List<?> keyComponents, RandomAccessData keyBytesToMutate, java.util.List<java.lang.Integer> keyComponentByteOffsetsToMutate)Computes the shard id for the given key component(s).booleanequals(@Nullable java.lang.Object other)java.util.List<org.apache.beam.sdk.coders.Coder<?>>getCoderArguments()<T> org.apache.beam.sdk.coders.Coder<T>getKeyComponentCoder(int index)Returns the key coder at the specified index.java.util.List<org.apache.beam.sdk.coders.Coder<?>>getKeyComponentCoders()Returns the list of key component coders.intgetNumberOfShardKeyCoders(java.util.List<?> keyComponents)org.apache.beam.sdk.coders.Coder<V>getValueCoder()Returns the value coder.inthash(java.util.List<?> keyComponents)Computes the shard id for the given key component(s).inthashCode()static <V> IsmFormat.IsmRecordCoder<V>of(int numberOfShardKeyCoders, int numberOfMetadataShardKeyCoders, java.util.List<org.apache.beam.sdk.coders.Coder<?>> keyComponentCoders, org.apache.beam.sdk.coders.Coder<V> valueCoder)Returns an IsmRecordCoder with the specified key component coders, value coder.java.lang.ObjectstructuralValue(IsmFormat.IsmRecord<V> record)voidverifyDeterministic()
-
-
-
Method Detail
-
of
public static <V> IsmFormat.IsmRecordCoder<V> of(int numberOfShardKeyCoders, int numberOfMetadataShardKeyCoders, java.util.List<org.apache.beam.sdk.coders.Coder<?>> keyComponentCoders, org.apache.beam.sdk.coders.Coder<V> valueCoder)
Returns an IsmRecordCoder with the specified key component coders, value coder.
-
getKeyComponentCoders
public java.util.List<org.apache.beam.sdk.coders.Coder<?>> getKeyComponentCoders()
Returns the list of key component coders.
-
getKeyComponentCoder
public <T> org.apache.beam.sdk.coders.Coder<T> getKeyComponentCoder(int index)
Returns the key coder at the specified index.
-
getValueCoder
public org.apache.beam.sdk.coders.Coder<V> getValueCoder()
Returns the value coder.
-
encode
public void encode(IsmFormat.IsmRecord<V> value, java.io.OutputStream outStream) throws org.apache.beam.sdk.coders.CoderException, java.io.IOException
- Specified by:
encodein classorg.apache.beam.sdk.coders.Coder<IsmFormat.IsmRecord<V>>- Throws:
org.apache.beam.sdk.coders.CoderExceptionjava.io.IOException
-
decode
public IsmFormat.IsmRecord<V> decode(java.io.InputStream inStream) throws org.apache.beam.sdk.coders.CoderException, java.io.IOException
- Specified by:
decodein classorg.apache.beam.sdk.coders.Coder<IsmFormat.IsmRecord<V>>- Throws:
org.apache.beam.sdk.coders.CoderExceptionjava.io.IOException
-
getNumberOfShardKeyCoders
public int getNumberOfShardKeyCoders(java.util.List<?> keyComponents)
-
hash
public int hash(java.util.List<?> keyComponents)
Computes the shard id for the given key component(s).The shard keys are encoded into their byte representations and hashed using the 32-bit murmur3 algorithm, x86 variant (little-endian variant), using
1225801234as the seed value. We ensure that shard ids for metadata keys and normal keys do not overlap.
-
encodeAndHash
public int encodeAndHash(java.util.List<?> keyComponents, RandomAccessData keyBytesToMutate)Computes the shard id for the given key component(s).Mutates
keyBytessuch that when returned, contains the encoded version of the key components.
-
encodeAndHash
public int encodeAndHash(java.util.List<?> keyComponents, RandomAccessData keyBytesToMutate, java.util.List<java.lang.Integer> keyComponentByteOffsetsToMutate)Computes the shard id for the given key component(s).Mutates
keyBytessuch that when returned, contains the encoded version of the key components. Also, mutateskeyComponentByteOffsetsToMutateto store the location where each key component's encoded byte representation ends withinkeyBytes.
-
getCoderArguments
public java.util.List<org.apache.beam.sdk.coders.Coder<?>> getCoderArguments()
- Overrides:
getCoderArgumentsin classorg.apache.beam.sdk.coders.CustomCoder<IsmFormat.IsmRecord<V>>
-
verifyDeterministic
public void verifyDeterministic() throws org.apache.beam.sdk.coders.Coder.NonDeterministicException- Overrides:
verifyDeterministicin classorg.apache.beam.sdk.coders.CustomCoder<IsmFormat.IsmRecord<V>>- Throws:
org.apache.beam.sdk.coders.Coder.NonDeterministicException
-
consistentWithEquals
public boolean consistentWithEquals()
- Overrides:
consistentWithEqualsin classorg.apache.beam.sdk.coders.Coder<IsmFormat.IsmRecord<V>>
-
structuralValue
public java.lang.Object structuralValue(IsmFormat.IsmRecord<V> record)
- Overrides:
structuralValuein classorg.apache.beam.sdk.coders.Coder<IsmFormat.IsmRecord<V>>
-
equals
public boolean equals(@Nullable java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-