pyignite.aio_client module

class pyignite.aio_client.AioClient(compact_footer: bool = None, partition_aware: bool = False, **kwargs)

Bases: pyignite.client.BaseClient

Asynchronous Client implementation.

__init__(compact_footer: bool = None, partition_aware: bool = False, **kwargs)

Initialize client.

Parameters:
close()
connect(*args)

Connect to Ignite cluster node(s).

Parameters:args – (optional) host(s) and port(s) to connect to.
create_cache(settings: Union[str, dict]) → pyignite.aio_cache.AioCache

Creates Ignite cache by name. Raises CacheError if such a cache is already exists.

Parameters:settings – cache name or dict of cache properties’ codes and values. All cache properties are documented here: Cache Properties. See also the cache creation example,
Returns:Cache object.
get_best_node()

Returns the node from the list of the nodes, opened by client, that most probably contains the needed key-value pair. See IEP-23.

This method is not a part of the public API. Unless you wish to extend the pyignite capabilities (with additional testing, logging, examining connections, et c.) you probably should not use it.

Parameters:
  • cache – Ignite cache, cache name or cache id,
  • key – (optional) pythonic key,
  • key_hint – (optional) Ignite data type, for which the given key should be converted,
Returns:

Ignite connection object.

get_binary_type(binary_type: Union[str, int]) → dict

Gets the binary type information from the Ignite server. This is quite a low-level implementation of Ignite thin client protocol’s OP_GET_BINARY_TYPE operation. You would probably want to use query_binary_type() instead.

Parameters:binary_type – binary type name or ID,
Returns:binary type description − a dict with the following fields:
  • type_exists: True if the type is registered, False otherwise. In the latter case all the following fields are omitted,
  • type_id: Complex object type ID,
  • type_name: Complex object type name,
  • affinity_key_field: string value or None,
  • is_enum: False in case of Complex object registration,
  • schemas: a list, containing the Complex object schemas in format: OrderedDict[field name: field type hint]. A schema can be empty.
get_cache(settings: Union[str, dict]) → pyignite.aio_cache.AioCache

Creates Cache object with a given cache name without checking it up on server. If such a cache does not exist, some kind of exception (most probably CacheError) may be raised later.

Parameters:settings – cache name or cache properties (but only PROP_NAME property is allowed),
Returns:Cache object.
get_cache_names() → list

Gets existing cache names.

Returns:list of cache names.
get_cluster() → pyignite.aio_cluster.AioCluster

Gets client cluster facade.

Returns:AioClient cluster facade.
get_or_create_cache(settings: Union[str, dict]) → pyignite.aio_cache.AioCache

Creates Ignite cache, if not exist.

Parameters:settings – cache name or dict of cache properties’ codes and values. All cache properties are documented here: Cache Properties. See also the cache creation example,
Returns:Cache object.
put_binary_type(type_name: str, affinity_key_field: str = None, is_enum=False, schema: dict = None)

Registers binary type information in cluster. Do not update binary registry. This is a literal implementation of Ignite thin client protocol’s OP_PUT_BINARY_TYPE operation. You would probably want to use register_binary_type() instead.

Parameters:
  • type_name – name of the data type being registered,
  • affinity_key_field – (optional) name of the affinity key field,
  • is_enum – (optional) register enum if True, binary object otherwise. Defaults to False,
  • schema – (optional) when register enum, pass a dict of enumerated parameter names as keys and an integers as values. When register binary type, pass a dict of field names: field types. Binary type with no fields is OK.
query_binary_type(binary_type: Union[int, str], schema: Union[int, dict] = None)

Queries the registry of Complex object classes.

Parameters:
  • binary_type – Complex object type name or ID,
  • schema – (optional) Complex object schema or schema ID,
Returns:

found dataclass or None, if schema parameter is provided, a dict of {schema ID: dataclass} format otherwise.

random_node() → pyignite.connection.aio_connection.AioConnection

Returns random usable node.

This method is not a part of the public API. Unless you wish to extend the pyignite capabilities (with additional testing, logging, examining connections, et c.) you probably should not use it.

register_binary_type(data_class: Type[CT_co], affinity_key_field: str = None)

Register the given class as a representation of a certain Complex object type. Discards autogenerated or previously registered class.

Parameters:
  • data_class – Complex object class,
  • affinity_key_field – (optional) affinity parameter.
sql()

Runs an SQL query and returns its result.

Parameters:
  • query_str – SQL query string,
  • page_size – (optional) cursor page size. Default is 1024, which means that client makes one server call per 1024 rows,
  • query_args – (optional) query arguments. List of values or (value, type hint) tuples,
  • schema – (optional) schema for the query. Defaults to PUBLIC,
  • statement_type

    (optional) statement type. Can be:

    • StatementType.ALL − any type (default),
    • StatementType.SELECT − select,
    • StatementType.UPDATE − update.
  • distributed_joins – (optional) distributed joins. Defaults to False,
  • local – (optional) pass True if this query should be executed on local node only. Defaults to False,
  • replicated_only – (optional) whether query contains only replicated tables or not. Defaults to False,
  • enforce_join_order – (optional) enforce join order. Defaults to False,
  • collocated – (optional) whether your data is co-located or not. Defaults to False,
  • lazy – (optional) lazy query execution. Defaults to False,
  • include_field_names – (optional) include field names in result. Defaults to False,
  • max_rows – (optional) query-wide maximum of rows. Defaults to -1 (all rows),
  • timeout – (optional) non-negative timeout value in ms. Zero disables timeout (default),
  • cache – (optional) Name or ID of the cache to use to infer schema. If set, ‘schema’ argument is ignored,
Returns:

async sql fields cursor with result rows as a lists. If include_field_names was set, the first row will hold field names.

unwrap_binary(value: Any) → Any

Detects and recursively unwraps Binary Object.

Parameters:value – anything that could be a Binary Object,
Returns:the result of the Binary Object unwrapping with all other data left intact.