_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q231200 | KustoResultTable.to_dict | train | def to_dict(self):
"""Converts the table to a dict."""
return {"name": self.table_name, "kind": self.table_kind, "data": [r.to_dict() for r in self]} | python | {
"resource": ""
} |
q231201 | to_datetime | train | def to_datetime(value):
"""Converts a string to a datetime."""
if value is None:
return None
if isinstance(value, six.integer_types):
return parser.parse(value)
return parser.isoparse(value) | python | {
"resource": ""
} |
q231202 | to_timedelta | train | def to_timedelta(value):
"""Converts a string to a timedelta."""
if value is None:
return None
if isinstance(value, (six.integer_types, float)):
return timedelta(microseconds=(float(value) / 10))
match = _TIMESPAN_PATTERN.match(value)
if match:
if match.group(1) == "-":
... | python | {
"resource": ""
} |
q231203 | _AadHelper.acquire_authorization_header | train | def acquire_authorization_header(self):
"""Acquire tokens from AAD."""
try:
return self._acquire_authorization_header()
except AdalError as error:
if self._authentication_method is AuthenticationMethod.aad_username_password:
kwargs = {"username": self._use... | python | {
"resource": ""
} |
q231204 | KustoClient._execute | train | 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 = {
... | python | {
"resource": ""
} |
q231205 | ClientRequestProperties.set_option | train | def set_option(self, name, value):
"""Sets an option's value"""
_assert_value_is_valid(name)
self._options[name] = value | python | {
"resource": ""
} |
q231206 | _ResourceUri.parse | train | 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)) | python | {
"resource": ""
} |
q231207 | IngestionProperties.get_mapping_format | train | 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 | python | {
"resource": ""
} |
q231208 | getAtomChars | train | 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") | python | {
"resource": ""
} |
q231209 | getBool | train | 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") | python | {
"resource": ""
} |
q231210 | getLong | train | 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") | python | {
"resource": ""
} |
q231211 | getFloat | train | 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") | python | {
"resource": ""
} |
q231212 | getString | train | 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") | python | {
"resource": ""
} |
q231213 | getList | train | 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 | python | {
"resource": ""
} |
q231214 | Atom.fromTerm | train | 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... | python | {
"resource": ""
} |
q231215 | Functor.fromTerm | train | 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... | python | {
"resource": ""
} |
q231216 | _findSwiplWin | train | 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... | python | {
"resource": ""
} |
q231217 | _findSwiplLin | train | 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... | python | {
"resource": ""
} |
q231218 | _findSwiplDar | train | 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)... | python | {
"resource": ""
} |
q231219 | _fixWindowsPath | train | 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... | python | {
"resource": ""
} |
q231220 | list_to_bytes_list | train | 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... | python | {
"resource": ""
} |
q231221 | check_strings | train | 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
... | python | {
"resource": ""
} |
q231222 | Queue.add | train | 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():
... | python | {
"resource": ""
} |
q231223 | Queue.add_all | train | 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(... | python | {
"resource": ""
} |
q231224 | Queue.contains_all | train | 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... | python | {
"resource": ""
} |
q231225 | Queue.drain_to | train | 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.
... | python | {
"resource": ""
} |
q231226 | Queue.put | train | 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... | python | {
"resource": ""
} |
q231227 | Queue.remove_all | train | 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... | python | {
"resource": ""
} |
q231228 | Queue.retain_all | train | 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... | python | {
"resource": ""
} |
q231229 | PNCounter.get_and_add | train | 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 ... | python | {
"resource": ""
} |
q231230 | PNCounter.add_and_get | train | 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... | python | {
"resource": ""
} |
q231231 | PNCounter.get_and_subtract | train | 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.
... | python | {
"resource": ""
} |
q231232 | PNCounter.subtract_and_get | train | 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.
... | python | {
"resource": ""
} |
q231233 | HazelcastClient.shutdown | train | 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... | python | {
"resource": ""
} |
q231234 | Topic.publish | train | 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) | python | {
"resource": ""
} |
q231235 | Topic.remove_listener | train | 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... | python | {
"resource": ""
} |
q231236 | validate_serializer | train | 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... | python | {
"resource": ""
} |
q231237 | create_exception | train | 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:
... | python | {
"resource": ""
} |
q231238 | Ringbuffer.capacity | train | 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... | python | {
"resource": ""
} |
q231239 | Ringbuffer.read_one | train | 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... | python | {
"resource": ""
} |
q231240 | Ringbuffer.read_many | train | 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... | python | {
"resource": ""
} |
q231241 | IdGenerator.init | train | def init(self, initial):
"""
Try to initialize this IdGenerator instance with the given id. The first generated id will be 1 greater than id.
:param initial: (long), the given id.
:return: (bool), ``true`` if initialization succeeded, ``false`` if id is less than 0.
"""
... | python | {
"resource": ""
} |
q231242 | IdGenerator.new_id | train | def new_id(self):
"""
Generates and returns a cluster-wide unique id. Generated ids are guaranteed to be unique for the entire cluster
as long as the cluster is live. If the cluster restarts, then id generation will start from 0.
:return: (long), cluster-wide new unique id.
"""
... | python | {
"resource": ""
} |
q231243 | Executor.execute_on_key_owner | train | def execute_on_key_owner(self, key, task):
"""
Executes a task on the owner of the specified key.
:param key: (object), the specified key.
:param task: (Task), a task executed on the owner of the specified key.
:return: (:class:`~hazelcast.future.Future`), future representing pe... | python | {
"resource": ""
} |
q231244 | Executor.execute_on_member | train | def execute_on_member(self, member, task):
"""
Executes a task on the specified member.
:param member: (Member), the specified member.
:param task: (Task), the task executed on the specified member.
:return: (:class:`~hazelcast.future.Future`), Future representing pending comple... | python | {
"resource": ""
} |
q231245 | Executor.execute_on_members | train | def execute_on_members(self, members, task):
"""
Executes a task on each of the specified members.
:param members: (Collection), the specified members.
:param task: (Task), the task executed on the specified members.
:return: (Map), :class:`~hazelcast.future.Future` tuples repre... | python | {
"resource": ""
} |
q231246 | Executor.execute_on_all_members | train | def execute_on_all_members(self, task):
"""
Executes a task on all of the known cluster members.
:param task: (Task), the task executed on the all of the members.
:return: (Map), :class:`~hazelcast.future.Future` tuples representing pending completion of the task on each member.
... | python | {
"resource": ""
} |
q231247 | LifecycleService.add_listener | train | def add_listener(self, on_lifecycle_change):
"""
Add a listener object to listen for lifecycle events.
:param on_lifecycle_change: (Function), function to be called when LifeCycle state is changed.
:return: (str), id of the listener.
"""
id = str(uuid.uuid4())
se... | python | {
"resource": ""
} |
q231248 | LifecycleService.remove_listener | train | def remove_listener(self, registration_id):
"""
Removes a lifecycle listener.
:param registration_id: (str), the id of the listener to be removed.
:return: (bool), ``true`` if the listener is removed successfully, ``false`` otherwise.
"""
try:
self._listeners... | python | {
"resource": ""
} |
q231249 | LifecycleService.fire_lifecycle_event | train | def fire_lifecycle_event(self, new_state):
"""
Called when instance's state changes.
:param new_state: (Lifecycle State), the new state of the instance.
"""
if new_state == LIFECYCLE_STATE_SHUTTING_DOWN:
self.is_live = False
self.state = new_state
se... | python | {
"resource": ""
} |
q231250 | Lock.lock | train | def lock(self, lease_time=-1):
"""
Acquires the lock. If a lease time is specified, lock will be released after this lease time.
If the lock is not available, the current thread becomes disabled for thread scheduling purposes and lies
dormant until the lock has been acquired.
:... | python | {
"resource": ""
} |
q231251 | Lock.try_lock | train | def try_lock(self, timeout=0, lease_time=-1):
"""
Tries to acquire the lock. When the lock is not available,
* If timeout is not provided, the current thread doesn't wait and returns ``false`` immediately.
* If a timeout is provided, the current thread becomes disabled for threa... | python | {
"resource": ""
} |
q231252 | MultiMap.contains_key | train | def contains_key(self, key):
"""
Determines whether this multimap contains an entry with the key.
**Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations
of __hash__ and __eq__ defined in key's class.**
:param key: (obje... | python | {
"resource": ""
} |
q231253 | MultiMap.contains_entry | train | def contains_entry(self, key, value):
"""
Returns whether the multimap contains an entry with the value.
:param key: (object), the specified key.
:param value: (object), the specified value.
:return: (bool), ``true`` if this multimap contains the key-value tuple.
"""
... | python | {
"resource": ""
} |
q231254 | MultiMap.get | train | def get(self, key):
"""
Returns the list of values associated with the key. ``None`` if this map does not contain this key.
**Warning:
This method uses hashCode and equals of the binary form of the key, not the actual implementations of hashCode
and equals defined in the key's c... | python | {
"resource": ""
} |
q231255 | MultiMap.is_locked | train | def is_locked(self, key):
"""
Checks the lock for the specified key. If the lock is acquired, returns ``true``. Otherwise, returns false.
**Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations
of __hash__ and __eq__ defined in k... | python | {
"resource": ""
} |
q231256 | MultiMap.remove | train | def remove(self, key, value):
"""
Removes the given key-value tuple from the multimap.
**Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations
of __hash__ and __eq__ defined in key's class.**
:param key: (object), the k... | python | {
"resource": ""
} |
q231257 | MultiMap.remove_all | train | def remove_all(self, key):
"""
Removes all the entries with the given key and returns the value list associated with this key.
**Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations
of __hash__ and __eq__ defined in key's class.... | python | {
"resource": ""
} |
q231258 | MultiMap.put | train | def put(self, key, value):
"""
Stores a key-value tuple in the multimap.
**Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations
of __hash__ and __eq__ defined in key's class.**
:param key: (object), the key to be stored... | python | {
"resource": ""
} |
q231259 | MultiMap.value_count | train | def value_count(self, key):
"""
Returns the number of values that match the given key in the multimap.
**Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations
of __hash__ and __eq__ defined in key's class.**
:param key: ... | python | {
"resource": ""
} |
q231260 | AtomicReference.alter | train | def alter(self, function):
"""
Alters the currently stored reference by applying a function on it.
:param function: (Function), A stateful serializable object which represents the Function defined on
server side.
This object must have a serializable Function counter part... | python | {
"resource": ""
} |
q231261 | AtomicReference.alter_and_get | train | def alter_and_get(self, function):
"""
Alters the currently stored reference by applying a function on it and gets the result.
:param function: (Function), A stateful serializable object which represents the Function defined on
server side.
This object must have a serial... | python | {
"resource": ""
} |
q231262 | AtomicReference.contains | train | def contains(self, expected):
"""
Checks if the reference contains the value.
:param expected: (object), the value to check (is allowed to be ``None``).
:return: (bool), ``true`` if the value is found, ``false`` otherwise.
"""
return self._encode_invoke(atomic_reference... | python | {
"resource": ""
} |
q231263 | AtomicReference.get_and_alter | train | def get_and_alter(self, function):
"""
Alters the currently stored reference by applying a function on it on and gets the old value.
:param function: (Function), A stateful serializable object which represents the Function defined on
server side.
This object must have a ... | python | {
"resource": ""
} |
q231264 | AtomicReference.get_and_set | train | def get_and_set(self, new_value):
"""
Gets the old value and sets the new value.
:param new_value: (object), the new value.
:return: (object), the old value.
"""
return self._encode_invoke(atomic_reference_get_and_set_codec,
new_value=s... | python | {
"resource": ""
} |
q231265 | AtomicReference.set | train | def set(self, new_value):
"""
Atomically sets the given value.
:param new_value: (object), the new value.
"""
return self._encode_invoke(atomic_reference_set_codec,
new_value=self._to_data(new_value)) | python | {
"resource": ""
} |
q231266 | AtomicReference.set_and_get | train | def set_and_get(self, new_value):
"""
Sets and gets the value.
:param new_value: (object), the new value.
:return: (object), the new value.
"""
return self._encode_invoke(atomic_reference_set_and_get_codec,
new_value=self._to_data(new_v... | python | {
"resource": ""
} |
q231267 | Data.get_type | train | def get_type(self):
"""
Returns serialization type of binary form.
:return: Serialization type of binary form.
"""
if self.total_size() == 0:
return CONSTANT_TYPE_NULL
return unpack_from(FMT_BE_INT, self._buffer, TYPE_OFFSET)[0] | python | {
"resource": ""
} |
q231268 | Data.has_partition_hash | train | def has_partition_hash(self):
"""
Determines whether this Data has partition hash or not.
:return: (bool), ``true`` if Data has partition hash, ``false`` otherwise.
"""
return self._buffer is not None \
and len(self._buffer) >= HEAP_DATA_OVERHEAD \
... | python | {
"resource": ""
} |
q231269 | SerializerRegistry.serializer_for | train | def serializer_for(self, obj):
"""
Searches for a serializer for the provided object
Serializers will be searched in this order;
1-NULL serializer
2-Default serializers, like primitives, arrays, string and some default types
3-Custom registered types... | python | {
"resource": ""
} |
q231270 | DataRecord.is_expired | train | def is_expired(self, max_idle_seconds):
"""
Determines whether this record is expired or not.
:param max_idle_seconds: (long), the maximum idle time of record, maximum time after the last access time.
:return: (bool), ``true`` is this record is not expired.
"""
now = cu... | python | {
"resource": ""
} |
q231271 | combine_futures | train | def combine_futures(*futures):
"""
Combines set of Futures.
:param futures: (Futures), Futures to be combined.
:return: Result of the combination.
"""
expected = len(futures)
results = []
completed = AtomicInteger()
combined = Future()
def done(f):
if not combined.done(... | python | {
"resource": ""
} |
q231272 | Future.set_result | train | def set_result(self, result):
"""
Sets the result of the Future.
:param result: Result of the Future.
"""
if result is None:
self._result = NONE_RESULT
else:
self._result = result
self._event.set()
self._invoke_callbacks() | python | {
"resource": ""
} |
q231273 | Future.set_exception | train | def set_exception(self, exception, traceback=None):
"""
Sets the exception for this Future in case of errors.
:param exception: (Exception), exception to be threw in case of error.
:param traceback: (Function), function to be called on traceback (optional).
"""
if not is... | python | {
"resource": ""
} |
q231274 | Future.result | train | def result(self):
"""
Returns the result of the Future, which makes the call synchronous if the result has not been computed yet.
:return: Result of the Future.
"""
self._reactor_check()
self._event.wait()
if self._exception:
six.reraise(self._excepti... | python | {
"resource": ""
} |
q231275 | Future.continue_with | train | def continue_with(self, continuation_func, *args):
"""
Create a continuation that executes when the Future is completed.
:param continuation_func: A function which takes the future as the only parameter. Return value of the function
will be set as the result of the continuation future.
... | python | {
"resource": ""
} |
q231276 | ConnectionManager.on_auth | train | def on_auth(self, f, connection, address):
"""
Checks for authentication of a connection.
:param f: (:class:`~hazelcast.future.Future`), future that contains the result of authentication.
:param connection: (:class:`~hazelcast.connection.Connection`), newly established connection.
... | python | {
"resource": ""
} |
q231277 | ConnectionManager.close_connection | train | def close_connection(self, address, cause):
"""
Closes the connection with given address.
:param address: (:class:`~hazelcast.core.Address`), address of the connection to be closed.
:param cause: (Exception), the cause for closing the connection.
:return: (bool), ``true`` if the... | python | {
"resource": ""
} |
q231278 | Heartbeat.start | train | def start(self):
"""
Starts sending periodic HeartBeat operations.
"""
def _heartbeat():
if not self._client.lifecycle.is_live:
return
self._heartbeat()
self._heartbeat_timer = self._client.reactor.add_timer(self._heartbeat_interval, _h... | python | {
"resource": ""
} |
q231279 | Connection.send_message | train | def send_message(self, message):
"""
Sends a message to this connection.
:param message: (Message), message to be sent to this connection.
"""
if not self.live():
raise IOError("Connection is not live.")
message.add_flag(BEGIN_END_FLAG)
self.write(me... | python | {
"resource": ""
} |
q231280 | Connection.receive_message | train | def receive_message(self):
"""
Receives a message from this connection.
"""
# split frames
while len(self._read_buffer) >= INT_SIZE_IN_BYTES:
frame_length = struct.unpack_from(FMT_LE_INT, self._read_buffer, 0)[0]
if frame_length > len(self._read_buffer):
... | python | {
"resource": ""
} |
q231281 | Semaphore.init | train | def init(self, permits):
"""
Try to initialize this Semaphore instance with the given permit count.
:param permits: (int), the given permit count.
:return: (bool), ``true`` if initialization success.
"""
check_not_negative(permits, "Permits cannot be negative!")
... | python | {
"resource": ""
} |
q231282 | Semaphore.acquire | train | def acquire(self, permits=1):
"""
Acquires one or specified amount of permits if available, and returns immediately, reducing the number of
available permits by one or given amount.
If insufficient permits are available then the current thread becomes disabled for thread scheduling purp... | python | {
"resource": ""
} |
q231283 | Semaphore.reduce_permits | train | def reduce_permits(self, reduction):
"""
Shrinks the number of available permits by the indicated reduction. This method differs from acquire in that it
does not block waiting for permits to become available.
:param reduction: (int), the number of permits to remove.
"""
... | python | {
"resource": ""
} |
q231284 | Semaphore.release | train | def release(self, permits=1):
"""
Releases one or given number of permits, increasing the number of available permits by one or that amount.
There is no requirement that a thread that releases a permit must have acquired that permit by calling one of
the acquire methods. Correct usage o... | python | {
"resource": ""
} |
q231285 | Semaphore.try_acquire | train | def try_acquire(self, permits=1, timeout=0):
"""
Tries to acquire one or the given number of permits, if they are available, and returns immediately, with the
value ``true``, reducing the number of available permits by the given amount.
If there are insufficient permits and a timeout is... | python | {
"resource": ""
} |
q231286 | ClientConfig.add_membership_listener | train | def add_membership_listener(self, member_added=None, member_removed=None, fire_for_existing=False):
"""
Helper method for adding membership listeners
:param member_added: (Function), Function to be called when a member is added, in the form of f(member)
(optional).
:param member... | python | {
"resource": ""
} |
q231287 | SerializationConfig.set_custom_serializer | train | def set_custom_serializer(self, _type, serializer):
"""
Assign a serializer for the type.
:param _type: (Type), the target type of the serializer
:param serializer: (Serializer), Custom Serializer constructor function
"""
validate_type(_type)
validate_serializer(... | python | {
"resource": ""
} |
q231288 | ClientProperties.get | train | def get(self, property):
"""
Gets the value of the given property. First checks client config properties, then environment variables
and lastly fall backs to the default value of the property.
:param property: (:class:`~hazelcast.config.ClientProperty`), Property to get value from
... | python | {
"resource": ""
} |
q231289 | ClientProperties.get_bool | train | def get_bool(self, property):
"""
Gets the value of the given property as boolean.
:param property: (:class:`~hazelcast.config.ClientProperty`), Property to get value from
:return: (bool), Value of the given property
"""
value = self.get(property)
if isinstance(v... | python | {
"resource": ""
} |
q231290 | ClientProperties.get_seconds | train | def get_seconds(self, property):
"""
Gets the value of the given property in seconds. If the value of the given property is not a number,
throws TypeError.
:param property: (:class:`~hazelcast.config.ClientProperty`), Property to get seconds from
:return: (float), Value of the g... | python | {
"resource": ""
} |
q231291 | ClientProperties.get_seconds_positive_or_default | train | def get_seconds_positive_or_default(self, property):
"""
Gets the value of the given property in seconds. If the value of the given property is not a number,
throws TypeError. If the value of the given property in seconds is not positive, tries to
return the default value in seconds.
... | python | {
"resource": ""
} |
q231292 | PartitionService.start | train | def start(self):
"""
Starts the partition service.
"""
self.logger.debug("Starting partition service", extra=self._logger_extras)
def partition_updater():
self._do_refresh()
self.timer = self._client.reactor.add_timer(PARTITION_UPDATE_INTERVAL, partition_... | python | {
"resource": ""
} |
q231293 | PartitionService.get_partition_owner | train | def get_partition_owner(self, partition_id):
"""
Gets the owner of the partition if it's set. Otherwise it will trigger partition assignment.
:param partition_id: (int), the partition id.
:return: (:class:`~hazelcast.core.Address`), owner of partition or ``None`` if it's not set yet.
... | python | {
"resource": ""
} |
q231294 | PartitionService.get_partition_id | train | def get_partition_id(self, key):
"""
Returns the partition id for a Data key.
:param key: (object), the data key.
:return: (int), the partition id.
"""
data = self._client.serialization_service.to_data(key)
count = self.get_partition_count()
if count <= 0... | python | {
"resource": ""
} |
q231295 | murmur_hash3_x86_32 | train | def murmur_hash3_x86_32(data, offset, size, seed=0x01000193):
"""
murmur3 hash function to determine partition
:param data: (byte array), input byte array
:param offset: (long), offset.
:param size: (long), byte length.
:param seed: murmur hash seed hazelcast uses 0x01000193
:return: (int32... | python | {
"resource": ""
} |
q231296 | List.add | train | def add(self, item):
"""
Adds the specified item to the end of this list.
:param item: (object), the specified item to be appended to this list.
:return: (bool), ``true`` if item is added, ``false`` otherwise.
"""
check_not_none(item, "Value can't be None")
eleme... | python | {
"resource": ""
} |
q231297 | List.add_at | train | def add_at(self, index, item):
"""
Adds the specified item at the specific position in this list. Element in this position and following elements
are shifted to the right, if any.
:param index: (int), the specified index to insert the item.
:param item: (object), the specified i... | python | {
"resource": ""
} |
q231298 | List.add_all | train | def add_all(self, items):
"""
Adds all of the items in the specified collection to the end of this list. The order of new elements is
determined by the specified collection's iterator.
:param items: (Collection), the specified collection which includes the elements to be added to list.
... | python | {
"resource": ""
} |
q231299 | List.add_all_at | train | def add_all_at(self, index, items):
"""
Adds all of the elements in the specified collection into this list at the specified position. Elements in this
positions and following elements are shifted to the right, if any. The order of new elements is determined by the
specified collection's... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.