Query
ObjectType
Bases: Enum
Based on : API description
Query
Query(constraints: Constraints = None, operations: Operations = None, with_class: str = '', limit: int = -1, sort: Sort = None, list: List[str] = None, group_by_src: bool = False, blobs: bool = False, adj_to: int = 0, set: str = None, vector: List[float] = None, k_neighbors: int = 0)
This is the underlying class to generate a query using python code.
connected_to
connected_to(spec: Query, adj_to: int = 0) -> Query
Can be used to connect two commands together, for non trivial queries. This is the lower level function to create a query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec | Query | One command of the query. | required |
adj_to | int | The command to refer to. Defaults to 0. | 0 |
Returns:
| Name | Type | Description |
|---|---|---|
Query | Query | The completed, connected query. |
command_properties
command_properties(prop: str = '') -> List[str]
Helper function to get the properties of all commands the query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop | str | Name of the query attribute to retrieve from each command. | '' |
Returns:
| Type | Description |
|---|---|
List[str] | List[str]: Properties from commands in the order they should be executed. |
spec classmethod
spec(constraints: Constraints = None, operations: Operations = None, with_class: str = '', limit: int = -1, sort: Sort = None, list: List[str] = None, group_by_src: bool = False, blobs: bool = False, set: str = None, vector: List[float] = None, k_neighbors: int = 0) -> Query
The specification for a command to be used in a query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
constraints | Constraints | Constraints . Defaults to None. | None |
with_class | ObjectType | description. Defaults to ObjectType.CUSTOM. | '' |
limit | int | description. Defaults to -1. | -1 |
sort | Sort | description. Defaults to None. | None |
list | List[str] | description. Defaults to None. | None |
Returns:
| Name | Type | Description |
|---|---|---|
Query | Query | The query object. |
get_specific
get_specific(obj: BaseModel) -> dict
This function is used to get the specific parameters for the object. Example: For a Descriptor object, the vector is packed into a blob.
generate_add_query
generate_add_query(obj: BaseModel, cached: List[str] = None, source_field: str = None, index: int = 1, parent: int = 0) -> Tuple[List[object], List[bytearray], int]
Takes the user model, and builds out a sequence of commands that creates a similar structure on ApertureDB's graph. For example, given the following
The function will generate the following commands:
AddVideo 1 AddClip 2 AddDescriptor 3 AddConnection 3-2
. . .
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj | BaseModel | The object from the user domain. | required |
cached | List[str] | helps to optimize sending one blob per node. Defaults to None. | None |
source_field | str | Preserves the relevant connection information from user objects. Defaults to None. | None |
index | int | The index to start creating references from. Defaults to 1. | 1 |
parent | int | The parent of the current node. Defaults to None. | 0 |
Returns:
| Name | Type | Description |
|---|---|---|
tuple | Tuple[List[object], List[bytearray], int] | Contains 3 items: * List of commands with current node and its children * List of blobs with current node and its children * index, adjusting the count of children + self for the number of commands in current query |