feat: add an API to time out query executions
Currently, if a predicate is hard to match on the Rust side, a sizable query against a very large file can take forever, and ends up hanging. This commit adds an API function `ts_query_cursor_set_timeout_micros` to limit how long query execution is allowed to take, thereby negating the chance of a hang to occur.
This commit is contained in:
parent
a748488596
commit
3f424c0121
11 changed files with 132 additions and 8 deletions
|
|
@ -983,6 +983,22 @@ bool ts_query_cursor_did_exceed_match_limit(const TSQueryCursor *self);
|
|||
uint32_t ts_query_cursor_match_limit(const TSQueryCursor *self);
|
||||
void ts_query_cursor_set_match_limit(TSQueryCursor *self, uint32_t limit);
|
||||
|
||||
/**
|
||||
* Set the maximum duration in microseconds that query execution should be allowed to
|
||||
* take before halting.
|
||||
*
|
||||
* If query execution takes longer than this, it will halt early, returning NULL.
|
||||
* See [`ts_query_cursor_next_match`] or [`ts_query_cursor_next_capture`] for more information.
|
||||
*/
|
||||
void ts_query_cursor_set_timeout_micros(TSQueryCursor *self, uint64_t timeout_micros);
|
||||
|
||||
/**
|
||||
* Get the duration in microseconds that query execution is allowed to take.
|
||||
*
|
||||
* This is set via [`ts_query_cursor_set_timeout_micros`].
|
||||
*/
|
||||
uint64_t ts_query_cursor_timeout_micros(const TSQueryCursor *self);
|
||||
|
||||
/**
|
||||
* Set the range of bytes or (row, column) positions in which the query
|
||||
* will be executed.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue