Skip to content

Commit

Permalink
withResource
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 c84e05e commit 4f33192
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1247,15 +1247,22 @@ case class GpuContainsAny(input: Expression, targets: Seq[UTF8String])
val boolCvs = withResource(ColumnVector.fromUTF8Strings(targetsBytes: _*)) { targetsCv =>
input.getBase.stringContains(targetsCv)
}
closeOnExcept(boolCvs.tail) { _ =>
boolCvs.tail.foldLeft(boolCvs.head) {
(l, r) => withResource(l) { _ =>
withResource(r) { _ =>
l.or(r)
}
var ret: ColumnVector = null
withResource(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
}
}
}
ret
}
}

Expand Down

0 comments on commit 4f33192

Please sign in to comment.