MongoDB of report diversity data source

Source: Internet
Author: User

NoSQL databases such as MongoDB have the advantages of scalability and high performance, but the computational power is weaker than traditional SQL, such as MongoDB's grouping result is not too large, and does not directly support join operations, and the calculation engine built in the integrated report can just add to this point, Gain the advantages of MongoDB while also having strong computing power.

We use a grouping instance to learn about the process of developing reports using a MONGODB data source for a collection report.

Report Description

Student performance information is stored in MongoDB, including classes, names, scores, subjects and other information, scores table (score) data content as follows:



According to the Student information summary total scores, and ranking. The following steps are implemented:

preparing the MongoDB JDBC driver package

The latest version of MongoDB2.6.4 is used here, because the collection report does not contain MongoDB's Java driver package. To access MongoDB using a collection report, you must prepare your MongoDB Java driver package in advance (the 2.12.2 or later driver for the aggregate report, such as Mongo-java-driver-2.12.2.jar).

because you want to use the collector to edit a calculation script and use the Set Report Designer to complete report template authoring, you need to place the above packages under the]\COMMON\JDBC report and the Collector installation directory (the Web deployment is placed in the classpath of your app). The Java driver package for MongoDB is: https://github.com/MongoDB/mongo-java-driver/releases.

writing a calculation script

Use the Collector Editor to write the set-up script (P1.DFX), complete the table data read calculation, and return the result set for the report (the right side is the result of the grid run).

A1: The connection Mongodb,ip and port number is localhost:27017, the database is test, and the user name and password are empty. If you need other parameters, you can follow mongo://ip:port/db?user=...&password= ... format to continue writing parameters.

A2: Use the Find function to take a number from MongoDB to form a cursor. The collection is score, removing all fields except _id. You can see that the Find function is similar to MongoDB's find function. The collector's cursors are read and processed in batches to avoid excessive amounts of data and memory overflow situations.

A3: Closes the connection.

A4: Group by ID field.

A5: summary total.

A6: Returns the result set for the report by total score.

edit a report template

You first create a new report in the collection Report Designer, set the dataset, and use the "collector" DataSet type to invoke the edited script file (p1.dfx).

Where the DFX file path can be either an absolute path or a relative path, relative paths are configured in the relative option of the DFX home directory.

Edit the report expression, use the result set returned by the collection script directly, and no longer group the sorting in the report, complete the report production

previewing the report in the designer can result in the following:

as can be seen from the above implementation, the use of the collector script can easily complete the MongoDB data read calculation, and the external set of the script has a visual editing debugging environment, the edited script can also be reused (by other reports or programs called). However, if the script has been debugged and does not need to be reused, it would be cumbersome to maintain the consistency of the two files (both the set and report templates), which makes it easier to use the script dataset directly for the set report.

In the script dataset, you can step through the script to complete the calculation tasks, the syntax is consistent with the concentrator, and you can use the report-defined parameters directly. This can be done using a script dataset:

1. Click the "Add" button in the DataSet Settings window, pop Up the DataSet Type dialog and select "Script Data Set";

2. Write scripts in the popup Script dataset editing window;

3, report expression, with the use of the collector data set consistent, no longer repeat.


MongoDB of report diversity data source

Related Article

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.