[SPARK-2531] [SQL] Make BroadcastNestedLoopJoin take into account a BuildSide

JIRA ticket: https://issues.apache.org/jira/browse/SPARK-2531
Can we just use a while loop instead of the collection actions (`zipWithIndex`, `map`, `filter`, `filter`, and `map` again)? While loop just require a single scan instead of 5.