use of org.apache.flink.table.runtime.generated.JoinCondition in project flink by apache.
the class WindowJoinOperator method open.
@Override
public void open() throws Exception {
super.open();
this.collector = new TimestampedCollector<>(output);
collector.eraseTimestamp();
final LongSerializer windowSerializer = LongSerializer.INSTANCE;
InternalTimerService<Long> internalTimerService = getInternalTimerService("window-timers", windowSerializer, this);
this.windowTimerService = new WindowTimerServiceImpl(internalTimerService, shiftTimeZone);
// init join condition
JoinCondition condition = generatedJoinCondition.newInstance(getRuntimeContext().getUserCodeClassLoader());
this.joinCondition = new JoinConditionWithNullFilters(condition, filterNullKeys, this);
this.joinCondition.setRuntimeContext(getRuntimeContext());
this.joinCondition.open(new Configuration());
// init state
ListStateDescriptor<RowData> leftRecordStateDesc = new ListStateDescriptor<>(LEFT_RECORDS_STATE_NAME, leftSerializer);
ListState<RowData> leftListState = getOrCreateKeyedState(windowSerializer, leftRecordStateDesc);
this.leftWindowState = new WindowListState<>((InternalListState<RowData, Long, RowData>) leftListState);
ListStateDescriptor<RowData> rightRecordStateDesc = new ListStateDescriptor<>(RIGHT_RECORDS_STATE_NAME, rightSerializer);
ListState<RowData> rightListState = getOrCreateKeyedState(windowSerializer, rightRecordStateDesc);
this.rightWindowState = new WindowListState<>((InternalListState<RowData, Long, RowData>) rightListState);
// metrics
this.leftNumLateRecordsDropped = metrics.counter(LEFT_LATE_ELEMENTS_DROPPED_METRIC_NAME);
this.leftLateRecordsDroppedRate = metrics.meter(LEFT_LATE_ELEMENTS_DROPPED_RATE_METRIC_NAME, new MeterView(leftNumLateRecordsDropped));
this.rightNumLateRecordsDropped = metrics.counter(RIGHT_LATE_ELEMENTS_DROPPED_METRIC_NAME);
this.rightLateRecordsDroppedRate = metrics.meter(RIGHT_LATE_ELEMENTS_DROPPED_RATE_METRIC_NAME, new MeterView(rightNumLateRecordsDropped));
this.watermarkLatency = metrics.gauge(WATERMARK_LATENCY_METRIC_NAME, () -> {
long watermark = windowTimerService.currentWatermark();
if (watermark < 0) {
return 0L;
} else {
return windowTimerService.currentProcessingTime() - watermark;
}
});
}
use of org.apache.flink.table.runtime.generated.JoinCondition in project flink by apache.
the class CodeSplitTest method testJoinCondition.
@Test
public void testJoinCondition() {
int numFields = 200;
FlinkTypeFactory typeFactory = FlinkTypeFactory.INSTANCE();
RexBuilder builder = new RexBuilder(typeFactory);
RelDataType intType = typeFactory.createFieldTypeFromLogicalType(new IntType());
RexNode[] conditions = new RexNode[numFields];
for (int i = 0; i < numFields; i++) {
conditions[i] = builder.makeCall(SqlStdOperatorTable.LESS_THAN, new RexInputRef(i, intType), new RexInputRef(numFields + i, intType));
}
RexNode joinCondition = builder.makeCall(SqlStdOperatorTable.AND, conditions);
RowType rowType = getIntRowType(numFields);
GenericRowData rowData1 = new GenericRowData(numFields);
GenericRowData rowData2 = new GenericRowData(numFields);
Random random = new Random();
for (int i = 0; i < numFields; i++) {
rowData1.setField(i, 0);
rowData2.setField(i, 1);
}
boolean result = random.nextBoolean();
if (!result) {
rowData1.setField(random.nextInt(numFields), 1);
}
Consumer<TableConfig> consumer = tableConfig -> {
JoinCondition instance = JoinUtil.generateConditionFunction(tableConfig, joinCondition, rowType, rowType).newInstance(classLoader);
for (int i = 0; i < 100; i++) {
Assert.assertEquals(result, instance.apply(rowData1, rowData2));
}
};
runTest(consumer);
}
use of org.apache.flink.table.runtime.generated.JoinCondition in project flink by apache.
the class AbstractStreamingJoinOperator method open.
@Override
public void open() throws Exception {
super.open();
JoinCondition condition = generatedJoinCondition.newInstance(getRuntimeContext().getUserCodeClassLoader());
this.joinCondition = new JoinConditionWithNullFilters(condition, filterNullKeys, this);
this.joinCondition.setRuntimeContext(getRuntimeContext());
this.joinCondition.open(new Configuration());
this.collector = new TimestampedCollector<>(output);
}
Aggregations