title: Spark Dataset: Filter if value is contained in other dataset
body: <p>I want to get all links out of a dataset of edges, whose source is contained in a dataset of all existing nodes.</p>
  <blockquote>
  <p>edges columns: | dst | src | type | (all strings)</p>
  <p>nodes columns: | id | pageid | (all strings)</p>
  </blockquote>
  <p>I did that by retrieving a list out of the dataset and used the contains() method.</p>
  <pre><code>List&lt;String&gt; allNodeList = allNodes.javaRDD().map(r -&gt; r.getString(0)).collect();
  Dataset&lt;Row&gt; allLinks = dfEdges.filter(&quot;type = 'link'&quot;).filter(r -&gt; allNodeList.contains(r.getString(1)));
  </code></pre>
  <p>But now i want to eliminate that additional piece of code and use a more native way. My approach was to use count, but that doesnt seem to work, due to a NotSerializableException.</p>
  <pre><code>Dataset&lt;Row&gt; allLinks = dfEdges.filter(&quot;type = 'link'&quot;).filter(r -&gt; (dfNodes.filter(&quot;id=&quot;+r.getString(1)).count()&gt;0));
  </code></pre>
  <p>Is there any simple way to solve that problem in java? Ive seen things in scala with &quot;is in&quot; or similar but have no idea how to solve it simply in java.</p>