A hook-up algorithm for optimizing application structure of run-dry set calculation report

Source: Internet
Author: User

in a report project, data calculation methods for some reports change frequently. For example, the real wages of an enterprise employee are calculated by the performance score, the algorithm changes frequently, and the old algorithm needs to be replaced with the new algorithm without altering the other code. If the computation is implemented in Java, it is possible to implement dynamic hook-up calculation module, but there are some problems such as lack of base class library and unnecessary memory.

The use of run-dry set calculation report can be a good solution to these problems, the realization of low-coupling, hot deployment of dynamic hook algorithm. The system structure of the set-calculation report hook algorithm system combined with other reporting tools +java is as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/65/wKioL1T9FsmyNrYQAAEF4a4vyB0316.jpg "style=" float: none; "title=" report5_structure_algorithm_1.jpg "alt=" Wkiol1t9fsmynryqaaef4a4vyb0316.jpg "/>

as you can see,Java programs must be compiled and packaged to be updated. The set-up script is interpreted, and the script file is also an executable file, so you can replace the file update directly. At the same time, the collection script can be stored in pairs with the report template and can be conveniently managed.

The following example of employee performance pay to see the implementation of the collection report, and the general Report Tool +java implementation of the comparison.

The employee performance salary report is as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/69/wKiom1T9Fa6AD5YTAACUnFdWTKc826.jpg "style=" float: none; "title=" report5_structure_algorithm_2.jpg "alt=" Wkiom1t9fa6ad5ytaacunfdwtkc826.jpg "/>

The report format is simple, but the calculation method is relatively complex and often changes. The first step in implementing a hook-up algorithm with a collection report is to write the collector script:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/65/wKioL1T9FsqA735tAAJIkljXGRs281.jpg "style=" float: none; "title=" report5_structure_algorithm_3.jpg "alt=" Wkiol1t9fsqa735taajikljxgrs281.jpg "/>

The A2 cell has an input parameter of gender, which is a selection input from the user on the report page. A13 Cell is the result returned to the report page. A2 to A12 is the calculation method of performance pay, not the focus of this article, here is not described in detail.

A report template for a collection report can define a computed dataset to invoke this hook-up compute module:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/69/wKiom1T9Fa7QRNAwAAD_yoAQD-Q502.jpg "style=" float: none; "title=" report5_structure_algorithm_4.jpg "alt=" Wkiom1t9fa7qrnawaad_yoaqd-q502.jpg "/>

wherethe gender parameter is the input parameter of the DYNAMIC.DFX, the dataset ds1 receives The result set returned by DYNAMIC.DFX.

you can see a very low degree of coupling between the DYNAMIC.DFX and report templates. If you want to change the calculation method of performance pay, you just need to write a new dynamic.dfx, replace the original DFX file on the server . Because DFX scripts are interpreted, they can be replaced without downtime, enabling true thermal deployment.

Finally, you design the report template in the collection Report Designer as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/69/wKiom1T9Fa_z9awjAABt8l8c1S0959.jpg "style=" float: none; "title=" report5_structure_algorithm_5.jpg "alt=" Wkiom1t9fa_z9awjaabt8l8c1s0959.jpg "/>

from this example, we can see that the hook-up algorithm implemented by the set-calculation report has many advantages over the general report Tool +java.

1. dynamic.dfx may use the various class libraries provided by the collection report: grouping, summarizing, sorting, filtering, associating, unique values, intersections, rankings, and so on. Java Programmers must manually write these basic algorithms. It is obviously unreasonable to implement these basic algorithms directly in the business logic, which causes each compute module to repeat similar code, the computational module is too large and the readability becomes worse. The ideal approach is to implement a set of basic algorithm class library, and then call these libraries in the calculation module, but it is difficult for the application programmer to design the complete and systematic excellent basic algorithm class library, often make the code of high coupling, poor stability, and ultimately lead to the maintenance of the computational module difficult.

the set-up engine itself is such a well-designed, complete base class library that requires only JAVA One-tenth Code volume can achieve the same function of the calculation module, the development efficiency is higher.

2,the Java code needs to recompile, the deployment is more troublesome; when there are many compute modules that can be hooked up, whether or not they are used, these Java Class/jar will occupy memory space and cannot be released, which has a certain effect on performance.

The Collector Engine main program and the script file of the collection report are separate, the coupling is very low, the maintenance is more convenient. In addition, the set-up script does not need to be compiled to be used, it is a true hot deployment. The script is not loaded into memory beforehand, but is loaded when it is used, and is released immediately after calculation and does not occupy memory for a long time.




This article is from the High performance report data calculation blog, so be sure to keep this source http://report5.blog.51cto.com/8028595/1618509

A hook-up algorithm for optimizing application structure of run-dry set calculation report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.