The half-keyed JOIN is a simpler version, wherein the INDEX is the right-hand recordset in the JOIN. Just as with the full-keyed JOIN, the join condition must use the key fields in the INDEX to do its work. The purpose of the half-keyed JOIN is the same as the full-keyed version.
In fact, a full-keyed JOIN is, behind the curtains, actually the same as a half-keyed JOIN then a FETCH to retrieve the base dataset records. Therefore, a half-keyed JOIN and a FETCH are semantically and functionally equivalent, as shown in this example code (contained in the IndexHalfKeyedJoin.ECL file):
IMPORT $; r1 := RECORD $.DeclareData.Layout_Person; $.DeclareData.Layout_Accounts; END; r2 := RECORD $.DeclareData.Layout_Person; UNSIGNED8 AcctRecPos; END; r2 Xform2($.DeclareData.Person.FilePlus L, $.DeclareData.IDX_Accounts_PersonID R) := TRANSFORM SELF.AcctRecPos := R.RecPos; SELF := L; END; J2 := JOIN($.DeclareData.Person.FilePlus(PersonID BETWEEN 1 AND 100), $.DeclareData.IDX_Accounts_PersonID, LEFT.PersonID=RIGHT.PersonID, Xform2(LEFT,RIGHT)); r1 Xform3($.DeclareData.Accounts L, r2 R) := TRANSFORM SELF := L; SELF := R; END; F1 := FETCH($.DeclareData.Accounts, J2, RIGHT.AcctRecPos, Xform3(LEFT,RIGHT)); OUTPUT(F1,ALL);
This code produces the same result set as the previous example.
The advantage of using half-keyed JOINs over the full-keyed version comes in where you may need to do several JOINs to fully perform whatever process is being run. Using the half-keyed form allows you to accomplish all the necessary JOINs before you explicitly do the FETCH to retrieve the final result records, thereby making the code more efficient.