use of org.apache.flink.table.data.utils.JoinedRowData in project flink by apache.
the class StreamArrowPythonGroupWindowAggregateFunctionOperator method open.
@Override
public void open() throws Exception {
super.open();
windowSerializer = windowAssigner.getWindowSerializer(new ExecutionConfig());
internalTimerService = getInternalTimerService("window-timers", windowSerializer, this);
triggerContext = new TriggerContext();
triggerContext.open();
StateDescriptor<ListState<RowData>, List<RowData>> windowStateDescriptor = new ListStateDescriptor<>("window-input", new RowDataSerializer(inputType));
StateDescriptor<ListState<RowData>, List<RowData>> dataRetractStateDescriptor = new ListStateDescriptor<>("data-retract", new RowDataSerializer(inputType));
this.windowAccumulateData = (InternalListState<K, W, RowData>) getOrCreateKeyedState(windowSerializer, windowStateDescriptor);
this.windowRetractData = (InternalListState<K, W, RowData>) getOrCreateKeyedState(windowSerializer, dataRetractStateDescriptor);
inputKeyAndWindow = new LinkedList<>();
windowProperty = new GenericRowData(namedProperties.length);
windowAggResult = new JoinedRowData();
WindowContext windowContext = new WindowContext();
windowAssigner.open(windowContext);
}
use of org.apache.flink.table.data.utils.JoinedRowData in project flink by apache.
the class EmbeddedPythonScalarFunctionOperator method processElement.
@SuppressWarnings("unchecked")
@Override
public void processElement(StreamRecord<RowData> element) {
RowData value = element.getValue();
Object udfArgs = null;
if (userDefinedFunctionInputArgs.length > 1) {
for (int i = 0; i < userDefinedFunctionInputArgs.length; i++) {
userDefinedFunctionInputArgs[i] = userDefinedFunctionInputConverters[i].toExternal(value, udfInputOffsets[i]);
}
udfArgs = userDefinedFunctionInputArgs;
} else if (userDefinedFunctionInputArgs.length == 1) {
udfArgs = userDefinedFunctionInputConverters[0].toExternal(value, udfInputOffsets[0]);
}
if (isOneFieldResult) {
Object udfResult = interpreter.invokeMethod("scalar_operation", "process_element", udfArgs);
reuseResultRowData.setField(0, userDefinedFunctionOutputConverters[0].toInternal(udfResult));
} else {
Object[] udfResult = (Object[]) interpreter.invokeMethod("scalar_operation", "process_element", udfArgs);
for (int i = 0; i < udfResult.length; i++) {
reuseResultRowData.setField(i, userDefinedFunctionOutputConverters[i].toInternal(udfResult[i]));
}
}
if (forwardedFieldProjection != null) {
BinaryRowData forwardedRowData = forwardedFieldProjection.apply(value).copy();
JoinedRowData reuseJoinedRow = new JoinedRowData(forwardedRowData, reuseResultRowData);
rowDataWrapper.collect(reuseJoinedRow);
} else {
rowDataWrapper.collect(reuseResultRowData);
}
}
use of org.apache.flink.table.data.utils.JoinedRowData in project flink by apache.
the class BatchArrowPythonGroupWindowAggregateFunctionOperator method open.
@Override
public void open() throws Exception {
super.open();
inputKeyAndWindow = new LinkedList<>();
windowProperty = new GenericRowData(namedProperties.length);
windowAggResult = new JoinedRowData();
windowsGrouping = new HeapWindowsGrouping(maxLimitSize, windowSize, slideSize, inputTimeFieldIndex, false);
forwardedInputSerializer = new RowDataSerializer(inputType);
}
use of org.apache.flink.table.data.utils.JoinedRowData in project flink by apache.
the class AbstractPythonScalarFunctionOperator method open.
@SuppressWarnings("unchecked")
@Override
public void open() throws Exception {
super.open();
rowDataWrapper = new StreamRecordRowDataWrappingCollector(output);
reuseJoinedRow = new JoinedRowData();
udfInputProjection = udfInputGeneratedProjection.newInstance(Thread.currentThread().getContextClassLoader());
forwardedFieldProjection = forwardedFieldGeneratedProjection.newInstance(Thread.currentThread().getContextClassLoader());
}
use of org.apache.flink.table.data.utils.JoinedRowData in project flink by apache.
the class PassThroughPythonStreamGroupWindowAggregateOperator method open.
@Override
public void open() throws Exception {
super.open();
windowBaos = new ByteArrayOutputStreamWithPos();
windowBaosWrapper = new DataOutputViewStreamWrapper(windowBaos);
reusePythonRowData = new UpdatableRowData(GenericRowData.of(NORMAL_RECORD, null, null), 3);
reusePythonTimerRowData = new UpdatableRowData(GenericRowData.of(TRIGGER_TIMER, null, null), 3);
reusePythonTimerData = new UpdatableRowData(GenericRowData.of(0, null, null, null), 4);
reuseJoinedRow = new JoinedRowData();
windowAggResult = new JoinedRowData();
reusePythonTimerRowData.setField(2, reusePythonTimerData);
windowAccumulateData = new HashMap<>();
windowRetractData = new HashMap<>();
mockPythonInternalService = (InternalTimerServiceImpl<K, TimeWindow>) getInternalTimerService("python-window-timers", windowSerializer, this.mockPythonWindowOperator);
this.groupKeyProjection = createProjection("GroupKey", grouping);
int inputFieldIndex = (int) aggregateFunction.getInputs()[0];
this.aggExtracter = input -> {
GenericRowData aggResult = new GenericRowData(1);
aggResult.setField(0, input.getLong(inputFieldIndex));
return aggResult;
};
this.windowExtractor = window -> {
GenericRowData windowProperty = new GenericRowData(namedProperties.length);
for (int i = 0; i < namedProperties.length; i++) {
switch(namedProperties[i]) {
case WINDOW_START:
windowProperty.setField(i, getShiftEpochMills(window.getStart()));
break;
case WINDOW_END:
windowProperty.setField(i, getShiftEpochMills(window.getEnd()));
break;
case ROW_TIME_ATTRIBUTE:
windowProperty.setField(i, getShiftEpochMills(window.getEnd() - 1));
break;
case PROC_TIME_ATTRIBUTE:
windowProperty.setField(i, -1L);
}
}
return windowProperty;
};
}
Aggregations