我需要就如何为Spring Batch中的目标Summary表设计ETL过程提出意见 .

Situation

我确实有一个(怪物)查询,它将多个查询的组合连接在一起,生成我想要作为我的最终汇总表的网格 . 查询的“形状”如下:

select A.student_id,
       A.anoterField,
       B.anotherField,
       B.anotherField,
       C.anotherField,
       C.anotherField,
       D.anotherField
from(               
          (select s.student_id         
           from table_name
           inner join another_table
               on
           where     
           and
           group by s.student_id
           )A
inner join (select s.student_id
                   , ...
                   , ...
            from table_name
            inner join another_table
            where    
            and
            group by s.student_id
            )B
    on a.student_id = b.student_id            
inner join (select s.student_id
                   , ...
                   , ...
            from table_name
            inner join another_table
            where    
            and
            group by s.student_id
            )C  
    on a.student_id = c.student_id              
.
.
.
.
.
.

Problem

此查询仅针对一所学校的基于Kimball的数据仓库运行,并且在所有总和,每个内部查询执行的分组等之后,它已经是一个相当激烈的查询 .

Solution

我决定要做一个能产生汇总表的ETL工作 .

我决定在数据库级别不进行任何数学运算 . 我只想选择更细粒度的数据,并让ETL为我进行分组和求和 .

Design Questions

我已经设法通过阅读,处理和编写项目来熟悉Spring Batch,但我仍在学习框架 .

那我该如何设计这份工作......

  • 我正在考虑创建与内部查询一样多的读者,然后将每个输出(A List of Objects)发送到 one and only processor 这个处理器将拥有所有业务逻辑(总和,拥有,分组查询上面有)并将为每个学生创建一个对象(数据库行) . 最后,将创建的对象列表发送到编写器,编写器将填充摘要表 . 这是否可能,因为我理解每一步都有读者,处理器和作家?

  • 鉴于每个步骤都有一个处理器和编写器,我应该在一个步骤中拥有每个内部查询,有自己的处理器来执行该特定数据的摘要,并将其写入文件 . 最后有一个 grab 所有这些文件的步骤,处理器合并创建一个Object的数据,最后是一个对象列表并将其发送给填充摘要表的编写器?

你会选哪一个?

如果是第二个选项,读者可以从多个来源读取一个步骤吗?换句话说,我可以在最后一步读取5个或6个文件,并将列表 Map 仅发送到一个处理器吗?

如果没有,我希望很清楚 . 我正在尝试使用Spring Batch设计批处理作业 .