Introduction to Roxie - index creation
In the FETCH_Example.ecl bundled along with Intro to Roxie online course material, I found the following piece of code (not complete):
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
- 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
Hi Gayathri,
on execution of SEQUENTIAL
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
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
- Posts: 1006
- Joined: Wed Jun 29, 2011 7:13 pm
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
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
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
- Posts: 1006
- Joined: Wed Jun 29, 2011 7:13 pm
By the way, very good questions! Keep them coming, and get some sleep 
Bob

Bob
- bforeman
- Community Advisory Board Member
- Posts: 1006
- Joined: Wed Jun 29, 2011 7:13 pm
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
- Posts: 571
- Joined: Tue Oct 18, 2011 4:45 pm
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest