gustavodemorais commented on code in PR #30182:
URL: https://github.com/apache/flink/pull/30182#discussion_r4773019330
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/ptf/DeduplicateFunctionBase.java:
##########
@@ -55,5 +77,72 @@ abstract class DeduplicateFunctionBase extends
BuiltInProcessTableFunction<RowDa
CallContextUtils.getStateTtl(callContext, ARG_STATE_TTL)
.orElseGet(() ->
context.getConfiguration().get(IDLE_STATE_RETENTION));
this.isTtlEnabled = !effectiveTtl.isZero();
+ this.isUpdateBeforeEmitted =
+ callContext
+ .getOutputChangelogMode()
+ .map(mode -> mode.contains(RowKind.UPDATE_BEFORE))
+ .orElse(false);
+ this.inputTypes =
+ DataType.getFieldDataTypes(inputRowType(context)).stream()
+ .map(DataType::getLogicalType)
+ .toArray(LogicalType[]::new);
+ }
+
+ @Override
+ public void open(final FunctionContext context) throws Exception {
+ super.open(context);
+ inputSerializer = new RowDataSerializer(inputTypes);
+ projectedRow = ProjectedRowData.from(outputIndices);
+ outputRow = new JoinedRowData();
+ emptyRow = GenericRowData.of();
+ }
+
+ /** Returns the type of a full input row, as kept in state. */
+ static DataType inputRowType(final SpecializedContext context) {
+ return DataTypes.ROW(
+ DataType.getFields(
+ CallContextUtils.getTableSemanticsOrThrow(
+ context.getCallContext(), ARG_INPUT)
+ .dataType()));
+ }
+
+ /** Returns the input as a binary row without copying it, valid until the
next call. */
+ protected BinaryRowData toBinaryRow(final RowData input) {
+ return inputSerializer.toBinaryRow(input);
+ }
+
+ protected static BinaryRowData copyAsStateRow(final BinaryRowData row) {
Review Comment:
Maybe `copyForState` here and `equalsStateRow` below? Both say what they're
for in one word.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]