Quantcast
Channel: SCN : Blog List - All Communities
Viewing all articles
Browse latest Browse all 2548

Design Studio: Parallel Processing and Scripting

$
0
0

Getting started with parallel processing is easy. Assign data sources to processing groups, set “Merge Prompts” to false, and just execute the application.

While this is true in general, there are some things you need to know.


 

Parallel processing is not present in all phases of application execution. Four specific phases take advantage of parallel processing (see also Chapter 29.10 of Design Studio’s “Application Designer Guide”):

 

  • Initialization of data sources on start-up
  • Fetching result sets during rendering
  • Submitting variables
  • Data binding

 

As you might have noticed, the execution of script statements is not mentioned in the above list.

 

 

Beware the Script Execution

 

Design Studio scripts are always executed sequentially, that is statement by statement. When one statement is executed, it must rely on the fact that the execution of the previous statement has been completed. This rules out parallel execution of statements. For example, if a statement makes a decision based on a result that was computed with a previous statement, the script must be processed in the defined sequence in order to arrive at a reproducible result.

 

     var value = LISTBOX_1.getSelectedValue();

     if (value == "DeleteOrder") {

          // ...

     }

 

Keep this in mind when using script functions that access data sources.

But there is no need to worry, there are solutions around that deal with these circumstances.

 

 

Solution 1: Load Multiple Data Sources in Parallel During Script Execution

 

When you are initializing several data sources in a Design Studio script, try to centralize data source initialization in one place and use APPLICATION.loadDataSources(). This function can initialize the given data sources in parallel.

 

Traditionally initializing several data sources needed multiple script statements:

 

     DS_1.loadDataSource();

     DS_2.loadDataSource();

     DS_3.loadDataSource();

 

As mentioned above these three statements would be executed in sequence. However the initialization of several data sources is a quite common scenario. Therefore a new statement is available that allows parallelization for this scenario:

 

     APPLICATION.loadDataSources([DS_1, DS_2, DS_3]);


Note that this statement does not process all data sources in parallel, but according to their assignment to a processing group.

 

 

Solution 2: Use Property Binding

 

Property binding allows replacing sequential script statements with binding information of data sources to properties of components. The processing of property bindings takes part in the parallel processing.

 

 

 

 

Property Binding - Simple Values

 

You want to set a text from a data source cell to a text field. Traditionally, a Design Studio script statement would retrieve the value of the cell with “getDataAsString” and assign it to the text property:

 

    var text = DS_1.getDataAsStringExt("store_sales", {});

    TEXT_1.setText(text);


When using property binding you create a property binding of type “Data Cell Binding” for the Text property of the text field:

 

dataBinding.png

 

Property Binding - Multiple Values

 

You want to populate a list box with members from a data source. Traditionally, a Design Studio script statement would retrieve the members with “getMembers” and assign it to the list box:

 

     var items = DS_1.getMemberList("city", ...);

     LISTBOX_1.setItems(items);

 

 

When using property binding you create a property binding of type “Dimension Members Binding” for the Items property of the list box:

 

dataBinding_member.png

 

 

Summary

 

Script statements are always executed in sequence. Use property bindings and “loadDataSources()” to leverage the full potential of parallel processing. These can replace specific script statements with techniques that are executed in parallel.


Viewing all articles
Browse latest Browse all 2548

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>