Skip to main content

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:

NameTypeDescriptionDefault
specQuery

One command of the query.

required
adj_toint

The command to refer to. Defaults to 0.

0

Returns:

NameTypeDescription
QueryQuery

The completed, connected query.

command_properties​

command_properties(prop: str = '') -> List[str]

Helper function to get the properties of all commands the query.

Parameters:

NameTypeDescriptionDefault
propstr

Name of the query attribute to retrieve from each command.

''

Returns:

TypeDescription
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:

NameTypeDescriptionDefault
constraintsConstraints

Constraints . Defaults to None.

None
with_classObjectType

description. Defaults to ObjectType.CUSTOM.

''
limitint

description. Defaults to -1.

-1
sortSort

description. Defaults to None.

None
listList[str]

description. Defaults to None.

None

Returns:

NameTypeDescription
QueryQuery

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:

NameTypeDescriptionDefault
objBaseModel

The object from the user domain.

required
cachedList[str]

helps to optimize sending one blob per node. Defaults to None.

None
source_fieldstr

Preserves the relevant connection information from user objects. Defaults to None.

None
indexint

The index to start creating references from. Defaults to 1.

1
parentint

The parent of the current node. Defaults to None.

0

Returns:

NameTypeDescription
tupleTuple[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