Package org.apache.flink.runtime.state
Class SerializedCompositeKeyBuilder<K>
- java.lang.Object
-
- org.apache.flink.runtime.state.SerializedCompositeKeyBuilder<K>
-
- Type Parameters:
K- type of the key.
@NotThreadSafe @Internal public final class SerializedCompositeKeyBuilder<K> extends Object
Responsible for serialization of currentKey, currentGroup and namespace. Will reuse the previous serialized currentKeyed if possible.
-
-
Constructor Summary
Constructors Constructor Description SerializedCompositeKeyBuilder(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, int keyGroupPrefixBytes, int initialSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]build()Returns a serialized composite key, from whatever was set so far.<N> byte[]buildCompositeKeyNamespace(N namespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)Returns a serialized composite key, from the key and key-group provided in a previous call tosetKeyAndKeyGroup(Object, int)and the given namespace.<N,UK>
byte[]buildCompositeKeyNamesSpaceUserKey(N namespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, UK userKey, org.apache.flink.api.common.typeutils.TypeSerializer<UK> userKeySerializer)Returns a serialized composite key, from the key and key-group provided in a previous call tosetKeyAndKeyGroup(Object, int)and the given namespace, followed by the given user-key.<UK> byte[]buildCompositeKeyUserKey(UK userKey, org.apache.flink.api.common.typeutils.TypeSerializer<UK> userKeySerializer)Returns a serialized composite key, from the key and key-group provided in a previous call tosetKeyAndKeyGroup(Object, int)and the namespace provided insetNamespace(Object, TypeSerializer), followed by the given user-key.voidsetKeyAndKeyGroup(K key, int keyGroupId)Sets the key and key-group as prefix.<N> voidsetNamespace(N namespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)
-
-
-
Constructor Detail
-
SerializedCompositeKeyBuilder
public SerializedCompositeKeyBuilder(@Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, @Nonnegative int keyGroupPrefixBytes, @Nonnegative int initialSize)
-
-
Method Detail
-
setKeyAndKeyGroup
public void setKeyAndKeyGroup(@Nonnull K key, @Nonnegative int keyGroupId)Sets the key and key-group as prefix. This will serialize them into the buffer and the will be used to create composite keys with provided namespaces.- Parameters:
key- the key.keyGroupId- the key-group id for the key.
-
setNamespace
public <N> void setNamespace(@Nonnull N namespace, @Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)
-
buildCompositeKeyNamespace
@Nonnull public <N> byte[] buildCompositeKeyNamespace(@Nonnull N namespace, @Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)Returns a serialized composite key, from the key and key-group provided in a previous call tosetKeyAndKeyGroup(Object, int)and the given namespace.- Type Parameters:
N- the type of the namespace.- Parameters:
namespace- the namespace to concatenate for the serialized composite key bytes.namespaceSerializer- the serializer to obtain the serialized form of the namespace.- Returns:
- the bytes for the serialized composite key of key-group, key, namespace.
-
buildCompositeKeyNamesSpaceUserKey
@Nonnull public <N,UK> byte[] buildCompositeKeyNamesSpaceUserKey(@Nonnull N namespace, @Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, @Nonnull UK userKey, @Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<UK> userKeySerializer) throws IOExceptionReturns a serialized composite key, from the key and key-group provided in a previous call tosetKeyAndKeyGroup(Object, int)and the given namespace, followed by the given user-key.- Type Parameters:
N- the type of the namespace.UK- the type of the user-key.- Parameters:
namespace- the namespace to concatenate for the serialized composite key bytes.namespaceSerializer- the serializer to obtain the serialized form of the namespace.userKey- the user-key to concatenate for the serialized composite key, after the namespace.userKeySerializer- the serializer to obtain the serialized form of the user-key.- Returns:
- the bytes for the serialized composite key of key-group, key, namespace.
- Throws:
IOException
-
buildCompositeKeyUserKey
@Nonnull public <UK> byte[] buildCompositeKeyUserKey(@Nonnull UK userKey, @Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<UK> userKeySerializer) throws IOExceptionReturns a serialized composite key, from the key and key-group provided in a previous call tosetKeyAndKeyGroup(Object, int)and the namespace provided insetNamespace(Object, TypeSerializer), followed by the given user-key.- Type Parameters:
UK- the type of the user-key.- Parameters:
userKey- the user-key to concatenate for the serialized composite key, after the namespace.userKeySerializer- the serializer to obtain the serialized form of the user-key.- Returns:
- the bytes for the serialized composite key of key-group, key, namespace.
- Throws:
IOException
-
build
@Nonnull public byte[] build() throws IOExceptionReturns a serialized composite key, from whatever was set so far.- Throws:
IOException
-
-