INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Creates a KustoConnection string builder that will authenticate with AAD application and key.
:param str connection_string: Kusto connection string should by of the format: https://<clusterName>.kusto.windows.net
:param str aad_app_id: AAD application ID.
:param str app_key: Corresponding key... | def with_aad_application_key_authentication(cls, connection_string, aad_app_id, app_key, authority_id):
"""Creates a KustoConnection string builder that will authenticate with AAD application and key.
:param str connection_string: Kusto connection string should by of the format: https://<clusterName>.... |
Creates a KustoConnection string builder that will authenticate with AAD application and
a certificate credentials.
:param str connection_string: Kusto connection string should by of the format:
https://<clusterName>.kusto.windows.net
:param str aad_app_id: AAD application ID.
... | def with_aad_application_certificate_authentication(
cls, connection_string, aad_app_id, certificate, thumbprint, authority_id
):
"""Creates a KustoConnection string builder that will authenticate with AAD application and
a certificate credentials.
:param str connection_string: ... |
Creates a KustoConnection string builder that will authenticate with AAD application and
password.
:param str connection_string: Kusto connection string should by of the format: https://<clusterName>.kusto.windows.net
:param str authority_id: optional param. defaults to "common" | def with_aad_device_authentication(cls, connection_string, authority_id="common"):
"""Creates a KustoConnection string builder that will authenticate with AAD application and
password.
:param str connection_string: Kusto connection string should by of the format: https://<clusterName>.kusto.w... |
Executes a query or management command.
:param str database: Database against query will be executed.
:param str query: Query to be executed.
:param azure.kusto.data.request.ClientRequestProperties properties: Optional additional properties.
:return: Kusto response data set.
... | def execute(self, database, query, properties=None):
"""Executes a query or management command.
:param str database: Database against query will be executed.
:param str query: Query to be executed.
:param azure.kusto.data.request.ClientRequestProperties properties: Optional additiona... |
Executes a query.
:param str database: Database against query will be executed.
:param str query: Query to be executed.
:param azure.kusto.data.request.ClientRequestProperties properties: Optional additional properties.
:return: Kusto response data set.
:rtype: azure.kusto.d... | def execute_query(self, database, query, properties=None):
"""Executes a query.
:param str database: Database against query will be executed.
:param str query: Query to be executed.
:param azure.kusto.data.request.ClientRequestProperties properties: Optional additional properties.
... |
Executes a management command.
:param str database: Database against query will be executed.
:param str query: Query to be executed.
:param azure.kusto.data.request.ClientRequestProperties properties: Optional additional properties.
:return: Kusto response data set.
:rtype: ... | def execute_mgmt(self, database, query, properties=None):
"""Executes a management command.
:param str database: Database against query will be executed.
:param str query: Query to be executed.
:param azure.kusto.data.request.ClientRequestProperties properties: Optional additional pr... |
Executes given query against this client | def _execute(self, endpoint, database, query, default_timeout, properties=None):
"""Executes given query against this client"""
request_payload = {"db": database, "csl": query}
if properties:
request_payload["properties"] = properties.to_json()
request_headers = {
... |
Executes streaming ingest against this client.
:param str database: Target database.
:param str table: Target table.
:param io.BaseIO stream: stream object which contains the data to ingest.
:param DataFormat stream_format: Format of the data in the stream.
:param str mappin... | def execute_streaming_ingest(
self,
database,
table,
stream,
stream_format,
mapping_name=None,
accept=None,
accept_encoding="gzip,deflate",
connection="Keep-Alive",
content_length=None,
content_encoding=None,
exp... |
Sets an option's value | def set_option(self, name, value):
"""Sets an option's value"""
_assert_value_is_valid(name)
self._options[name] = value |
Parses uri into a ResourceUri object | def parse(cls, uri):
"""Parses uri into a ResourceUri object"""
match = _URI_FORMAT.search(uri)
return cls(match.group(1), match.group(2), match.group(3), match.group(4)) |
Peek status queue
:param int n: number of messages to return as part of peek.
:param bool raw: should message content be returned as is (no parsing). | def peek(self, n=1, raw=False):
"""Peek status queue
:param int n: number of messages to return as part of peek.
:param bool raw: should message content be returned as is (no parsing).
"""
def _peek_specific_q(_q, _n):
has_messages = False
for m i... |
Pop status queue
:param int n: number of messages to return as part of peek.
:param bool raw: should message content be returned as is (no parsing).
:param bool delete: should message be deleted after pop. default is True as this is expected of a q. | def pop(self, n=1, raw=False, delete=True):
"""Pop status queue
:param int n: number of messages to return as part of peek.
:param bool raw: should message content be returned as is (no parsing).
:param bool delete: should message be deleted after pop. default is True as this is expected... |
Ingest from pandas DataFrame.
:param pandas.DataFrame df: input dataframe to ingest.
:param azure.kusto.ingest.IngestionProperties ingestion_properties: Ingestion properties. | def ingest_from_dataframe(self, df, ingestion_properties):
"""Ingest from pandas DataFrame.
:param pandas.DataFrame df: input dataframe to ingest.
:param azure.kusto.ingest.IngestionProperties ingestion_properties: Ingestion properties.
"""
from pandas import DataFrame
... |
Ingest from local files.
:param file_descriptor: a FileDescriptor to be ingested.
:param azure.kusto.ingest.IngestionProperties ingestion_properties: Ingestion properties. | def ingest_from_file(self, file_descriptor, ingestion_properties):
"""Ingest from local files.
:param file_descriptor: a FileDescriptor to be ingested.
:param azure.kusto.ingest.IngestionProperties ingestion_properties: Ingestion properties.
"""
if isinstance(file_descriptor, Fi... |
Ingest from io streams.
:param azure.kusto.ingest.StreamDescriptor stream_descriptor: An object that contains a description of the stream to
be ingested.
:param azure.kusto.ingest.IngestionProperties ingestion_properties: Ingestion properties. | def ingest_from_stream(self, stream_descriptor, ingestion_properties):
"""Ingest from io streams.
:param azure.kusto.ingest.StreamDescriptor stream_descriptor: An object that contains a description of the stream to
be ingested.
:param azure.kusto.ingest.IngestionProperties ingesti... |
Dictating the corresponding mapping to the format. | def get_mapping_format(self):
"""Dictating the corresponding mapping to the format."""
if self.format == DataFormat.json or self.format == DataFormat.avro:
return self.format.name
else:
return DataFormat.csv.name |
If t is an atom, return it as a string, otherwise raise InvalidTypeError. | def getAtomChars(t):
"""If t is an atom, return it as a string, otherwise raise InvalidTypeError.
"""
s = c_char_p()
if PL_get_atom_chars(t, byref(s)):
return s.value
else:
raise InvalidTypeError("atom") |
If t is of type bool, return it, otherwise raise InvalidTypeError. | def getBool(t):
"""If t is of type bool, return it, otherwise raise InvalidTypeError.
"""
b = c_int()
if PL_get_long(t, byref(b)):
return bool(b.value)
else:
raise InvalidTypeError("bool") |
If t is of type long, return it, otherwise raise InvalidTypeError. | def getLong(t):
"""If t is of type long, return it, otherwise raise InvalidTypeError.
"""
i = c_long()
if PL_get_long(t, byref(i)):
return i.value
else:
raise InvalidTypeError("long") |
If t is of type float, return it, otherwise raise InvalidTypeError. | def getFloat(t):
"""If t is of type float, return it, otherwise raise InvalidTypeError.
"""
d = c_double()
if PL_get_float(t, byref(d)):
return d.value
else:
raise InvalidTypeError("float") |
If t is of type string, return it, otherwise raise InvalidTypeError. | def getString(t):
"""If t is of type string, return it, otherwise raise InvalidTypeError.
"""
slen = c_int()
s = c_char_p()
if PL_get_string_chars(t, byref(s), byref(slen)):
return s.value
else:
raise InvalidTypeError("string") |
Return t as a list. | def getList(x):
"""
Return t as a list.
"""
t = PL_copy_term_ref(x)
head = PL_new_term_ref()
result = []
while PL_get_list(t, head, t):
result.append(getTerm(head))
head = PL_new_term_ref()
return result |
Register a Python predicate
``func``: Function to be registered. The function should return a value in
``foreign_t``, ``True`` or ``False``.
``name`` : Name of the function. If this value is not used, ``func.func_name``
should exist.
``arity``: Arity (number of arguments) of the function. If this va... | def registerForeign(func, name=None, arity=None, flags=0):
"""Register a Python predicate
``func``: Function to be registered. The function should return a value in
``foreign_t``, ``True`` or ``False``.
``name`` : Name of the function. If this value is not used, ``func.func_name``
should exist.
... |
Call term in module.
``term``: a Term or term handle | def call(*terms, **kwargs):
"""Call term in module.
``term``: a Term or term handle
"""
for kwarg in kwargs:
if kwarg not in ["module"]:
raise KeyError
module = kwargs.get("module", None)
t = terms[0]
for tx in terms[1:]:
t = _comma(t, tx)
return PL_call(t.... |
Create a new module.
``name``: An Atom or a string | def newModule(name):
"""Create a new module.
``name``: An Atom or a string
"""
if isinstance(name, str):
name = Atom(name)
return PL_new_module(name.handle) |
Create an atom from a Term or term handle. | def fromTerm(cls, term):
"""Create an atom from a Term or term handle."""
if isinstance(term, Term):
term = term.handle
elif not isinstance(term, (c_void_p, int)):
raise ArgumentTypeError((str(Term), str(c_void_p)), str(type(term)))
a = atom_t()
if PL_ge... |
Create a functor from a Term or term handle. | def fromTerm(cls, term):
"""Create a functor from a Term or term handle."""
if isinstance(term, Term):
term = term.handle
elif not isinstance(term, (c_void_p, int)):
raise ArgumentTypeError((str(Term), str(int)), str(type(term)))
f = functor_t()
if PL_ge... |
This function tries to use an executable on the path to find SWI-Prolog
SO/DLL and the resource file.
:returns:
A tuple of (path to the swipl DLL, path to the resource file)
:returns type:
({str, None}, {str, None}) | def _findSwiplFromExec():
"""
This function tries to use an executable on the path to find SWI-Prolog
SO/DLL and the resource file.
:returns:
A tuple of (path to the swipl DLL, path to the resource file)
:returns type:
({str, None}, {str, None})
"""
platform = sys.platform... |
This function uses several heuristics to gues where SWI-Prolog is installed
in Windows. It always returns None as the path of the resource file because,
in Windows, the way to find it is more robust so the SWI-Prolog DLL is
always able to find it.
:returns:
A tuple of (path to the swipl DLL, pa... | def _findSwiplWin():
import re
"""
This function uses several heuristics to gues where SWI-Prolog is installed
in Windows. It always returns None as the path of the resource file because,
in Windows, the way to find it is more robust so the SWI-Prolog DLL is
always able to find it.
:return... |
This function uses several heuristics to guess where SWI-Prolog is
installed in Linuxes.
:returns:
A tuple of (path to the swipl so, path to the resource file)
:returns type:
({str, None}, {str, None}) | def _findSwiplLin():
"""
This function uses several heuristics to guess where SWI-Prolog is
installed in Linuxes.
:returns:
A tuple of (path to the swipl so, path to the resource file)
:returns type:
({str, None}, {str, None})
"""
# Maybe the exec is on path?
(path, sw... |
This function is a 2-time recursive func,
that findin file in dirs
:parameters:
- `path` (str) - Directory path
- `name` (str) - Name of file, that we lookin for
:returns:
Path to the swipl so, path to the resource file
:returns type:
(str) | def walk(path, name):
"""
This function is a 2-time recursive func,
that findin file in dirs
:parameters:
- `path` (str) - Directory path
- `name` (str) - Name of file, that we lookin for
:returns:
Path to the swipl so, path to the resource file
:returns type:
... |
This function is guesing where SWI-Prolog is
installed in MacOS via .app.
:parameters:
- `swi_ver` (str) - Version of SWI-Prolog in '[0-9].[0-9].[0-9]' format
:returns:
A tuple of (path to the swipl so, path to the resource file)
:returns type:
({str, None}, {str, Non... | def _findSwiplMacOSHome():
"""
This function is guesing where SWI-Prolog is
installed in MacOS via .app.
:parameters:
- `swi_ver` (str) - Version of SWI-Prolog in '[0-9].[0-9].[0-9]' format
:returns:
A tuple of (path to the swipl so, path to the resource file)
:return... |
This function uses several heuristics to guess where SWI-Prolog is
installed in MacOS.
:returns:
A tuple of (path to the swipl so, path to the resource file)
:returns type:
({str, None}, {str, None}) | def _findSwiplDar():
"""
This function uses several heuristics to guess where SWI-Prolog is
installed in MacOS.
:returns:
A tuple of (path to the swipl so, path to the resource file)
:returns type:
({str, None}, {str, None})
"""
# If the exec is in path
(path, swiHome)... |
This function makes a big effort to find the path to the SWI-Prolog shared
library. Since this is both OS dependent and installation dependent, we may
not aways succeed. If we do, we return a name/path that can be used by
CDLL(). Otherwise we raise an exception.
:return: Tuple. Fist element is the name... | def _findSwipl():
"""
This function makes a big effort to find the path to the SWI-Prolog shared
library. Since this is both OS dependent and installation dependent, we may
not aways succeed. If we do, we return a name/path that can be used by
CDLL(). Otherwise we raise an exception.
:return: T... |
When the path to the DLL is not in Windows search path, Windows will not be
able to find other DLLs on the same directory, so we have to add it to the
path. This function takes care of it.
:parameters:
- `dll` (str) - File name of the DLL | def _fixWindowsPath(dll):
"""
When the path to the DLL is not in Windows search path, Windows will not be
able to find other DLLs on the same directory, so we have to add it to the
path. This function takes care of it.
:parameters:
- `dll` (str) - File name of the DLL
"""
if sys.pla... |
Turns a string into a bytes if necessary (i.e. if it is not already a bytes
object or None).
If string is None, int or c_char_p it will be returned directly.
:param string: The string that shall be transformed
:type string: str, bytes or type(None)
:return: Transformed string
:rtype: c_char_p c... | def str_to_bytes(string):
"""
Turns a string into a bytes if necessary (i.e. if it is not already a bytes
object or None).
If string is None, int or c_char_p it will be returned directly.
:param string: The string that shall be transformed
:type string: str, bytes or type(None)
:return: Tra... |
This function turns an array of strings into a pointer array
with pointers pointing to the encodings of those strings
Possibly contained bytes are kept as they are.
:param strList: List of strings that shall be converted
:type strList: List of strings
:returns: Pointer array with pointers pointing ... | def list_to_bytes_list(strList):
"""
This function turns an array of strings into a pointer array
with pointers pointing to the encodings of those strings
Possibly contained bytes are kept as they are.
:param strList: List of strings that shall be converted
:type strList: List of strings
:r... |
Decorator function which can be used to automatically turn an incoming
string into a bytes object and an incoming list to a pointer array if
necessary.
:param strings: Indices of the arguments must be pointers to bytes
:type strings: List of integers
:param arrays: Indices of the arguments must be ... | def check_strings(strings, arrays):
"""
Decorator function which can be used to automatically turn an incoming
string into a bytes object and an incoming list to a pointer array if
necessary.
:param strings: Indices of the arguments must be pointers to bytes
:type strings: List of integers
... |
Run a prolog query and return a generator.
If the query is a yes/no question, returns {} for yes, and nothing for no.
Otherwise returns a generator of dicts with variables as keys.
>>> prolog = Prolog()
>>> prolog.assertz("father(michael,john)")
>>> prolog.assertz("father(michae... | def query(cls, query, maxresult=-1, catcherrors=True, normalize=True):
"""Run a prolog query and return a generator.
If the query is a yes/no question, returns {} for yes, and nothing for no.
Otherwise returns a generator of dicts with variables as keys.
>>> prolog = Prolog()
>>... |
Calculates the request payload size | def calculate_size(uuid, partition_id, interrupt):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(uuid)
data_size += INT_SIZE_IN_BYTES
data_size += BOOLEAN_SIZE_IN_BYTES
return data_size |
Encode request into client_message | def encode_request(uuid, partition_id, interrupt):
""" Encode request into client_message"""
client_message = ClientMessage(payload_size=calculate_size(uuid, partition_id, interrupt))
client_message.set_message_type(REQUEST_TYPE)
client_message.set_retryable(RETRYABLE)
client_message.append_str(uuid... |
Calculates the request payload size | def calculate_size(name, include_value, local_only):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += BOOLEAN_SIZE_IN_BYTES
data_size += BOOLEAN_SIZE_IN_BYTES
return data_size |
Decode response from client message | def decode_response(client_message, to_object=None):
""" Decode response from client message"""
parameters = dict(response=None)
parameters['response'] = client_message.read_str()
return parameters |
Event handler | def handle(client_message, handle_event_entry=None, to_object=None):
""" Event handler """
message_type = client_message.get_message_type()
if message_type == EVENT_ENTRY and handle_event_entry is not None:
key = None
if not client_message.read_bool():
key = client_message.read_d... |
Calculates the request payload size | def calculate_size(name, function):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += calculate_size_data(function)
return data_size |
Decode response from client message | def decode_response(client_message, to_object=None):
""" Decode response from client message"""
parameters = dict(response=None)
if not client_message.read_bool():
parameters['response'] = to_object(client_message.read_data())
return parameters |
Calculates the request payload size | def calculate_size(name, expected):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += BOOLEAN_SIZE_IN_BYTES
if expected is not None:
data_size += calculate_size_data(expected)
return data_size |
Calculates the request payload size | def calculate_size(name, permits):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += INT_SIZE_IN_BYTES
return data_size |
Calculates the request payload size | def calculate_size(name, value_list):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += INT_SIZE_IN_BYTES
for value_list_item in value_list:
data_size += calculate_size_data(value_list_item)
return data_size |
Encode request into client_message | def encode_request(name, value_list):
""" Encode request into client_message"""
client_message = ClientMessage(payload_size=calculate_size(name, value_list))
client_message.set_message_type(REQUEST_TYPE)
client_message.set_retryable(RETRYABLE)
client_message.append_str(name)
client_message.appen... |
Adds the specified item to this queue if there is available space.
:param item: (object), the specified item.
:return: (bool), ``true`` if element is successfully added, ``false`` otherwise. | def add(self, item):
"""
Adds the specified item to this queue if there is available space.
:param item: (object), the specified item.
:return: (bool), ``true`` if element is successfully added, ``false`` otherwise.
"""
def result_fnc(f):
if f.result():
... |
Adds the elements in the specified collection to this queue.
:param items: (Collection), collection which includes the items to be added.
:return: (bool), ``true`` if this queue is changed after call, ``false`` otherwise. | def add_all(self, items):
"""
Adds the elements in the specified collection to this queue.
:param items: (Collection), collection which includes the items to be added.
:return: (bool), ``true`` if this queue is changed after call, ``false`` otherwise.
"""
check_not_none(... |
Adds an item listener for this queue. Listener will be notified for all queue add/remove events.
:param include_value: (bool), whether received events include the updated item or not (optional).
:param item_added_func: Function to be called when an item is added to this set (optional).
:param i... | def add_listener(self, include_value=False, item_added_func=None, item_removed_func=None):
"""
Adds an item listener for this queue. Listener will be notified for all queue add/remove events.
:param include_value: (bool), whether received events include the updated item or not (optional).
... |
Determines whether this queue contains all of the items in the specified collection or not.
:param items: (Collection), the specified collection which includes the items to be searched.
:return: (bool), ``true`` if all of the items in the specified collection exist in this queue, ``false`` otherwise. | def contains_all(self, items):
"""
Determines whether this queue contains all of the items in the specified collection or not.
:param items: (Collection), the specified collection which includes the items to be searched.
:return: (bool), ``true`` if all of the items in the specified col... |
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity
restrictions. Returns ``true`` upon success. If there is no space currently available:
* If a timeout is provided, it waits until this timeout elapses and returns the result.
*... | def offer(self, item, timeout=0):
"""
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity
restrictions. Returns ``true`` upon success. If there is no space currently available:
* If a timeout is provided, it waits until this... |
Transfers all available items to the given `list`_ and removes these items from this queue. If a max_size is
specified, it transfers at most the given number of items. In case of a failure, an item can exist in both
collections or none of them.
This operation may be more efficient than polling ... | def drain_to(self, list, max_size=-1):
"""
Transfers all available items to the given `list`_ and removes these items from this queue. If a max_size is
specified, it transfers at most the given number of items. In case of a failure, an item can exist in both
collections or none of them.
... |
Adds the specified element into this queue. If there is no space, it waits until necessary space becomes
available.
:param item: (object), the specified item. | def put(self, item):
"""
Adds the specified element into this queue. If there is no space, it waits until necessary space becomes
available.
:param item: (object), the specified item.
"""
check_not_none(item, "Value can't be None")
element_data = self._to_data(it... |
Removes all of the elements of the specified collection from this queue.
:param items: (Collection), the specified collection.
:return: (bool), ``true`` if the call changed this queue, ``false`` otherwise. | def remove_all(self, items):
"""
Removes all of the elements of the specified collection from this queue.
:param items: (Collection), the specified collection.
:return: (bool), ``true`` if the call changed this queue, ``false`` otherwise.
"""
check_not_none(items, "Value... |
Removes the specified item listener. Returns silently if the specified listener was not added before.
:param registration_id: (str), id of the listener to be deleted.
:return: (bool), ``true`` if the item listener is removed, ``false`` otherwise. | def remove_listener(self, registration_id):
"""
Removes the specified item listener. Returns silently if the specified listener was not added before.
:param registration_id: (str), id of the listener to be deleted.
:return: (bool), ``true`` if the item listener is removed, ``false`` oth... |
Removes the items which are not contained in the specified collection. In other words, only the items that
are contained in the specified collection will be retained.
:param items: (Collection), collection which includes the elements to be retained in this set.
:return: (bool), ``true`` if this... | def retain_all(self, items):
"""
Removes the items which are not contained in the specified collection. In other words, only the items that
are contained in the specified collection will be retained.
:param items: (Collection), collection which includes the elements to be retained in th... |
Decode response from client message | def decode_response(client_message, to_object=None):
""" Decode response from client message"""
parameters = dict(partitions=None)
partitions_size = client_message.read_int()
partitions = {}
for _ in range(0, partitions_size):
partitions_key = AddressCodec.decode(client_message, to_object)
... |
Calculates the request payload size | def calculate_size(name, data_list):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += INT_SIZE_IN_BYTES
for data_list_item in data_list:
data_size += calculate_size_data(data_list_item)
return data_size |
Encode request into client_message | def encode_request(name, data_list):
""" Encode request into client_message"""
client_message = ClientMessage(payload_size=calculate_size(name, data_list))
client_message.set_message_type(REQUEST_TYPE)
client_message.set_retryable(RETRYABLE)
client_message.append_str(name)
client_message.append_... |
Calculates the request payload size | def calculate_size(name, new_value):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += LONG_SIZE_IN_BYTES
return data_size |
Adds the given value to the current value and returns the previous value.
:raises NoDataMemberInClusterError: if the cluster does not contain any data members.
:raises UnsupportedOperationError: if the cluster version is less than 3.10.
:raises ConsistencyLostError: if the session guarantees ha... | def get_and_add(self, delta):
"""
Adds the given value to the current value and returns the previous value.
:raises NoDataMemberInClusterError: if the cluster does not contain any data members.
:raises UnsupportedOperationError: if the cluster version is less than 3.10.
:raises ... |
Adds the given value to the current value and returns the updated value.
:raises NoDataMemberInClusterError: if the cluster does not contain any data members.
:raises UnsupportedOperationError: if the cluster version is less than 3.10.
:raises ConsistencyLostError: if the session guarantees hav... | def add_and_get(self, delta):
"""
Adds the given value to the current value and returns the updated value.
:raises NoDataMemberInClusterError: if the cluster does not contain any data members.
:raises UnsupportedOperationError: if the cluster version is less than 3.10.
:raises C... |
Subtracts the given value from the current value and returns the previous value.
:raises NoDataMemberInClusterError: if the cluster does not contain any data members.
:raises UnsupportedOperationError: if the cluster version is less than 3.10.
:raises ConsistencyLostError: if the session guaran... | def get_and_subtract(self, delta):
"""
Subtracts the given value from the current value and returns the previous value.
:raises NoDataMemberInClusterError: if the cluster does not contain any data members.
:raises UnsupportedOperationError: if the cluster version is less than 3.10.
... |
Subtracts the given value from the current value and returns the updated value.
:raises NoDataMemberInClusterError: if the cluster does not contain any data members.
:raises UnsupportedOperationError: if the cluster version is less than 3.10.
:raises ConsistencyLostError: if the session guarant... | def subtract_and_get(self, delta):
"""
Subtracts the given value from the current value and returns the updated value.
:raises NoDataMemberInClusterError: if the cluster does not contain any data members.
:raises UnsupportedOperationError: if the cluster version is less than 3.10.
... |
Decode response from client message | def decode_response(client_message, to_object=None):
""" Decode response from client message"""
parameters = dict(response=None)
parameters['response'] = client_message.read_int()
return parameters |
Event handler | def handle(client_message, handle_event_map_partition_lost=None, to_object=None):
""" Event handler """
message_type = client_message.get_message_type()
if message_type == EVENT_MAPPARTITIONLOST and handle_event_map_partition_lost is not None:
partition_id = client_message.read_int()
uuid = ... |
Transactional implementation of :func:`List.add(item) <hazelcast.proxy.list.List.add>`
:param item: (object), the new item to be added.
:return: (bool), ``true`` if the item is added successfully, ``false`` otherwise. | def add(self, item):
"""
Transactional implementation of :func:`List.add(item) <hazelcast.proxy.list.List.add>`
:param item: (object), the new item to be added.
:return: (bool), ``true`` if the item is added successfully, ``false`` otherwise.
"""
check_not_none(item, "it... |
Transactional implementation of :func:`List.remove(item) <hazelcast.proxy.list.List.remove>`
:param item: (object), the specified item to be removed.
:return: (bool), ``true`` if the item is removed successfully, ``false`` otherwise. | def remove(self, item):
"""
Transactional implementation of :func:`List.remove(item) <hazelcast.proxy.list.List.remove>`
:param item: (object), the specified item to be removed.
:return: (bool), ``true`` if the item is removed successfully, ``false`` otherwise.
"""
check... |
Calculates the request payload size | def calculate_size(name, service_name):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += calculate_size_str(service_name)
return data_size |
Calculates the request payload size | def calculate_size(name, permits, timeout):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += INT_SIZE_IN_BYTES
data_size += LONG_SIZE_IN_BYTES
return data_size |
Creates cluster-wide :class:`~hazelcast.proxy.id_generator.IdGenerator`.
:param name: (str), name of the IdGenerator proxy.
:return: (:class:`~hazelcast.proxy.id_generator.IdGenerator`), IdGenerator proxy for the given name. | def get_id_generator(self, name):
"""
Creates cluster-wide :class:`~hazelcast.proxy.id_generator.IdGenerator`.
:param name: (str), name of the IdGenerator proxy.
:return: (:class:`~hazelcast.proxy.id_generator.IdGenerator`), IdGenerator proxy for the given name.
"""
atom... |
Creates a new :class:`~hazelcast.transaction.Transaction` associated with the current thread using default or given options.
:param timeout: (long), the timeout in seconds determines the maximum lifespan of a transaction. So if a
transaction is configured with a timeout of 2 minutes, then it will a... | def new_transaction(self, timeout=120, durability=1, type=TWO_PHASE):
"""
Creates a new :class:`~hazelcast.transaction.Transaction` associated with the current thread using default or given options.
:param timeout: (long), the timeout in seconds determines the maximum lifespan of a transaction.... |
Shuts down this HazelcastClient. | def shutdown(self):
"""
Shuts down this HazelcastClient.
"""
if self.lifecycle.is_live:
self.lifecycle.fire_lifecycle_event(LIFECYCLE_STATE_SHUTTING_DOWN)
self.near_cache_manager.destroy_all_near_caches()
self.statistics.shutdown()
self.par... |
Event handler | def handle(client_message, handle_event_member=None, handle_event_member_list=None, handle_event_member_attribute_change=None, to_object=None):
""" Event handler """
message_type = client_message.get_message_type()
if message_type == EVENT_MEMBER and handle_event_member is not None:
member = MemberC... |
Subscribes to this topic. When someone publishes a message on this topic, on_message() function is called if
provided.
:param on_message: (Function), function to be called when a message is published.
:return: (str), a registration id which is used as a key to remove the listener. | def add_listener(self, on_message=None):
"""
Subscribes to this topic. When someone publishes a message on this topic, on_message() function is called if
provided.
:param on_message: (Function), function to be called when a message is published.
:return: (str), a registration id... |
Publishes the message to all subscribers of this topic
:param message: (object), the message to be published. | def publish(self, message):
"""
Publishes the message to all subscribers of this topic
:param message: (object), the message to be published.
"""
message_data = self._to_data(message)
self._encode_invoke(topic_publish_codec, message=message_data) |
Stops receiving messages for the given message listener. If the given listener already removed, this method does
nothing.
:param registration_id: (str), registration id of the listener to be removed.
:return: (bool), ``true`` if the listener is removed, ``false`` otherwise. | def remove_listener(self, registration_id):
"""
Stops receiving messages for the given message listener. If the given listener already removed, this method does
nothing.
:param registration_id: (str), registration id of the listener to be removed.
:return: (bool), ``true`` if th... |
Calculates the request payload size | def calculate_size(name, from_, to):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += INT_SIZE_IN_BYTES
data_size += INT_SIZE_IN_BYTES
return data_size |
Encode request into client_message | def encode_request(name, from_, to):
""" Encode request into client_message"""
client_message = ClientMessage(payload_size=calculate_size(name, from_, to))
client_message.set_message_type(REQUEST_TYPE)
client_message.set_retryable(RETRYABLE)
client_message.append_str(name)
client_message.append_... |
Decode response from client message | def decode_response(client_message, to_object=None):
""" Decode response from client message"""
parameters = dict(response=None)
response_size = client_message.read_int()
response = []
for _ in range(0, response_size):
response_item = client_message.read_data()
response.append(respon... |
Validates the serializer for given type.
:param serializer: (Serializer), the serializer to be validated.
:param _type: (Type), type to be used for serializer validation. | def validate_serializer(serializer, _type):
"""
Validates the serializer for given type.
:param serializer: (Serializer), the serializer to be validated.
:param _type: (Type), type to be used for serializer validation.
"""
if not issubclass(serializer, _type):
raise ValueError("Serializ... |
Utility method for defining enums.
:param enums: Parameters of enumeration.
:return: (Enum), the created enumerations. | def enum(**enums):
"""
Utility method for defining enums.
:param enums: Parameters of enumeration.
:return: (Enum), the created enumerations.
"""
enums['reverse'] = dict((value, key) for key, value in six.iteritems(enums))
return type('Enum', (), enums) |
:param value: (Number), value to be translated to seconds
:param time_unit: Time duration in seconds
:return: Value of the value in seconds | def to_seconds(value, time_unit):
"""
:param value: (Number), value to be translated to seconds
:param time_unit: Time duration in seconds
:return: Value of the value in seconds
"""
if isinstance(value, bool):
# bool is a subclass of int. Don't let bool and fl... |
Calculates the request payload size | def calculate_size(name, listener_flags, local_only):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += INT_SIZE_IN_BYTES
data_size += BOOLEAN_SIZE_IN_BYTES
return data_size |
Event handler | def handle(client_message, handle_event_imap_invalidation=None, handle_event_imap_batch_invalidation=None, to_object=None):
""" Event handler """
message_type = client_message.get_message_type()
if message_type == EVENT_IMAPINVALIDATION and handle_event_imap_invalidation is not None:
key = None
... |
Creates an exception with given error codec.
:param error_codec: (Error Codec), error codec which includes the class name, message and exception trace.
:return: (Exception), the created exception. | def create_exception(error_codec):
"""
Creates an exception with given error codec.
:param error_codec: (Error Codec), error codec which includes the class name, message and exception trace.
:return: (Exception), the created exception.
"""
if error_codec.error_code in ERROR_CODE_TO_ERROR:
... |
Calculates the request payload size | def calculate_size(name, start_sequence, min_count, max_count, filter):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += LONG_SIZE_IN_BYTES
data_size += INT_SIZE_IN_BYTES
data_size += INT_SIZE_IN_BYTES
data_size += BOOLEAN_SIZE_IN_BY... |
Encode request into client_message | def encode_request(name, start_sequence, min_count, max_count, filter):
""" Encode request into client_message"""
client_message = ClientMessage(payload_size=calculate_size(name, start_sequence, min_count, max_count, filter))
client_message.set_message_type(REQUEST_TYPE)
client_message.set_retryable(RET... |
Decode response from client message | def decode_response(client_message, to_object=None):
""" Decode response from client message"""
parameters = dict(read_count=None, items=None)
parameters['read_count'] = client_message.read_int()
items_size = client_message.read_int()
items = []
for _ in range(0, items_size):
items_item ... |
Calculates the request payload size | def calculate_size(name, items):
""" Calculates the request payload size"""
data_size = 0
data_size += calculate_size_str(name)
data_size += INT_SIZE_IN_BYTES
for items_item in items:
data_size += calculate_size_data(items_item)
return data_size |
Encode request into client_message | def encode_request(name, items):
""" Encode request into client_message"""
client_message = ClientMessage(payload_size=calculate_size(name, items))
client_message.set_message_type(REQUEST_TYPE)
client_message.set_retryable(RETRYABLE)
client_message.append_str(name)
client_message.append_int(len(... |
Returns the capacity of this Ringbuffer.
:return: (long), the capacity of Ringbuffer. | def capacity(self):
"""
Returns the capacity of this Ringbuffer.
:return: (long), the capacity of Ringbuffer.
"""
if not self._capacity:
def cache_capacity(f):
self._capacity = f.result()
return f.result()
return self._enc... |
Adds the specified item to the tail of the Ringbuffer. If there is no space in the Ringbuffer, the action is
determined by overflow policy as :const:`OVERFLOW_POLICY_OVERWRITE` or :const:`OVERFLOW_POLICY_FAIL`.
:param item: (object), the specified item to be added.
:param overflow_policy: (int)... | def add(self, item, overflow_policy=OVERFLOW_POLICY_OVERWRITE):
"""
Adds the specified item to the tail of the Ringbuffer. If there is no space in the Ringbuffer, the action is
determined by overflow policy as :const:`OVERFLOW_POLICY_OVERWRITE` or :const:`OVERFLOW_POLICY_FAIL`.
:param i... |
Adds all of the item in the specified collection to the tail of the Ringbuffer. An add_all is likely to
outperform multiple calls to add(object) due to better io utilization and a reduced number of executed
operations. The items are added in the order of the Iterator of the collection.
If there... | def add_all(self, items, overflow_policy=OVERFLOW_POLICY_OVERWRITE):
"""
Adds all of the item in the specified collection to the tail of the Ringbuffer. An add_all is likely to
outperform multiple calls to add(object) due to better io utilization and a reduced number of executed
operatio... |
Reads one item from the Ringbuffer. If the sequence is one beyond the current tail, this call blocks until an
item is added. Currently it isn't possible to control how long this call is going to block.
:param sequence: (long), the sequence of the item to read.
:return: (object), the read item. | def read_one(self, sequence):
"""
Reads one item from the Ringbuffer. If the sequence is one beyond the current tail, this call blocks until an
item is added. Currently it isn't possible to control how long this call is going to block.
:param sequence: (long), the sequence of the item t... |
Reads a batch of items from the Ringbuffer. If the number of available items after the first read item is
smaller than the max_count, these items are returned. So it could be the number of items read is smaller than
the max_count. If there are less items available than min_count, then this call blocks. ... | def read_many(self, start_sequence, min_count, max_count):
"""
Reads a batch of items from the Ringbuffer. If the number of available items after the first read item is
smaller than the max_count, these items are returned. So it could be the number of items read is smaller than
the max_c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.