Fixed ASTERIXDB-1249 and ASTERIXDB-1250: self index-nested-loop join correctly identifies the outer and the inner branch.

The first dataset becomes the outer branch.
The second dataset becomes the inner branch.
The optimizer for index-nested-loop join now only try to use an index from the inner branch.

Change-Id: I0d4291197c2bcfbcdcde998c5952af41960c4ad7
Reviewed-on: https://asterix-gerrit.ics.uci.edu/576
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multipred.aql b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multipred.aql
index dd4ca77..bffaf9c 100644
--- a/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multipred.aql
+++ b/asterix-app/src/test/resources/optimizerts/queries/btree-index-join/secondary-equi-join-multipred.aql
@@ -18,9 +18,9 @@
  */
 /*
  * Description    : Equi joins two datasets, DBLP and CSX, based on their title.
- *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint 
+ *                  DBLP has a secondary btree index on title, and given the 'indexnl' hint
  *                  we expect the join to be transformed into an indexed nested-loop join.
- *                  We expect the additional predicates to be put into a select above the 
+ *                  We expect the additional predicates to be put into a select above the
  *                  primary index search.
  * Success        : Yes
  */
@@ -30,7 +30,7 @@
 use dataverse test;
 
 create type DBLPType as closed {
-  id: int32, 
+  id: int32,
   dblpid: string,
   title: string,
   authors: string,
@@ -38,7 +38,7 @@
 }
 
 create type CSXType as closed {
-  id: int32, 
+  id: int32,
   csxid: string,
   title: string,
   authors: string,
@@ -53,7 +53,7 @@
 
 write output to asterix_nc1:"rttest/btree-index-join_title-secondary-equi-join-multipred.adm";
 
-for $a in dataset('DBLP')
 for $b in dataset('CSX')
+for $a in dataset('DBLP')
 where $a.title /*+ indexnl */ = $b.title and $a.authors < $b.authors and $a.misc > $b.misc
 return {"arec": $a, "brec": $b}