Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ workflows:
matrix:
parameters:
# TODO: Revisit why pyenv doesn't recognize 3.12
python_version: ["3.8", "3.9", "3.10", "3.11"] # "3.12"
python_version: ["3.9", "3.10", "3.11"] # "3.12"
arangodb_config: ["single", "cluster"]
arangodb_license: ["community", "enterprise"]
arangodb_version: ["3.11", "latest"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ database natively supporting documents, graphs and search.
## Requirements

- ArangoDB version 3.11+
- Python version 3.8+
- Python version 3.9+

## Installation

Expand Down
39 changes: 37 additions & 2 deletions arango/aql.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,36 @@ def response_handler(resp: Response) -> bool:

return self._execute(request, response_handler)

def plan_entries(self) -> Result[Jsons]:
"""Return a list of all AQL query plan cache entries.

:return: List of AQL query plan cache entries.
:rtype: list
:raise arango.exceptions.AQLCacheEntriesError: If retrieval fails.
"""
request = Request(method="get", endpoint="/_api/query-plan-cache")

def response_handler(resp: Response) -> Jsons:
if not resp.is_success:
raise AQLCacheEntriesError(resp, request)
result: Jsons = resp.body
return result

return self._execute(request, response_handler)

def clear_plan(self) -> Result[None]:
"""Clear the AQL query plan cache.

:raises arango.exceptions.AQLCacheClearError: If clearing the cache fails.
"""
request = Request(method="delete", endpoint="/_api/query-plan-cache")

def response_handler(resp: Response) -> None:
if not resp.is_success:
raise AQLCacheClearError(resp, request)

return self._execute(request, response_handler)


class AQL(ApiGroup):
"""AQL (ArangoDB Query Language) API wrapper.
Expand Down Expand Up @@ -277,6 +307,7 @@ def execute(
allow_dirty_read: bool = False,
allow_retry: bool = False,
force_one_shard_attribute_value: Optional[str] = None,
use_plan_cache: Optional[bool] = None,
) -> Result[Cursor]:
"""Execute the query and return the result cursor.

Expand Down Expand Up @@ -388,6 +419,8 @@ def execute(
shipped to a wrong DB server and may not return results
(i.e. empty result set). Use at your own risk.
:param force_one_shard_attribute_value: str | None
:param use_plan_cache: If set to True, the query plan cache is used.
:param use_plan_cache: bool | None
:return: Result cursor.
:rtype: arango.cursor.Cursor
:raise arango.exceptions.AQLQueryExecuteError: If execute fails.
Expand All @@ -399,8 +432,6 @@ def execute(
data["ttl"] = ttl
if bind_vars is not None:
data["bindVars"] = bind_vars
if cache is not None:
data["cache"] = cache
if memory_limit is not None:
data["memoryLimit"] = memory_limit

Expand Down Expand Up @@ -437,6 +468,10 @@ def execute(
options["allowRetry"] = allow_retry
if force_one_shard_attribute_value is not None:
options["forceOneShardAttributeValue"] = force_one_shard_attribute_value
if cache is not None:
options["cache"] = cache
if use_plan_cache is not None:
options["usePlanCache"] = use_plan_cache

if options:
data["options"] = options
Expand Down
Loading
Loading