Wed Oct 28, 2020 8:34 pm
Login Register Lost Password? Contact Us


Introduction to Roxie - index creation

Questions and comments regarding the Online Lessons should be posted here.

Mon Sep 30, 2013 11:18 am Change Time Zone

In the FETCH_Example.ecl bundled along with Intro to Roxie online course material, I found the following piece of code (not complete):

Code: Select all
AlphaInStateCity := INDEX(Ptbl,
         {address,csz_id,lname,fname,RecPos},
         KeyFile);
Bld :=   BUILD(AlphaInStateCity,OVERWRITE);
AlphaPeople := FETCH(Ptbl,
         AlphaInStateCity(WILD(address),
         WILD(csz_id),
         KEYED(Lname='WIK')
         ),
         RIGHT.RecPos);
OutFile := OUTPUT(CHOOSEN(AlphaPeople,10));
SEQUENTIAL(PtblOut,Bld,OutFile)


When exactly does the index 'AlphaInStateCity' get built here? Is it
i) on execution of BUILD?
ii) on execution of the following FETCH?
iii) on execution of SEQUENTIAL?

What if there was no SEQUENTIAL statement?

Thanks,
Gayathri
Gayathri_Jayaraman
 
Posts: 75
Joined: Wed May 08, 2013 5:03 am

Mon Sep 30, 2013 1:16 pm Change Time Zone

Hi Gayathri,

When exactly does the index 'AlphaInStateCity' get built here? Is it
i) on execution of BUILD?
ii) on execution of the following FETCH?
iii) on execution of SEQUENTIAL?


on execution of SEQUENTIAL

What if there was no SEQUENTIAL statement?


Without SEQUENTIAL, all actions would be executed in parallel, and there is a chance that if the OUTPUT action did not completely write out the recordset, the BUILD could create a corrupted index, so the SEQUENTIAL action forces the actions to occur in sequence, where the output file is written first, and then the BUILD action creates the INDEX.

Regards,

Bob
bforeman
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1002
Joined: Wed Jun 29, 2011 7:13 pm

Tue Oct 01, 2013 10:08 am Change Time Zone

Do we then need to compulsorily use SEQUENTIAL in all places where subsequent steps depend on values from prior assignment statements (in any conventional example)?

In this example, all statements until SEQUENTIAL are attribute definition statements. In the absence of action statements, if there was no SEQUENTIAL, would the code still get executed and index get built?

Regards,
Gayathri
Gayathri_Jayaraman
 
Posts: 75
Joined: Wed May 08, 2013 5:03 am

Tue Oct 01, 2013 11:51 am Change Time Zone

Do we then need to compulsorily use SEQUENTIAL in all places where subsequent steps depend on values from prior assignment statements (in any conventional example)?


It's a good practice, but you could always separate the process into different workunits, and then SEQUENTIAL of course would not be necessary. But if one action is dependent on another action that needs to be completed first, SEQUENTIAL is the way to go.

In this example, all statements until SEQUENTIAL are attribute definition statements. In the absence of action statements, if there was no SEQUENTIAL, would the code still get executed and index get built?


No. When any action is used in a definition, that definition needs to be explicitly referenced to be executed. Remember that the rule for any ECL file with regards to the compiler is that a file must have at least one EXPORT or SHARED definition, OR, any action (explicit using OUTPUT or SEQUENTIAL or another action statement, or implicit by just naming the definition).

Hope this helps! :-)

Bob
bforeman
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1002
Joined: Wed Jun 29, 2011 7:13 pm

Tue Oct 01, 2013 11:53 am Change Time Zone

Got it! Thanks :)
Gayathri_Jayaraman
 
Posts: 75
Joined: Wed May 08, 2013 5:03 am

Tue Oct 01, 2013 11:55 am Change Time Zone

By the way, very good questions! Keep them coming, and get some sleep :-)

Bob
bforeman
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1002
Joined: Wed Jun 29, 2011 7:13 pm

Tue Oct 01, 2013 12:47 pm Change Time Zone

bforeman wrote:
Do we then need to compulsorily use SEQUENTIAL in all places where subsequent steps depend on values from prior assignment statements (in any conventional example)?


It's a good practice, but you could always separate the process into different workunits, and then SEQUENTIAL of course would not be necessary. But if one action is dependent on another action that needs to be completed first, SEQUENTIAL is the way to go.

SEQUENTIAL can have some performance impacts if you over-use it. The ECL compiler typically does a fantastic job of finding "common code" and making sure that it is executed only once. However, if such code was referenced by two different statements within a SEQUENTIAL then it may not be commoned-up and you end up executing that code multiple times.

As a rule of thumb, I use SEQUENTIAL only in certain situations, usually when dealing with the file system. The compiler doesn't really understand dependencies in the file system, such as writing a file and then reading it later, or manipulating superfiles. In general, if you have one piece of code that "touches" an external resource (like a file) and then another piece of code that needs to access that touched resource, you need to wrap the statements in a SEQUENTIAL. If your subsequent statements reference only internal data or attributes, the compiler will always order things correctly.

Cheers,

Dan
DSC
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 568
Joined: Tue Oct 18, 2011 4:45 pm

Thu Oct 03, 2013 10:45 am Change Time Zone

Thanks Dan!
Gayathri_Jayaraman
 
Posts: 75
Joined: Wed May 08, 2013 5:03 am


Return to Online Classroom

Who is online

Users browsing this forum: No registered users and 1 guest