exit loop if no next recordSet present

Signed-off-by: Sebastian Schüpbach's avatarSebastian Schüpbach <sebastian.schuepbach@unibas.ch>
parent b6b43f9e
Pipeline #22606 passed with stages
in 6 minutes and 46 seconds
......@@ -57,16 +57,16 @@ trait MariaDBClient {
val statement = connection.createStatement()
val resultSet = statement.executeQuery(sql)
Iterator.continually(resultSet)
.map {
case rS if rS.next =>
val record = extractRecord(rS)
if (record.isFailure) {
logger.warn(s"Extraction failed: ${record.failed.get.getMessage}")
} else {
logger.debug(s"Processing record ${record.get.recordId}")
}
record.toOption
case _ => None
.takeWhile(_.next)
.map { rS => {
val record = extractRecord(rS)
if (record.isFailure) {
logger.warn(s"Extraction failed: ${record.failed.get.getMessage}")
} else {
logger.debug(s"Processing record ${record.get.recordId}")
}
record.toOption
}
}
.collect {
case r if r.isDefined => r.get
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment