Skip to content

Instantly share code, notes, and snippets.

@aseigneurin
Last active July 22, 2016 16:38
Show Gist options
  • Save aseigneurin/b11afd1247752db952f163b6f8b9b508 to your computer and use it in GitHub Desktop.
Save aseigneurin/b11afd1247752db952f163b6f8b9b508 to your computer and use it in GitHub Desktop.
case class PendingResult(k1: Long, k2: String, futureResults: ResultSetFuture)
val pendingResults = ArrayBuffer.empty[PendingResult]
for (i <- 1 to iterations) {
val k1 = ...
val k2 = ...
val futureResults = session.executeAsync(s"SELECT * FROM ${tableName} WHERE k1=${k1} AND k2='${k2}'")
pendingResults += PendingResult(k1, k2, futureResults)
}
for (pendingResult <- pendingResults) {
val results = pendingResult.futureResults.get()
val ids = ArrayBuffer.empty[Long]
for (row <- results) {
ids += row.getLong("id")
}
if (verbose) {
println(s"${pendingResult.k1}, ${pendingResult.k2}, ${ids.mkString(",")}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment