avg bucket aggregation.

@see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html

@param string      $name
@param string|null $bucketsPath

@return AvgBucket
558874
public function avg_bucket(string $name, string $bucketsPath = null): AvgBucket
    {
        return new AvgBucket($name, $bucketsPath);
    }
581714
private function getBuilder($bucketType)
    {
        if (!isset($this->builders[$bucketType])) {
            throw new \InvalidArgumentException("No builder found for aggregation type {$bucketType}.");
        }

        return $this->builders[$bucketType];
    }
859197
protected function _mkdir($path, $name) {
		
		$newkey = $this->_normpath($path);
		$newkey = preg_replace("/\/$/", "", $newkey);
		$newkey = "$newkey/$name/";

		try {
			$obj = $this->s3->PutObjectInline(array('Bucket' => $this->options['bucket'], 'Key' => $newkey , 'ContentLength' => 0, 'Data' => ''));
		} catch (Exception $e) {
		
		}
		
		if (isset($obj)) {
			return "$path/$name";
		}
		
		return false;
	}
590892
protected function getPath(BucketInterface $bucket, string $name): string
    {
        return $this->files->normalizePath(
            $this->options['home'] . '/' . $bucket->getOption('directory') . $name
        );
    }
401829
public function getBucket(string $name): array
    {
        if (!$this->hasBucket($name)) {
            throw new ConfigException("Undefined bucket `{$name}`");
        }

        $bucket = $this->config['buckets'][$name];

        if (!array_key_exists('options', $bucket)) {
            throw new ConfigException("Bucket `{$name}` must specify `options`");
        }

        if (!array_key_exists('prefix', $bucket)) {
            throw new ConfigException("Bucket `{$name}` must specify `prefix`");
        }

        if (!array_key_exists('server', $bucket)) {
            throw new ConfigException("Bucket `{$name}` must specify `server` name.");
        }

        return $bucket;
    }
400411
public function child($name)
    {
        $path = $this->normalize($name);

        $this->append($path);

        return $this;
    }
760315
public function buildBucket(BucketInterface $bucket)
    {
        if ($bucket->getType() !== BucketInterface::TYPE_DATE_HISTOGRAM) {
            throw new \InvalidArgumentException("Query builder : invalid aggregation type {$bucket->getType()}.");
        }

        $aggParams = [
            'field'         => $bucket->getField(),
            'interval'      => $bucket->getInterval(),
            'min_doc_count' => $bucket->getMinDocCount(),
        ];

        return ['date_histogram' => $aggParams];
    }
588997
private Bucket getCachedBucket(final String name) {
        Bucket cachedBucket = bucketCache.get(name);

        if(cachedBucket != null) {
            if (cachedBucket.isClosed()) {
                LOGGER.debug("Not returning cached bucket \"{}\", because it is closed.", name);
                bucketCache.remove(name);
            } else {
                LOGGER.debug("Returning still open, cached bucket \"{}\"", name);
                return cachedBucket;
            }
        }

        return null;
    }
489391
public function stats($name = null) {
		if ($name) {
			return isset($this->_stats[$name]) ? $this->_stats[$name] : null;
		}
		return $this->_stats;
	}
896271
public static function create($name)
    {
        if (!isset(self::$_pool[$name])) {
            $classname = self::__getClassName($name);
            $path = self::__getDriverPath($name);

            if (!is_file($path)) {
                $errMsg = __('Could not find extension %s at location %s.', array(
                    '<code>' . $name . '</code>',
                    '<code>' . str_replace(DOCROOT . '/', '', $path) . '</code>'
                ));
                try {
                    Symphony::Engine()->throwCustomError(
                        $errMsg,
                        __('Symphony Extension Missing Error'),
                        Page::HTTP_STATUS_ERROR,
                        'missing_extension',
                        array(
                            'name' => $name,
                            'path' => $path
                        )
                    );
                } catch (Exception $ex) {
                    throw new Exception($errMsg, 0, $ex);
                }
            }

            if (!class_exists($classname)) {
                require_once($path);
            }

            // Create the extension object
            self::$_pool[$name] = new $classname(array());
        }

        return self::$_pool[$name];
    }
1327998
protected function refreshPermissions(BucketInterface $bucket, string $name): bool
    {
        if (!function_exists('ssh2_sftp_chmod')) {
            return true;
        }

        return ssh2_sftp_chmod(
            $this->conn,
            $this->castPath($bucket, $name),
            $bucket->getOption('mode', FilesInterface::RUNTIME)
        );
    }
333587
private static function statBase($bucketName, $path)
    {
        $path = self::cosUrlEncode($path);
        $expired = self::time() + self::EXPIRED_SECONDS;
        $url = self::generateResUrl($bucketName, $path);
        $sign = Auth::appSign($expired, $bucketName);

        $data = [
            'op' => 'stat',
        ];

        $url = $url.'?'.http_build_query($data);

        $req = [
            'url'     => $url,
            'method'  => 'get',
            'timeout' => self::$timeout,
            'header'  => [
                'Authorization:'.$sign,
            ],
        ];

        return self::sendRequest($req);
    }
186794
public static function statFolder($bucketName, $path)
    {
        $path = self::normalizerPath($path, true);

        return self::statBase($bucketName, $path);
    }
1165950
func (a *AvgBucketAggregation) BucketsPath(bucketsPaths ...string) *AvgBucketAggregation {
	a.bucketsPaths = append(a.bucketsPaths, bucketsPaths...)
	return a
}
881475
public function addFolder($path, $name = null)
    {
        $folders = is_string($name) ? [$name => $path] : [$path];
        $this->finder()->in($folders);

        return $this;
    }
566192
func (a *CumulativeSumAggregation) BucketsPath(bucketsPaths ...string) *CumulativeSumAggregation {
	a.bucketsPaths = append(a.bucketsPaths, bucketsPaths...)
	return a
}
453311
protected function ensureLocation(BucketInterface $bucket, string $name): string
    {
        $directory = dirname($this->getPath($bucket, $name));
        $mode = $bucket->getOption('mode', FilesInterface::RUNTIME);

        try {
            if (ftp_chdir($this->conn, $directory)) {
                ftp_chmod($this->conn, $mode | 0111, $directory);

                return $this->getPath($bucket, $name);
            }
        } catch (\Exception $e) {
            //Directory has to be created
        }

        ftp_chdir($this->conn, $this->options['home']);

        $directories = explode('/', substr($directory, strlen($this->options['home'])));
        foreach ($directories as $directory) {
            if (!$directory) {
                continue;
            }

            try {
                ftp_chdir($this->conn, $directory);
            } catch (\Exception $e) {
                ftp_mkdir($this->conn, $directory);
                ftp_chmod($this->conn, $mode | 0111, $directory);
                ftp_chdir($this->conn, $directory);
            }
        }

        return $this->getPath($bucket, $name);
    }