Store a batch of vectors in Redis.
        Stores vector and JSON-serializable data in bucket with specified key.
484813
def store_many_vectors(self, hash_name, bucket_keys, vs, data):
        
        with self.redis_object.pipeline() as pipeline:
            if data is None:
                data = [None] * len(vs)
            for bucket_key, data, v in zip(bucket_keys, data, vs):
                self._add_vector(hash_name, bucket_key, v, data, pipeline)
            pipeline.execute()
1332659
def hash_vector(self, v, querying=False):
        

        bucket_keys = []

        if querying:
            # If we are querying, use the permuted indexes to get bucket keys
            for child_hash in self.child_hashes:
                lshash = child_hash['hash']
                # Make sure the permuted index for this hash is existing
                if not lshash.hash_name in self.permutation.permutedIndexs:
                    raise AttributeError('Permuted index is not existing for hash with name %s' % lshash.hash_name)

                # Get regular bucket keys from hash
                for bucket_key in lshash.hash_vector(v, querying):
                    #print 'Regular bucket key %s' % bucket_key
                    # Get neighbour keys from permuted index
                    neighbour_keys = self.permutation.get_neighbour_keys(lshash.hash_name,bucket_key)
                    # Add them to result, but prefix with hash name
                    for n in neighbour_keys:
                        bucket_keys.append(lshash.hash_name+'_'+n)

        else:
            # If we are indexing (storing) just use child hashes without permuted index
            for child_hash in self.child_hashes:
                lshash = child_hash['hash']

                # Get regular bucket keys from hash
                for bucket_key in lshash.hash_vector(v, querying):
                    # Register bucket key in child hash dict
                    child_hash['bucket_keys'][bucket_key] = bucket_key
                    # Append bucket key to result prefixed with child hash name
                    bucket_keys.append(lshash.hash_name+'_'+bucket_key)

        # Return all the bucket keys
        return bucket_keys
91962
def store_vector(self, hash_name, bucket_key, v, data):
        
        mongo_key = self._format_mongo_key(hash_name, bucket_key)

        val_dict = {}
        val_dict['lsh'] = mongo_key

        # Depending on type (sparse or not) fill value dict
        if scipy.sparse.issparse(v):
            # Make sure that we are using COO format (easy to handle)
            if not scipy.sparse.isspmatrix_coo(v):
                v = scipy.sparse.coo_matrix(v)

            # Construct list of [index, value] items,
            # one for each non-zero element of the sparse vector
            encoded_values = []

            for k in range(v.data.size):
                row_index = v.row[k]
                value = v.data[k]
                encoded_values.append([int(row_index), value])

            val_dict['sparse'] = 1
            val_dict['nonzeros'] = encoded_values
            val_dict['dim'] = v.shape[0]
        else:
            # Make sure it is a 1d vector
            v = numpy.reshape(v, v.shape[0])
            val_dict['vector'] = v.tostring()

        val_dict['dtype'] = v.dtype.name

        # Add data if set
        if data is not None:
            val_dict['data'] = data

        # Push JSON representation of dict to end of bucket list
        self.mongo_object.insert_one(val_dict)
1041471
def store_json(self, filename, dict_to_store):
        """"""
        epoch = int(time.time() * (10 ** 6))
        s3_key = Key(self.bucket)
        s3_key.key = os.path.join(
            '/data',
            "%s_%s.json" % (filename, epoch)
        )
        s3_key.set_contents_from_string(
            json.dumps(dict_to_store),
            headers={'Content-Type': 'application/json; charset=UTF-8'},
            replace=True
        )
385472
def copy(self, key=None):
        
        other = self.__class__(
            self.__iter__(),
            self.maxlen,
            redis=self.redis,
            key=key,
            writeback=self.writeback,
        )

        return other
559716
def sunionstore(self, dest, keys, *args):
        """"""
        result = self.sunion(keys, *args)
        self.redis[self._encode(dest)] = result
        return len(result)
554441
def save(self):
        '''  '''
        redis = type(self).get_redis()
        pipe = to_pipeline(redis)

        pipe.hset(self.key(), 'id', self.id)

        for fieldname, field in self.proxy:
            if not isinstance(field, Relation):
                field.save(getattr(self, fieldname), pipe, commit=False)

        pipe.sadd(type(self).members_key(), self.id)

        pipe.execute()

        if self.notify:
            data = json.dumps({
                'event': 'create' if not self._persisted else 'update',
                'data': self.to_json(),
            })
            redis.publish(type(self).cls_key(), data)
            redis.publish(self.key(), data)

        self._persisted = True

        return self
34126
def populate(self, deserialized_txs=None, filename=None, retry=None):
        
        if not deserialized_txs:
            raise BatchError("Failed to populate batch. There are no objects to add.")
        self.filename = filename
        if not self.filename:
            raise BatchError("Invalid filename. Got None")
        try:
            for deserialized_tx in deserialized_txs:
                self.peek(deserialized_tx)
                self.objects.append(deserialized_tx.object)
                break
            for deserialized_tx in deserialized_txs:
                self.objects.append(deserialized_tx.object)
        except DeserializationError as e:
            raise BatchDeserializationError(e) from e
        except JSONFileError as e:
            raise BatchDeserializationError(e) from e
1006830
def store_data(self, data, datatype, mode, disp, clobber=False):
        

        # Imports
        import h5py as h5
        from ..error import RepoError as RErr
        from ..const import EnumDispDirection as _E_DD
        from ..const import EnumAnharmRepoData

        # Must be valid mode
        if not (mode >=0 and isinstance(mode, int)):
            raise ValueError("Mode must be a non-negative integer")
        ## end if

        # Must be a valid disp direction
        if not disp in _E_DD:
            raise ValueError("'{0}' is not a valid " +
                    "displacement enum value".format(disp))
        ## end if

        # Must be a valid repo data type
        if not datatype in EnumAnharmRepoData:
            raise ValueError("'{0}' is not a valid " +
                    "data type enum value".format(datatype))
        ## end if

        # Get the appropriate geom group name
        if disp == _E_DD.NO_DISP:
            grpname = self.G_geom_ref
        else:
            grpname = self.F_mode_fmt % (mode, self.dircode[disp])
        ## end if

        # Get the group, creating if absent
        try:
            grp = self._repo.require_group(grpname)
        except AttributeError:
            # Presume repo not open/attached
            raise RErr(RErr.STATUS,
                        "Cannot store; no repository open", "")
        ## end try

        # If dataset exists in repo group, obliterate or complain. Can't use
        #  'require_dataset' since the object could be changing dimension(s)
        #  and h5py can't do that
        if datatype in grp.keys():
            if clobber:
                grp.pop(datatype)
            else:
                raise RErr(RErr.DATA,
                        "Dataset to be stored exists and clobber == False",
                        self._repo.filename)
            ## end if
        ## end if

        # Store the new data. DOES NOT ENSURE CONSISTENCY with any
        #  other data in the repository.
        grp.create_dataset(datatype, data=data)

        # Set as dirty and flush the repo
        self.set_dirty(True)
        self._repo.flush()
778224
def store_data(data):
    
    with open(url_json_path) as json_file:
        try:
            json_file_data = load(json_file)
            json_file_data.update(data)
        except (AttributeError, JSONDecodeError):
            json_file_data = data
    with open(url_json_path, 'w') as json_file:
        dump(json_file_data, json_file, indent=4, sort_keys=True)
135760
def _store_object(self, obj_name, content, etag=None, chunked=False,
            chunk_size=None, headers=None):
        
        head_etag = headers.pop("ETag", "")
        if chunked:
            headers.pop("Content-Length", "")
            headers["Transfer-Encoding"] = "chunked"
        elif etag is None and content is not None:
            etag = utils.get_checksum(content)
        if etag:
            headers["ETag"] = etag
        if not headers.get("Content-Type"):
            headers["Content-Type"] = None
        uri = "/%s/%s" % (self.uri_base, obj_name)
        resp, resp_body = self.api.method_put(uri, data=content,
                headers=headers)
892069
function RedisJsonStorage(redis, preopts) {
  if (!(this instanceof RedisJsonStorage)) {
    return new RedisJsonStorage(redis, preopts);
  }

  RedisStorageRelyQ.call(this, redis, preopts);
}
797594
function RedisStorageRelyQ(redis, preopts) {
  Q.call(this, redis, preopts);

  this._storage_prefix = this._prefix + this._delimeter + 'jobs';
}
1285924
def redis_key(cls, key):
        
        keyspace = cls.keyspace
        tpl = cls.keyspace_template
        key = "%s" % key if keyspace is None else tpl % (keyspace, key)
        return cls.keyparse.encode(key)
927380
def store(key, value, mode = nil)
      if mode == :dup
        if value.is_a? Array
          Utilities.temp_list(value.size) do |list|
            list.push(*value) { |string| cast_value_in(string) }
            try(:putdup3, cast_key_in(key), list.pointer)
          end
        else
          try(:putdup, cast_key_in(key), cast_value_in(value))
        end
        value
      else
        super
      end
    end
89090
def set(self, key, value):
        """"""
        key = "{0}{1}".format(self.prefix, key)

        value = json.dumps(value, cls=NumpyEncoder)
        self.redis.set(key, value)
734115
def mapred(self, inputs, query, timeout=None):
        
        # Construct the job, optionally set the timeout...
        content = self._construct_mapred_json(inputs, query, timeout)

        # Do the request...
        url = self.mapred_path()
        headers = {'Content-Type': 'application/json'}
        status, headers, body = self._request('POST', url, headers, content)

        # Make sure the expected status code came back...
        if status != 200:
            raise RiakError(
                'Error running MapReduce operation. Headers: %s Body: %s' %
                (repr(headers), repr(body)))

        result = json.loads(bytes_to_str(body))
        return result