Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

ColdFusion Capabilities and Constraints With Handling Large Datasets

DZone's Guide to

ColdFusion Capabilities and Constraints With Handling Large Datasets

ColdFusion may be one of the more obscure languages out there, but it's great for handling large datasets. Read on to learn why.

· Big Data Zone ·
Free Resource

Hortonworks Sandbox for HDP and HDF is your chance to get started on learning, developing, testing and trying out new features. Each download comes preconfigured with interactive tutorials, sample data and developments from the Apache community.

Handling big data capabilities can be very challenging without using a high-level programming language. ColdFusion is a language that tackles many of these obstacles. It is a powerful and highly expressive language that can process large data sets, provided you utilize the right methodologies. Nevertheless, ColdFusion has its own limitations that any data developer or project manager must be aware of.

Before you begin the long, arduous process of mastering this complex programming language, it is important to familiarize yourself with the benefits and limits. Here are some things to understand.

Query of Queries

ColdFusion is slowly evolving programming language. It wasn’t until the fifth generation of ColdFusion that Macromedia introduced a solution for developers to execute SQL statements along with pre-existing query result sets. Macromedia officially dubbed this functionality as the Query of Queries. This is a complex concept for new ColdFusion developers, so you may need to find programmers ready to help you with advice in algorithms and coding.

The latest generation has built upon the Query of Queries foundation. You can execute a number of SQL statements against any results that you already derived from a Query of Queries compilation.

Although Macromedia has significantly expanded the functionality of the Query of Queries, there are still some limits. This feature doesn’t support the entire spectrum of ANSI SQL capabilities. However, it is far more versatile at processing SQL functions than preceeding versions of ColdFusion. Many of the most popular SQL aggregate functions and commands are supported.

Since the new Query of Queries functionality is able to process multi-dimensional arrays, it is ideal for handling applications that require you to process very large data sets. You can continually run new iterations.

The problem is the lack of SQL commands that you can use at your disposal. You can make the most use of the WHERE clause. This clause accepts a wide range of conditionals, including LIKE, IN, BETWEEN, as well as the  Min()Max(), Average(), sum(), and count() methods.

You can also use over half a dozen of the most popular sorting clauses. ORDER BY and GROUP BY are two of the most important. Make sure that you are familiar with their breadth of commands and use them to their fullest potential.

This is actually an impressive picture that ColdFusion was able to provide over a decade ago before the term “big data” was even on most peoples' radar. You can use the clear buffer() method to write large files with applications that require you to process huge record sets.

Ben Nadel discussed this after reading a post on CF-talk. Ben’s blog post was originally meant for the OP of that thread, but he points out that it has important messages for anybody that wants to write large files. Here is an excerpt of the code he provides to help illustrate the process:

<cfset int offset = (int offset + in headcount) />
        <!---
            Reset the buffer. This should kill the white space

            that is building up in the ColdFusion memory space.
        --->
        <cfset GetPageContext().GetOut().ClearBuffer() />
    <cfelse>

Keep in mind that this blog post was written for people using the first edition of ColdFusion. However, the same methods are still supported today, so you can still use them to write large files.

Populate Arrays With Data

Another important application for ColdFusion is being able to populate arrays with data. Adobe has a detailed blog post on the process. Here is a quick explanation that they have provided:

“You can use the  ArraySet  function to populate a 1D array, or one dimension of a multidimensional array, with some initial value, such as an empty string or zero. This can be useful to create an array of a certain size, without adding data to it right away. One reason to do this is so that you can reference all the array indexes. If you reference an array index that does not contain some value, such as an empty string, you get an error.” - Adobe Docs

Here is a quick overview of the process that you will follow:

  • Write the code for a cfloop.
  • Nest your cfloop tags in 2D and 3D arrays.
  • Populate your arrays from queries.

This is an easy way to handle different types of data. Most standard data types are supported.

Hortonworks Community Connection (HCC) is an online collaboration destination for developers, DevOps, customers and partners to get answers to questions, collaborate on technical articles and share code examples from GitHub.  Join the discussion.

Topics:
coldfusion ,data sets ,big data ,query of queries

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}