Skip to content

Commit

Permalink
foldLeft again
Browse files Browse the repository at this point in the history
Signed-off-by: Haoyang Li <[email protected]>
  • Loading branch information
thirtiseven committed Dec 13, 2024
1 parent ca1ba0c commit c84e05e
Showing 1 changed file with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1247,26 +1247,15 @@ case class GpuContainsAny(input: Expression, targets: Seq[UTF8String])
val boolCvs = withResource(ColumnVector.fromUTF8Strings(targetsBytes: _*)) { targetsCv =>
input.getBase.stringContains(targetsCv)
}
// withResource(boolCvs.tail) { _ =>
// // boolCvs.head and intermediate values are closed within the withResource in the lambda
// boolCvs.tail.foldLeft(boolCvs.head)((l, r) => withResource(l) { _ => l.or(r)})
// }
var ret: ColumnVector = null
closeOnExcept(boolCvs) { _ =>
boolCvs.indices.foreach { i =>
if (ret == null) {
ret = boolCvs(i)
boolCvs(i) = null
} else {
val tmp = ret.or(boolCvs(i))
ret.close()
ret = tmp
boolCvs(i).close()
boolCvs(i) = null
closeOnExcept(boolCvs.tail) { _ =>
boolCvs.tail.foldLeft(boolCvs.head) {
(l, r) => withResource(l) { _ =>
withResource(r) { _ =>
l.or(r)
}
}
}
}
ret
}
}

Expand Down

0 comments on commit c84e05e

Please sign in to comment.