@@ -66,7 +66,7 @@ public class PostTransformOperator extends AbstractStreamOperator<Event>
66
66
/** keep the relationship of TableId and table information. */
67
67
private final Map <TableId , TableInfo > tableInfoMap ;
68
68
69
- private transient Map <TransformProjection , TransformProjectionProcessor >
69
+ private transient Map <TransformProjection , PostTransformProcessor >
70
70
transformProjectionProcessorMap ;
71
71
private transient Map <TransformFilter , TransformFilterProcessor > transformFilterProcessorMap ;
72
72
@@ -217,7 +217,7 @@ private SchemaChangeEvent cacheSchema(SchemaChangeEvent event) throws Exception
217
217
}
218
218
219
219
Schema projectedSchema = transformSchema (tableId , schema );
220
- tableInfoMap .put (tableId , TableInfo .of (tableId , schema , projectedSchema ));
220
+ tableInfoMap .put (tableId , TableInfo .of (tableId , projectedSchema , schema ));
221
221
222
222
if (event instanceof CreateTableEvent ) {
223
223
return new CreateTableEvent (event .tableId (), projectedSchema );
@@ -231,7 +231,7 @@ private TableInfo getTableInfoFromSchemaEvolutionClient(TableId tableId) throws
231
231
Optional <Schema > schemaOptional = schemaEvolutionClient .getLatestSchema (tableId );
232
232
if (schemaOptional .isPresent ()) {
233
233
Schema projectedSchema = transformSchema (tableId , schemaOptional .get ());
234
- tableInfo = TableInfo .of (tableId , schemaOptional .get (), projectedSchema );
234
+ tableInfo = TableInfo .of (tableId , projectedSchema , schemaOptional .get ());
235
235
} else {
236
236
throw new RuntimeException (
237
237
"Could not find schema message from SchemaRegistry for " + tableId );
@@ -251,14 +251,12 @@ private Schema transformSchema(TableId tableId, Schema schema) throws Exception
251
251
if (!transformProjectionProcessorMap .containsKey (transformProjection )) {
252
252
transformProjectionProcessorMap .put (
253
253
transformProjection ,
254
- TransformProjectionProcessor .of (
255
- transformProjection , transformFilter ));
254
+ PostTransformProcessor .of (transformProjection , transformFilter ));
256
255
}
257
- TransformProjectionProcessor transformProjectionProcessor =
256
+ PostTransformProcessor postTransformProcessor =
258
257
transformProjectionProcessorMap .get (transformProjection );
259
258
// update the columns of projection and add the column of projection into Schema
260
- newSchemas .add (
261
- transformProjectionProcessor .processSchemaChangeEvent (schema , false ));
259
+ newSchemas .add (postTransformProcessor .processSchemaChangeEvent (schema ));
262
260
}
263
261
}
264
262
}
@@ -289,36 +287,13 @@ private Optional<DataChangeEvent> processDataChangeEvent(DataChangeEvent dataCha
289
287
long epochTime = System .currentTimeMillis ();
290
288
for (PostTransformers transform : transforms ) {
291
289
Selectors selectors = transform .getSelectors ();
292
- boolean isPreProjection = transform . isContainFilteredComputedColumn ();
290
+
293
291
if (selectors .isMatch (tableId )) {
294
292
Optional <DataChangeEvent > dataChangeEventOptional = Optional .of (dataChangeEvent );
295
293
Optional <TransformProjection > transformProjectionOptional =
296
294
transform .getProjection ();
297
295
Optional <TransformFilter > transformFilterOptional = transform .getFilter ();
298
- if (isPreProjection
299
- && transformProjectionOptional .isPresent ()
300
- && transformProjectionOptional .get ().isValid ()) {
301
- TransformProjection transformProjection = transformProjectionOptional .get ();
302
- if (!transformProjectionProcessorMap .containsKey (transformProjection )
303
- || !transformProjectionProcessorMap
304
- .get (transformProjection )
305
- .hasTableInfo ()) {
306
- transformProjectionProcessorMap .put (
307
- transformProjection ,
308
- TransformProjectionProcessor .of (
309
- tableInfo ,
310
- transformProjection ,
311
- transformFilterOptional .orElse (null ),
312
- timezone ));
313
- }
314
- TransformProjectionProcessor transformProjectionProcessor =
315
- transformProjectionProcessorMap .get (transformProjection );
316
- dataChangeEventOptional =
317
- processProjection (
318
- transformProjectionProcessor ,
319
- dataChangeEventOptional .get (),
320
- epochTime );
321
- }
296
+
322
297
if (transformFilterOptional .isPresent ()
323
298
&& transformFilterOptional .get ().isVaild ()) {
324
299
TransformFilter transformFilter = transformFilterOptional .get ();
@@ -335,8 +310,7 @@ private Optional<DataChangeEvent> processDataChangeEvent(DataChangeEvent dataCha
335
310
dataChangeEventOptional .get (),
336
311
epochTime );
337
312
}
338
- if (!isPreProjection
339
- && dataChangeEventOptional .isPresent ()
313
+ if (dataChangeEventOptional .isPresent ()
340
314
&& transformProjectionOptional .isPresent ()
341
315
&& transformProjectionOptional .get ().isValid ()) {
342
316
TransformProjection transformProjection = transformProjectionOptional .get ();
@@ -346,17 +320,17 @@ private Optional<DataChangeEvent> processDataChangeEvent(DataChangeEvent dataCha
346
320
.hasTableInfo ()) {
347
321
transformProjectionProcessorMap .put (
348
322
transformProjection ,
349
- TransformProjectionProcessor .of (
323
+ PostTransformProcessor .of (
350
324
tableInfo ,
351
325
transformProjection ,
352
326
transformFilterOptional .orElse (null ),
353
327
timezone ));
354
328
}
355
- TransformProjectionProcessor transformProjectionProcessor =
329
+ PostTransformProcessor postTransformProcessor =
356
330
transformProjectionProcessorMap .get (transformProjection );
357
331
dataChangeEventOptional =
358
332
processProjection (
359
- transformProjectionProcessor ,
333
+ postTransformProcessor ,
360
334
dataChangeEventOptional .get (),
361
335
epochTime );
362
336
}
@@ -402,20 +376,18 @@ private Optional<DataChangeEvent> processFilter(
402
376
}
403
377
404
378
private Optional <DataChangeEvent > processProjection (
405
- TransformProjectionProcessor transformProjectionProcessor ,
379
+ PostTransformProcessor postTransformProcessor ,
406
380
DataChangeEvent dataChangeEvent ,
407
- long epochTime )
408
- throws Exception {
381
+ long epochTime ) {
409
382
BinaryRecordData before = (BinaryRecordData ) dataChangeEvent .before ();
410
383
BinaryRecordData after = (BinaryRecordData ) dataChangeEvent .after ();
411
384
if (before != null ) {
412
385
BinaryRecordData projectedBefore =
413
- transformProjectionProcessor .processData (before , epochTime );
386
+ postTransformProcessor .processData (before , epochTime );
414
387
dataChangeEvent = DataChangeEvent .projectBefore (dataChangeEvent , projectedBefore );
415
388
}
416
389
if (after != null ) {
417
- BinaryRecordData projectedAfter =
418
- transformProjectionProcessor .processData (after , epochTime );
390
+ BinaryRecordData projectedAfter = postTransformProcessor .processData (after , epochTime );
419
391
dataChangeEvent = DataChangeEvent .projectAfter (dataChangeEvent , projectedAfter );
420
392
}
421
393
return Optional .of (dataChangeEvent );
@@ -438,14 +410,14 @@ private Optional<DataChangeEvent> processPostProjection(
438
410
439
411
private BinaryRecordData projectRecord (TableInfo tableInfo , BinaryRecordData recordData ) {
440
412
List <Object > valueList = new ArrayList <>();
441
- RecordData .FieldGetter [] fieldGetters = tableInfo .getProjectedFieldGetters ();
413
+ RecordData .FieldGetter [] fieldGetters = tableInfo .getFieldGetters ();
442
414
443
415
for (RecordData .FieldGetter fieldGetter : fieldGetters ) {
444
416
valueList .add (fieldGetter .getFieldOrNull (recordData ));
445
417
}
446
418
447
419
return tableInfo
448
- .getProjectedRecordDataGenerator ()
420
+ .getRecordDataGenerator ()
449
421
.generate (valueList .toArray (new Object [valueList .size ()]));
450
422
}
451
423
0 commit comments