id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
18,900
basho/riak-python-client
riak/mapreduce.py
RiakMapReduce.reduce_slice
def reduce_slice(self, start, end, options=None): """ Adds the Javascript built-in ``Riak.reduceSlice`` to the query as a reduce phase. :param start: the beginning of the slice :type start: integer :param end: the end of the slice :type end: integer :para...
python
def reduce_slice(self, start, end, options=None): """ Adds the Javascript built-in ``Riak.reduceSlice`` to the query as a reduce phase. :param start: the beginning of the slice :type start: integer :param end: the end of the slice :type end: integer :para...
[ "def", "reduce_slice", "(", "self", ",", "start", ",", "end", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "dict", "(", ")", "options", "[", "'arg'", "]", "=", "[", "start", ",", "end", "]", "return", ...
Adds the Javascript built-in ``Riak.reduceSlice`` to the query as a reduce phase. :param start: the beginning of the slice :type start: integer :param end: the end of the slice :type end: integer :param options: phase options, containing 'language', 'keep' flag...
[ "Adds", "the", "Javascript", "built", "-", "in", "Riak", ".", "reduceSlice", "to", "the", "query", "as", "a", "reduce", "phase", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/mapreduce.py#L500-L517
18,901
basho/riak-python-client
riak/mapreduce.py
RiakMapReducePhase.to_array
def to_array(self): """ Convert the RiakMapReducePhase to a format that can be output into JSON. Used internally. :rtype: dict """ stepdef = {'keep': self._keep, 'language': self._language, 'arg': self._arg} if self._languag...
python
def to_array(self): """ Convert the RiakMapReducePhase to a format that can be output into JSON. Used internally. :rtype: dict """ stepdef = {'keep': self._keep, 'language': self._language, 'arg': self._arg} if self._languag...
[ "def", "to_array", "(", "self", ")", ":", "stepdef", "=", "{", "'keep'", ":", "self", ".", "_keep", ",", "'language'", ":", "self", ".", "_language", ",", "'arg'", ":", "self", ".", "_arg", "}", "if", "self", ".", "_language", "==", "'javascript'", "...
Convert the RiakMapReducePhase to a format that can be output into JSON. Used internally. :rtype: dict
[ "Convert", "the", "RiakMapReducePhase", "to", "a", "format", "that", "can", "be", "output", "into", "JSON", ".", "Used", "internally", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/mapreduce.py#L569-L598
18,902
basho/riak-python-client
riak/mapreduce.py
RiakLinkPhase.to_array
def to_array(self): """ Convert the RiakLinkPhase to a format that can be output into JSON. Used internally. """ stepdef = {'bucket': self._bucket, 'tag': self._tag, 'keep': self._keep} return {'link': stepdef}
python
def to_array(self): """ Convert the RiakLinkPhase to a format that can be output into JSON. Used internally. """ stepdef = {'bucket': self._bucket, 'tag': self._tag, 'keep': self._keep} return {'link': stepdef}
[ "def", "to_array", "(", "self", ")", ":", "stepdef", "=", "{", "'bucket'", ":", "self", ".", "_bucket", ",", "'tag'", ":", "self", ".", "_tag", ",", "'keep'", ":", "self", ".", "_keep", "}", "return", "{", "'link'", ":", "stepdef", "}" ]
Convert the RiakLinkPhase to a format that can be output into JSON. Used internally.
[ "Convert", "the", "RiakLinkPhase", "to", "a", "format", "that", "can", "be", "output", "into", "JSON", ".", "Used", "internally", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/mapreduce.py#L626-L634
18,903
basho/riak-python-client
riak/resolver.py
last_written_resolver
def last_written_resolver(riak_object): """ A conflict-resolution function that resolves by selecting the most recently-modified sibling by timestamp. :param riak_object: an object-in-conflict that will be resolved :type riak_object: :class:`RiakObject <riak.riak_object.RiakObject>` """ ria...
python
def last_written_resolver(riak_object): """ A conflict-resolution function that resolves by selecting the most recently-modified sibling by timestamp. :param riak_object: an object-in-conflict that will be resolved :type riak_object: :class:`RiakObject <riak.riak_object.RiakObject>` """ ria...
[ "def", "last_written_resolver", "(", "riak_object", ")", ":", "riak_object", ".", "siblings", "=", "[", "max", "(", "riak_object", ".", "siblings", ",", "key", "=", "lambda", "x", ":", "x", ".", "last_modified", ")", ",", "]" ]
A conflict-resolution function that resolves by selecting the most recently-modified sibling by timestamp. :param riak_object: an object-in-conflict that will be resolved :type riak_object: :class:`RiakObject <riak.riak_object.RiakObject>`
[ "A", "conflict", "-", "resolution", "function", "that", "resolves", "by", "selecting", "the", "most", "recently", "-", "modified", "sibling", "by", "timestamp", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/resolver.py#L31-L40
18,904
basho/riak-python-client
riak/transports/security.py
verify_cb
def verify_cb(conn, cert, errnum, depth, ok): """ The default OpenSSL certificate verification callback. """ if not ok: raise SecurityError("Could not verify CA certificate {0}" .format(cert.get_subject())) return ok
python
def verify_cb(conn, cert, errnum, depth, ok): """ The default OpenSSL certificate verification callback. """ if not ok: raise SecurityError("Could not verify CA certificate {0}" .format(cert.get_subject())) return ok
[ "def", "verify_cb", "(", "conn", ",", "cert", ",", "errnum", ",", "depth", ",", "ok", ")", ":", "if", "not", "ok", ":", "raise", "SecurityError", "(", "\"Could not verify CA certificate {0}\"", ".", "format", "(", "cert", ".", "get_subject", "(", ")", ")",...
The default OpenSSL certificate verification callback.
[ "The", "default", "OpenSSL", "certificate", "verification", "callback", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/security.py#L27-L34
18,905
basho/riak-python-client
riak/client/index_page.py
IndexPage.next_page
def next_page(self, timeout=None, stream=None): """ Fetches the next page using the same parameters as the original query. Note that if streaming was used before, it will be used again unless overridden. :param stream: whether to enable streaming. `True` enables, ...
python
def next_page(self, timeout=None, stream=None): """ Fetches the next page using the same parameters as the original query. Note that if streaming was used before, it will be used again unless overridden. :param stream: whether to enable streaming. `True` enables, ...
[ "def", "next_page", "(", "self", ",", "timeout", "=", "None", ",", "stream", "=", "None", ")", ":", "if", "not", "self", ".", "continuation", ":", "raise", "ValueError", "(", "\"Cannot get next index page, no continuation\"", ")", "if", "stream", "is", "not", ...
Fetches the next page using the same parameters as the original query. Note that if streaming was used before, it will be used again unless overridden. :param stream: whether to enable streaming. `True` enables, `False` disables, `None` uses previous value. :type st...
[ "Fetches", "the", "next", "page", "using", "the", "same", "parameters", "as", "the", "original", "query", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/index_page.py#L117-L150
18,906
basho/riak-python-client
riak/client/operations.py
_validate_timeout
def _validate_timeout(timeout, infinity_ok=False): """ Raises an exception if the given timeout is an invalid value. """ if timeout is None: return if timeout == 'infinity': if infinity_ok: return else: raise ValueError( 'timeout must ...
python
def _validate_timeout(timeout, infinity_ok=False): """ Raises an exception if the given timeout is an invalid value. """ if timeout is None: return if timeout == 'infinity': if infinity_ok: return else: raise ValueError( 'timeout must ...
[ "def", "_validate_timeout", "(", "timeout", ",", "infinity_ok", "=", "False", ")", ":", "if", "timeout", "is", "None", ":", "return", "if", "timeout", "==", "'infinity'", ":", "if", "infinity_ok", ":", "return", "else", ":", "raise", "ValueError", "(", "'t...
Raises an exception if the given timeout is an invalid value.
[ "Raises", "an", "exception", "if", "the", "given", "timeout", "is", "an", "invalid", "value", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L1270-L1288
18,907
basho/riak-python-client
riak/client/operations.py
RiakClientOperations.stream_buckets
def stream_buckets(self, bucket_type=None, timeout=None): """ Streams the list of buckets. This is a generator method that should be iterated over. .. warning:: Do not use this in production, as it requires traversing through all keys stored in a cluster. The caller ...
python
def stream_buckets(self, bucket_type=None, timeout=None): """ Streams the list of buckets. This is a generator method that should be iterated over. .. warning:: Do not use this in production, as it requires traversing through all keys stored in a cluster. The caller ...
[ "def", "stream_buckets", "(", "self", ",", "bucket_type", "=", "None", ",", "timeout", "=", "None", ")", ":", "if", "not", "riak", ".", "disable_list_exceptions", ":", "raise", "ListError", "(", ")", "_validate_timeout", "(", "timeout", ")", "if", "bucket_ty...
Streams the list of buckets. This is a generator method that should be iterated over. .. warning:: Do not use this in production, as it requires traversing through all keys stored in a cluster. The caller should explicitly close the returned iterator, either using :func:`con...
[ "Streams", "the", "list", "of", "buckets", ".", "This", "is", "a", "generator", "method", "that", "should", "be", "iterated", "over", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L72-L125
18,908
basho/riak-python-client
riak/client/operations.py
RiakClientOperations.stream_index
def stream_index(self, bucket, index, startkey, endkey=None, return_terms=None, max_results=None, continuation=None, timeout=None, term_regex=None): """ Queries a secondary index, streaming matching keys through an iterator. The caller should ex...
python
def stream_index(self, bucket, index, startkey, endkey=None, return_terms=None, max_results=None, continuation=None, timeout=None, term_regex=None): """ Queries a secondary index, streaming matching keys through an iterator. The caller should ex...
[ "def", "stream_index", "(", "self", ",", "bucket", ",", "index", ",", "startkey", ",", "endkey", "=", "None", ",", "return_terms", "=", "None", ",", "max_results", "=", "None", ",", "continuation", "=", "None", ",", "timeout", "=", "None", ",", "term_reg...
Queries a secondary index, streaming matching keys through an iterator. The caller should explicitly close the returned iterator, either using :func:`contextlib.closing` or calling ``close()`` explicitly. Consuming the entire iterator will also close the stream. If it does not, ...
[ "Queries", "a", "secondary", "index", "streaming", "matching", "keys", "through", "an", "iterator", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L238-L301
18,909
basho/riak-python-client
riak/client/operations.py
RiakClientOperations.stream_keys
def stream_keys(self, bucket, timeout=None): """ Lists all keys in a bucket via a stream. This is a generator method which should be iterated over. .. warning:: Do not use this in production, as it requires traversing through all keys stored in a cluster. The caller ...
python
def stream_keys(self, bucket, timeout=None): """ Lists all keys in a bucket via a stream. This is a generator method which should be iterated over. .. warning:: Do not use this in production, as it requires traversing through all keys stored in a cluster. The caller ...
[ "def", "stream_keys", "(", "self", ",", "bucket", ",", "timeout", "=", "None", ")", ":", "if", "not", "riak", ".", "disable_list_exceptions", ":", "raise", "ListError", "(", ")", "_validate_timeout", "(", "timeout", ")", "def", "make_op", "(", "transport", ...
Lists all keys in a bucket via a stream. This is a generator method which should be iterated over. .. warning:: Do not use this in production, as it requires traversing through all keys stored in a cluster. The caller should explicitly close the returned iterator, either usi...
[ "Lists", "all", "keys", "in", "a", "bucket", "via", "a", "stream", ".", "This", "is", "a", "generator", "method", "which", "should", "be", "iterated", "over", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L484-L530
18,910
basho/riak-python-client
riak/client/operations.py
RiakClientOperations.ts_stream_keys
def ts_stream_keys(self, table, timeout=None): """ Lists all keys in a time series table via a stream. This is a generator method which should be iterated over. The caller should explicitly close the returned iterator, either using :func:`contextlib.closing` or calling ``close()...
python
def ts_stream_keys(self, table, timeout=None): """ Lists all keys in a time series table via a stream. This is a generator method which should be iterated over. The caller should explicitly close the returned iterator, either using :func:`contextlib.closing` or calling ``close()...
[ "def", "ts_stream_keys", "(", "self", ",", "table", ",", "timeout", "=", "None", ")", ":", "if", "not", "riak", ".", "disable_list_exceptions", ":", "raise", "ListError", "(", ")", "t", "=", "table", "if", "isinstance", "(", "t", ",", "six", ".", "stri...
Lists all keys in a time series table via a stream. This is a generator method which should be iterated over. The caller should explicitly close the returned iterator, either using :func:`contextlib.closing` or calling ``close()`` explicitly. Consuming the entire iterator will also clos...
[ "Lists", "all", "keys", "in", "a", "time", "series", "table", "via", "a", "stream", ".", "This", "is", "a", "generator", "method", "which", "should", "be", "iterated", "over", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L665-L713
18,911
basho/riak-python-client
riak/client/operations.py
RiakClientOperations.multiget
def multiget(self, pairs, **params): """Fetches many keys in parallel via threads. :param pairs: list of bucket_type/bucket/key tuple triples :type pairs: list :param params: additional request flags, e.g. r, pr :type params: dict :rtype: list of :class:`RiakObjects <ria...
python
def multiget(self, pairs, **params): """Fetches many keys in parallel via threads. :param pairs: list of bucket_type/bucket/key tuple triples :type pairs: list :param params: additional request flags, e.g. r, pr :type params: dict :rtype: list of :class:`RiakObjects <ria...
[ "def", "multiget", "(", "self", ",", "pairs", ",", "*", "*", "params", ")", ":", "if", "self", ".", "_multiget_pool", ":", "params", "[", "'pool'", "]", "=", "self", ".", "_multiget_pool", "return", "riak", ".", "client", ".", "multi", ".", "multiget",...
Fetches many keys in parallel via threads. :param pairs: list of bucket_type/bucket/key tuple triples :type pairs: list :param params: additional request flags, e.g. r, pr :type params: dict :rtype: list of :class:`RiakObjects <riak.riak_object.RiakObject>`, :class:`...
[ "Fetches", "many", "keys", "in", "parallel", "via", "threads", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L1003-L1016
18,912
basho/riak-python-client
riak/client/operations.py
RiakClientOperations.multiput
def multiput(self, objs, **params): """ Stores objects in parallel via threads. :param objs: the objects to store :type objs: list of `RiakObject <riak.riak_object.RiakObject>` :param params: additional request flags, e.g. w, dw, pw :type params: dict :rtype: lis...
python
def multiput(self, objs, **params): """ Stores objects in parallel via threads. :param objs: the objects to store :type objs: list of `RiakObject <riak.riak_object.RiakObject>` :param params: additional request flags, e.g. w, dw, pw :type params: dict :rtype: lis...
[ "def", "multiput", "(", "self", ",", "objs", ",", "*", "*", "params", ")", ":", "if", "self", ".", "_multiput_pool", ":", "params", "[", "'pool'", "]", "=", "self", ".", "_multiput_pool", "return", "riak", ".", "client", ".", "multi", ".", "multiput", ...
Stores objects in parallel via threads. :param objs: the objects to store :type objs: list of `RiakObject <riak.riak_object.RiakObject>` :param params: additional request flags, e.g. w, dw, pw :type params: dict :rtype: list of boolean or :class:`RiakObjects <riak.ri...
[ "Stores", "objects", "in", "parallel", "via", "threads", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L1018-L1031
18,913
basho/riak-python-client
riak/client/operations.py
RiakClientOperations.fetch_datatype
def fetch_datatype(self, bucket, key, r=None, pr=None, basic_quorum=None, notfound_ok=None, timeout=None, include_context=None): """ Fetches the value of a Riak Datatype. .. note:: This request is automatically retried :attr:`retries` tim...
python
def fetch_datatype(self, bucket, key, r=None, pr=None, basic_quorum=None, notfound_ok=None, timeout=None, include_context=None): """ Fetches the value of a Riak Datatype. .. note:: This request is automatically retried :attr:`retries` tim...
[ "def", "fetch_datatype", "(", "self", ",", "bucket", ",", "key", ",", "r", "=", "None", ",", "pr", "=", "None", ",", "basic_quorum", "=", "None", ",", "notfound_ok", "=", "None", ",", "timeout", "=", "None", ",", "include_context", "=", "None", ")", ...
Fetches the value of a Riak Datatype. .. note:: This request is automatically retried :attr:`retries` times if it fails due to network error. :param bucket: the bucket of the datatype, which must belong to a :class:`~riak.bucket.BucketType` :type bucket: :class:`~riak.buck...
[ "Fetches", "the", "value", "of", "a", "Riak", "Datatype", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L1106-L1143
18,914
basho/riak-python-client
riak/client/operations.py
RiakClientOperations.update_datatype
def update_datatype(self, datatype, w=None, dw=None, pw=None, return_body=None, timeout=None, include_context=None): """ Sends an update to a Riak Datatype to the server. This operation is not idempotent and so will not be retried automatically. ...
python
def update_datatype(self, datatype, w=None, dw=None, pw=None, return_body=None, timeout=None, include_context=None): """ Sends an update to a Riak Datatype to the server. This operation is not idempotent and so will not be retried automatically. ...
[ "def", "update_datatype", "(", "self", ",", "datatype", ",", "w", "=", "None", ",", "dw", "=", "None", ",", "pw", "=", "None", ",", "return_body", "=", "None", ",", "timeout", "=", "None", ",", "include_context", "=", "None", ")", ":", "_validate_timeo...
Sends an update to a Riak Datatype to the server. This operation is not idempotent and so will not be retried automatically. :param datatype: the datatype with pending updates :type datatype: :class:`~riak.datatypes.Datatype` :param w: the write quorum :type w: integer, string, ...
[ "Sends", "an", "update", "to", "a", "Riak", "Datatype", "to", "the", "server", ".", "This", "operation", "is", "not", "idempotent", "and", "so", "will", "not", "be", "retried", "automatically", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L1145-L1175
18,915
basho/riak-python-client
riak/transports/tcp/connection.py
TcpConnection._non_connect_send_recv
def _non_connect_send_recv(self, msg_code, data=None): """ Similar to self._send_recv, but doesn't try to initiate a connection, thus preventing an infinite loop. """ self._non_connect_send_msg(msg_code, data) return self._recv_msg()
python
def _non_connect_send_recv(self, msg_code, data=None): """ Similar to self._send_recv, but doesn't try to initiate a connection, thus preventing an infinite loop. """ self._non_connect_send_msg(msg_code, data) return self._recv_msg()
[ "def", "_non_connect_send_recv", "(", "self", ",", "msg_code", ",", "data", "=", "None", ")", ":", "self", ".", "_non_connect_send_msg", "(", "msg_code", ",", "data", ")", "return", "self", ".", "_recv_msg", "(", ")" ]
Similar to self._send_recv, but doesn't try to initiate a connection, thus preventing an infinite loop.
[ "Similar", "to", "self", ".", "_send_recv", "but", "doesn", "t", "try", "to", "initiate", "a", "connection", "thus", "preventing", "an", "infinite", "loop", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/tcp/connection.py#L53-L59
18,916
basho/riak-python-client
riak/transports/tcp/connection.py
TcpConnection._non_connect_send_msg
def _non_connect_send_msg(self, msg_code, data): """ Similar to self._send, but doesn't try to initiate a connection, thus preventing an infinite loop. """ try: self._socket.sendall(self._encode_msg(msg_code, data)) except (IOError, socket.error) as e: ...
python
def _non_connect_send_msg(self, msg_code, data): """ Similar to self._send, but doesn't try to initiate a connection, thus preventing an infinite loop. """ try: self._socket.sendall(self._encode_msg(msg_code, data)) except (IOError, socket.error) as e: ...
[ "def", "_non_connect_send_msg", "(", "self", ",", "msg_code", ",", "data", ")", ":", "try", ":", "self", ".", "_socket", ".", "sendall", "(", "self", ".", "_encode_msg", "(", "msg_code", ",", "data", ")", ")", "except", "(", "IOError", ",", "socket", "...
Similar to self._send, but doesn't try to initiate a connection, thus preventing an infinite loop.
[ "Similar", "to", "self", ".", "_send", "but", "doesn", "t", "try", "to", "initiate", "a", "connection", "thus", "preventing", "an", "infinite", "loop", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/tcp/connection.py#L65-L76
18,917
basho/riak-python-client
riak/transports/tcp/connection.py
TcpConnection._init_security
def _init_security(self): """ Initialize a secure connection to the server. """ if not self._starttls(): raise SecurityError("Could not start TLS connection") # _ssh_handshake() will throw an exception upon failure self._ssl_handshake() if not self._au...
python
def _init_security(self): """ Initialize a secure connection to the server. """ if not self._starttls(): raise SecurityError("Could not start TLS connection") # _ssh_handshake() will throw an exception upon failure self._ssl_handshake() if not self._au...
[ "def", "_init_security", "(", "self", ")", ":", "if", "not", "self", ".", "_starttls", "(", ")", ":", "raise", "SecurityError", "(", "\"Could not start TLS connection\"", ")", "# _ssh_handshake() will throw an exception upon failure", "self", ".", "_ssl_handshake", "(",...
Initialize a secure connection to the server.
[ "Initialize", "a", "secure", "connection", "to", "the", "server", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/tcp/connection.py#L82-L91
18,918
basho/riak-python-client
riak/transports/tcp/connection.py
TcpConnection._starttls
def _starttls(self): """ Exchange a STARTTLS message with Riak to initiate secure communications return True is Riak responds with a STARTTLS response, False otherwise """ resp_code, _ = self._non_connect_send_recv( riak.pb.messages.MSG_CODE_START_TLS) if resp...
python
def _starttls(self): """ Exchange a STARTTLS message with Riak to initiate secure communications return True is Riak responds with a STARTTLS response, False otherwise """ resp_code, _ = self._non_connect_send_recv( riak.pb.messages.MSG_CODE_START_TLS) if resp...
[ "def", "_starttls", "(", "self", ")", ":", "resp_code", ",", "_", "=", "self", ".", "_non_connect_send_recv", "(", "riak", ".", "pb", ".", "messages", ".", "MSG_CODE_START_TLS", ")", "if", "resp_code", "==", "riak", ".", "pb", ".", "messages", ".", "MSG_...
Exchange a STARTTLS message with Riak to initiate secure communications return True is Riak responds with a STARTTLS response, False otherwise
[ "Exchange", "a", "STARTTLS", "message", "with", "Riak", "to", "initiate", "secure", "communications", "return", "True", "is", "Riak", "responds", "with", "a", "STARTTLS", "response", "False", "otherwise" ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/tcp/connection.py#L93-L103
18,919
basho/riak-python-client
riak/transports/tcp/connection.py
TcpConnection.close
def close(self): """ Closes the underlying socket of the PB connection. """ if self._socket: if USE_STDLIB_SSL: # NB: Python 2.7.8 and earlier does not have a compatible # shutdown() method due to the SSL lib try: ...
python
def close(self): """ Closes the underlying socket of the PB connection. """ if self._socket: if USE_STDLIB_SSL: # NB: Python 2.7.8 and earlier does not have a compatible # shutdown() method due to the SSL lib try: ...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_socket", ":", "if", "USE_STDLIB_SSL", ":", "# NB: Python 2.7.8 and earlier does not have a compatible", "# shutdown() method due to the SSL lib", "try", ":", "self", ".", "_socket", ".", "shutdown", "(", "soc...
Closes the underlying socket of the PB connection.
[ "Closes", "the", "underlying", "socket", "of", "the", "PB", "connection", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/tcp/connection.py#L266-L283
18,920
basho/riak-python-client
riak/riak_object.py
content_property
def content_property(name, doc=None): """ Delegates a property to the first sibling in a RiakObject, raising an error when the object is in conflict. """ def _setter(self, value): if len(self.siblings) == 0: # In this case, assume that what the user wants is to # crea...
python
def content_property(name, doc=None): """ Delegates a property to the first sibling in a RiakObject, raising an error when the object is in conflict. """ def _setter(self, value): if len(self.siblings) == 0: # In this case, assume that what the user wants is to # crea...
[ "def", "content_property", "(", "name", ",", "doc", "=", "None", ")", ":", "def", "_setter", "(", "self", ",", "value", ")", ":", "if", "len", "(", "self", ".", "siblings", ")", "==", "0", ":", "# In this case, assume that what the user wants is to", "# crea...
Delegates a property to the first sibling in a RiakObject, raising an error when the object is in conflict.
[ "Delegates", "a", "property", "to", "the", "first", "sibling", "in", "a", "RiakObject", "raising", "an", "error", "when", "the", "object", "is", "in", "conflict", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/riak_object.py#L22-L43
18,921
basho/riak-python-client
riak/riak_object.py
content_method
def content_method(name): """ Delegates a method to the first sibling in a RiakObject, raising an error when the object is in conflict. """ def _delegate(self, *args, **kwargs): if len(self.siblings) != 1: raise ConflictError() return getattr(self.siblings[0], name).__cal...
python
def content_method(name): """ Delegates a method to the first sibling in a RiakObject, raising an error when the object is in conflict. """ def _delegate(self, *args, **kwargs): if len(self.siblings) != 1: raise ConflictError() return getattr(self.siblings[0], name).__cal...
[ "def", "content_method", "(", "name", ")", ":", "def", "_delegate", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "self", ".", "siblings", ")", "!=", "1", ":", "raise", "ConflictError", "(", ")", "return", "get...
Delegates a method to the first sibling in a RiakObject, raising an error when the object is in conflict.
[ "Delegates", "a", "method", "to", "the", "first", "sibling", "in", "a", "RiakObject", "raising", "an", "error", "when", "the", "object", "is", "in", "conflict", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/riak_object.py#L46-L58
18,922
basho/riak-python-client
riak/riak_object.py
RiakObject.store
def store(self, w=None, dw=None, pw=None, return_body=True, if_none_match=False, timeout=None): """ Store the object in Riak. When this operation completes, the object could contain new metadata and possibly new data if Riak contains a newer version of the object according ...
python
def store(self, w=None, dw=None, pw=None, return_body=True, if_none_match=False, timeout=None): """ Store the object in Riak. When this operation completes, the object could contain new metadata and possibly new data if Riak contains a newer version of the object according ...
[ "def", "store", "(", "self", ",", "w", "=", "None", ",", "dw", "=", "None", ",", "pw", "=", "None", ",", "return_body", "=", "True", ",", "if_none_match", "=", "False", ",", "timeout", "=", "None", ")", ":", "if", "len", "(", "self", ".", "siblin...
Store the object in Riak. When this operation completes, the object could contain new metadata and possibly new data if Riak contains a newer version of the object according to the object's vector clock. :param w: W-value, wait for this many partitions to respond before returni...
[ "Store", "the", "object", "in", "Riak", ".", "When", "this", "operation", "completes", "the", "object", "could", "contain", "new", "metadata", "and", "possibly", "new", "data", "if", "Riak", "contains", "a", "newer", "version", "of", "the", "object", "accord...
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/riak_object.py#L247-L283
18,923
basho/riak-python-client
riak/riak_object.py
RiakObject.reload
def reload(self, r=None, pr=None, timeout=None, basic_quorum=None, notfound_ok=None, head_only=False): """ Reload the object from Riak. When this operation completes, the object could contain new metadata and a new value, if the object was updated in Riak since it was last...
python
def reload(self, r=None, pr=None, timeout=None, basic_quorum=None, notfound_ok=None, head_only=False): """ Reload the object from Riak. When this operation completes, the object could contain new metadata and a new value, if the object was updated in Riak since it was last...
[ "def", "reload", "(", "self", ",", "r", "=", "None", ",", "pr", "=", "None", ",", "timeout", "=", "None", ",", "basic_quorum", "=", "None", ",", "notfound_ok", "=", "None", ",", "head_only", "=", "False", ")", ":", "self", ".", "client", ".", "get"...
Reload the object from Riak. When this operation completes, the object could contain new metadata and a new value, if the object was updated in Riak since it was last retrieved. .. note:: Even if the key is not found in Riak, this will return a :class:`RiakObject`. Check the :attr:`e...
[ "Reload", "the", "object", "from", "Riak", ".", "When", "this", "operation", "completes", "the", "object", "could", "contain", "new", "metadata", "and", "a", "new", "value", "if", "the", "object", "was", "updated", "in", "Riak", "since", "it", "was", "last...
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/riak_object.py#L285-L317
18,924
basho/riak-python-client
riak/riak_object.py
RiakObject.delete
def delete(self, r=None, w=None, dw=None, pr=None, pw=None, timeout=None): """ Delete this object from Riak. :param r: R-value, wait for this many partitions to read object before performing the put :type r: integer :param w: W-value, wait for this many p...
python
def delete(self, r=None, w=None, dw=None, pr=None, pw=None, timeout=None): """ Delete this object from Riak. :param r: R-value, wait for this many partitions to read object before performing the put :type r: integer :param w: W-value, wait for this many p...
[ "def", "delete", "(", "self", ",", "r", "=", "None", ",", "w", "=", "None", ",", "dw", "=", "None", ",", "pr", "=", "None", ",", "pw", "=", "None", ",", "timeout", "=", "None", ")", ":", "self", ".", "client", ".", "delete", "(", "self", ",",...
Delete this object from Riak. :param r: R-value, wait for this many partitions to read object before performing the put :type r: integer :param w: W-value, wait for this many partitions to respond before returning to client. :type w: integer :param dw: DW-value...
[ "Delete", "this", "object", "from", "Riak", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/riak_object.py#L319-L348
18,925
basho/riak-python-client
riak/bucket.py
RiakBucket.get_encoder
def get_encoder(self, content_type): """ Get the encoding function for the provided content type for this bucket. :param content_type: the requested media type :type content_type: str :param content_type: Content type requested """ if content_type in self...
python
def get_encoder(self, content_type): """ Get the encoding function for the provided content type for this bucket. :param content_type: the requested media type :type content_type: str :param content_type: Content type requested """ if content_type in self...
[ "def", "get_encoder", "(", "self", ",", "content_type", ")", ":", "if", "content_type", "in", "self", ".", "_encoders", ":", "return", "self", ".", "_encoders", "[", "content_type", "]", "else", ":", "return", "self", ".", "_client", ".", "get_encoder", "(...
Get the encoding function for the provided content type for this bucket. :param content_type: the requested media type :type content_type: str :param content_type: Content type requested
[ "Get", "the", "encoding", "function", "for", "the", "provided", "content", "type", "for", "this", "bucket", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/bucket.py#L88-L100
18,926
basho/riak-python-client
riak/bucket.py
RiakBucket.get_decoder
def get_decoder(self, content_type): """ Get the decoding function for the provided content type for this bucket. :param content_type: the requested media type :type content_type: str :rtype: function """ if content_type in self._decoders: ret...
python
def get_decoder(self, content_type): """ Get the decoding function for the provided content type for this bucket. :param content_type: the requested media type :type content_type: str :rtype: function """ if content_type in self._decoders: ret...
[ "def", "get_decoder", "(", "self", ",", "content_type", ")", ":", "if", "content_type", "in", "self", ".", "_decoders", ":", "return", "self", ".", "_decoders", "[", "content_type", "]", "else", ":", "return", "self", ".", "_client", ".", "get_decoder", "(...
Get the decoding function for the provided content type for this bucket. :param content_type: the requested media type :type content_type: str :rtype: function
[ "Get", "the", "decoding", "function", "for", "the", "provided", "content", "type", "for", "this", "bucket", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/bucket.py#L116-L128
18,927
basho/riak-python-client
riak/bucket.py
RiakBucket.multiget
def multiget(self, keys, r=None, pr=None, timeout=None, basic_quorum=None, notfound_ok=None, head_only=False): """ Retrieves a list of keys belonging to this bucket in parallel. :param keys: the keys to fetch :type keys: list :param r: R-Value f...
python
def multiget(self, keys, r=None, pr=None, timeout=None, basic_quorum=None, notfound_ok=None, head_only=False): """ Retrieves a list of keys belonging to this bucket in parallel. :param keys: the keys to fetch :type keys: list :param r: R-Value f...
[ "def", "multiget", "(", "self", ",", "keys", ",", "r", "=", "None", ",", "pr", "=", "None", ",", "timeout", "=", "None", ",", "basic_quorum", "=", "None", ",", "notfound_ok", "=", "None", ",", "head_only", "=", "False", ")", ":", "bkeys", "=", "[",...
Retrieves a list of keys belonging to this bucket in parallel. :param keys: the keys to fetch :type keys: list :param r: R-Value for the requests (defaults to bucket's R) :type r: integer :param pr: PR-Value for the requests (defaults to bucket's PR) :type pr: integer ...
[ "Retrieves", "a", "list", "of", "keys", "belonging", "to", "this", "bucket", "in", "parallel", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/bucket.py#L238-L268
18,928
basho/riak-python-client
riak/bucket.py
BucketType.stream_buckets
def stream_buckets(self, timeout=None): """ Streams the list of buckets under this bucket-type. This is a generator method that should be iterated over. The caller must close the stream when finished. See :meth:`RiakClient.stream_buckets() <riak.client.RiakClient.stream...
python
def stream_buckets(self, timeout=None): """ Streams the list of buckets under this bucket-type. This is a generator method that should be iterated over. The caller must close the stream when finished. See :meth:`RiakClient.stream_buckets() <riak.client.RiakClient.stream...
[ "def", "stream_buckets", "(", "self", ",", "timeout", "=", "None", ")", ":", "return", "self", ".", "_client", ".", "stream_buckets", "(", "bucket_type", "=", "self", ",", "timeout", "=", "timeout", ")" ]
Streams the list of buckets under this bucket-type. This is a generator method that should be iterated over. The caller must close the stream when finished. See :meth:`RiakClient.stream_buckets() <riak.client.RiakClient.stream_buckets>` for more details. .. warning:: Do not us...
[ "Streams", "the", "list", "of", "buckets", "under", "this", "bucket", "-", "type", ".", "This", "is", "a", "generator", "method", "that", "should", "be", "iterated", "over", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/bucket.py#L712-L729
18,929
basho/riak-python-client
riak/node.py
Decaying.incr
def incr(self, d): """ Increases the value by the argument. :param d: the value to increase by :type d: float """ with self.lock: self.p = self.value() + d
python
def incr(self, d): """ Increases the value by the argument. :param d: the value to increase by :type d: float """ with self.lock: self.p = self.value() + d
[ "def", "incr", "(", "self", ",", "d", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "p", "=", "self", ".", "value", "(", ")", "+", "d" ]
Increases the value by the argument. :param d: the value to increase by :type d: float
[ "Increases", "the", "value", "by", "the", "argument", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/node.py#L46-L54
18,930
basho/riak-python-client
riak/transports/transport.py
Transport.make_random_client_id
def make_random_client_id(self): """ Returns a random client identifier """ if PY2: return ('py_%s' % base64.b64encode(str(random.randint(1, 0x40000000)))) else: return ('py_%s' % base64.b64encode(bytes(str(random.ra...
python
def make_random_client_id(self): """ Returns a random client identifier """ if PY2: return ('py_%s' % base64.b64encode(str(random.randint(1, 0x40000000)))) else: return ('py_%s' % base64.b64encode(bytes(str(random.ra...
[ "def", "make_random_client_id", "(", "self", ")", ":", "if", "PY2", ":", "return", "(", "'py_%s'", "%", "base64", ".", "b64encode", "(", "str", "(", "random", ".", "randint", "(", "1", ",", "0x40000000", ")", ")", ")", ")", "else", ":", "return", "("...
Returns a random client identifier
[ "Returns", "a", "random", "client", "identifier" ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/transport.py#L42-L52
18,931
basho/riak-python-client
riak/transports/transport.py
Transport.get
def get(self, robj, r=None, pr=None, timeout=None, basic_quorum=None, notfound_ok=None, head_only=False): """ Fetches an object. """ raise NotImplementedError
python
def get(self, robj, r=None, pr=None, timeout=None, basic_quorum=None, notfound_ok=None, head_only=False): """ Fetches an object. """ raise NotImplementedError
[ "def", "get", "(", "self", ",", "robj", ",", "r", "=", "None", ",", "pr", "=", "None", ",", "timeout", "=", "None", ",", "basic_quorum", "=", "None", ",", "notfound_ok", "=", "None", ",", "head_only", "=", "False", ")", ":", "raise", "NotImplementedE...
Fetches an object.
[ "Fetches", "an", "object", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/transport.py#L70-L75
18,932
basho/riak-python-client
riak/transports/transport.py
Transport.put
def put(self, robj, w=None, dw=None, pw=None, return_body=None, if_none_match=None, timeout=None): """ Stores an object. """ raise NotImplementedError
python
def put(self, robj, w=None, dw=None, pw=None, return_body=None, if_none_match=None, timeout=None): """ Stores an object. """ raise NotImplementedError
[ "def", "put", "(", "self", ",", "robj", ",", "w", "=", "None", ",", "dw", "=", "None", ",", "pw", "=", "None", ",", "return_body", "=", "None", ",", "if_none_match", "=", "None", ",", "timeout", "=", "None", ")", ":", "raise", "NotImplementedError" ]
Stores an object.
[ "Stores", "an", "object", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/transport.py#L77-L82
18,933
basho/riak-python-client
riak/transports/transport.py
Transport.delete
def delete(self, robj, rw=None, r=None, w=None, dw=None, pr=None, pw=None, timeout=None): """ Deletes an object. """ raise NotImplementedError
python
def delete(self, robj, rw=None, r=None, w=None, dw=None, pr=None, pw=None, timeout=None): """ Deletes an object. """ raise NotImplementedError
[ "def", "delete", "(", "self", ",", "robj", ",", "rw", "=", "None", ",", "r", "=", "None", ",", "w", "=", "None", ",", "dw", "=", "None", ",", "pr", "=", "None", ",", "pw", "=", "None", ",", "timeout", "=", "None", ")", ":", "raise", "NotImple...
Deletes an object.
[ "Deletes", "an", "object", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/transport.py#L84-L89
18,934
basho/riak-python-client
riak/transports/transport.py
Transport.update_counter
def update_counter(self, bucket, key, value, w=None, dw=None, pw=None, returnvalue=False): """ Updates a counter by the given value. """ raise NotImplementedError
python
def update_counter(self, bucket, key, value, w=None, dw=None, pw=None, returnvalue=False): """ Updates a counter by the given value. """ raise NotImplementedError
[ "def", "update_counter", "(", "self", ",", "bucket", ",", "key", ",", "value", ",", "w", "=", "None", ",", "dw", "=", "None", ",", "pw", "=", "None", ",", "returnvalue", "=", "False", ")", ":", "raise", "NotImplementedError" ]
Updates a counter by the given value.
[ "Updates", "a", "counter", "by", "the", "given", "value", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/transport.py#L285-L290
18,935
basho/riak-python-client
riak/transports/transport.py
Transport.fetch_datatype
def fetch_datatype(self, bucket, key, r=None, pr=None, basic_quorum=None, notfound_ok=None, timeout=None, include_context=None): """ Fetches a Riak Datatype. """ raise NotImplementedError
python
def fetch_datatype(self, bucket, key, r=None, pr=None, basic_quorum=None, notfound_ok=None, timeout=None, include_context=None): """ Fetches a Riak Datatype. """ raise NotImplementedError
[ "def", "fetch_datatype", "(", "self", ",", "bucket", ",", "key", ",", "r", "=", "None", ",", "pr", "=", "None", ",", "basic_quorum", "=", "None", ",", "notfound_ok", "=", "None", ",", "timeout", "=", "None", ",", "include_context", "=", "None", ")", ...
Fetches a Riak Datatype.
[ "Fetches", "a", "Riak", "Datatype", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/transport.py#L292-L297
18,936
basho/riak-python-client
riak/transports/transport.py
Transport.update_datatype
def update_datatype(self, datatype, w=None, dw=None, pw=None, return_body=None, timeout=None, include_context=None): """ Updates a Riak Datatype by sending local operations to the server. """ raise NotImplementedError
python
def update_datatype(self, datatype, w=None, dw=None, pw=None, return_body=None, timeout=None, include_context=None): """ Updates a Riak Datatype by sending local operations to the server. """ raise NotImplementedError
[ "def", "update_datatype", "(", "self", ",", "datatype", ",", "w", "=", "None", ",", "dw", "=", "None", ",", "pw", "=", "None", ",", "return_body", "=", "None", ",", "timeout", "=", "None", ",", "include_context", "=", "None", ")", ":", "raise", "NotI...
Updates a Riak Datatype by sending local operations to the server.
[ "Updates", "a", "Riak", "Datatype", "by", "sending", "local", "operations", "to", "the", "server", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/transport.py#L299-L304
18,937
basho/riak-python-client
riak/transports/transport.py
Transport._search_mapred_emu
def _search_mapred_emu(self, index, query): """ Emulates a search request via MapReduce. Used in the case where the transport supports MapReduce but has no native search capability. """ phases = [] if not self.phaseless_mapred(): phases.append({'langua...
python
def _search_mapred_emu(self, index, query): """ Emulates a search request via MapReduce. Used in the case where the transport supports MapReduce but has no native search capability. """ phases = [] if not self.phaseless_mapred(): phases.append({'langua...
[ "def", "_search_mapred_emu", "(", "self", ",", "index", ",", "query", ")", ":", "phases", "=", "[", "]", "if", "not", "self", ".", "phaseless_mapred", "(", ")", ":", "phases", ".", "append", "(", "{", "'language'", ":", "'erlang'", ",", "'module'", ":"...
Emulates a search request via MapReduce. Used in the case where the transport supports MapReduce but has no native search capability.
[ "Emulates", "a", "search", "request", "via", "MapReduce", ".", "Used", "in", "the", "case", "where", "the", "transport", "supports", "MapReduce", "but", "has", "no", "native", "search", "capability", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/transport.py#L313-L336
18,938
basho/riak-python-client
riak/transports/transport.py
Transport._get_index_mapred_emu
def _get_index_mapred_emu(self, bucket, index, startkey, endkey=None): """ Emulates a secondary index request via MapReduce. Used in the case where the transport supports MapReduce but has no native secondary index query capability. """ phases = [] if not self.pha...
python
def _get_index_mapred_emu(self, bucket, index, startkey, endkey=None): """ Emulates a secondary index request via MapReduce. Used in the case where the transport supports MapReduce but has no native secondary index query capability. """ phases = [] if not self.pha...
[ "def", "_get_index_mapred_emu", "(", "self", ",", "bucket", ",", "index", ",", "startkey", ",", "endkey", "=", "None", ")", ":", "phases", "=", "[", "]", "if", "not", "self", ".", "phaseless_mapred", "(", ")", ":", "phases", ".", "append", "(", "{", ...
Emulates a secondary index request via MapReduce. Used in the case where the transport supports MapReduce but has no native secondary index query capability.
[ "Emulates", "a", "secondary", "index", "request", "via", "MapReduce", ".", "Used", "in", "the", "case", "where", "the", "transport", "supports", "MapReduce", "but", "has", "no", "native", "secondary", "index", "query", "capability", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/transport.py#L339-L362
18,939
basho/riak-python-client
riak/codecs/http.py
HttpCodec._parse_body
def _parse_body(self, robj, response, expected_statuses): """ Parse the body of an object response and populate the object. """ # If no response given, then return. if response is None: return None status, headers, data = response # Check if the serv...
python
def _parse_body(self, robj, response, expected_statuses): """ Parse the body of an object response and populate the object. """ # If no response given, then return. if response is None: return None status, headers, data = response # Check if the serv...
[ "def", "_parse_body", "(", "self", ",", "robj", ",", "response", ",", "expected_statuses", ")", ":", "# If no response given, then return.", "if", "response", "is", "None", ":", "return", "None", "status", ",", "headers", ",", "data", "=", "response", "# Check i...
Parse the body of an object response and populate the object.
[ "Parse", "the", "body", "of", "an", "object", "response", "and", "populate", "the", "object", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/codecs/http.py#L46-L104
18,940
basho/riak-python-client
riak/codecs/http.py
HttpCodec._parse_sibling
def _parse_sibling(self, sibling, headers, data): """ Parses a single sibling out of a response. """ sibling.exists = True # Parse the headers... for header, value in headers: header = header.lower() if header == 'content-type': s...
python
def _parse_sibling(self, sibling, headers, data): """ Parses a single sibling out of a response. """ sibling.exists = True # Parse the headers... for header, value in headers: header = header.lower() if header == 'content-type': s...
[ "def", "_parse_sibling", "(", "self", ",", "sibling", ",", "headers", ",", "data", ")", ":", "sibling", ".", "exists", "=", "True", "# Parse the headers...", "for", "header", ",", "value", "in", "headers", ":", "header", "=", "header", ".", "lower", "(", ...
Parses a single sibling out of a response.
[ "Parses", "a", "single", "sibling", "out", "of", "a", "response", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/codecs/http.py#L106-L140
18,941
basho/riak-python-client
riak/codecs/http.py
HttpCodec._to_link_header
def _to_link_header(self, link): """ Convert the link tuple to a link header string. Used internally. """ try: bucket, key, tag = link except ValueError: raise RiakError("Invalid link tuple %s" % link) tag = tag if tag is not None else bucket ...
python
def _to_link_header(self, link): """ Convert the link tuple to a link header string. Used internally. """ try: bucket, key, tag = link except ValueError: raise RiakError("Invalid link tuple %s" % link) tag = tag if tag is not None else bucket ...
[ "def", "_to_link_header", "(", "self", ",", "link", ")", ":", "try", ":", "bucket", ",", "key", ",", "tag", "=", "link", "except", "ValueError", ":", "raise", "RiakError", "(", "\"Invalid link tuple %s\"", "%", "link", ")", "tag", "=", "tag", "if", "tag"...
Convert the link tuple to a link header string. Used internally.
[ "Convert", "the", "link", "tuple", "to", "a", "link", "header", "string", ".", "Used", "internally", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/codecs/http.py#L142-L153
18,942
basho/riak-python-client
riak/codecs/http.py
HttpCodec._normalize_json_search_response
def _normalize_json_search_response(self, json): """ Normalizes a JSON search response so that PB and HTTP have the same return value """ result = {} if 'facet_counts' in json: result['facet_counts'] = json[u'facet_counts'] if 'grouped' in json: ...
python
def _normalize_json_search_response(self, json): """ Normalizes a JSON search response so that PB and HTTP have the same return value """ result = {} if 'facet_counts' in json: result['facet_counts'] = json[u'facet_counts'] if 'grouped' in json: ...
[ "def", "_normalize_json_search_response", "(", "self", ",", "json", ")", ":", "result", "=", "{", "}", "if", "'facet_counts'", "in", "json", ":", "result", "[", "'facet_counts'", "]", "=", "json", "[", "u'facet_counts'", "]", "if", "'grouped'", "in", "json",...
Normalizes a JSON search response so that PB and HTTP have the same return value
[ "Normalizes", "a", "JSON", "search", "response", "so", "that", "PB", "and", "HTTP", "have", "the", "same", "return", "value" ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/codecs/http.py#L223-L252
18,943
basho/riak-python-client
riak/codecs/http.py
HttpCodec._normalize_xml_search_response
def _normalize_xml_search_response(self, xml): """ Normalizes an XML search response so that PB and HTTP have the same return value """ target = XMLSearchResult() parser = ElementTree.XMLParser(target=target) parser.feed(xml) return parser.close()
python
def _normalize_xml_search_response(self, xml): """ Normalizes an XML search response so that PB and HTTP have the same return value """ target = XMLSearchResult() parser = ElementTree.XMLParser(target=target) parser.feed(xml) return parser.close()
[ "def", "_normalize_xml_search_response", "(", "self", ",", "xml", ")", ":", "target", "=", "XMLSearchResult", "(", ")", "parser", "=", "ElementTree", ".", "XMLParser", "(", "target", "=", "target", ")", "parser", ".", "feed", "(", "xml", ")", "return", "pa...
Normalizes an XML search response so that PB and HTTP have the same return value
[ "Normalizes", "an", "XML", "search", "response", "so", "that", "PB", "and", "HTTP", "have", "the", "same", "return", "value" ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/codecs/http.py#L254-L262
18,944
basho/riak-python-client
riak/transports/http/__init__.py
NoNagleHTTPConnection.connect
def connect(self): """ Set TCP_NODELAY on socket """ HTTPConnection.connect(self) self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
python
def connect(self): """ Set TCP_NODELAY on socket """ HTTPConnection.connect(self) self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
[ "def", "connect", "(", "self", ")", ":", "HTTPConnection", ".", "connect", "(", "self", ")", "self", ".", "sock", ".", "setsockopt", "(", "socket", ".", "IPPROTO_TCP", ",", "socket", ".", "TCP_NODELAY", ",", "1", ")" ]
Set TCP_NODELAY on socket
[ "Set", "TCP_NODELAY", "on", "socket" ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/__init__.py#L52-L57
18,945
basho/riak-python-client
riak/client/transport.py
RiakClientTransport._with_retries
def _with_retries(self, pool, fn): """ Performs the passed function with retries against the given pool. :param pool: the connection pool to use :type pool: Pool :param fn: the function to pass a transport :type fn: function """ skip_nodes = [] d...
python
def _with_retries(self, pool, fn): """ Performs the passed function with retries against the given pool. :param pool: the connection pool to use :type pool: Pool :param fn: the function to pass a transport :type fn: function """ skip_nodes = [] d...
[ "def", "_with_retries", "(", "self", ",", "pool", ",", "fn", ")", ":", "skip_nodes", "=", "[", "]", "def", "_skip_bad_nodes", "(", "transport", ")", ":", "return", "transport", ".", "_node", "not", "in", "skip_nodes", "retry_count", "=", "self", ".", "re...
Performs the passed function with retries against the given pool. :param pool: the connection pool to use :type pool: Pool :param fn: the function to pass a transport :type fn: function
[ "Performs", "the", "passed", "function", "with", "retries", "against", "the", "given", "pool", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/transport.py#L143-L188
18,946
basho/riak-python-client
riak/client/transport.py
RiakClientTransport._choose_pool
def _choose_pool(self, protocol=None): """ Selects a connection pool according to the default protocol and the passed one. :param protocol: the protocol to use :type protocol: string :rtype: Pool """ if not protocol: protocol = self.protocol ...
python
def _choose_pool(self, protocol=None): """ Selects a connection pool according to the default protocol and the passed one. :param protocol: the protocol to use :type protocol: string :rtype: Pool """ if not protocol: protocol = self.protocol ...
[ "def", "_choose_pool", "(", "self", ",", "protocol", "=", "None", ")", ":", "if", "not", "protocol", ":", "protocol", "=", "self", ".", "protocol", "if", "protocol", "==", "'http'", ":", "pool", "=", "self", ".", "_http_pool", "elif", "protocol", "==", ...
Selects a connection pool according to the default protocol and the passed one. :param protocol: the protocol to use :type protocol: string :rtype: Pool
[ "Selects", "a", "connection", "pool", "according", "to", "the", "default", "protocol", "and", "the", "passed", "one", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/transport.py#L190-L210
18,947
basho/riak-python-client
riak/client/__init__.py
default_encoder
def default_encoder(obj): """ Default encoder for JSON datatypes, which returns UTF-8 encoded json instead of the default bloated backslash u XXXX escaped ASCII strings. """ if isinstance(obj, bytes): return json.dumps(bytes_to_str(obj), ensure_ascii=False).encode("...
python
def default_encoder(obj): """ Default encoder for JSON datatypes, which returns UTF-8 encoded json instead of the default bloated backslash u XXXX escaped ASCII strings. """ if isinstance(obj, bytes): return json.dumps(bytes_to_str(obj), ensure_ascii=False).encode("...
[ "def", "default_encoder", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "bytes", ")", ":", "return", "json", ".", "dumps", "(", "bytes_to_str", "(", "obj", ")", ",", "ensure_ascii", "=", "False", ")", ".", "encode", "(", "\"utf-8\"", ")", ...
Default encoder for JSON datatypes, which returns UTF-8 encoded json instead of the default bloated backslash u XXXX escaped ASCII strings.
[ "Default", "encoder", "for", "JSON", "datatypes", "which", "returns", "UTF", "-", "8", "encoded", "json", "instead", "of", "the", "default", "bloated", "backslash", "u", "XXXX", "escaped", "ASCII", "strings", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/__init__.py#L37-L46
18,948
basho/riak-python-client
riak/client/__init__.py
RiakClient.close
def close(self): """ Iterate through all of the connections and close each one. """ if not self._closed: self._closed = True self._stop_multi_pools() if self._http_pool is not None: self._http_pool.clear() self._http_poo...
python
def close(self): """ Iterate through all of the connections and close each one. """ if not self._closed: self._closed = True self._stop_multi_pools() if self._http_pool is not None: self._http_pool.clear() self._http_poo...
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "_closed", ":", "self", ".", "_closed", "=", "True", "self", ".", "_stop_multi_pools", "(", ")", "if", "self", ".", "_http_pool", "is", "not", "None", ":", "self", ".", "_http_pool", "....
Iterate through all of the connections and close each one.
[ "Iterate", "through", "all", "of", "the", "connections", "and", "close", "each", "one", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/__init__.py#L319-L331
18,949
basho/riak-python-client
riak/client/__init__.py
RiakClient._create_credentials
def _create_credentials(self, n): """ Create security credentials, if necessary. """ if not n: return n elif isinstance(n, SecurityCreds): return n elif isinstance(n, dict): return SecurityCreds(**n) else: raise Type...
python
def _create_credentials(self, n): """ Create security credentials, if necessary. """ if not n: return n elif isinstance(n, SecurityCreds): return n elif isinstance(n, dict): return SecurityCreds(**n) else: raise Type...
[ "def", "_create_credentials", "(", "self", ",", "n", ")", ":", "if", "not", "n", ":", "return", "n", "elif", "isinstance", "(", "n", ",", "SecurityCreds", ")", ":", "return", "n", "elif", "isinstance", "(", "n", ",", "dict", ")", ":", "return", "Secu...
Create security credentials, if necessary.
[ "Create", "security", "credentials", "if", "necessary", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/__init__.py#L355-L367
18,950
basho/riak-python-client
riak/transports/http/connection.py
HttpConnection._connect
def _connect(self): """ Use the appropriate connection class; optionally with security. """ timeout = None if self._options is not None and 'timeout' in self._options: timeout = self._options['timeout'] if self._client._credentials: self._connecti...
python
def _connect(self): """ Use the appropriate connection class; optionally with security. """ timeout = None if self._options is not None and 'timeout' in self._options: timeout = self._options['timeout'] if self._client._credentials: self._connecti...
[ "def", "_connect", "(", "self", ")", ":", "timeout", "=", "None", "if", "self", ".", "_options", "is", "not", "None", "and", "'timeout'", "in", "self", ".", "_options", ":", "timeout", "=", "self", ".", "_options", "[", "'timeout'", "]", "if", "self", ...
Use the appropriate connection class; optionally with security.
[ "Use", "the", "appropriate", "connection", "class", ";", "optionally", "with", "security", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/connection.py#L65-L86
18,951
basho/riak-python-client
riak/transports/http/connection.py
HttpConnection._security_auth_headers
def _security_auth_headers(self, username, password, headers): """ Add in the requisite HTTP Authentication Headers :param username: Riak Security Username :type str :param password: Riak Security Password :type str :param headers: Dictionary of headers :...
python
def _security_auth_headers(self, username, password, headers): """ Add in the requisite HTTP Authentication Headers :param username: Riak Security Username :type str :param password: Riak Security Password :type str :param headers: Dictionary of headers :...
[ "def", "_security_auth_headers", "(", "self", ",", "username", ",", "password", ",", "headers", ")", ":", "userColonPassword", "=", "username", "+", "\":\"", "+", "password", "b64UserColonPassword", "=", "base64", ".", "b64encode", "(", "str_to_bytes", "(", "use...
Add in the requisite HTTP Authentication Headers :param username: Riak Security Username :type str :param password: Riak Security Password :type str :param headers: Dictionary of headers :type dict
[ "Add", "in", "the", "requisite", "HTTP", "Authentication", "Headers" ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/connection.py#L101-L115
18,952
basho/riak-python-client
riak/table.py
Table.query
def query(self, query, interpolations=None): """ Queries a timeseries table. :param query: The timeseries query. :type query: string :rtype: :class:`TsObject <riak.ts_object.TsObject>` """ return self._client.ts_query(self, query, interpolations)
python
def query(self, query, interpolations=None): """ Queries a timeseries table. :param query: The timeseries query. :type query: string :rtype: :class:`TsObject <riak.ts_object.TsObject>` """ return self._client.ts_query(self, query, interpolations)
[ "def", "query", "(", "self", ",", "query", ",", "interpolations", "=", "None", ")", ":", "return", "self", ".", "_client", ".", "ts_query", "(", "self", ",", "query", ",", "interpolations", ")" ]
Queries a timeseries table. :param query: The timeseries query. :type query: string :rtype: :class:`TsObject <riak.ts_object.TsObject>`
[ "Queries", "a", "timeseries", "table", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/table.py#L94-L102
18,953
adamrehn/ue4cli
ue4cli/ConfigurationManager.py
ConfigurationManager.getConfigDirectory
def getConfigDirectory(): """ Determines the platform-specific config directory location for ue4cli """ if platform.system() == 'Windows': return os.path.join(os.environ['APPDATA'], 'ue4cli') else: return os.path.join(os.environ['HOME'], '.config', 'ue4cli')
python
def getConfigDirectory(): """ Determines the platform-specific config directory location for ue4cli """ if platform.system() == 'Windows': return os.path.join(os.environ['APPDATA'], 'ue4cli') else: return os.path.join(os.environ['HOME'], '.config', 'ue4cli')
[ "def", "getConfigDirectory", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'APPDATA'", "]", ",", "'ue4cli'", ")", "else", ":", "return", "o...
Determines the platform-specific config directory location for ue4cli
[ "Determines", "the", "platform", "-", "specific", "config", "directory", "location", "for", "ue4cli" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ConfigurationManager.py#L10-L17
18,954
adamrehn/ue4cli
ue4cli/ConfigurationManager.py
ConfigurationManager.setConfigKey
def setConfigKey(key, value): """ Sets the config data value for the specified dictionary key """ configFile = ConfigurationManager._configFile() return JsonDataManager(configFile).setKey(key, value)
python
def setConfigKey(key, value): """ Sets the config data value for the specified dictionary key """ configFile = ConfigurationManager._configFile() return JsonDataManager(configFile).setKey(key, value)
[ "def", "setConfigKey", "(", "key", ",", "value", ")", ":", "configFile", "=", "ConfigurationManager", ".", "_configFile", "(", ")", "return", "JsonDataManager", "(", "configFile", ")", ".", "setKey", "(", "key", ",", "value", ")" ]
Sets the config data value for the specified dictionary key
[ "Sets", "the", "config", "data", "value", "for", "the", "specified", "dictionary", "key" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ConfigurationManager.py#L28-L33
18,955
adamrehn/ue4cli
ue4cli/CachedDataManager.py
CachedDataManager.clearCache
def clearCache(): """ Clears any cached data we have stored about specific engine versions """ if os.path.exists(CachedDataManager._cacheDir()) == True: shutil.rmtree(CachedDataManager._cacheDir())
python
def clearCache(): """ Clears any cached data we have stored about specific engine versions """ if os.path.exists(CachedDataManager._cacheDir()) == True: shutil.rmtree(CachedDataManager._cacheDir())
[ "def", "clearCache", "(", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "CachedDataManager", ".", "_cacheDir", "(", ")", ")", "==", "True", ":", "shutil", ".", "rmtree", "(", "CachedDataManager", ".", "_cacheDir", "(", ")", ")" ]
Clears any cached data we have stored about specific engine versions
[ "Clears", "any", "cached", "data", "we", "have", "stored", "about", "specific", "engine", "versions" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/CachedDataManager.py#L11-L16
18,956
adamrehn/ue4cli
ue4cli/CachedDataManager.py
CachedDataManager.getCachedDataKey
def getCachedDataKey(engineVersionHash, key): """ Retrieves the cached data value for the specified engine version hash and dictionary key """ cacheFile = CachedDataManager._cacheFileForHash(engineVersionHash) return JsonDataManager(cacheFile).getKey(key)
python
def getCachedDataKey(engineVersionHash, key): """ Retrieves the cached data value for the specified engine version hash and dictionary key """ cacheFile = CachedDataManager._cacheFileForHash(engineVersionHash) return JsonDataManager(cacheFile).getKey(key)
[ "def", "getCachedDataKey", "(", "engineVersionHash", ",", "key", ")", ":", "cacheFile", "=", "CachedDataManager", ".", "_cacheFileForHash", "(", "engineVersionHash", ")", "return", "JsonDataManager", "(", "cacheFile", ")", ".", "getKey", "(", "key", ")" ]
Retrieves the cached data value for the specified engine version hash and dictionary key
[ "Retrieves", "the", "cached", "data", "value", "for", "the", "specified", "engine", "version", "hash", "and", "dictionary", "key" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/CachedDataManager.py#L19-L24
18,957
adamrehn/ue4cli
ue4cli/CachedDataManager.py
CachedDataManager.setCachedDataKey
def setCachedDataKey(engineVersionHash, key, value): """ Sets the cached data value for the specified engine version hash and dictionary key """ cacheFile = CachedDataManager._cacheFileForHash(engineVersionHash) return JsonDataManager(cacheFile).setKey(key, value)
python
def setCachedDataKey(engineVersionHash, key, value): """ Sets the cached data value for the specified engine version hash and dictionary key """ cacheFile = CachedDataManager._cacheFileForHash(engineVersionHash) return JsonDataManager(cacheFile).setKey(key, value)
[ "def", "setCachedDataKey", "(", "engineVersionHash", ",", "key", ",", "value", ")", ":", "cacheFile", "=", "CachedDataManager", ".", "_cacheFileForHash", "(", "engineVersionHash", ")", "return", "JsonDataManager", "(", "cacheFile", ")", ".", "setKey", "(", "key", ...
Sets the cached data value for the specified engine version hash and dictionary key
[ "Sets", "the", "cached", "data", "value", "for", "the", "specified", "engine", "version", "hash", "and", "dictionary", "key" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/CachedDataManager.py#L27-L32
18,958
adamrehn/ue4cli
ue4cli/Utility.py
Utility.writeFile
def writeFile(filename, data): """ Writes data to a file """ with open(filename, 'wb') as f: f.write(data.encode('utf-8'))
python
def writeFile(filename, data): """ Writes data to a file """ with open(filename, 'wb') as f: f.write(data.encode('utf-8'))
[ "def", "writeFile", "(", "filename", ",", "data", ")", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "f", ":", "f", ".", "write", "(", "data", ".", "encode", "(", "'utf-8'", ")", ")" ]
Writes data to a file
[ "Writes", "data", "to", "a", "file" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L34-L39
18,959
adamrehn/ue4cli
ue4cli/Utility.py
Utility.patchFile
def patchFile(filename, replacements): """ Applies the supplied list of replacements to a file """ patched = Utility.readFile(filename) # Perform each of the replacements in the supplied dictionary for key in replacements: patched = patched.replace(key, replacements[key]) Utility.writeFile(filena...
python
def patchFile(filename, replacements): """ Applies the supplied list of replacements to a file """ patched = Utility.readFile(filename) # Perform each of the replacements in the supplied dictionary for key in replacements: patched = patched.replace(key, replacements[key]) Utility.writeFile(filena...
[ "def", "patchFile", "(", "filename", ",", "replacements", ")", ":", "patched", "=", "Utility", ".", "readFile", "(", "filename", ")", "# Perform each of the replacements in the supplied dictionary", "for", "key", "in", "replacements", ":", "patched", "=", "patched", ...
Applies the supplied list of replacements to a file
[ "Applies", "the", "supplied", "list", "of", "replacements", "to", "a", "file" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L42-L52
18,960
adamrehn/ue4cli
ue4cli/Utility.py
Utility.escapePathForShell
def escapePathForShell(path): """ Escapes a filesystem path for use as a command-line argument """ if platform.system() == 'Windows': return '"{}"'.format(path.replace('"', '""')) else: return shellescape.quote(path)
python
def escapePathForShell(path): """ Escapes a filesystem path for use as a command-line argument """ if platform.system() == 'Windows': return '"{}"'.format(path.replace('"', '""')) else: return shellescape.quote(path)
[ "def", "escapePathForShell", "(", "path", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", "return", "'\"{}\"'", ".", "format", "(", "path", ".", "replace", "(", "'\"'", ",", "'\"\"'", ")", ")", "else", ":", "return", "shell...
Escapes a filesystem path for use as a command-line argument
[ "Escapes", "a", "filesystem", "path", "for", "use", "as", "a", "command", "-", "line", "argument" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L62-L69
18,961
adamrehn/ue4cli
ue4cli/Utility.py
Utility.join
def join(delim, items, quotes=False): """ Joins the supplied list of strings after removing any empty strings from the list """ transform = lambda s: s if quotes == True: transform = lambda s: s if ' ' not in s else '"{}"'.format(s) stripped = list([transform(i) for i in items if len(i) > 0]) if len...
python
def join(delim, items, quotes=False): """ Joins the supplied list of strings after removing any empty strings from the list """ transform = lambda s: s if quotes == True: transform = lambda s: s if ' ' not in s else '"{}"'.format(s) stripped = list([transform(i) for i in items if len(i) > 0]) if len...
[ "def", "join", "(", "delim", ",", "items", ",", "quotes", "=", "False", ")", ":", "transform", "=", "lambda", "s", ":", "s", "if", "quotes", "==", "True", ":", "transform", "=", "lambda", "s", ":", "s", "if", "' '", "not", "in", "s", "else", "'\"...
Joins the supplied list of strings after removing any empty strings from the list
[ "Joins", "the", "supplied", "list", "of", "strings", "after", "removing", "any", "empty", "strings", "from", "the", "list" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L72-L83
18,962
ageitgey/face_recognition
examples/face_recognition_knn.py
train
def train(train_dir, model_save_path=None, n_neighbors=None, knn_algo='ball_tree', verbose=False): """ Trains a k-nearest neighbors classifier for face recognition. :param train_dir: directory that contains a sub-directory for each known person, with its name. (View in source code to see train_dir ex...
python
def train(train_dir, model_save_path=None, n_neighbors=None, knn_algo='ball_tree', verbose=False): """ Trains a k-nearest neighbors classifier for face recognition. :param train_dir: directory that contains a sub-directory for each known person, with its name. (View in source code to see train_dir ex...
[ "def", "train", "(", "train_dir", ",", "model_save_path", "=", "None", ",", "n_neighbors", "=", "None", ",", "knn_algo", "=", "'ball_tree'", ",", "verbose", "=", "False", ")", ":", "X", "=", "[", "]", "y", "=", "[", "]", "# Loop through each person in the ...
Trains a k-nearest neighbors classifier for face recognition. :param train_dir: directory that contains a sub-directory for each known person, with its name. (View in source code to see train_dir example tree structure) Structure: <train_dir>/ ├── <person1>/ │ ├── <somename1>....
[ "Trains", "a", "k", "-", "nearest", "neighbors", "classifier", "for", "face", "recognition", "." ]
c96b010c02f15e8eeb0f71308c641179ac1f19bb
https://github.com/ageitgey/face_recognition/blob/c96b010c02f15e8eeb0f71308c641179ac1f19bb/examples/face_recognition_knn.py#L46-L108
18,963
ageitgey/face_recognition
examples/face_recognition_knn.py
predict
def predict(X_img_path, knn_clf=None, model_path=None, distance_threshold=0.6): """ Recognizes faces in given image using a trained KNN classifier :param X_img_path: path to image to be recognized :param knn_clf: (optional) a knn classifier object. if not specified, model_save_path must be specified. ...
python
def predict(X_img_path, knn_clf=None, model_path=None, distance_threshold=0.6): """ Recognizes faces in given image using a trained KNN classifier :param X_img_path: path to image to be recognized :param knn_clf: (optional) a knn classifier object. if not specified, model_save_path must be specified. ...
[ "def", "predict", "(", "X_img_path", ",", "knn_clf", "=", "None", ",", "model_path", "=", "None", ",", "distance_threshold", "=", "0.6", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "X_img_path", ")", "or", "os", ".", "path", ".", "s...
Recognizes faces in given image using a trained KNN classifier :param X_img_path: path to image to be recognized :param knn_clf: (optional) a knn classifier object. if not specified, model_save_path must be specified. :param model_path: (optional) path to a pickled knn classifier. if not specified, model_s...
[ "Recognizes", "faces", "in", "given", "image", "using", "a", "trained", "KNN", "classifier" ]
c96b010c02f15e8eeb0f71308c641179ac1f19bb
https://github.com/ageitgey/face_recognition/blob/c96b010c02f15e8eeb0f71308c641179ac1f19bb/examples/face_recognition_knn.py#L111-L150
18,964
ageitgey/face_recognition
examples/face_recognition_knn.py
show_prediction_labels_on_image
def show_prediction_labels_on_image(img_path, predictions): """ Shows the face recognition results visually. :param img_path: path to image to be recognized :param predictions: results of the predict function :return: """ pil_image = Image.open(img_path).convert("RGB") draw = ImageDraw....
python
def show_prediction_labels_on_image(img_path, predictions): """ Shows the face recognition results visually. :param img_path: path to image to be recognized :param predictions: results of the predict function :return: """ pil_image = Image.open(img_path).convert("RGB") draw = ImageDraw....
[ "def", "show_prediction_labels_on_image", "(", "img_path", ",", "predictions", ")", ":", "pil_image", "=", "Image", ".", "open", "(", "img_path", ")", ".", "convert", "(", "\"RGB\"", ")", "draw", "=", "ImageDraw", ".", "Draw", "(", "pil_image", ")", "for", ...
Shows the face recognition results visually. :param img_path: path to image to be recognized :param predictions: results of the predict function :return:
[ "Shows", "the", "face", "recognition", "results", "visually", "." ]
c96b010c02f15e8eeb0f71308c641179ac1f19bb
https://github.com/ageitgey/face_recognition/blob/c96b010c02f15e8eeb0f71308c641179ac1f19bb/examples/face_recognition_knn.py#L153-L181
18,965
ageitgey/face_recognition
face_recognition/api.py
face_distance
def face_distance(face_encodings, face_to_compare): """ Given a list of face encodings, compare them to a known face encoding and get a euclidean distance for each comparison face. The distance tells you how similar the faces are. :param faces: List of face encodings to compare :param face_to_compa...
python
def face_distance(face_encodings, face_to_compare): """ Given a list of face encodings, compare them to a known face encoding and get a euclidean distance for each comparison face. The distance tells you how similar the faces are. :param faces: List of face encodings to compare :param face_to_compa...
[ "def", "face_distance", "(", "face_encodings", ",", "face_to_compare", ")", ":", "if", "len", "(", "face_encodings", ")", "==", "0", ":", "return", "np", ".", "empty", "(", "(", "0", ")", ")", "return", "np", ".", "linalg", ".", "norm", "(", "face_enco...
Given a list of face encodings, compare them to a known face encoding and get a euclidean distance for each comparison face. The distance tells you how similar the faces are. :param faces: List of face encodings to compare :param face_to_compare: A face encoding to compare against :return: A numpy ndar...
[ "Given", "a", "list", "of", "face", "encodings", "compare", "them", "to", "a", "known", "face", "encoding", "and", "get", "a", "euclidean", "distance", "for", "each", "comparison", "face", ".", "The", "distance", "tells", "you", "how", "similar", "the", "f...
c96b010c02f15e8eeb0f71308c641179ac1f19bb
https://github.com/ageitgey/face_recognition/blob/c96b010c02f15e8eeb0f71308c641179ac1f19bb/face_recognition/api.py#L63-L75
18,966
ageitgey/face_recognition
face_recognition/api.py
batch_face_locations
def batch_face_locations(images, number_of_times_to_upsample=1, batch_size=128): """ Returns an 2d array of bounding boxes of human faces in a image using the cnn face detector If you are using a GPU, this can give you much faster results since the GPU can process batches of images at once. If you aren'...
python
def batch_face_locations(images, number_of_times_to_upsample=1, batch_size=128): """ Returns an 2d array of bounding boxes of human faces in a image using the cnn face detector If you are using a GPU, this can give you much faster results since the GPU can process batches of images at once. If you aren'...
[ "def", "batch_face_locations", "(", "images", ",", "number_of_times_to_upsample", "=", "1", ",", "batch_size", "=", "128", ")", ":", "def", "convert_cnn_detections_to_css", "(", "detections", ")", ":", "return", "[", "_trim_css_to_bounds", "(", "_rect_to_css", "(", ...
Returns an 2d array of bounding boxes of human faces in a image using the cnn face detector If you are using a GPU, this can give you much faster results since the GPU can process batches of images at once. If you aren't using a GPU, you don't need this function. :param img: A list of images (each as a num...
[ "Returns", "an", "2d", "array", "of", "bounding", "boxes", "of", "human", "faces", "in", "a", "image", "using", "the", "cnn", "face", "detector", "If", "you", "are", "using", "a", "GPU", "this", "can", "give", "you", "much", "faster", "results", "since",...
c96b010c02f15e8eeb0f71308c641179ac1f19bb
https://github.com/ageitgey/face_recognition/blob/c96b010c02f15e8eeb0f71308c641179ac1f19bb/face_recognition/api.py#L135-L151
18,967
ageitgey/face_recognition
face_recognition/api.py
face_encodings
def face_encodings(face_image, known_face_locations=None, num_jitters=1): """ Given an image, return the 128-dimension face encoding for each face in the image. :param face_image: The image that contains one or more faces :param known_face_locations: Optional - the bounding boxes of each face if you al...
python
def face_encodings(face_image, known_face_locations=None, num_jitters=1): """ Given an image, return the 128-dimension face encoding for each face in the image. :param face_image: The image that contains one or more faces :param known_face_locations: Optional - the bounding boxes of each face if you al...
[ "def", "face_encodings", "(", "face_image", ",", "known_face_locations", "=", "None", ",", "num_jitters", "=", "1", ")", ":", "raw_landmarks", "=", "_raw_face_landmarks", "(", "face_image", ",", "known_face_locations", ",", "model", "=", "\"small\"", ")", "return"...
Given an image, return the 128-dimension face encoding for each face in the image. :param face_image: The image that contains one or more faces :param known_face_locations: Optional - the bounding boxes of each face if you already know them. :param num_jitters: How many times to re-sample the face when cal...
[ "Given", "an", "image", "return", "the", "128", "-", "dimension", "face", "encoding", "for", "each", "face", "in", "the", "image", "." ]
c96b010c02f15e8eeb0f71308c641179ac1f19bb
https://github.com/ageitgey/face_recognition/blob/c96b010c02f15e8eeb0f71308c641179ac1f19bb/face_recognition/api.py#L203-L213
18,968
apache/spark
python/pyspark/sql/types.py
_int_size_to_type
def _int_size_to_type(size): """ Return the Catalyst datatype from the size of integers. """ if size <= 8: return ByteType if size <= 16: return ShortType if size <= 32: return IntegerType if size <= 64: return LongType
python
def _int_size_to_type(size): """ Return the Catalyst datatype from the size of integers. """ if size <= 8: return ByteType if size <= 16: return ShortType if size <= 32: return IntegerType if size <= 64: return LongType
[ "def", "_int_size_to_type", "(", "size", ")", ":", "if", "size", "<=", "8", ":", "return", "ByteType", "if", "size", "<=", "16", ":", "return", "ShortType", "if", "size", "<=", "32", ":", "return", "IntegerType", "if", "size", "<=", "64", ":", "return"...
Return the Catalyst datatype from the size of integers.
[ "Return", "the", "Catalyst", "datatype", "from", "the", "size", "of", "integers", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L944-L955
18,969
apache/spark
python/pyspark/sql/types.py
_infer_type
def _infer_type(obj): """Infer the DataType from obj """ if obj is None: return NullType() if hasattr(obj, '__UDT__'): return obj.__UDT__ dataType = _type_mappings.get(type(obj)) if dataType is DecimalType: # the precision and scale of `obj` may be different from row to...
python
def _infer_type(obj): """Infer the DataType from obj """ if obj is None: return NullType() if hasattr(obj, '__UDT__'): return obj.__UDT__ dataType = _type_mappings.get(type(obj)) if dataType is DecimalType: # the precision and scale of `obj` may be different from row to...
[ "def", "_infer_type", "(", "obj", ")", ":", "if", "obj", "is", "None", ":", "return", "NullType", "(", ")", "if", "hasattr", "(", "obj", ",", "'__UDT__'", ")", ":", "return", "obj", ".", "__UDT__", "dataType", "=", "_type_mappings", ".", "get", "(", ...
Infer the DataType from obj
[ "Infer", "the", "DataType", "from", "obj" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1003-L1038
18,970
apache/spark
python/pyspark/sql/types.py
_has_nulltype
def _has_nulltype(dt): """ Return whether there is NullType in `dt` or not """ if isinstance(dt, StructType): return any(_has_nulltype(f.dataType) for f in dt.fields) elif isinstance(dt, ArrayType): return _has_nulltype((dt.elementType)) elif isinstance(dt, MapType): return _has_...
python
def _has_nulltype(dt): """ Return whether there is NullType in `dt` or not """ if isinstance(dt, StructType): return any(_has_nulltype(f.dataType) for f in dt.fields) elif isinstance(dt, ArrayType): return _has_nulltype((dt.elementType)) elif isinstance(dt, MapType): return _has_...
[ "def", "_has_nulltype", "(", "dt", ")", ":", "if", "isinstance", "(", "dt", ",", "StructType", ")", ":", "return", "any", "(", "_has_nulltype", "(", "f", ".", "dataType", ")", "for", "f", "in", "dt", ".", "fields", ")", "elif", "isinstance", "(", "dt...
Return whether there is NullType in `dt` or not
[ "Return", "whether", "there", "is", "NullType", "in", "dt", "or", "not" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1068-L1077
18,971
apache/spark
python/pyspark/sql/types.py
_create_converter
def _create_converter(dataType): """Create a converter to drop the names of fields in obj """ if not _need_converter(dataType): return lambda x: x if isinstance(dataType, ArrayType): conv = _create_converter(dataType.elementType) return lambda row: [conv(v) for v in row] elif i...
python
def _create_converter(dataType): """Create a converter to drop the names of fields in obj """ if not _need_converter(dataType): return lambda x: x if isinstance(dataType, ArrayType): conv = _create_converter(dataType.elementType) return lambda row: [conv(v) for v in row] elif i...
[ "def", "_create_converter", "(", "dataType", ")", ":", "if", "not", "_need_converter", "(", "dataType", ")", ":", "return", "lambda", "x", ":", "x", "if", "isinstance", "(", "dataType", ",", "ArrayType", ")", ":", "conv", "=", "_create_converter", "(", "da...
Create a converter to drop the names of fields in obj
[ "Create", "a", "converter", "to", "drop", "the", "names", "of", "fields", "in", "obj" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1133-L1180
18,972
apache/spark
python/pyspark/sql/types.py
to_arrow_type
def to_arrow_type(dt): """ Convert Spark data type to pyarrow type """ import pyarrow as pa if type(dt) == BooleanType: arrow_type = pa.bool_() elif type(dt) == ByteType: arrow_type = pa.int8() elif type(dt) == ShortType: arrow_type = pa.int16() elif type(dt) == Integ...
python
def to_arrow_type(dt): """ Convert Spark data type to pyarrow type """ import pyarrow as pa if type(dt) == BooleanType: arrow_type = pa.bool_() elif type(dt) == ByteType: arrow_type = pa.int8() elif type(dt) == ShortType: arrow_type = pa.int16() elif type(dt) == Integ...
[ "def", "to_arrow_type", "(", "dt", ")", ":", "import", "pyarrow", "as", "pa", "if", "type", "(", "dt", ")", "==", "BooleanType", ":", "arrow_type", "=", "pa", ".", "bool_", "(", ")", "elif", "type", "(", "dt", ")", "==", "ByteType", ":", "arrow_type"...
Convert Spark data type to pyarrow type
[ "Convert", "Spark", "data", "type", "to", "pyarrow", "type" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1581-L1622
18,973
apache/spark
python/pyspark/sql/types.py
to_arrow_schema
def to_arrow_schema(schema): """ Convert a schema from Spark to Arrow """ import pyarrow as pa fields = [pa.field(field.name, to_arrow_type(field.dataType), nullable=field.nullable) for field in schema] return pa.schema(fields)
python
def to_arrow_schema(schema): """ Convert a schema from Spark to Arrow """ import pyarrow as pa fields = [pa.field(field.name, to_arrow_type(field.dataType), nullable=field.nullable) for field in schema] return pa.schema(fields)
[ "def", "to_arrow_schema", "(", "schema", ")", ":", "import", "pyarrow", "as", "pa", "fields", "=", "[", "pa", ".", "field", "(", "field", ".", "name", ",", "to_arrow_type", "(", "field", ".", "dataType", ")", ",", "nullable", "=", "field", ".", "nullab...
Convert a schema from Spark to Arrow
[ "Convert", "a", "schema", "from", "Spark", "to", "Arrow" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1625-L1631
18,974
apache/spark
python/pyspark/sql/types.py
from_arrow_type
def from_arrow_type(at): """ Convert pyarrow type to Spark data type. """ import pyarrow.types as types if types.is_boolean(at): spark_type = BooleanType() elif types.is_int8(at): spark_type = ByteType() elif types.is_int16(at): spark_type = ShortType() elif types.is_...
python
def from_arrow_type(at): """ Convert pyarrow type to Spark data type. """ import pyarrow.types as types if types.is_boolean(at): spark_type = BooleanType() elif types.is_int8(at): spark_type = ByteType() elif types.is_int16(at): spark_type = ShortType() elif types.is_...
[ "def", "from_arrow_type", "(", "at", ")", ":", "import", "pyarrow", ".", "types", "as", "types", "if", "types", ".", "is_boolean", "(", "at", ")", ":", "spark_type", "=", "BooleanType", "(", ")", "elif", "types", ".", "is_int8", "(", "at", ")", ":", ...
Convert pyarrow type to Spark data type.
[ "Convert", "pyarrow", "type", "to", "Spark", "data", "type", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1634-L1674
18,975
apache/spark
python/pyspark/sql/types.py
from_arrow_schema
def from_arrow_schema(arrow_schema): """ Convert schema from Arrow to Spark. """ return StructType( [StructField(field.name, from_arrow_type(field.type), nullable=field.nullable) for field in arrow_schema])
python
def from_arrow_schema(arrow_schema): """ Convert schema from Arrow to Spark. """ return StructType( [StructField(field.name, from_arrow_type(field.type), nullable=field.nullable) for field in arrow_schema])
[ "def", "from_arrow_schema", "(", "arrow_schema", ")", ":", "return", "StructType", "(", "[", "StructField", "(", "field", ".", "name", ",", "from_arrow_type", "(", "field", ".", "type", ")", ",", "nullable", "=", "field", ".", "nullable", ")", "for", "fiel...
Convert schema from Arrow to Spark.
[ "Convert", "schema", "from", "Arrow", "to", "Spark", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1677-L1682
18,976
apache/spark
python/pyspark/sql/types.py
_check_series_localize_timestamps
def _check_series_localize_timestamps(s, timezone): """ Convert timezone aware timestamps to timezone-naive in the specified timezone or local timezone. If the input series is not a timestamp series, then the same series is returned. If the input series is a timestamp series, then a converted series is...
python
def _check_series_localize_timestamps(s, timezone): """ Convert timezone aware timestamps to timezone-naive in the specified timezone or local timezone. If the input series is not a timestamp series, then the same series is returned. If the input series is a timestamp series, then a converted series is...
[ "def", "_check_series_localize_timestamps", "(", "s", ",", "timezone", ")", ":", "from", "pyspark", ".", "sql", ".", "utils", "import", "require_minimum_pandas_version", "require_minimum_pandas_version", "(", ")", "from", "pandas", ".", "api", ".", "types", "import"...
Convert timezone aware timestamps to timezone-naive in the specified timezone or local timezone. If the input series is not a timestamp series, then the same series is returned. If the input series is a timestamp series, then a converted series is returned. :param s: pandas.Series :param timezone: the...
[ "Convert", "timezone", "aware", "timestamps", "to", "timezone", "-", "naive", "in", "the", "specified", "timezone", "or", "local", "timezone", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1700-L1720
18,977
apache/spark
python/pyspark/sql/types.py
_check_dataframe_localize_timestamps
def _check_dataframe_localize_timestamps(pdf, timezone): """ Convert timezone aware timestamps to timezone-naive in the specified timezone or local timezone :param pdf: pandas.DataFrame :param timezone: the timezone to convert. if None then use local timezone :return pandas.DataFrame where any time...
python
def _check_dataframe_localize_timestamps(pdf, timezone): """ Convert timezone aware timestamps to timezone-naive in the specified timezone or local timezone :param pdf: pandas.DataFrame :param timezone: the timezone to convert. if None then use local timezone :return pandas.DataFrame where any time...
[ "def", "_check_dataframe_localize_timestamps", "(", "pdf", ",", "timezone", ")", ":", "from", "pyspark", ".", "sql", ".", "utils", "import", "require_minimum_pandas_version", "require_minimum_pandas_version", "(", ")", "for", "column", ",", "series", "in", "pdf", "....
Convert timezone aware timestamps to timezone-naive in the specified timezone or local timezone :param pdf: pandas.DataFrame :param timezone: the timezone to convert. if None then use local timezone :return pandas.DataFrame where any timezone aware columns have been converted to tz-naive
[ "Convert", "timezone", "aware", "timestamps", "to", "timezone", "-", "naive", "in", "the", "specified", "timezone", "or", "local", "timezone" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1723-L1736
18,978
apache/spark
python/pyspark/sql/types.py
_check_series_convert_timestamps_internal
def _check_series_convert_timestamps_internal(s, timezone): """ Convert a tz-naive timestamp in the specified timezone or local timezone to UTC normalized for Spark internal storage :param s: a pandas.Series :param timezone: the timezone to convert. if None then use local timezone :return panda...
python
def _check_series_convert_timestamps_internal(s, timezone): """ Convert a tz-naive timestamp in the specified timezone or local timezone to UTC normalized for Spark internal storage :param s: a pandas.Series :param timezone: the timezone to convert. if None then use local timezone :return panda...
[ "def", "_check_series_convert_timestamps_internal", "(", "s", ",", "timezone", ")", ":", "from", "pyspark", ".", "sql", ".", "utils", "import", "require_minimum_pandas_version", "require_minimum_pandas_version", "(", ")", "from", "pandas", ".", "api", ".", "types", ...
Convert a tz-naive timestamp in the specified timezone or local timezone to UTC normalized for Spark internal storage :param s: a pandas.Series :param timezone: the timezone to convert. if None then use local timezone :return pandas.Series where if it is a timestamp, has been UTC normalized without a t...
[ "Convert", "a", "tz", "-", "naive", "timestamp", "in", "the", "specified", "timezone", "or", "local", "timezone", "to", "UTC", "normalized", "for", "Spark", "internal", "storage" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1739-L1789
18,979
apache/spark
python/pyspark/sql/types.py
_check_series_convert_timestamps_localize
def _check_series_convert_timestamps_localize(s, from_timezone, to_timezone): """ Convert timestamp to timezone-naive in the specified timezone or local timezone :param s: a pandas.Series :param from_timezone: the timezone to convert from. if None then use local timezone :param to_timezone: the tim...
python
def _check_series_convert_timestamps_localize(s, from_timezone, to_timezone): """ Convert timestamp to timezone-naive in the specified timezone or local timezone :param s: a pandas.Series :param from_timezone: the timezone to convert from. if None then use local timezone :param to_timezone: the tim...
[ "def", "_check_series_convert_timestamps_localize", "(", "s", ",", "from_timezone", ",", "to_timezone", ")", ":", "from", "pyspark", ".", "sql", ".", "utils", "import", "require_minimum_pandas_version", "require_minimum_pandas_version", "(", ")", "import", "pandas", "as...
Convert timestamp to timezone-naive in the specified timezone or local timezone :param s: a pandas.Series :param from_timezone: the timezone to convert from. if None then use local timezone :param to_timezone: the timezone to convert to. if None then use local timezone :return pandas.Series where if it...
[ "Convert", "timestamp", "to", "timezone", "-", "naive", "in", "the", "specified", "timezone", "or", "local", "timezone" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1792-L1817
18,980
apache/spark
python/pyspark/sql/types.py
Row.asDict
def asDict(self, recursive=False): """ Return as an dict :param recursive: turns the nested Row as dict (default: False). >>> Row(name="Alice", age=11).asDict() == {'name': 'Alice', 'age': 11} True >>> row = Row(key=1, value=Row(name='a', age=2)) >>> row.asDict(...
python
def asDict(self, recursive=False): """ Return as an dict :param recursive: turns the nested Row as dict (default: False). >>> Row(name="Alice", age=11).asDict() == {'name': 'Alice', 'age': 11} True >>> row = Row(key=1, value=Row(name='a', age=2)) >>> row.asDict(...
[ "def", "asDict", "(", "self", ",", "recursive", "=", "False", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"__fields__\"", ")", ":", "raise", "TypeError", "(", "\"Cannot convert a Row class into dict\"", ")", "if", "recursive", ":", "def", "conv", "...
Return as an dict :param recursive: turns the nested Row as dict (default: False). >>> Row(name="Alice", age=11).asDict() == {'name': 'Alice', 'age': 11} True >>> row = Row(key=1, value=Row(name='a', age=2)) >>> row.asDict() == {'key': 1, 'value': Row(age=2, name='a')} ...
[ "Return", "as", "an", "dict" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/types.py#L1463-L1492
18,981
apache/spark
python/pyspark/shuffle.py
_get_local_dirs
def _get_local_dirs(sub): """ Get all the directories """ path = os.environ.get("SPARK_LOCAL_DIRS", "/tmp") dirs = path.split(",") if len(dirs) > 1: # different order in different processes and instances rnd = random.Random(os.getpid() + id(dirs)) random.shuffle(dirs, rnd.random)...
python
def _get_local_dirs(sub): """ Get all the directories """ path = os.environ.get("SPARK_LOCAL_DIRS", "/tmp") dirs = path.split(",") if len(dirs) > 1: # different order in different processes and instances rnd = random.Random(os.getpid() + id(dirs)) random.shuffle(dirs, rnd.random)...
[ "def", "_get_local_dirs", "(", "sub", ")", ":", "path", "=", "os", ".", "environ", ".", "get", "(", "\"SPARK_LOCAL_DIRS\"", ",", "\"/tmp\"", ")", "dirs", "=", "path", ".", "split", "(", "\",\"", ")", "if", "len", "(", "dirs", ")", ">", "1", ":", "#...
Get all the directories
[ "Get", "all", "the", "directories" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/shuffle.py#L71-L79
18,982
apache/spark
python/pyspark/shuffle.py
ExternalMerger.mergeValues
def mergeValues(self, iterator): """ Combine the items by creator and combiner """ # speedup attribute lookup creator, comb = self.agg.createCombiner, self.agg.mergeValue c, data, pdata, hfun, batch = 0, self.data, self.pdata, self._partition, self.batch limit = self.memory_limit...
python
def mergeValues(self, iterator): """ Combine the items by creator and combiner """ # speedup attribute lookup creator, comb = self.agg.createCombiner, self.agg.mergeValue c, data, pdata, hfun, batch = 0, self.data, self.pdata, self._partition, self.batch limit = self.memory_limit...
[ "def", "mergeValues", "(", "self", ",", "iterator", ")", ":", "# speedup attribute lookup", "creator", ",", "comb", "=", "self", ".", "agg", ".", "createCombiner", ",", "self", ".", "agg", ".", "mergeValue", "c", ",", "data", ",", "pdata", ",", "hfun", "...
Combine the items by creator and combiner
[ "Combine", "the", "items", "by", "creator", "and", "combiner" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/shuffle.py#L231-L253
18,983
apache/spark
python/pyspark/shuffle.py
ExternalMerger.items
def items(self): """ Return all merged items as iterator """ if not self.pdata and not self.spills: return iter(self.data.items()) return self._external_items()
python
def items(self): """ Return all merged items as iterator """ if not self.pdata and not self.spills: return iter(self.data.items()) return self._external_items()
[ "def", "items", "(", "self", ")", ":", "if", "not", "self", ".", "pdata", "and", "not", "self", ".", "spills", ":", "return", "iter", "(", "self", ".", "data", ".", "items", "(", ")", ")", "return", "self", ".", "_external_items", "(", ")" ]
Return all merged items as iterator
[ "Return", "all", "merged", "items", "as", "iterator" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/shuffle.py#L339-L343
18,984
apache/spark
python/pyspark/shuffle.py
ExternalMerger._external_items
def _external_items(self): """ Return all partitioned items as iterator """ assert not self.data if any(self.pdata): self._spill() # disable partitioning and spilling when merge combiners from disk self.pdata = [] try: for i in range(self.partitio...
python
def _external_items(self): """ Return all partitioned items as iterator """ assert not self.data if any(self.pdata): self._spill() # disable partitioning and spilling when merge combiners from disk self.pdata = [] try: for i in range(self.partitio...
[ "def", "_external_items", "(", "self", ")", ":", "assert", "not", "self", ".", "data", "if", "any", "(", "self", ".", "pdata", ")", ":", "self", ".", "_spill", "(", ")", "# disable partitioning and spilling when merge combiners from disk", "self", ".", "pdata", ...
Return all partitioned items as iterator
[ "Return", "all", "partitioned", "items", "as", "iterator" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/shuffle.py#L345-L364
18,985
apache/spark
python/pyspark/shuffle.py
ExternalMerger._recursive_merged_items
def _recursive_merged_items(self, index): """ merge the partitioned items and return the as iterator If one partition can not be fit in memory, then them will be partitioned and merged recursively. """ subdirs = [os.path.join(d, "parts", str(index)) for d in self.localdi...
python
def _recursive_merged_items(self, index): """ merge the partitioned items and return the as iterator If one partition can not be fit in memory, then them will be partitioned and merged recursively. """ subdirs = [os.path.join(d, "parts", str(index)) for d in self.localdi...
[ "def", "_recursive_merged_items", "(", "self", ",", "index", ")", ":", "subdirs", "=", "[", "os", ".", "path", ".", "join", "(", "d", ",", "\"parts\"", ",", "str", "(", "index", ")", ")", "for", "d", "in", "self", ".", "localdirs", "]", "m", "=", ...
merge the partitioned items and return the as iterator If one partition can not be fit in memory, then them will be partitioned and merged recursively.
[ "merge", "the", "partitioned", "items", "and", "return", "the", "as", "iterator" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/shuffle.py#L386-L409
18,986
apache/spark
python/pyspark/shuffle.py
ExternalSorter.sorted
def sorted(self, iterator, key=None, reverse=False): """ Sort the elements in iterator, do external sort when the memory goes above the limit. """ global MemoryBytesSpilled, DiskBytesSpilled batch, limit = 100, self._next_limit() chunks, current_chunk = [], [] ...
python
def sorted(self, iterator, key=None, reverse=False): """ Sort the elements in iterator, do external sort when the memory goes above the limit. """ global MemoryBytesSpilled, DiskBytesSpilled batch, limit = 100, self._next_limit() chunks, current_chunk = [], [] ...
[ "def", "sorted", "(", "self", ",", "iterator", ",", "key", "=", "None", ",", "reverse", "=", "False", ")", ":", "global", "MemoryBytesSpilled", ",", "DiskBytesSpilled", "batch", ",", "limit", "=", "100", ",", "self", ".", "_next_limit", "(", ")", "chunks...
Sort the elements in iterator, do external sort when the memory goes above the limit.
[ "Sort", "the", "elements", "in", "iterator", "do", "external", "sort", "when", "the", "memory", "goes", "above", "the", "limit", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/shuffle.py#L455-L501
18,987
apache/spark
python/pyspark/shuffle.py
ExternalList._spill
def _spill(self): """ dump the values into disk """ global MemoryBytesSpilled, DiskBytesSpilled if self._file is None: self._open_file() used_memory = get_used_memory() pos = self._file.tell() self._ser.dump_stream(self.values, self._file) self.values...
python
def _spill(self): """ dump the values into disk """ global MemoryBytesSpilled, DiskBytesSpilled if self._file is None: self._open_file() used_memory = get_used_memory() pos = self._file.tell() self._ser.dump_stream(self.values, self._file) self.values...
[ "def", "_spill", "(", "self", ")", ":", "global", "MemoryBytesSpilled", ",", "DiskBytesSpilled", "if", "self", ".", "_file", "is", "None", ":", "self", ".", "_open_file", "(", ")", "used_memory", "=", "get_used_memory", "(", ")", "pos", "=", "self", ".", ...
dump the values into disk
[ "dump", "the", "values", "into", "disk" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/shuffle.py#L590-L602
18,988
apache/spark
python/pyspark/shuffle.py
ExternalGroupBy._merge_sorted_items
def _merge_sorted_items(self, index): """ load a partition from disk, then sort and group by key """ def load_partition(j): path = self._get_spill_dir(j) p = os.path.join(path, str(index)) with open(p, 'rb', 65536) as f: for v in self.serializer.load_s...
python
def _merge_sorted_items(self, index): """ load a partition from disk, then sort and group by key """ def load_partition(j): path = self._get_spill_dir(j) p = os.path.join(path, str(index)) with open(p, 'rb', 65536) as f: for v in self.serializer.load_s...
[ "def", "_merge_sorted_items", "(", "self", ",", "index", ")", ":", "def", "load_partition", "(", "j", ")", ":", "path", "=", "self", ".", "_get_spill_dir", "(", "j", ")", "p", "=", "os", ".", "path", ".", "join", "(", "path", ",", "str", "(", "inde...
load a partition from disk, then sort and group by key
[ "load", "a", "partition", "from", "disk", "then", "sort", "and", "group", "by", "key" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/shuffle.py#L786-L808
18,989
apache/spark
python/pyspark/rdd.py
portable_hash
def portable_hash(x): """ This function returns consistent hash code for builtin types, especially for None and tuple with None. The algorithm is similar to that one used by CPython 2.7 >>> portable_hash(None) 0 >>> portable_hash((None, 1)) & 0xffffffff 219750521 """ if sys.ve...
python
def portable_hash(x): """ This function returns consistent hash code for builtin types, especially for None and tuple with None. The algorithm is similar to that one used by CPython 2.7 >>> portable_hash(None) 0 >>> portable_hash((None, 1)) & 0xffffffff 219750521 """ if sys.ve...
[ "def", "portable_hash", "(", "x", ")", ":", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "2", ",", "3", ")", "and", "'PYTHONHASHSEED'", "not", "in", "os", ".", "environ", ":", "raise", "Exception", "(", "\"Randomness of hash of string should be dis...
This function returns consistent hash code for builtin types, especially for None and tuple with None. The algorithm is similar to that one used by CPython 2.7 >>> portable_hash(None) 0 >>> portable_hash((None, 1)) & 0xffffffff 219750521
[ "This", "function", "returns", "consistent", "hash", "code", "for", "builtin", "types", "especially", "for", "None", "and", "tuple", "with", "None", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L78-L106
18,990
apache/spark
python/pyspark/rdd.py
ignore_unicode_prefix
def ignore_unicode_prefix(f): """ Ignore the 'u' prefix of string in doc tests, to make it works in both python 2 and 3 """ if sys.version >= '3': # the representation of unicode string in Python 3 does not have prefix 'u', # so remove the prefix 'u' for doc tests literal_re ...
python
def ignore_unicode_prefix(f): """ Ignore the 'u' prefix of string in doc tests, to make it works in both python 2 and 3 """ if sys.version >= '3': # the representation of unicode string in Python 3 does not have prefix 'u', # so remove the prefix 'u' for doc tests literal_re ...
[ "def", "ignore_unicode_prefix", "(", "f", ")", ":", "if", "sys", ".", "version", ">=", "'3'", ":", "# the representation of unicode string in Python 3 does not have prefix 'u',", "# so remove the prefix 'u' for doc tests", "literal_re", "=", "re", ".", "compile", "(", "r\"(...
Ignore the 'u' prefix of string in doc tests, to make it works in both python 2 and 3
[ "Ignore", "the", "u", "prefix", "of", "string", "in", "doc", "tests", "to", "make", "it", "works", "in", "both", "python", "2", "and", "3" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L150-L160
18,991
apache/spark
python/pyspark/rdd.py
RDD.unpersist
def unpersist(self, blocking=False): """ Mark the RDD as non-persistent, and remove all blocks for it from memory and disk. .. versionchanged:: 3.0.0 Added optional argument `blocking` to specify whether to block until all blocks are deleted. """ se...
python
def unpersist(self, blocking=False): """ Mark the RDD as non-persistent, and remove all blocks for it from memory and disk. .. versionchanged:: 3.0.0 Added optional argument `blocking` to specify whether to block until all blocks are deleted. """ se...
[ "def", "unpersist", "(", "self", ",", "blocking", "=", "False", ")", ":", "self", ".", "is_cached", "=", "False", "self", ".", "_jrdd", ".", "unpersist", "(", "blocking", ")", "return", "self" ]
Mark the RDD as non-persistent, and remove all blocks for it from memory and disk. .. versionchanged:: 3.0.0 Added optional argument `blocking` to specify whether to block until all blocks are deleted.
[ "Mark", "the", "RDD", "as", "non", "-", "persistent", "and", "remove", "all", "blocks", "for", "it", "from", "memory", "and", "disk", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L247-L258
18,992
apache/spark
python/pyspark/rdd.py
RDD.getCheckpointFile
def getCheckpointFile(self): """ Gets the name of the file to which this RDD was checkpointed Not defined if RDD is checkpointed locally. """ checkpointFile = self._jrdd.rdd().getCheckpointFile() if checkpointFile.isDefined(): return checkpointFile.get()
python
def getCheckpointFile(self): """ Gets the name of the file to which this RDD was checkpointed Not defined if RDD is checkpointed locally. """ checkpointFile = self._jrdd.rdd().getCheckpointFile() if checkpointFile.isDefined(): return checkpointFile.get()
[ "def", "getCheckpointFile", "(", "self", ")", ":", "checkpointFile", "=", "self", ".", "_jrdd", ".", "rdd", "(", ")", ".", "getCheckpointFile", "(", ")", "if", "checkpointFile", ".", "isDefined", "(", ")", ":", "return", "checkpointFile", ".", "get", "(", ...
Gets the name of the file to which this RDD was checkpointed Not defined if RDD is checkpointed locally.
[ "Gets", "the", "name", "of", "the", "file", "to", "which", "this", "RDD", "was", "checkpointed" ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L307-L315
18,993
apache/spark
python/pyspark/rdd.py
RDD.map
def map(self, f, preservesPartitioning=False): """ Return a new RDD by applying a function to each element of this RDD. >>> rdd = sc.parallelize(["b", "a", "c"]) >>> sorted(rdd.map(lambda x: (x, 1)).collect()) [('a', 1), ('b', 1), ('c', 1)] """ def func(_, iterat...
python
def map(self, f, preservesPartitioning=False): """ Return a new RDD by applying a function to each element of this RDD. >>> rdd = sc.parallelize(["b", "a", "c"]) >>> sorted(rdd.map(lambda x: (x, 1)).collect()) [('a', 1), ('b', 1), ('c', 1)] """ def func(_, iterat...
[ "def", "map", "(", "self", ",", "f", ",", "preservesPartitioning", "=", "False", ")", ":", "def", "func", "(", "_", ",", "iterator", ")", ":", "return", "map", "(", "fail_on_stopiteration", "(", "f", ")", ",", "iterator", ")", "return", "self", ".", ...
Return a new RDD by applying a function to each element of this RDD. >>> rdd = sc.parallelize(["b", "a", "c"]) >>> sorted(rdd.map(lambda x: (x, 1)).collect()) [('a', 1), ('b', 1), ('c', 1)]
[ "Return", "a", "new", "RDD", "by", "applying", "a", "function", "to", "each", "element", "of", "this", "RDD", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L317-L327
18,994
apache/spark
python/pyspark/rdd.py
RDD.flatMap
def flatMap(self, f, preservesPartitioning=False): """ Return a new RDD by first applying a function to all elements of this RDD, and then flattening the results. >>> rdd = sc.parallelize([2, 3, 4]) >>> sorted(rdd.flatMap(lambda x: range(1, x)).collect()) [1, 1, 1, 2, 2,...
python
def flatMap(self, f, preservesPartitioning=False): """ Return a new RDD by first applying a function to all elements of this RDD, and then flattening the results. >>> rdd = sc.parallelize([2, 3, 4]) >>> sorted(rdd.flatMap(lambda x: range(1, x)).collect()) [1, 1, 1, 2, 2,...
[ "def", "flatMap", "(", "self", ",", "f", ",", "preservesPartitioning", "=", "False", ")", ":", "def", "func", "(", "s", ",", "iterator", ")", ":", "return", "chain", ".", "from_iterable", "(", "map", "(", "fail_on_stopiteration", "(", "f", ")", ",", "i...
Return a new RDD by first applying a function to all elements of this RDD, and then flattening the results. >>> rdd = sc.parallelize([2, 3, 4]) >>> sorted(rdd.flatMap(lambda x: range(1, x)).collect()) [1, 1, 1, 2, 2, 3] >>> sorted(rdd.flatMap(lambda x: [(x, x), (x, x)]).collect(...
[ "Return", "a", "new", "RDD", "by", "first", "applying", "a", "function", "to", "all", "elements", "of", "this", "RDD", "and", "then", "flattening", "the", "results", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L329-L342
18,995
apache/spark
python/pyspark/rdd.py
RDD.mapPartitions
def mapPartitions(self, f, preservesPartitioning=False): """ Return a new RDD by applying a function to each partition of this RDD. >>> rdd = sc.parallelize([1, 2, 3, 4], 2) >>> def f(iterator): yield sum(iterator) >>> rdd.mapPartitions(f).collect() [3, 7] """ ...
python
def mapPartitions(self, f, preservesPartitioning=False): """ Return a new RDD by applying a function to each partition of this RDD. >>> rdd = sc.parallelize([1, 2, 3, 4], 2) >>> def f(iterator): yield sum(iterator) >>> rdd.mapPartitions(f).collect() [3, 7] """ ...
[ "def", "mapPartitions", "(", "self", ",", "f", ",", "preservesPartitioning", "=", "False", ")", ":", "def", "func", "(", "s", ",", "iterator", ")", ":", "return", "f", "(", "iterator", ")", "return", "self", ".", "mapPartitionsWithIndex", "(", "func", ",...
Return a new RDD by applying a function to each partition of this RDD. >>> rdd = sc.parallelize([1, 2, 3, 4], 2) >>> def f(iterator): yield sum(iterator) >>> rdd.mapPartitions(f).collect() [3, 7]
[ "Return", "a", "new", "RDD", "by", "applying", "a", "function", "to", "each", "partition", "of", "this", "RDD", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L344-L355
18,996
apache/spark
python/pyspark/rdd.py
RDD.distinct
def distinct(self, numPartitions=None): """ Return a new RDD containing the distinct elements in this RDD. >>> sorted(sc.parallelize([1, 1, 2, 3]).distinct().collect()) [1, 2, 3] """ return self.map(lambda x: (x, None)) \ .reduceByKey(lambda x, _: x, n...
python
def distinct(self, numPartitions=None): """ Return a new RDD containing the distinct elements in this RDD. >>> sorted(sc.parallelize([1, 1, 2, 3]).distinct().collect()) [1, 2, 3] """ return self.map(lambda x: (x, None)) \ .reduceByKey(lambda x, _: x, n...
[ "def", "distinct", "(", "self", ",", "numPartitions", "=", "None", ")", ":", "return", "self", ".", "map", "(", "lambda", "x", ":", "(", "x", ",", "None", ")", ")", ".", "reduceByKey", "(", "lambda", "x", ",", "_", ":", "x", ",", "numPartitions", ...
Return a new RDD containing the distinct elements in this RDD. >>> sorted(sc.parallelize([1, 1, 2, 3]).distinct().collect()) [1, 2, 3]
[ "Return", "a", "new", "RDD", "containing", "the", "distinct", "elements", "in", "this", "RDD", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L407-L416
18,997
apache/spark
python/pyspark/rdd.py
RDD.sample
def sample(self, withReplacement, fraction, seed=None): """ Return a sampled subset of this RDD. :param withReplacement: can elements be sampled multiple times (replaced when sampled out) :param fraction: expected size of the sample as a fraction of this RDD's size without r...
python
def sample(self, withReplacement, fraction, seed=None): """ Return a sampled subset of this RDD. :param withReplacement: can elements be sampled multiple times (replaced when sampled out) :param fraction: expected size of the sample as a fraction of this RDD's size without r...
[ "def", "sample", "(", "self", ",", "withReplacement", ",", "fraction", ",", "seed", "=", "None", ")", ":", "assert", "fraction", ">=", "0.0", ",", "\"Negative fraction value: %s\"", "%", "fraction", "return", "self", ".", "mapPartitionsWithIndex", "(", "RDDSampl...
Return a sampled subset of this RDD. :param withReplacement: can elements be sampled multiple times (replaced when sampled out) :param fraction: expected size of the sample as a fraction of this RDD's size without replacement: probability that each element is chosen; fraction must be [0, 1]...
[ "Return", "a", "sampled", "subset", "of", "this", "RDD", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L418-L436
18,998
apache/spark
python/pyspark/rdd.py
RDD.randomSplit
def randomSplit(self, weights, seed=None): """ Randomly splits this RDD with the provided weights. :param weights: weights for splits, will be normalized if they don't sum to 1 :param seed: random seed :return: split RDDs in a list >>> rdd = sc.parallelize(range(500), 1...
python
def randomSplit(self, weights, seed=None): """ Randomly splits this RDD with the provided weights. :param weights: weights for splits, will be normalized if they don't sum to 1 :param seed: random seed :return: split RDDs in a list >>> rdd = sc.parallelize(range(500), 1...
[ "def", "randomSplit", "(", "self", ",", "weights", ",", "seed", "=", "None", ")", ":", "s", "=", "float", "(", "sum", "(", "weights", ")", ")", "cweights", "=", "[", "0.0", "]", "for", "w", "in", "weights", ":", "cweights", ".", "append", "(", "c...
Randomly splits this RDD with the provided weights. :param weights: weights for splits, will be normalized if they don't sum to 1 :param seed: random seed :return: split RDDs in a list >>> rdd = sc.parallelize(range(500), 1) >>> rdd1, rdd2 = rdd.randomSplit([2, 3], 17) ...
[ "Randomly", "splits", "this", "RDD", "with", "the", "provided", "weights", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L438-L462
18,999
apache/spark
python/pyspark/rdd.py
RDD.takeSample
def takeSample(self, withReplacement, num, seed=None): """ Return a fixed-size sampled subset of this RDD. .. note:: This method should only be used if the resulting array is expected to be small, as all the data is loaded into the driver's memory. >>> rdd = sc.parallelize(...
python
def takeSample(self, withReplacement, num, seed=None): """ Return a fixed-size sampled subset of this RDD. .. note:: This method should only be used if the resulting array is expected to be small, as all the data is loaded into the driver's memory. >>> rdd = sc.parallelize(...
[ "def", "takeSample", "(", "self", ",", "withReplacement", ",", "num", ",", "seed", "=", "None", ")", ":", "numStDev", "=", "10.0", "if", "num", "<", "0", ":", "raise", "ValueError", "(", "\"Sample size cannot be negative.\"", ")", "elif", "num", "==", "0",...
Return a fixed-size sampled subset of this RDD. .. note:: This method should only be used if the resulting array is expected to be small, as all the data is loaded into the driver's memory. >>> rdd = sc.parallelize(range(0, 10)) >>> len(rdd.takeSample(True, 20, 1)) 20 ...
[ "Return", "a", "fixed", "-", "size", "sampled", "subset", "of", "this", "RDD", "." ]
618d6bff71073c8c93501ab7392c3cc579730f0b
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L465-L518