Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#
from pyignite.datatypes import Int, Bool, String, Struct, StructArray
binary_fields_struct = StructArray([
('field_name', String),
('type_id', Int),
('field_id', Int),
])
body_struct = Struct([
('type_id', Int),
('type_name', String),
('affinity_key_field', String),
('binary_fields', binary_fields_struct),
('is_enum', Bool),
])
enum_struct = StructArray([
('literal', String),
('type_id', Int),
])
schema_fields_struct = StructArray([
('schema_field_id', Int),
])
schema_struct = StructArray([
('schema_id', Int),
('schema_fields', schema_fields_struct),
])
query_struct = Query(
OP_GET_BINARY_TYPE,
[
('type_id', Int),
],
query_id=query_id,
)
_, send_buffer = query_struct.from_python({
'type_id': entity_id(binary_type),
})
connection.send(send_buffer)
response_head_struct = Response([
('type_exists', Bool),
])
response_head_type, recv_buffer = response_head_struct.parse(connection)
response_head = response_head_type.from_buffer_copy(recv_buffer)
response_parts = []
if response_head.type_exists:
resp_body_type, resp_body_buffer = body_struct.parse(connection)
response_parts.append(('body', resp_body_type))
resp_body = resp_body_type.from_buffer_copy(resp_body_buffer)
recv_buffer += resp_body_buffer
if resp_body.is_enum:
resp_enum, resp_enum_buffer = enum_struct.parse(connection)
response_parts.append(('enums', resp_enum))
recv_buffer += resp_enum_buffer
resp_schema_type, resp_schema_buffer = schema_struct.parse(connection)
response_parts.append(('schema', resp_schema_type))
recv_buffer += resp_schema_buffer
('flag', Byte),
('key', key_hint or AnyDataObject),
('sample', sample_hint or AnyDataObject),
],
query_id=query_id,
)
result = query_struct.perform(
connection,
query_params={
'hash_code': cache_id(cache),
'flag': 1 if binary else 0,
'key': key,
'sample': sample,
},
response_config=[
('success', Bool),
],
)
if result.status == 0:
result.value = result.value['success']
return result
OP_QUERY_SQL_FIELDS,
[
('hash_code', Int),
('flag', Byte),
('schema', String),
('page_size', Int),
('max_rows', Int),
('query_str', String),
('query_args', AnyDataArray()),
('statement_type', StatementType),
('distributed_joins', Bool),
('local', Bool),
('replicated_only', Bool),
('enforce_join_order', Bool),
('collocated', Bool),
('lazy', Bool),
('timeout', Long),
('include_field_names', Bool),
],
query_id=query_id,
)
_, send_buffer = query_struct.from_python({
'hash_code': cache_id(cache),
'flag': 1 if binary else 0,
'schema': schema,
'page_size': page_size,
'max_rows': max_rows,
'query_str': query_str,
'query_args': query_args,
'statement_type': statement_type,
'distributed_joins': distributed_joins,