iotdb
iotdb copied to clipboard
[IOTDB-4832] Introducing freemarker to auto-generate type-specific code
During the execution of the vectorization engine, the primitive method is type-specific, so you must write separate method for each primitive data type. For example, IoTDB has six data types (except vector), so you must write six almost identical codes. These codes have the same method logic except for different type names, which brings a lot of work to the development process and code maintenance. Therefore, we can consider introducing a template based code generation framework to solve this problem.
Freemarker is a popular code generation framework. Freemarker preprocessor based on freemarker can iterate folders to generate code. With the help of some existing fmpp tools, we can easily introduce this framework. I added the drill-fmpp -maven-plugin
to the pom file, which can automatically generate code during compilation and package it with other code.
I have changed some codes related to Fill. There are many redundant codes caused by type-specific method in the warehouse. I didn't change them all becuase it's a big work. After introducing this framework, we can slowly change it.
向量化引擎执行过程中,原语方法是type-specific的,因此必须为每种原始数据类型编写单独的代码,例如 IoTDB 有 6种数据类型(除vector),则必须编写六份代码。这些代码除了类型名称不同以外方法逻辑均是相同的,这给开发过程和代码维护都带来了很大的工作量。因此,我们可以考虑引入基于模版的代码生成框架,来解决这一问题。 Freemarker 是一套流行的代码生成框架,基于 freemarker 的 freemarker preprocessor 可以迭代文件夹生成代码。借助一些现有的基于 fmpp 的 tool,我们可以非常方便的引进这一框架。我在 pom 文件中添加了 drill-fmpp-maven-plugin 插件,该工具可以在编译过程中自动生成代码并和其他代码一起打包。 我目前更改了 Fill 相关的一些代码,仓库内还有很多基于 type-specific 的冗余代码,在引入这一框架后,我们可以慢慢改掉它。