Package org.apache.flink.runtime.state
Class SerializedCompositeKeyBuilder<K>
- java.lang.Object
-
- org.apache.flink.runtime.state.SerializedCompositeKeyBuilder<K>
-
-
Constructor Summary
Constructors Constructor Description SerializedCompositeKeyBuilder(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, 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, TypeSerializer<N> namespaceSerializer, UK userKey, 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, 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.void
setKeyAndKeyGroup(K key, int keyGroupId)
Sets the key and key-group as prefix.<N> void
setNamespace(N namespace, TypeSerializer<N> namespaceSerializer)
-
-
-
Constructor Detail
-
SerializedCompositeKeyBuilder
public SerializedCompositeKeyBuilder(@Nonnull 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 TypeSerializer<N> namespaceSerializer)
-
buildCompositeKeyNamespace
@Nonnull public <N> byte[] buildCompositeKeyNamespace(@Nonnull N namespace, @Nonnull 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 TypeSerializer<N> namespaceSerializer, @Nonnull UK userKey, @Nonnull TypeSerializer<UK> userKeySerializer) throws IOException
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.- 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 TypeSerializer<UK> userKeySerializer) throws IOException
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.- 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 IOException
Returns a serialized composite key, from whatever was set so far.- Throws:
IOException
-
-