在 MarkLogic 中,如果 EvaluResultIterator 未使用或包含空序列,您应该关闭它吗?
In MarkLogic should you close EvaluResultIterator if it is unused or contains the empty sequence?
我正在使用 MarkLogic 的 java-api 来评估 XQueries。有时这些 XQueries return 什么都没有(空序列)或结果未被使用。
根据文档(https://docs.marklogic.com/javadoc/client/com/marklogic/client/eval/ServerEvaluationCall.html):
NOTE: EvalResultIterator MUST BE CLOSED. If you call eval() don't forget to call close() on the returned EvalResultIterator to free up the underlying resources.
当然,当你使用资源进行空尝试时,这看起来不太好
try (EvalResultIterator eval = invoker.eval()) {
// No result is returned
}
在这种情况下真的有必要关闭 EvalResultIterator 吗?最好的方法是什么?
只需调用invoker.eval().close()
。如果 invoker.eval()
抛出异常,那么 EvalResultIterator
将不会返回 到 关闭,因此无需担心 finally
块。
我正在使用 MarkLogic 的 java-api 来评估 XQueries。有时这些 XQueries return 什么都没有(空序列)或结果未被使用。
根据文档(https://docs.marklogic.com/javadoc/client/com/marklogic/client/eval/ServerEvaluationCall.html):
NOTE: EvalResultIterator MUST BE CLOSED. If you call eval() don't forget to call close() on the returned EvalResultIterator to free up the underlying resources.
当然,当你使用资源进行空尝试时,这看起来不太好
try (EvalResultIterator eval = invoker.eval()) {
// No result is returned
}
在这种情况下真的有必要关闭 EvalResultIterator 吗?最好的方法是什么?
只需调用invoker.eval().close()
。如果 invoker.eval()
抛出异常,那么 EvalResultIterator
将不会返回 到 关闭,因此无需担心 finally
块。