The Open-source SPL Boosts MongoDB Computing Ability

Judy - Feb 7 - - Dev Community

MongoDB is a typical NoSQL database. Its document-oriented structure makes both storage and access convenient and efficient. But the database has rather weak computing ability. Computations on MongoDB data, particularly complex ones, are hard to handle. A data computing engine having powerful computing capability is needed to work with MongoDB to achieve relevant computing tasks.

The open-source esProc SPL is a specialized structured data computation engine. It supplies rich class libraries and all-around, database-independent computational capabilities. SPL has an independent procedural syntax that is particularly good at handling complex computations. It can help MongoDB increase its ability to compute, accomplish grouping & aggregation, joins, subqueries, and all the other computing tasks effortlessly.

Regular queries
It is easy to achieve JOINs MongoDB finds it difficult to handle in SPL:

Image description
SPL can reuse the result of handling data of a table that is repeatedly involved in computations:

Image description
Perform IN conditional query in SPL:

Image description
SPL’s technique to turn foreign key values to objects – the object-referencing foreign key – creates efficient foreign key pointers:

Image description

SPL achieves APPLY algorithm in a simple way:

Image description
SPL’s way of performing set-oriented calculations – intersection, union, difference and concatenation:

Image description
Get sequence number of a member in a sequence in SPL:

Image description
Perform intersection of multi-member collections in SPL:
Image description

Complex queries
Getting TopN in SPL:

Image description
Summarize a nested-structure collection in SPL:

Image description
Combine subdocuments made up of multiple attributes in SPL:

Image description
Query nested List subdocument in SPL:

Image description
SPL Cross-sector aggregation:

Image description
SPL segment-based grouping:

Image description
Data writing
Export data as CSV in SPL:

Image description
SPL database update (from MongoDB to MySQL):

Image description
SPL database update (from MySQL to MongoDB):

Image description
Mixed computations
SPL enables convenient mixed computation between MongoDB and another data source:

Image description
SQL support
Besides the native syntax, SPL offers support of SQL92 standard. You can use SQL to query MongoDB. To achieve the above join operation, for instance:

Image description
Integration into application
SPL provides standard JDBC/ODBC drivers through which SPL can be conveniently integrated into an application or invoked by it. To invoke SPL code through JDBC, for instance:

…
Class.forName("com.esproc.jdbc.InternalDriver");

Connection conn = DriverManager.getConnection("jdbc:esproc:local://");

PrepareStatement st=con.prepareStatement("call splScript(?)"); // splScript is the name of SPL script file

st.setObject(1,"California");

st.execute();

ResultSet rs = st.getResultSet();
…

Enter fullscreen mode Exit fullscreen mode

With all those functionalities, you’ll sure to be impressed by MongoDB’s strikingly boosted computing ability. Try your hand now.

SPL source code

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .