title: Constructing Java hashmap from Spark dataframe
body: <p>I am using spark-sql-2.4.1v with Java 8 in my project.</p>
  <p>I need to construct a loop up hashmap from given dataframe as below:</p>
  <pre class="lang-java prettyprint-override"><code>List ll = Arrays.asList(
        (&quot;aaaa&quot;, 11),
        (&quot;aaa&quot;, 12),
        (&quot;aa&quot;, 13),
        (&quot;a&quot;, 14)
      )
  
  Dataset&lt;Row&gt; codeValudeDf = ll.toDF( &quot;code&quot;, &quot;value&quot;)
  </code></pre>
  <p>Given the above dataframe I need to create a hashmap</p>
  <p>i.e.</p>
  <pre class="lang-java prettyprint-override"><code>Map&lt;String, String&gt; lookUpHm = new Hashmap&lt;&gt;();
  
  lookUpHm  =&gt; aaaa-&gt;11  , aaa-&gt;12 , aa-&gt;13, a-&gt;14
  </code></pre>
  <p>How can it it be done in Java?</p>