Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def decode_index_value(self, index, value): if index.endswith("_int"): return int(value) else: return bytes_to_str(value)
[ "\n Decodes a secondary index value into the correct Python type.\n :param index: the name of the index\n :type index: str\n :param value: the value of the index entry\n :type value: str\n :rtype str or int\n " ]
Please provide a description of the function:def encode_bucket_props(self, props, msg): for prop in NORMAL_PROPS: if prop in props and props[prop] is not None: if isinstance(props[prop], six.string_types): setattr(msg.props, prop, str_to_bytes(props[prop]...
[ "\n Encodes a dict of bucket properties into the protobuf message.\n\n :param props: bucket properties\n :type props: dict\n :param msg: the protobuf message to fill\n :type msg: riak.pb.riak_pb2.RpbSetBucketReq\n " ]
Please provide a description of the function:def decode_bucket_props(self, msg): props = {} for prop in NORMAL_PROPS: if msg.HasField(prop): props[prop] = getattr(msg, prop) if isinstance(props[prop], bytes): props[prop] = bytes_to...
[ "\n Decodes the protobuf bucket properties message into a dict.\n\n :param msg: the protobuf message to decode\n :type msg: riak.pb.riak_pb2.RpbBucketProps\n :rtype dict\n " ]
Please provide a description of the function:def encode_modfun(self, props, msg=None): if msg is None: msg = riak.pb.riak_pb2.RpbModFun() msg.module = str_to_bytes(props['mod']) msg.function = str_to_bytes(props['fun']) return msg
[ "\n Encodes a dict with 'mod' and 'fun' keys into a protobuf\n modfun pair. Used in bucket properties.\n\n :param props: the module/function pair\n :type props: dict\n :param msg: the protobuf message to fill\n :type msg: riak.pb.riak_pb2.RpbModFun\n :rtype riak.pb.r...
Please provide a description of the function:def encode_hooklist(self, hooklist, msg): for hook in hooklist: pbhook = msg.add() self.encode_hook(hook, pbhook)
[ "\n Encodes a list of commit hooks into their protobuf equivalent.\n Used in bucket properties.\n\n :param hooklist: a list of commit hooks\n :type hooklist: list\n :param msg: a protobuf field that is a list of commit hooks\n " ]
Please provide a description of the function:def decode_hook(self, hook): if hook.HasField('modfun'): return self.decode_modfun(hook.modfun) else: return {'name': bytes_to_str(hook.name)}
[ "\n Decodes a protobuf commit hook message into a dict. Used in\n bucket properties.\n\n :param hook: the hook to decode\n :type hook: riak.pb.riak_pb2.RpbCommitHook\n :rtype dict\n " ]
Please provide a description of the function:def encode_hook(self, hook, msg): if 'name' in hook: msg.name = str_to_bytes(hook['name']) else: self.encode_modfun(hook, msg.modfun) return msg
[ "\n Encodes a commit hook dict into the protobuf message. Used in\n bucket properties.\n\n :param hook: the hook to encode\n :type hook: dict\n :param msg: the protobuf message to fill\n :type msg: riak.pb.riak_pb2.RpbCommitHook\n :rtype riak.pb.riak_pb2.RpbCommitHoo...
Please provide a description of the function:def encode_index_req(self, bucket, index, startkey, endkey=None, return_terms=None, max_results=None, continuation=None, timeout=None, term_regex=None, streaming=False): req = riak.pb...
[ "\n Encodes a secondary index request into the protobuf message.\n\n :param bucket: the bucket whose index to query\n :type bucket: string\n :param index: the index to query\n :type index: string\n :param startkey: the value or beginning of the range\n :type startkey...
Please provide a description of the function:def decode_search_index(self, index): result = {} result['name'] = bytes_to_str(index.name) if index.HasField('schema'): result['schema'] = bytes_to_str(index.schema) if index.HasField('n_val'): result['n_val']...
[ "\n Fills an RpbYokozunaIndex message with the appropriate data.\n\n :param index: a yz index message\n :type index: riak.pb.riak_yokozuna_pb2.RpbYokozunaIndex\n :rtype dict\n " ]
Please provide a description of the function:def encode_timeseries_put(self, tsobj): req = riak.pb.riak_ts_pb2.TsPutReq() req.table = str_to_bytes(tsobj.table.name) if tsobj.columns: raise NotImplementedError("columns are not implemented yet") if tsobj.rows and isi...
[ "\n Fills an TsPutReq message with the appropriate data and\n metadata from a TsObject.\n\n :param tsobj: a TsObject\n :type tsobj: TsObject\n :param req: the protobuf message to fill\n :type req: riak.pb.riak_ts_pb2.TsPutReq\n " ]
Please provide a description of the function:def decode_timeseries(self, resp, tsobj, convert_timestamp=False): if resp.columns is not None: col_names = [] col_types = [] for col in resp.columns: col_names.append(bytes_to_str...
[ "\n Fills an TsObject with the appropriate data and\n metadata from a TsGetResp / TsQueryResp.\n\n :param resp: the protobuf message from which to process data\n :type resp: riak.pb.riak_ts_pb2.TsQueryRsp or\n riak.pb.riak_ts_pb2.TsGetResp\n :param tsobj: a TsOb...
Please provide a description of the function:def decode_timeseries_row(self, tsrow, tscols=None, convert_timestamp=False): row = [] for i, cell in enumerate(tsrow.cells): col = None if tscols is not None: col = tscols[i] ...
[ "\n Decodes a TsRow into a list\n\n :param tsrow: the protobuf TsRow to decode.\n :type tsrow: riak.pb.riak_ts_pb2.TsRow\n :param tscols: the protobuf TsColumn data to help decode.\n :type tscols: list\n :rtype list\n " ]
Please provide a description of the function:def decode_preflist(self, item): result = {'partition': item.partition, 'node': bytes_to_str(item.node), 'primary': item. primary} return result
[ "\n Decodes a preflist response\n\n :param preflist: a bucket/key preflist\n :type preflist: list of\n riak.pb.riak_kv_pb2.RpbBucketKeyPreflistItem\n :rtype dict\n " ]
Please provide a description of the function:def ping(self): msg_code = riak.pb.messages.MSG_CODE_PING_REQ codec = self._get_codec(msg_code) msg = codec.encode_ping() resp_code, _ = self._request(msg, codec) if resp_code == riak.pb.messages.MSG_CODE_PING_RESP: ...
[ "\n Ping the remote server\n " ]
Please provide a description of the function:def get_server_info(self): # NB: can't do it this way due to recursion # codec = self._get_codec(ttb_supported=False) codec = PbufCodec() msg = Msg(riak.pb.messages.MSG_CODE_GET_SERVER_INFO_REQ, None, riak.pb.message...
[ "\n Get information about the server\n " ]
Please provide a description of the function:def get(self, robj, r=None, pr=None, timeout=None, basic_quorum=None, notfound_ok=None, head_only=False): msg_code = riak.pb.messages.MSG_CODE_GET_REQ codec = self._get_codec(msg_code) msg = codec.encode_get(robj, r, pr, ...
[ "\n Serialize get request and deserialize response\n " ]
Please provide a description of the function:def ts_stream_keys(self, table, timeout=None): msg_code = riak.pb.messages.MSG_CODE_TS_LIST_KEYS_REQ codec = self._get_codec(msg_code) msg = codec.encode_timeseries_listkeysreq(table, timeout) self._send_msg(msg.msg_code, msg.data) ...
[ "\n Streams keys from a timeseries table, returning an iterator that\n yields lists of keys.\n " ]
Please provide a description of the function:def get_keys(self, bucket, timeout=None): msg_code = riak.pb.messages.MSG_CODE_LIST_KEYS_REQ codec = self._get_codec(msg_code) stream = self.stream_keys(bucket, timeout=timeout) return codec.decode_get_keys(stream)
[ "\n Lists all keys within a bucket.\n " ]
Please provide a description of the function:def stream_keys(self, bucket, timeout=None): msg_code = riak.pb.messages.MSG_CODE_LIST_KEYS_REQ codec = self._get_codec(msg_code) msg = codec.encode_stream_keys(bucket, timeout) self._send_msg(msg.msg_code, msg.data) return Pb...
[ "\n Streams keys from a bucket, returning an iterator that yields\n lists of keys.\n " ]
Please provide a description of the function:def get_buckets(self, bucket_type=None, timeout=None): msg_code = riak.pb.messages.MSG_CODE_LIST_BUCKETS_REQ codec = self._get_codec(msg_code) msg = codec.encode_get_buckets(bucket_type, timeout, streami...
[ "\n Serialize bucket listing request and deserialize response\n " ]
Please provide a description of the function:def stream_buckets(self, bucket_type=None, timeout=None): if not self.bucket_stream(): raise NotImplementedError('Streaming list-buckets is not ' 'supported') msg_code = riak.pb.messages.MSG_CODE_LIST...
[ "\n Stream list of buckets through an iterator\n " ]
Please provide a description of the function:def get_bucket_props(self, bucket): msg_code = riak.pb.messages.MSG_CODE_GET_BUCKET_REQ codec = self._get_codec(msg_code) msg = codec.encode_get_bucket_props(bucket) resp_code, resp = self._request(msg, codec) return codec.dec...
[ "\n Serialize bucket property request and deserialize response\n " ]
Please provide a description of the function:def set_bucket_props(self, bucket, props): if not self.pb_all_bucket_props(): for key in props: if key not in ('n_val', 'allow_mult'): raise NotImplementedError('Server only supports n_val and ' ...
[ "\n Serialize set bucket property request and deserialize response\n " ]
Please provide a description of the function:def clear_bucket_props(self, bucket): if not self.pb_clear_bucket_props(): return False msg_code = riak.pb.messages.MSG_CODE_RESET_BUCKET_REQ codec = self._get_codec(msg_code) msg = codec.encode_clear_bucket_props(bucket) ...
[ "\n Clear bucket properties, resetting them to their defaults\n " ]
Please provide a description of the function:def get_bucket_type_props(self, bucket_type): self._check_bucket_types(bucket_type) msg_code = riak.pb.messages.MSG_CODE_GET_BUCKET_TYPE_REQ codec = self._get_codec(msg_code) msg = codec.encode_get_bucket_type_props(bucket_type) ...
[ "\n Fetch bucket-type properties\n " ]
Please provide a description of the function:def set_bucket_type_props(self, bucket_type, props): self._check_bucket_types(bucket_type) msg_code = riak.pb.messages.MSG_CODE_SET_BUCKET_TYPE_REQ codec = self._get_codec(msg_code) msg = codec.encode_set_bucket_type_props(bucket_type...
[ "\n Set bucket-type properties\n " ]
Please provide a description of the function:def get_preflist(self, bucket, key): if not self.preflists(): raise NotImplementedError("fetching preflists is not supported.") msg_code = riak.pb.messages.MSG_CODE_GET_BUCKET_KEY_PREFLIST_REQ codec = self._get_codec(msg_code) ...
[ "\n Get the preflist for a bucket/key\n\n :param bucket: Riak Bucket\n :type bucket: :class:`~riak.bucket.RiakBucket`\n :param key: Riak Key\n :type key: string\n :rtype: list of dicts\n " ]
Please provide a description of the function:def print_report(label, user, system, real): print("{:<12s} {:12f} {:12f} ( {:12f} )".format(label, user, system, ...
[ "\n Prints the report of one step of a benchmark.\n " ]
Please provide a description of the function:def next(self): if self.count == 0: raise StopIteration elif self.count > 1: print_rehearsal_header() else: if self.rehearse: gc.collect() print("-" * 59) pri...
[ "\n Runs the next iteration of the benchmark.\n " ]
Please provide a description of the function:def add(self, arg1, arg2=None, arg3=None, bucket_type=None): from riak.riak_object import RiakObject if (arg2 is None) and (arg3 is None): if isinstance(arg1, RiakObject): return self.add_object(arg1) else: ...
[ "\n Add inputs to a map/reduce operation. This method takes three\n different forms, depending on the provided inputs. You can\n specify either a RiakObject, a string bucket name, or a bucket,\n key, and additional arg.\n\n :param arg1: the object or bucket to add\n :type a...
Please provide a description of the function:def add_object(self, obj): return self.add_bucket_key_data(obj._bucket._name, obj._key, None)
[ "\n Adds a RiakObject to the inputs.\n\n :param obj: the object to add\n :type obj: RiakObject\n :rtype: :class:`RiakMapReduce`\n " ]
Please provide a description of the function:def add_bucket_key_data(self, bucket, key, data, bucket_type=None): if self._input_mode == 'bucket': raise ValueError('Already added a bucket, can\'t add an object.') elif self._input_mode == 'query': raise ValueError('Already...
[ "\n Adds a bucket/key/keydata triple to the inputs.\n\n :param bucket: the bucket\n :type bucket: string\n :param key: the key or list of keys\n :type key: string\n :param data: the key-specific data\n :type data: string, list, dict, None\n :param bucket_type:...
Please provide a description of the function:def add_bucket(self, bucket, bucket_type=None): if not riak.disable_list_exceptions: raise riak.ListError() self._input_mode = 'bucket' if isinstance(bucket, riak.RiakBucket): if bucket.bucket_type.is_default(): ...
[ "\n Adds all keys in a bucket to the inputs.\n\n :param bucket: the bucket\n :type bucket: string\n :param bucket_type: Optional name of a bucket type\n :type bucket_type: string, None\n :rtype: :class:`RiakMapReduce`\n " ]
Please provide a description of the function:def add_key_filters(self, key_filters): if self._input_mode == 'query': raise ValueError('Key filters are not supported in a query.') self._key_filters.extend(key_filters) return self
[ "\n Adds key filters to the inputs.\n\n :param key_filters: a list of filters\n :type key_filters: list\n :rtype: :class:`RiakMapReduce`\n " ]
Please provide a description of the function:def add_key_filter(self, *args): if self._input_mode == 'query': raise ValueError('Key filters are not supported in a query.') self._key_filters.append(args) return self
[ "\n Add a single key filter to the inputs.\n\n :param args: a filter\n :type args: list\n :rtype: :class:`RiakMapReduce`\n " ]
Please provide a description of the function:def search(self, index, query): self._input_mode = 'query' self._inputs = {'bucket': index, 'index': index, 'query': query} return self
[ "\n Begin a map/reduce operation using a Search. This command will\n return an error unless executed against a Riak Search cluster.\n\n :param index: The Solr index used in the search\n :type index: string\n :param query: The search query\n :type query: string\n :rty...
Please provide a description of the function:def index(self, bucket, index, startkey, endkey=None, bucket_type=None): self._input_mode = 'query' if endkey is None: self._inputs = {'bucket': bucket, 'index': index, 'key': start...
[ "\n Begin a map/reduce operation using a Secondary Index\n query.\n\n :param bucket: The bucket over which to perform the query\n :type bucket: string\n :param index: The index to use for query\n :type index: string\n :param startkey: The start key of index range, or...
Please provide a description of the function:def link(self, bucket='_', tag='_', keep=False): self._phases.append(RiakLinkPhase(bucket, tag, keep)) return self
[ "\n Add a link phase to the map/reduce operation.\n\n :param bucket: Bucket name (default '_', which means all\n buckets)\n :type bucket: string\n :param tag: Tag (default '_', which means any tag)\n :type tag: string\n :param keep: Flag whether to keep results ...
Please provide a description of the function:def map(self, function, options=None): if options is None: options = dict() if isinstance(function, list): language = 'erlang' else: language = 'javascript' mr = RiakMapReducePhase('map', ...
[ "\n Add a map phase to the map/reduce operation.\n\n :param function: Either a named Javascript function (ie:\n 'Riak.mapValues'), or an anonymous javascript function (ie:\n 'function(...) ... ' or an array ['erlang_module',\n 'function'].\n :type function: string, li...
Please provide a description of the function:def run(self, timeout=None): query, link_results_flag = self._normalize_query() try: result = self._client.mapred(self._inputs, query, timeout) except riak.RiakError as e: if 'worker_startup_failed' in e.value: ...
[ "\n Run the map/reduce operation synchronously. Returns a list of\n results, or a list of links if the last phase is a link phase.\n Shortcut for :meth:`riak.client.RiakClient.mapred`.\n\n :param timeout: Timeout in milliseconds\n :type timeout: integer, None\n :rtype: list...
Please provide a description of the function:def stream(self, timeout=None): query, lrf = self._normalize_query() return self._client.stream_mapred(self._inputs, query, timeout)
[ "\n Streams the MapReduce query (returns an iterator). Shortcut\n for :meth:`riak.client.RiakClient.stream_mapred`.\n\n :param timeout: Timeout in milliseconds\n :type timeout: integer\n :rtype: iterator that yields (phase_num, data) tuples\n " ]
Please provide a description of the function:def reduce_sort(self, js_cmp=None, options=None): if options is None: options = dict() if js_cmp: options['arg'] = js_cmp return self.reduce("Riak.reduceSort", options=options)
[ "\n Adds the Javascript built-in ``Riak.reduceSort`` to the query\n as a reduce phase.\n\n :param js_cmp: A Javascript comparator function as specified by\n Array.sort()\n :type js_cmp: string\n :param options: phase options, containing 'language', 'keep'\n flag,...
Please provide a description of the function:def reduce_limit(self, limit, options=None): if options is None: options = dict() options['arg'] = limit # reduceLimit is broken in riak_kv code = return self.reduce(code, options=options)
[ "\n Adds the Javascript built-in ``Riak.reduceLimit`` to the query\n as a reduce phase.\n\n :param limit: the maximum number of results to return\n :type limit: integer\n :param options: phase options, containing 'language', 'keep'\n flag, and/or 'arg'.\n :type opt...
Please provide a description of the function:def reduce_slice(self, start, end, options=None): if options is None: options = dict() options['arg'] = [start, end] return self.reduce("Riak.reduceSlice", options=options)
[ "\n Adds the Javascript built-in ``Riak.reduceSlice`` to the\n query as a reduce phase.\n\n :param start: the beginning of the slice\n :type start: integer\n :param end: the end of the slice\n :type end: integer\n :param options: phase options, containing 'language',...
Please provide a description of the function:def to_array(self): stepdef = {'keep': self._keep, 'language': self._language, 'arg': self._arg} if self._language == 'javascript': if isinstance(self._function, list): stepdef['bucke...
[ "\n Convert the RiakMapReducePhase to a format that can be output\n into JSON. Used internally.\n\n :rtype: dict\n " ]
Please provide a description of the function:def to_array(self): stepdef = {'bucket': self._bucket, 'tag': self._tag, 'keep': self._keep} return {'link': stepdef}
[ "\n Convert the RiakLinkPhase to a format that can be output into\n JSON. Used internally.\n " ]
Please provide a description of the function:def add(self, arg1, arg2=None, arg3=None, bucket_type=None): mr = RiakMapReduce(self) return mr.add(arg1, arg2, arg3, bucket_type)
[ "\n Start assembling a Map/Reduce operation. A shortcut for\n :func:`RiakMapReduce.add`.\n\n :param arg1: the object or bucket to add\n :type arg1: RiakObject, string\n :param arg2: a key or list of keys to add (if a bucket is\n given in arg1)\n :type arg2: string,...
Please provide a description of the function:def index(self, bucket, index, startkey, endkey=None, bucket_type=None): mr = RiakMapReduce(self) return mr.index(bucket, index, startkey, endkey, bucket_type)
[ "\n Start assembling a Map/Reduce operation based on secondary\n index query results.\n\n :param bucket: The bucket over which to perform the query\n :type bucket: string\n :param index: The index to use for query\n :type index: string\n :param startkey: The start ke...
Please provide a description of the function:def add_index(self, field, value): if field[-4:] not in ("_bin", "_int"): raise RiakError("Riak 2i fields must end with either '_bin'" " or '_int'.") self.indexes.add((field, value)) return self._robj...
[ "\n add_index(field, value)\n\n Tag this object with the specified field/value pair for\n indexing.\n\n :param field: The index field.\n :type field: string\n :param value: The index value.\n :type value: string or integer\n :rtype: :class:`RiakObject <riak.ri...
Please provide a description of the function:def remove_index(self, field=None, value=None): if not field and not value: self.indexes.clear() elif field and not value: for index in [x for x in self.indexes if x[0] == field]: self.indexes.remove(index) ...
[ "\n remove_index(field=None, value=None)\n\n Remove the specified field/value pair as an index on this\n object.\n\n :param field: The index field.\n :type field: string\n :param value: The index value.\n :type value: string or integer\n :rtype: :class:`RiakOb...
Please provide a description of the function:def set_index(self, field, value): to_rem = set((x for x in self.indexes if x[0] == field)) self.indexes.difference_update(to_rem) return self.add_index(field, value)
[ "\n set_index(field, value)\n\n Works like :meth:`add_index`, but ensures that there is only\n one index on given field. If other found, then removes it\n first.\n\n :param field: The index field.\n :type field: string\n :param value: The index value.\n :type ...
Please provide a description of the function:def add_link(self, obj, tag=None): if isinstance(obj, tuple): newlink = obj else: newlink = (obj.bucket.name, obj.key, tag) self.links.append(newlink) return self._robject
[ "\n add_link(obj, tag=None)\n\n Add a link to a RiakObject.\n\n :param obj: Either a RiakObject or 3 item link tuple consisting\n of (bucket, key, tag).\n :type obj: mixed\n :param tag: Optional link tag. Defaults to bucket name. It is ignored\n if ``obj`` is...
Please provide a description of the function:def last_written_resolver(riak_object): riak_object.siblings = [max(riak_object.siblings, key=lambda x: x.last_modified), ]
[ "\n A conflict-resolution function that resolves by selecting the most\n recently-modified sibling by timestamp.\n\n :param riak_object: an object-in-conflict that will be resolved\n :type riak_object: :class:`RiakObject <riak.riak_object.RiakObject>`\n " ]
Please provide a description of the function:def verify_cb(conn, cert, errnum, depth, ok): if not ok: raise SecurityError("Could not verify CA certificate {0}" .format(cert.get_subject())) return ok
[ "\n The default OpenSSL certificate verification callback.\n " ]
Please provide a description of the function: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 None: self.stream = stream args = {'bucket': self.bucket, ...
[ "\n Fetches the next page using the same parameters as the\n original query.\n\n Note that if streaming was used before, it will be used again\n unless overridden.\n\n :param stream: whether to enable streaming. `True` enables,\n `False` disables, `None` uses previous v...
Please provide a description of the function:def _inject_term(self, result): if self._should_inject_term(result): if type(result) is list: return [(self.startkey, r) for r in result] else: return (self.startkey, result) else: r...
[ "\n Upgrades a result (streamed or not) to include the index term\n when an equality query is used with return_terms.\n " ]
Please provide a description of the function:def is_retryable(err): if isinstance(err, ConnectionClosed): # NB: only retryable if we're not mid-streaming if err.mid_stream: return False else: return True elif isinstance(err, socket.error): code = err....
[ "\n Determines if the given exception is something that is\n network/socket-related and should thus cause the TCP connection to\n close and the operation retried on another node.\n\n :rtype: boolean\n " ]
Please provide a description of the function:def _validate_timeout(timeout, infinity_ok=False): if timeout is None: return if timeout == 'infinity': if infinity_ok: return else: raise ValueError( 'timeout must be a positive integer ' ...
[ "\n Raises an exception if the given timeout is an invalid value.\n " ]
Please provide a description of the function:def get_buckets(self, transport, bucket_type=None, timeout=None): if not riak.disable_list_exceptions: raise ListError() _validate_timeout(timeout) if bucket_type: bucketfn = self._bucket_type_bucket_builder ...
[ "\n get_buckets(bucket_type=None, timeout=None)\n\n Get the list of buckets as :class:`RiakBucket\n <riak.bucket.RiakBucket>` instances.\n\n .. warning:: Do not use this in production, as it requires\n traversing through all keys stored in a cluster.\n\n .. note:: This r...
Please provide a description of the function:def stream_buckets(self, bucket_type=None, timeout=None): if not riak.disable_list_exceptions: raise ListError() _validate_timeout(timeout) if bucket_type: bucketfn = self._bucket_type_bucket_builder else: ...
[ "\n Streams the list of buckets. This is a generator method that\n should be iterated over.\n\n .. warning:: Do not use this in production, as it requires\n traversing through all keys stored in a cluster.\n\n The caller should explicitly close the returned iterator,\n e...
Please provide a description of the function:def get_index(self, transport, bucket, index, startkey, endkey=None, return_terms=None, max_results=None, continuation=None, timeout=None, term_regex=None): _validate_timeout(timeout, infinity_ok=True) page = Inde...
[ "\n get_index(bucket, index, startkey, endkey=None, return_terms=None,\\\n max_results=None, continuation=None, timeout=None,\\\n term_regex=None)\n\n Queries a secondary index, returning matching keys.\n\n .. note:: This request is automatically retried :attr:...
Please provide a description of the function:def paginate_index(self, bucket, index, startkey, endkey=None, max_results=1000, return_terms=None, continuation=None, timeout=None, term_regex=None): page = self.get_index(bucket, index, startkey, ...
[ "\n Iterates over a paginated index query. This is equivalent to calling\n :meth:`get_index` and then successively calling\n :meth:`~riak.client.index_page.IndexPage.next_page` until all\n results are exhausted.\n\n Because limiting the result set is necessary to invoke pagination...
Please provide a description of the function:def stream_index(self, bucket, index, startkey, endkey=None, return_terms=None, max_results=None, continuation=None, timeout=None, term_regex=None): # TODO FUTURE: implement "retry on connection closed" # as ...
[ "\n Queries a secondary index, streaming matching keys through an\n iterator.\n\n The caller should explicitly close the returned iterator,\n either using :func:`contextlib.closing` or calling ``close()``\n explicitly. Consuming the entire iterator will also close the\n str...
Please provide a description of the function:def paginate_stream_index(self, bucket, index, startkey, endkey=None, max_results=1000, return_terms=None, continuation=None, timeout=None, term_regex=None): # TODO FUT...
[ "\n Iterates over a streaming paginated index query. This is equivalent to\n calling :meth:`stream_index` and then successively calling\n :meth:`~riak.client.index_page.IndexPage.next_page` until all\n results are exhausted.\n\n Because limiting the result set is necessary to invo...
Please provide a description of the function:def set_bucket_props(self, transport, bucket, props): _validate_bucket_props(props) return transport.set_bucket_props(bucket, props)
[ "\n set_bucket_props(bucket, props)\n\n Sets bucket properties for the given bucket.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param bucket: the bucket whose properties will be set\n :type bucket: R...
Please provide a description of the function:def set_bucket_type_props(self, transport, bucket_type, props): _validate_bucket_props(props) return transport.set_bucket_type_props(bucket_type, props)
[ "\n set_bucket_type_props(bucket_type, props)\n\n Sets properties for the given bucket-type.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param bucket_type: the bucket-type whose properties will be set\n ...
Please provide a description of the function:def get_keys(self, transport, bucket, timeout=None): if not riak.disable_list_exceptions: raise ListError() _validate_timeout(timeout) return transport.get_keys(bucket, timeout=timeout)
[ "\n get_keys(bucket, timeout=None)\n\n Lists all keys in a bucket.\n\n .. warning:: Do not use this in production, as it requires\n traversing through all keys stored in a cluster.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails...
Please provide a description of the function:def stream_keys(self, bucket, timeout=None): if not riak.disable_list_exceptions: raise ListError() _validate_timeout(timeout) def make_op(transport): return transport.stream_keys(bucket, timeout=timeout) fo...
[ "\n Lists all keys in a bucket via a stream. This is a generator\n method which should be iterated over.\n\n .. warning:: Do not use this in production, as it requires\n traversing through all keys stored in a cluster.\n\n The caller should explicitly close the returned iterato...
Please provide a description of the function:def put(self, transport, robj, w=None, dw=None, pw=None, return_body=None, if_none_match=None, timeout=None): _validate_timeout(timeout) return transport.put(robj, w=w, dw=dw, pw=pw, return_body=return_body, ...
[ "\n put(robj, w=None, dw=None, pw=None, return_body=None,\\\n if_none_match=None, timeout=None)\n\n Stores an object in the Riak cluster.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param robj: th...
Please provide a description of the function:def ts_describe(self, transport, table): t = table if isinstance(t, six.string_types): t = Table(self, table) return transport.ts_describe(t)
[ "\n ts_describe(table)\n\n Retrieve a time series table description from the Riak cluster.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param table: The timeseries table.\n :type table: string or :clas...
Please provide a description of the function:def ts_get(self, transport, table, key): t = table if isinstance(t, six.string_types): t = Table(self, table) return transport.ts_get(t, key)
[ "\n ts_get(table, key)\n\n Retrieve timeseries value by key\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param table: The timeseries table.\n :type table: string or :class:`Table <riak.table.Table>`\n ...
Please provide a description of the function:def ts_query(self, transport, table, query, interpolations=None): t = table if isinstance(t, six.string_types): t = Table(self, table) return transport.ts_query(t, query, interpolations)
[ "\n ts_query(table, query, interpolations=None)\n\n Queries time series data in the Riak cluster.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param table: The timeseries table.\n :type table: string o...
Please provide a description of the function:def ts_stream_keys(self, table, timeout=None): if not riak.disable_list_exceptions: raise ListError() t = table if isinstance(t, six.string_types): t = Table(self, table) _validate_timeout(timeout) r...
[ "\n Lists all keys in a time series table via a stream. This is a\n generator method which should be iterated over.\n\n The caller should explicitly close the returned iterator,\n either using :func:`contextlib.closing` or calling ``close()``\n explicitly. Consuming the entire ite...
Please provide a description of the function:def get(self, transport, robj, r=None, pr=None, timeout=None, basic_quorum=None, notfound_ok=None, head_only=False): _validate_timeout(timeout) if not isinstance(robj.key, six.string_types): raise TypeError( 'k...
[ "\n get(robj, r=None, pr=None, timeout=None)\n\n Fetches the contents of a Riak object.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param robj: the object to fetch\n :type robj: RiakObject\n :p...
Please provide a description of the function:def delete(self, transport, robj, rw=None, r=None, w=None, dw=None, pr=None, pw=None, timeout=None): _validate_timeout(timeout) return transport.delete(robj, rw=rw, r=r, w=w, dw=dw, pr=pr, pw=pw, timeout...
[ "\n delete(robj, rw=None, r=None, w=None, dw=None, pr=None, pw=None,\\\n timeout=None)\n\n Deletes an object from Riak.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param robj: the object to del...
Please provide a description of the function:def mapred(self, transport, inputs, query, timeout): _validate_timeout(timeout) return transport.mapred(inputs, query, timeout)
[ "\n mapred(inputs, query, timeout)\n\n Executes a MapReduce query.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param inputs: the input list/structure\n :type inputs: list, dict\n :param query: ...
Please provide a description of the function:def stream_mapred(self, inputs, query, timeout): _validate_timeout(timeout) def make_op(transport): return transport.stream_mapred(inputs, query, timeout) for phase, data in self._stream_with_retry(make_op): yield ph...
[ "\n Streams a MapReduce query as (phase, data) pairs. This is a\n generator method which should be iterated over.\n\n The caller should explicitly close the returned iterator,\n either using :func:`contextlib.closing` or calling ``close()``\n explicitly. Consuming the entire itera...
Please provide a description of the function:def create_search_index(self, transport, index, schema=None, n_val=None, timeout=None): return transport.create_search_index(index, schema, n_val, timeout)
[ "\n create_search_index(index, schema=None, n_val=None)\n\n Create a search index of the given name, and optionally set\n a schema. If no schema is set, the default will be used.\n\n :param index: the name of the index to create\n :type index: string\n :param schema: the sc...
Please provide a description of the function:def fulltext_search(self, transport, index, query, **params): return transport.search(index, query, **params)
[ "\n fulltext_search(index, query, **params)\n\n Performs a full-text search query.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param index: the bucket/index to search over\n :type index: string\n ...
Please provide a description of the function:def fulltext_delete(self, transport, index, docs=None, queries=None): transport.fulltext_delete(index, docs, queries)
[ "\n fulltext_delete(index, docs=None, queries=None)\n\n .. deprecated:: 2.1.0 (Riak 2.0)\n Manual index maintenance is not supported for\n :ref:`Riak Search 2.0 <yz-label>`.\n\n Removes documents from the full-text index.\n\n .. note:: This request is automatically re...
Please provide a description of the function:def multiget(self, pairs, **params): if self._multiget_pool: params['pool'] = self._multiget_pool return riak.client.multi.multiget(self, pairs, **params)
[ "Fetches many keys in parallel via threads.\n\n :param pairs: list of bucket_type/bucket/key tuple triples\n :type pairs: list\n :param params: additional request flags, e.g. r, pr\n :type params: dict\n :rtype: list of :class:`RiakObjects <riak.riak_object.RiakObject>`,\n ...
Please provide a description of the function:def multiput(self, objs, **params): if self._multiput_pool: params['pool'] = self._multiput_pool return riak.client.multi.multiput(self, objs, **params)
[ "\n Stores objects in parallel via threads.\n\n :param objs: the objects to store\n :type objs: list of `RiakObject <riak.riak_object.RiakObject>`\n :param params: additional request flags, e.g. w, dw, pw\n :type params: dict\n :rtype: list of boolean or\n :class...
Please provide a description of the function:def get_counter(self, transport, bucket, key, r=None, pr=None, basic_quorum=None, notfound_ok=None): return transport.get_counter(bucket, key, r=r, pr=pr)
[ "get_counter(bucket, key, r=None, pr=None, basic_quorum=None,\\\n notfound_ok=None)\n\n Gets the value of a counter.\n\n .. deprecated:: 2.1.0 (Riak 2.0) Riak 1.4-style counters are\n deprecated in favor of the :class:`~riak.datatypes.Counter`\n datatype.\n\n ...
Please provide a description of the function:def update_counter(self, bucket, key, value, w=None, dw=None, pw=None, returnvalue=False): if not isinstance(value, six.integer_types): raise TypeError("Counter update amount must be an integer") if value == 0: ...
[ "\n update_counter(bucket, key, value, w=None, dw=None, pw=None,\\\n returnvalue=False)\n\n .. deprecated:: 2.1.0 (Riak 2.0) Riak 1.4-style counters are\n deprecated in favor of the :class:`~riak.datatypes.Counter`\n datatype.\n\n Updates a counter by t...
Please provide a description of the function:def fetch_datatype(self, bucket, key, r=None, pr=None, basic_quorum=None, notfound_ok=None, timeout=None, include_context=None): dtype, value, context = self._fetch_datatype( bucket, key, r=r, pr=pr, ...
[ "\n Fetches the value of a Riak Datatype.\n\n .. note:: This request is automatically retried :attr:`retries`\n times if it fails due to network error.\n\n :param bucket: the bucket of the datatype, which must belong to a\n :class:`~riak.bucket.BucketType`\n :type buck...
Please provide a description of the function:def update_datatype(self, datatype, w=None, dw=None, pw=None, return_body=None, timeout=None, include_context=None): _validate_timeout(timeout) with self._transport() as transport: return t...
[ "\n Sends an update to a Riak Datatype to the server. This operation is not\n idempotent and so will not be retried automatically.\n\n :param datatype: the datatype with pending updates\n :type datatype: :class:`~riak.datatypes.Datatype`\n :param w: the write quorum\n :type...
Please provide a description of the function:def _fetch_datatype(self, transport, bucket, key, r=None, pr=None, basic_quorum=None, notfound_ok=None, timeout=None, include_context=None): _validate_timeout(timeout) return transport.fetch_datatype(b...
[ "\n _fetch_datatype(bucket, key, r=None, pr=None, basic_quorum=None,\n notfound_ok=None, timeout=None, include_context=None)\n\n\n Fetches the value of a Riak Datatype as raw data. This is used\n internally to update already reified Datatype objects. Use the\n publi...
Please provide a description of the function:def _non_connect_send_recv(self, msg_code, data=None): self._non_connect_send_msg(msg_code, data) return self._recv_msg()
[ "\n Similar to self._send_recv, but doesn't try to initiate a connection,\n thus preventing an infinite loop.\n " ]
Please provide a description of the function:def _non_connect_send_msg(self, msg_code, data): try: self._socket.sendall(self._encode_msg(msg_code, data)) except (IOError, socket.error) as e: if e.errno == errno.EPIPE: raise ConnectionClosed(e) ...
[ "\n Similar to self._send, but doesn't try to initiate a connection,\n thus preventing an infinite loop.\n " ]
Please provide a description of the function: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() if not self._auth(): raise ...
[ "\n Initialize a secure connection to the server.\n " ]
Please provide a description of the function:def _starttls(self): resp_code, _ = self._non_connect_send_recv( riak.pb.messages.MSG_CODE_START_TLS) if resp_code == riak.pb.messages.MSG_CODE_START_TLS: return True else: return False
[ "\n Exchange a STARTTLS message with Riak to initiate secure communications\n return True is Riak responds with a STARTTLS response, False otherwise\n " ]
Please provide a description of the function:def _auth(self): codec = PbufCodec() username = self._client._credentials.username password = self._client._credentials.password if not password: password = '' msg = codec.encode_auth(username, password) re...
[ "\n Perform an authorization request against Riak\n returns True upon success, False otherwise\n Note: Riak will sleep for a short period of time upon a failed\n auth request/response to prevent denial of service attacks\n " ]
Please provide a description of the function:def _recv_msg(self, mid_stream=False): try: msgbuf = self._recv_pkt() except BadResource as e: e.mid_stream = mid_stream raise except socket.timeout as e: # A timeout can leave the socket in an ...
[ "\n :param mid_stream: are we receiving in a streaming operation?\n :type mid_stream: boolean\n " ]
Please provide a description of the function: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(s...
[ "\n Closes the underlying socket of the PB connection.\n " ]
Please provide a description of the function: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 # create a new sibling inside an empty object. self.siblings = [RiakContent(...
[ "\n Delegates a property to the first sibling in a RiakObject, raising\n an error when the object is in conflict.\n " ]
Please provide a description of the function:def content_method(name): def _delegate(self, *args, **kwargs): if len(self.siblings) != 1: raise ConflictError() return getattr(self.siblings[0], name).__call__(*args, **kwargs) _delegate.__doc__ = getattr(RiakContent, name).__doc__...
[ "\n Delegates a method to the first sibling in a RiakObject, raising\n an error when the object is in conflict.\n " ]
Please provide a description of the function:def store(self, w=None, dw=None, pw=None, return_body=True, if_none_match=False, timeout=None): if len(self.siblings) != 1: raise ConflictError("Attempting to store an invalid object, " "resolve the s...
[ "\n Store the object in Riak. When this operation completes, the\n object could contain new metadata and possibly new data if Riak\n contains a newer version of the object according to the object's\n vector clock.\n\n :param w: W-value, wait for this many partitions to respond\n ...
Please provide a description of the function:def reload(self, r=None, pr=None, timeout=None, basic_quorum=None, notfound_ok=None, head_only=False): self.client.get(self, r=r, pr=pr, timeout=timeout, head_only=head_only) return self
[ "\n Reload the object from Riak. When this operation completes, the\n object could contain new metadata and a new value, if the object\n was updated in Riak since it was last retrieved.\n\n .. note:: Even if the key is not found in Riak, this will\n return a :class:`RiakObject`...
Please provide a description of the function:def delete(self, r=None, w=None, dw=None, pr=None, pw=None, timeout=None): self.client.delete(self, r=r, w=w, dw=dw, pr=pr, pw=pw, timeout=timeout) self.clear() return self
[ "\n Delete this object from Riak.\n\n :param r: R-value, wait for this many partitions to read object\n before performing the put\n :type r: integer\n :param w: W-value, wait for this many partitions to respond\n before returning to client.\n :type w: integer\n ...
Please provide a description of the function:def add(self, arg1, arg2=None, arg3=None, bucket_type=None): mr = RiakMapReduce(self.client) mr.add(self.bucket.name, self.key, bucket_type=bucket_type) return mr.add(arg1, arg2, arg3, bucket_type)
[ "\n Start assembling a Map/Reduce operation.\n A shortcut for :meth:`~riak.mapreduce.RiakMapReduce.add`.\n\n :param arg1: the object or bucket to add\n :type arg1: RiakObject, string\n :param arg2: a key or list of keys to add (if a bucket is\n given in arg1)\n :ty...