title: Using a Datastax Cassandra ResultSet with Java 8 Parallel Streams - Quickly
body: <p>I am fetching a lot of rows from Cassandra using the Datastax Driver and I need to process them as quickly as possible.</p>
  
  <p>I have looked into using <code>List::parallelStream().forEach()</code> which seems great at first since <code>ResultSet</code> acts a lot like a <code>List</code>, but sadly I am unable to use <code>parallelStream()</code> directly on <code>ResultSet</code>. To get this to work I first have to use <code>ResultSet::all()</code> which really is slow - I assume it iterates over each element.</p>
  
  <pre><code>ResultSet rs = this.getResultSet(); // Takes &lt;1 second
  
  // Convert the ResultSet to a list so as I can use parallelStream().
  List&lt;Row&gt; rsList = rs.all(); // Takes 21 seconds
  
  rsList.parallelStream().forEach(this::processRow); // Takes 3 seconds
  </code></pre>
  
  <p>Is there any faster way I can process each row of the result set?</p>