本文整理汇总了Python中pyignite.queries.Query.perform方法的典型用法代码示例。如果您正苦于以下问题:Python Query.perform方法的具体用法?Python Query.perform怎么用?Python Query.perform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyignite.queries.Query
的用法示例。
在下文中一共展示了Query.perform方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cache_create
# 需要导入模块: from pyignite.queries import Query [as 别名]
# 或者: from pyignite.queries.Query import perform [as 别名]
def cache_create(
connection: 'Connection', name: str, query_id=None,
) -> 'APIResult':
"""
Creates a cache with a given name. Returns error if a cache with specified
name already exists.
:param connection: connection to Ignite server,
:param name: cache name,
:param query_id: (optional) a value generated by client and returned as-is
in response.query_id. When the parameter is omitted, a random value
is generated,
:return: API result data object. Contains zero status if a cache is
created successfully, non-zero status and an error description otherwise.
"""
query_struct = Query(
OP_CACHE_CREATE_WITH_NAME,
[
('cache_name', String),
],
query_id=query_id,
)
return query_struct.perform(
connection,
query_params={
'cache_name': name,
},
)
示例2: cache_destroy
# 需要导入模块: from pyignite.queries import Query [as 别名]
# 或者: from pyignite.queries.Query import perform [as 别名]
def cache_destroy(
connection: 'Connection', cache: Union[str, int], query_id=None,
) -> 'APIResult':
"""
Destroys cache with a given name.
:param connection: connection to Ignite server,
:param cache: name or ID of the cache,
:param query_id: (optional) a value generated by client and returned as-is
in response.query_id. When the parameter is omitted, a random value
is generated,
:return: API result data object.
"""
query_struct = Query(
OP_CACHE_DESTROY,[
('hash_code', Int),
],
query_id=query_id,
)
return query_struct.perform(
connection,
query_params={
'hash_code': cache_id(cache),
},
)
示例3: cache_get_names
# 需要导入模块: from pyignite.queries import Query [as 别名]
# 或者: from pyignite.queries.Query import perform [as 别名]
def cache_get_names(connection: 'Connection', query_id=None) -> 'APIResult':
"""
Gets existing cache names.
:param connection: connection to Ignite server,
:param query_id: (optional) a value generated by client and returned as-is
in response.query_id. When the parameter is omitted, a random value
is generated,
:return: API result data object. Contains zero status and a list of cache
names, non-zero status and an error description otherwise.
"""
query_struct = Query(OP_CACHE_GET_NAMES, query_id=query_id)
result = query_struct.perform(
connection,
response_config=[
('cache_names', StringArray),
],
)
if result.status == 0:
result.value = result.value['cache_names']
return result
示例4: cache_get_configuration
# 需要导入模块: from pyignite.queries import Query [as 别名]
# 或者: from pyignite.queries.Query import perform [as 别名]
def cache_get_configuration(
connection: 'Connection', cache: Union[str, int], flags: int=0, query_id=None,
) -> 'APIResult':
"""
Gets configuration for the given cache.
:param connection: connection to Ignite server,
:param cache: name or ID of the cache,
:param flags: Ignite documentation is unclear on this subject,
:param query_id: (optional) a value generated by client and returned as-is
in response.query_id. When the parameter is omitted, a random value
is generated,
:return: API result data object. Result value is OrderedDict with
the cache configuration parameters.
"""
query_struct = Query(
OP_CACHE_GET_CONFIGURATION,
[
('hash_code', Int),
('flags', Byte),
],
query_id=query_id,
)
result = query_struct.perform(
connection,
query_params={
'hash_code': cache_id(cache),
'flags': flags,
},
response_config=[
('cache_config', cache_config_struct),
],
)
if result.status == 0:
result.value = compact_cache_config(result.value['cache_config'])
return result
示例5: put_binary_type
# 需要导入模块: from pyignite.queries import Query [as 别名]
# 或者: from pyignite.queries.Query import perform [as 别名]
def put_binary_type(
connection: 'Connection', type_name: str, affinity_key_field: str=None,
is_enum=False, schema: dict=None, query_id=None,
) -> APIResult:
"""
Registers binary type information in cluster.
:param connection: connection to Ignite server,
:param type_name: name of the data type being registered,
:param affinity_key_field: (optional) name of the affinity key field,
:param is_enum: (optional) register enum if True, binary object otherwise.
Defaults to False,
:param 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,
:param query_id: (optional) a value generated by client and returned as-is
in response.query_id. When the parameter is omitted, a random value
is generated,
:return: API result data object.
"""
# prepare data
if schema is None:
schema = {}
type_id = entity_id(type_name)
data = {
'type_name': type_name,
'type_id': type_id,
'affinity_key_field': affinity_key_field,
'binary_fields': [],
'is_enum': is_enum,
'schema': [],
}
schema_id = None
if is_enum:
data['enums'] = []
for literal, ordinal in schema.items():
data['enums'].append({
'literal': literal,
'type_id': ordinal,
})
else:
# assemble schema and calculate schema ID in one go
schema_id = FNV1_OFFSET_BASIS if schema else 0
for field_name, data_type in schema.items():
# TODO: check for allowed data types
field_id = entity_id(field_name)
data['binary_fields'].append({
'field_name': field_name,
'type_id': int.from_bytes(
data_type.type_code,
byteorder=PROTOCOL_BYTE_ORDER
),
'field_id': field_id,
})
schema_id ^= (field_id & 0xff)
schema_id = int_overflow(schema_id * FNV1_PRIME)
schema_id ^= ((field_id >> 8) & 0xff)
schema_id = int_overflow(schema_id * FNV1_PRIME)
schema_id ^= ((field_id >> 16) & 0xff)
schema_id = int_overflow(schema_id * FNV1_PRIME)
schema_id ^= ((field_id >> 24) & 0xff)
schema_id = int_overflow(schema_id * FNV1_PRIME)
data['schema'].append({
'schema_id': schema_id,
'schema_fields': [
{'schema_field_id': entity_id(x)} for x in schema
],
})
# do query
if is_enum:
query_struct = Query(
OP_PUT_BINARY_TYPE,
[
('type_id', Int),
('type_name', String),
('affinity_key_field', String),
('binary_fields', binary_fields_struct),
('is_enum', Bool),
('enums', enum_struct),
('schema', schema_struct),
],
query_id=query_id,
)
else:
query_struct = Query(
OP_PUT_BINARY_TYPE,
[
('type_id', Int),
('type_name', String),
('affinity_key_field', String),
('binary_fields', binary_fields_struct),
('is_enum', Bool),
('schema', schema_struct),
],
query_id=query_id,
)
result = query_struct.perform(connection, query_params=data)
#.........这里部分代码省略.........