Enum HashFunctionStrategy
- java.lang.Object
-
- java.lang.Enum<HashFunctionStrategy>
-
- org.apache.flink.cdc.common.pipeline.HashFunctionStrategy
-
- All Implemented Interfaces:
Serializable,Comparable<HashFunctionStrategy>
@PublicEvolving public enum HashFunctionStrategy extends Enum<HashFunctionStrategy>
Partitioning strategy forDataChangeEventin Flink CDC pipeline.This enum defines different strategies used by
PrePartitionOperatorto determine which downstream subtask an event should be routed to.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description PRIMARY_KEYHash by TableId and primary keys.SINK_DEFINEDUse the HashFunctionProvider defined by the sink.TABLE_IDHash by TableId only.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static HashFunctionStrategyvalueOf(String name)Returns the enum constant of this type with the specified name.static HashFunctionStrategy[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
SINK_DEFINED
public static final HashFunctionStrategy SINK_DEFINED
Use the HashFunctionProvider defined by the sink.This is the default behavior when
sink.partitioning.strategyis not explicitly set. The provider returned by the sink'sgetDataChangeEventHashFunctionProvidermethod will be used, preserving backward compatibility with existing pipeline configurations.This is the only supported strategy for sinks that require sink-defined routing, such as paimon, fluss, and maxcompute.
-
PRIMARY_KEY
public static final HashFunctionStrategy PRIMARY_KEY
Hash by TableId and primary keys.This strategy computes hash based on TableId (namespace, schema, table) combined with primary key column values. Events with the same TableId and primary key will be routed to the same subtask, while events from the same table with different primary keys may be spread across multiple subtasks for load balancing.
This is suitable when you want good distribution of data across subtasks and don't require strict ordering within a table.
This strategy is not supported for paimon, fluss, or maxcompute sinks.
-
TABLE_ID
public static final HashFunctionStrategy TABLE_ID
Hash by TableId only.This strategy computes hash based solely on TableId (namespace, schema, table), ignoring the record payload entirely. All events from the same table will be routed to the same subtask, ensuring per-table ordering semantics.
This is suitable when:
- The sink requires strict single-writer-per-table semantics.
- The table has no primary key or has a changing primary key set.
- You want to avoid cross-subtask reordering within the same table.
This strategy is not supported for paimon, fluss, or maxcompute sinks.
-
-
Method Detail
-
values
public static HashFunctionStrategy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (HashFunctionStrategy c : HashFunctionStrategy.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static HashFunctionStrategy valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
-