use of org.apache.flink.table.data.GenericRowData in project flink by apache.
the class StreamingJoinOperator method open.
@Override
public void open() throws Exception {
super.open();
this.outRow = new JoinedRowData();
this.leftNullRow = new GenericRowData(leftType.toRowSize());
this.rightNullRow = new GenericRowData(rightType.toRowSize());
// initialize states
if (leftIsOuter) {
this.leftRecordStateView = OuterJoinRecordStateViews.create(getRuntimeContext(), "left-records", leftInputSideSpec, leftType, stateRetentionTime);
} else {
this.leftRecordStateView = JoinRecordStateViews.create(getRuntimeContext(), "left-records", leftInputSideSpec, leftType, stateRetentionTime);
}
if (rightIsOuter) {
this.rightRecordStateView = OuterJoinRecordStateViews.create(getRuntimeContext(), "right-records", rightInputSideSpec, rightType, stateRetentionTime);
} else {
this.rightRecordStateView = JoinRecordStateViews.create(getRuntimeContext(), "right-records", rightInputSideSpec, rightType, stateRetentionTime);
}
}
use of org.apache.flink.table.data.GenericRowData in project flink by apache.
the class BufferDataOverWindowOperatorTest method test.
private void test(OverWindowFrame[] frames, GenericRowData[] expect) throws Exception {
MockEnvironment env = new MockEnvironmentBuilder().setIOManager(ioManager).setMemoryManager(memoryManager).build();
StreamTask<Object, StreamOperator<Object>> task = new StreamTask<Object, StreamOperator<Object>>(env) {
@Override
protected void init() {
}
};
operator = new BufferDataOverWindowOperator(frames, comparator, true) {
{
output = new NonBufferOverWindowOperatorTest.ConsumerOutput(new Consumer<RowData>() {
@Override
public void accept(RowData r) {
collect.add(GenericRowData.of(r.getInt(0), r.getLong(1), r.getLong(2), r.getLong(3), r.getLong(4)));
}
});
}
@Override
public ClassLoader getUserCodeClassloader() {
return Thread.currentThread().getContextClassLoader();
}
@Override
public StreamConfig getOperatorConfig() {
StreamConfig conf = mock(StreamConfig.class);
when(conf.<RowData>getTypeSerializerIn1(getUserCodeClassloader())).thenReturn(inputSer);
when(conf.getManagedMemoryFractionOperatorUseCaseOfSlot(eq(ManagedMemoryUseCase.OPERATOR), any(Configuration.class), any(ClassLoader.class))).thenReturn(0.99);
return conf;
}
@Override
public StreamTask<?, ?> getContainingTask() {
return task;
}
@Override
public StreamingRuntimeContext getRuntimeContext() {
return mock(StreamingRuntimeContext.class);
}
};
operator.setProcessingTimeService(new TestProcessingTimeService());
operator.open();
addRow(0, 1L, 4L);
/* 1 **/
addRow(0, 1L, 1L);
/* 2 **/
addRow(0, 1L, 1L);
/* 3 **/
addRow(0, 1L, 1L);
/* 4 **/
addRow(1, 5L, 2L);
/* 5 **/
addRow(2, 5L, 4L);
/* 6 **/
addRow(2, 6L, 2L);
/* 7 **/
addRow(2, 6L, 2L);
/* 8 **/
addRow(2, 6L, 2L);
/* 9 **/
operator.endInput();
GenericRowData[] outputs = this.collect.toArray(new GenericRowData[0]);
Assert.assertArrayEquals(expect, outputs);
operator.close();
}
use of org.apache.flink.table.data.GenericRowData in project flink by apache.
the class RankOperator method open.
@Override
public void open() throws Exception {
super.open();
ClassLoader cl = getUserCodeClassloader();
inputSer = (AbstractRowDataSerializer) getOperatorConfig().getTypeSerializerIn1(cl);
partitionByComp = partitionByGenComp.newInstance(cl);
partitionByGenComp = null;
orderByComp = orderByGenComp.newInstance(cl);
orderByGenComp = null;
if (outputRankFunColumn) {
joinedRow = new JoinedRowData();
rankValueRow = new GenericRowData(1);
}
collector = new StreamRecordCollector<>(output);
}
use of org.apache.flink.table.data.GenericRowData in project flink by apache.
the class FirstValueAggFunction method resetAccumulator.
public void resetAccumulator(RowData rowData) {
GenericRowData acc = (GenericRowData) rowData;
acc.setField(0, null);
acc.setField(1, Long.MAX_VALUE);
}
use of org.apache.flink.table.data.GenericRowData in project flink by apache.
the class LastValueAggFunction method resetAccumulator.
public void resetAccumulator(RowData rowData) {
GenericRowData acc = (GenericRowData) rowData;
acc.setField(0, null);
acc.setField(1, Long.MIN_VALUE);
}
Aggregations