Increment the bucket count based on a given value from the user
434067
def increment_bucket_count(self, value):
        """"""
        if len(self._bounds) == 0:
            self._counts_per_bucket[0] += 1
            return 0

        for ii, bb in enumerate(self._bounds):
            if value < bb:
                self._counts_per_bucket[ii] += 1
                return ii
        else:
            last_bucket_index = len(self._bounds)
            self._counts_per_bucket[last_bucket_index] += 1
            return last_bucket_index
1055195
function(transaction, bucket, key, values){
		contract(arguments)
			.params('array', 'string', 'string|number','string|array|number')
			.end()
		;
		
		var self = this;
		var table = '';
		values = Array.isArray(values) ? values : [values]; // we always want to have an array for values
		
		transaction.push(function(cb){
			
			if (bucket.indexOf('allows') != -1) {
				table = self.prefix + self.buckets.permissions;
				self.db
					.select('key', 'value')
					.from(table)
					.where({'key': bucket})
					.then(function(result) {
						var json = {};
						
						if (result.length === 0) {
							
							// if no results found do a fresh insert
							json[key] = values;
							return self.db(table)
								.insert({key: bucket, value: json})
							;
						} else {
							
							// if we have found the key in the table then lets refresh the data
							if (_.has(result[0].value, key)) {
								result[0].value[key] = _.union(values, result[0].value[key]);
							} else {
								result[0].value[key] = values;
							}
							
							return self.db(table)
								.where('key', bucket)
								.update({key: bucket, value: result[0].value})
							;
						}
					})
					.then(function() {
						cb(undefined);
					})
				;
			} else {
				table = self.prefix + bucket;
				self.db
					.select('key', 'value')
					.from(table)
					.where({'key': key})
					.then(function(result) {
						
						if (result.length === 0) {
							
							// if no results found do a fresh insert
							return self.db(table)
								.insert({key: key, value: values})
							;
						} else {
							
							// if we have found the key in the table then lets refresh the data
							return self.db(table)
								.where('key', key)
								.update({value: _.union(values, result[0].value)})
							;
						}
					})
					.then(function() {
						cb(undefined);
					})
				;
			}
		});
	}
83585
function increment(redisClient, amount, keyPrepend, key, callback) {

    if (typeof amount !== 'number') {
        callback("increment amount is not number");
        return;
    }

    var multi = redisClient.multi();

    // Chain each redis command.
    incrementMinute(multi, amount, keyPrepend, key);
    incrementHour(multi, amount, keyPrepend, key);
    incrementDays(multi, amount, keyPrepend, key);
    incrementWeeks(multi, amount, keyPrepend, key);

    // Do it
    multi.exec(callback);

}
1259210
private static int getBucketCount(SimpleOrderedMap<Object> solrFacets, int defaultCount) {
        List<SimpleOrderedMap<Object>> solrBuckets = (List<SimpleOrderedMap<Object>>) solrFacets.get("buckets");
        if (solrBuckets == null) {
            for (int i = 0; i < solrFacets.size(); i++) {
                if (solrFacets.getName(i).equals("count")) {
                    return (int) solrFacets.getVal(i);
                }
            }
        }
        return defaultCount;
    }
624927
def record_value(self, value, count=1):
        '''
        '''
        if value < 0:
            return False
        counts_index = self._counts_index_for(value)
        if (counts_index < 0) or (self.counts_len <= counts_index):
            return False
        self.counts[counts_index] += count
        self.total_count += count
        self.min_value = min(self.min_value, value)
        self.max_value = max(self.max_value, value)
        return True
639577
def Increment(self, delta, fields=None):
    """"""
    if delta < 0:
      raise ValueError(
          "Counter increment should not be < 0 (received: %d)" % delta)

    self._metric_values[_FieldsToKey(fields)] = self.Get(fields=fields) + delta
1323136
def increment(self, n=1):
        
        with self.count.get_lock():
            self.count.value += n
86811
final public void increment(long incVal) {
        if (enabled) { // synchronize the update of lastValue
            lastSampleTime = updateIntegral();
            synchronized (this) {
                current += incVal;
            }
            updateWaterMark();
        } else {
            current += incVal;
        }
    }
1328761
def increment(self, delta=1):
        
        check_call(_LIB.MXProfileAdjustCounter(self.handle, int(delta)))
19670
def increment(key, delta=1, host=DEFAULT_HOST, port=DEFAULT_PORT):
    '''
    
    '''
    conn = _connect(host, port)
    _check_stats(conn)
    cur = get(key)

    if cur is None:
        raise CommandExecutionError('Key \'{0}\' does not exist'.format(key))
    elif not isinstance(cur, six.integer_types):
        raise CommandExecutionError(
            'Value for key \'{0}\' must be an integer to be '
            'incremented'.format(key)
        )

    try:
        return conn.incr(key, delta)
    except ValueError:
        raise SaltInvocationError('Delta value must be an integer')
54603
def add_sample(self, value, timestamp, attachments):
        """"""
        self._count_data += 1
        bucket = self.increment_bucket_count(value)

        if attachments is not None and self.exemplars is not None:
            self.exemplars[bucket] = Exemplar(value, timestamp, attachments)
        if self.count_data == 1:
            self._mean_data = value
            return

        old_mean = self._mean_data
        self._mean_data = self._mean_data + (
            (value - self._mean_data) / self._count_data)
        self._sum_of_sqd_deviations = self._sum_of_sqd_deviations + (
            (value - old_mean) * (value - self._mean_data))
713460
def increment(self, delta=1, text=None):
        """"""
        return self.update(value=min(self.max, self.value + delta), text=text)
385205
def get_buckets(min_length, max_length, bucket_count):
    '''
    
    '''
    if bucket_count <= 0:
        return [max_length]
    unit_length = int((max_length - min_length) // (bucket_count))
    buckets = [min_length + unit_length *
               (i + 1) for i in range(0, bucket_count)]
    buckets[-1] = max_length
    return buckets
81064
function swsBucketStats(buckets) {

    // Total count of events that have been observed
    this.count = 0;

    // Buckets boundaries, with default bucket values
    this.buckets = [5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000];

    // Values
    this.values = [0,0,0,0,0,0,0,0,0,0,0,0];

    if(typeof buckets === "object" ){
        if( Array.isArray(buckets)){
            this.buckets = Array.from(buckets);
            this.values = new Array(this.buckets.length);
            this.values.fill(0);
            this.values.push(0);
        }
    }

}
1211820
def increment_score(self, member, amount=1):
        
        return self.redis.zincrby(
            self.key, float(amount), self._pickle(member)
        )
1176670
def create(cls, bucket, key, value):
        """"""
        with db.session.begin_nested():
            obj = cls(
                bucket_id=as_bucket_id(bucket),
                key=key,
                value=value
            )
            db.session.add(obj)
        return obj
392221
def _handle_userCount(self, data):
        """"""

        self.room.user_count = data
        self.conn.enqueue_data("user_count", self.room.user_count)