_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q20000 | Query.setRescore | train | public function setRescore($rescore)
{
if (\is_array($rescore)) {
$buffer = [];
foreach ($rescore as $rescoreQuery) {
$buffer[] = $rescoreQuery;
}
| php | {
"resource": ""
} |
q20001 | Stats.refresh | train | public function refresh()
{
$this->_response = $this->getIndex()->requestEndpoint(new \Elasticsearch\Endpoints\Indices\Stats());
| php | {
"resource": ""
} |
q20002 | Query.setRescoreQuery | train | public function setRescoreQuery($rescoreQuery): Query
{
$rescoreQuery = BaseQuery::create($rescoreQuery);
$query = $this->getParam('query');
| php | {
"resource": ""
} |
q20003 | Query.setQueryWeight | train | public function setQueryWeight(float $weight): Query
{
$query = $this->getParam('query');
$query['query_weight'] | php | {
"resource": ""
} |
q20004 | Query.setRescoreQueryWeight | train | public function setRescoreQueryWeight(float $weight): Query
{
$query = $this->getParam('query');
$query['rescore_query_weight'] | php | {
"resource": ""
} |
q20005 | Util.escapeDateMath | train | public static function escapeDateMath($requestUri)
{
if (empty($requestUri)) {
return $requestUri;
}
// Check if date math if used at all. Find last '>'. E.g. /<log-{now/d}>,log-2011.12.01/log/_refresh
$pos1 = \strrpos($requestUri, '>');
if (false === $pos1) {
... | php | {
"resource": ""
} |
q20006 | Util.convertRequestToCurlCommand | train | public static function convertRequestToCurlCommand(Request $request)
{
$message = 'curl -X'.\strtoupper($request->getMethod()).' ';
$message .= '\'http://'.$request->getConnection()->getHost().':'.$request->getConnection()->getPort().'/';
| php | {
"resource": ""
} |
q20007 | Response.getError | train | public function getError()
{
$error = $this->getFullError();
if (!$error) {
return '';
}
if (\is_string($error)) {
return $error;
}
$rootError = $error;
if (isset($error['root_cause'][0])) {
| php | {
"resource": ""
} |
q20008 | Response.isOk | train | public function isOk()
{
$data = $this->getData();
// Bulk insert checks. Check every item
if (isset($data['status'])) {
return $data['status'] >= 200 && $data['status'] <= 300;
}
if (isset($data['items'])) {
if (isset($data['errors']) && true === $d... | php | {
"resource": ""
} |
q20009 | Response.getData | train | public function getData()
{
if (null == $this->_response) {
$response = $this->_responseString;
try {
if ($this->getJsonBigintConversion()) {
$response = JSON::parse($response, true, 512, JSON_BIGINT_AS_STRING);
} else {
... | php | {
"resource": ""
} |
q20010 | JSON.parse | train | public static function parse($args/* inherit from json_decode */)
{
// extract arguments
$args = \func_get_args();
// default to decoding into an assoc array
if (1 === \count($args)) {
$args[] = true;
}
// run decode
| php | {
"resource": ""
} |
q20011 | JSON.stringify | train | public static function stringify($args/* inherit from json_encode */)
{
// extract arguments
$args = \func_get_args();
// run encode and output
$string = \call_user_func_array('json_encode', | php | {
"resource": ""
} |
q20012 | Histogram.setOrder | train | public function setOrder(string $order, string $direction): self | php | {
"resource": ""
} |
q20013 | Terms.setTerms | train | public function setTerms(string $key, array $terms): self
{
$this->_key = $key;
$this->_terms = | php | {
"resource": ""
} |
q20014 | Terms.setTermsLookup | train | public function setTermsLookup(string $key, array $termsLookup): self
{
$this->_key = $key;
| php | {
"resource": ""
} |
q20015 | Query.match | train | public function match(string $field = null, $values = | php | {
"resource": ""
} |
q20016 | Query.common_terms | train | public function common_terms(string $field, string $query, float $cutoffFrequency): Common | php | {
"resource": ""
} |
q20017 | Query.fuzzy | train | public function fuzzy(string $fieldName = null, string $value | php | {
"resource": ""
} |
q20018 | Query.regexp | train | public function regexp(string $key = '', string $value = null, float $boost = 1.0): Regexp
{
| php | {
"resource": ""
} |
q20019 | Query.span_first | train | public function span_first($match = null, int $end = | php | {
"resource": ""
} |
q20020 | Query.span_near | train | public function span_near(array $clauses = [], int $slop = 1, bool $inOrder | php | {
"resource": ""
} |
q20021 | Query.span_containing | train | public function span_containing(AbstractSpanQuery $little = null, AbstractSpanQuery $big = null): SpanContaining
{ | php | {
"resource": ""
} |
q20022 | Query.span_within | train | public function span_within(AbstractSpanQuery $little = null, AbstractSpanQuery $big = null): SpanWithin
{ | php | {
"resource": ""
} |
q20023 | Query.wildcard | train | public function wildcard(string $key = '', string $value = null, float $boost = 1.0): Wildcard
{
| php | {
"resource": ""
} |
q20024 | Query.geo_distance | train | public function geo_distance(string $key, $location, string $distance): GeoDistance | php | {
"resource": ""
} |
q20025 | NullTransport.generateDefaultResponse | train | public function generateDefaultResponse(array $params): Response
{
$response = [
'took' => 0,
'timed_out' => false,
'_shards' => [
'total' => 0,
'successful' => 0,
'failed' => 0,
],
'hits' => [
... | php | {
"resource": ""
} |
q20026 | Param._convertArrayable | train | protected function _convertArrayable(array $array)
{
$arr = [];
foreach ($array as $key => $value) {
if ($value instanceof ArrayableInterface) {
$arr[$value instanceof NameableInterface ? $value->getName() : $key] = $value->toArray();
} elseif (\is_array($val... | php | {
"resource": ""
} |
q20027 | Param.getParam | train | public function getParam($key)
{
if (!$this->hasParam($key)) {
throw new InvalidException('Param | php | {
"resource": ""
} |
q20028 | Mapping.setParam | train | public function setParam(string $key, $value): Mapping
{
| php | {
"resource": ""
} |
q20029 | Mapping.toArray | train | public function toArray(): array
{
$type = $this->getType();
if (empty($type)) {
throw new InvalidException('Type has to | php | {
"resource": ""
} |
q20030 | Mapping.send | train | public function send(array $query = []): Response
{
$endpoint = new Put();
$endpoint->setBody($this->toArray()); | php | {
"resource": ""
} |
q20031 | Mapping.create | train | public static function create($mapping): Mapping
{
if (\is_array($mapping)) {
$mappingObject = new self();
$mappingObject->setProperties($mapping);
return $mappingObject;
}
if ($mapping instanceof | php | {
"resource": ""
} |
q20032 | ProcessingBuilder.buildResultSet | train | public function buildResultSet(Response $response, Query $query): ResultSet
{
$resultSet = $this->builder->buildResultSet($response, $query);
| php | {
"resource": ""
} |
q20033 | IpRange.addRange | train | public function addRange(string $fromValue = null, string $toValue = null): self
{
if (null === $fromValue && null === $toValue) {
throw new InvalidException('Either fromValue or toValue must be set. Both cannot be null.');
}
$range = [];
| php | {
"resource": ""
} |
q20034 | AbstractAggregation.addAggregation | train | public function addAggregation(AbstractAggregation $aggregation): self
{
if ($aggregation instanceof GlobalAggregation) {
throw new InvalidException('Global aggregators can | php | {
"resource": ""
} |
q20035 | ResponseSet.getError | train | public function getError(): string
{
foreach ($this->getBulkResponses() as $bulkResponse) {
| php | {
"resource": ""
} |
q20036 | GeoBoundingBox.addCoordinates | train | public function addCoordinates(string $key, array $coordinates): self
{
if (!isset($coordinates[0]) || !isset($coordinates[1])) {
throw new InvalidException('expected $coordinates to | php | {
"resource": ""
} |
q20037 | QueryBuilder.addDSL | train | public function addDSL(DSL $dsl)
{
$this->_facades[$dsl->getType()] = new | php | {
"resource": ""
} |
q20038 | Index.updateByQuery | train | public function updateByQuery($query, AbstractScript $script, array $options = [])
{
$query = Query::create($query)->getQuery();
$endpoint = new UpdateByQuery();
$body = ['query' => \is_array($query)
? $query
: $query->toArray(), ];
| php | {
"resource": ""
} |
q20039 | Index.forcemerge | train | public function forcemerge($args = [])
{
$endpoint = new ForceMerge();
$endpoint->setParams($args); | php | {
"resource": ""
} |
q20040 | Index.create | train | public function create(array $args = [], $options = null)
{
if (\is_bool($options) && $options) {
try {
$this->delete();
} catch (ResponseException $e) {
// Table can't be deleted, because doesn't exist
}
} elseif (\is_array($option... | php | {
"resource": ""
} |
q20041 | Index.addAlias | train | public function addAlias($name, $replace = false)
{
$data = ['actions' => []];
if ($replace) {
$status = new Status($this->getClient());
foreach ($status->getIndicesWithAlias($name) as $index) {
| php | {
"resource": ""
} |
q20042 | Index.removeAlias | train | public function removeAlias($name)
{
$endpoint = new \Elasticsearch\Endpoints\Indices\Alias\Delete(); | php | {
"resource": ""
} |
q20043 | Index.getAliases | train | public function getAliases()
{
$endpoint = new \Elasticsearch\Endpoints\Indices\Alias\Get();
$endpoint->setName('*');
$responseData = $this->requestEndpoint($endpoint)->getData();
if (!isset($responseData[$this->getName()])) {
return [];
}
| php | {
"resource": ""
} |
q20044 | Index.flush | train | public function flush(array $options = [])
{
$endpoint = new Flush();
| php | {
"resource": ""
} |
q20045 | Index.setSettings | train | public function setSettings(array $data)
{
$endpoint = new Put(); | php | {
"resource": ""
} |
q20046 | Index.requestEndpoint | train | public function requestEndpoint(AbstractEndpoint $endpoint)
{
$cloned = clone $endpoint;
| php | {
"resource": ""
} |
q20047 | Index.analyze | train | public function analyze(array $body, $args = [])
{
$endpoint = new Analyze();
$endpoint->setBody($body);
$endpoint->setParams($args);
$data = $this->requestEndpoint($endpoint)->getData();
// Support for "Explain" parameter, that returns a different response structure from E... | php | {
"resource": ""
} |
q20048 | DefaultBuilder.buildResultSet | train | public function buildResultSet(Response $response, Query $query): ResultSet
{
$results = $this->buildResults($response);
| php | {
"resource": ""
} |
q20049 | DefaultBuilder.buildResults | train | private function buildResults(Response $response): array
{
$data = $response->getData();
$results = [];
if (!isset($data['hits']['hits'])) {
| php | {
"resource": ""
} |
q20050 | Common.setQueryParam | train | public function setQueryParam(string $key, $value): self
{
| php | {
"resource": ""
} |
q20051 | AbstractTermsAggregation.setInclude | train | public function setInclude(string $pattern, string $flags = null): self
{
if (null === $flags) {
return $this->setParam('include', $pattern);
}
| php | {
"resource": ""
} |
q20052 | AbstractTermsAggregation.setExclude | train | public function setExclude(string $pattern, string $flags = null): self
{
if (null === $flags) {
return $this->setParam('exclude', $pattern);
}
| php | {
"resource": ""
} |
q20053 | FileStore.createCacheFile | train | protected function createCacheFile()
{
$this->createCacheDir();
$cacheFilePath = $this->getCacheFile();
| php | {
"resource": ""
} |
q20054 | FileStore.put | train | public function put(string $path, string $contents) : int | php | {
"resource": ""
} |
q20055 | FileStore.isValid | train | public function isValid(string $key) : bool
{
$key = $this->getActualCacheKey($key);
$meta = $this->getCacheContents()[$key] ?? [];
if (empty($meta['expires_at'])) {
return false;
| php | {
"resource": ""
} |
q20056 | FileStore.getCacheContents | train | public function getCacheContents()
{
$cacheFile = $this->getCacheFile();
if ( ! | php | {
"resource": ""
} |
q20057 | FileStore.getActualCacheKey | train | public function getActualCacheKey(string $key) : string
{
$prefix = $this->getPrefix();
if (false === strpos($key, $prefix)) {
| php | {
"resource": ""
} |
q20058 | Response.send | train | public function send($content, int $status = HttpResponse::HTTP_OK, array $headers = []) : HttpResponse
{
$headers = array_merge($this->headers, $headers);
if (is_array($content)) {
$content = json_encode($content);
} | php | {
"resource": ""
} |
q20059 | Client.file | train | public function file(string $file, string $name = null) : self
{
$this->filePath = $file;
if ( ! file_exists($file) || ! is_readable($file)) {
throw new FileException('Cannot read file: ' . $file);
}
| php | {
"resource": ""
} |
q20060 | Client.getChecksum | train | public function getChecksum() : string
{
if (empty($this->checksum)) {
| php | {
"resource": ""
} |
q20061 | Client.isExpired | train | public function isExpired() : bool
{
$expiresAt = $this->getCache()->get($this->getKey())['expires_at'] ?? null;
| php | {
"resource": ""
} |
q20062 | Client.seek | train | public function seek(int $offset) : self
{
$this->partialOffset = $offset;
| php | {
"resource": ""
} |
q20063 | Client.create | train | public function create(string $key) : string
{
$headers = [
'Upload-Length' => $this->fileSize,
'Upload-Key' => $key,
'Upload-Checksum' => $this->getUploadChecksumHeader(),
'Upload-Metadata' => 'filename ' . base64_encode($this->fileName),
];
... | php | {
"resource": ""
} |
q20064 | Client.concat | train | public function concat(string $key, ...$partials) : string
{
$response = $this->getClient()->post($this->apiPath, [
'headers' => [
'Upload-Length' => $this->fileSize,
'Upload-Key' => $key,
'Upload-Checksum' => $this->getUploadChecksumHeader(),
... | php | {
"resource": ""
} |
q20065 | Client.delete | train | public function delete()
{
try {
$this->getClient()->delete($this->getUrl());
} catch (ClientException $e) {
$statusCode = $e->getResponse()->getStatusCode();
if (HttpResponse::HTTP_NOT_FOUND === | php | {
"resource": ""
} |
q20066 | Client.partial | train | protected function partial(bool $state = true)
{
$this->partial = $state;
if ( ! $this->partial) {
return;
}
$key = $this->getKey();
| php | {
"resource": ""
} |
q20067 | Client.handleClientException | train | protected function handleClientException(ClientException $e)
{
$statusCode = $e->getResponse()->getStatusCode();
if (HttpResponse::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE === $statusCode) {
return new FileException('The uploaded file is corrupt.');
}
if (HttpResponse::HTTP... | php | {
"resource": ""
} |
q20068 | Client.getData | train | protected function getData(int $offset, int $bytes) : string
{
$file = new File;
$handle = $file->open($this->getFilePath(), $file::READ_BINARY);
$file->seek($handle, $offset);
| php | {
"resource": ""
} |
q20069 | File.setMeta | train | public function setMeta(int $offset, int $fileSize, string $filePath, string $location = null) : self
{
$this->offset = $offset;
$this->fileSize = | php | {
"resource": ""
} |
q20070 | File.details | train | public function details() : array
{
$now = Carbon::now();
return [
'name' => $this->name,
'size' => $this->fileSize,
'offset' => $this->offset,
'checksum' => $this->checksum,
'location' => $this->location,
| php | {
"resource": ""
} |
q20071 | File.upload | train | public function upload(int $totalBytes) : int
{
if ($this->offset === $totalBytes) {
return $this->offset;
}
$input = $this->open($this->getInputStream(), self::READ_BINARY);
$output = $this->open($this->getFilePath(), self::APPEND_BINARY);
$key = $this->getK... | php | {
"resource": ""
} |
q20072 | File.open | train | public function open(string $filePath, string $mode)
{
$this->exists($filePath, $mode);
$ptr = @fopen($filePath, $mode);
if (false === $ptr) {
| php | {
"resource": ""
} |
q20073 | File.exists | train | public function exists(string $filePath, string $mode = self::READ_BINARY) : bool
{
if (self::INPUT_STREAM === $filePath) {
return true;
}
if (self::READ_BINARY === $mode | php | {
"resource": ""
} |
q20074 | File.seek | train | public function seek($handle, int $offset, int $whence = SEEK_SET) : int
{
$position = fseek($handle, $offset, $whence);
if (-1 === $position) {
| php | {
"resource": ""
} |
q20075 | File.read | train | public function read($handle, int $chunkSize) : string
{
$data = fread($handle, $chunkSize);
if (false === $data) {
| php | {
"resource": ""
} |
q20076 | File.write | train | public function write($handle, string $data, $length = null) : int
{
$bytesWritten = is_int($length) ? fwrite($handle, $data, $length) | php | {
"resource": ""
} |
q20077 | File.merge | train | public function merge(array $files) : int
{
$destination = $this->getFilePath();
$firstFile = array_shift($files);
// First partial file can directly be copied.
$this->copy($firstFile['file_path'], $destination);
$this->offset = $firstFile['offset'];
$this->file... | php | {
"resource": ""
} |
q20078 | File.copy | train | public function copy(string $source, string $destination) : bool
{
$status = @copy($source, $destination);
if (false === $status) {
| php | {
"resource": ""
} |
q20079 | File.deleteFiles | train | public function deleteFiles(array $files) : bool
{
if (empty($files)) {
return false;
}
$status = true;
foreach ($files as $file) {
if (file_exists($file)) {
| php | {
"resource": ""
} |
q20080 | Request.allowedHttpVerbs | train | public function allowedHttpVerbs() : array
{
return [
HttpRequest::METHOD_GET,
HttpRequest::METHOD_POST,
HttpRequest::METHOD_PATCH,
| php | {
"resource": ""
} |
q20081 | Request.extractFromHeader | train | public function extractFromHeader(string $key, string $value) : array
{
$meta = $this->header($key);
if (false !== strpos($meta, $value)) {
| php | {
"resource": ""
} |
q20082 | Request.extractMeta | train | public function extractMeta(string $requestedKey) : string
{
$uploadMetaData = $this->request->headers->get('Upload-Metadata');
if (empty($uploadMetaData)) {
return '';
}
$uploadMetaDataChunks = explode(',', $uploadMetaData);
foreach ($uploadMetaDataChunks as $... | php | {
"resource": ""
} |
q20083 | AbstractCache.deleteAll | train | public function deleteAll(array $keys) : bool
{
if (empty($keys)) {
return false;
}
$status = true;
foreach ($keys as $key) {
| php | {
"resource": ""
} |
q20084 | Middleware.add | train | public function add(...$middleware) : self
{
foreach ($middleware as $m) {
if ($m instanceof TusMiddleware) {
$this->globalMiddleware[get_class($m)] = $m;
} elseif (is_string($m)) {
| php | {
"resource": ""
} |
q20085 | Middleware.skip | train | public function skip(...$middleware) : self
{
foreach ($middleware as | php | {
"resource": ""
} |
q20086 | Server.getChecksumAlgorithm | train | public function getChecksumAlgorithm() : ?string
{
$checksumHeader = $this->getRequest()->header('Upload-Checksum');
if (empty($checksumHeader)) {
| php | {
"resource": ""
} |
q20087 | Server.getUploadKey | train | public function getUploadKey()
{
if ( ! empty($this->uploadKey)) {
return $this->uploadKey;
}
$key = $this->getRequest()->header('Upload-Key') ?? Uuid::uuid4()->toString();
if (empty($key)) {
| php | {
"resource": ""
} |
q20088 | Server.serve | train | public function serve()
{
$this->applyMiddleware();
$requestMethod = $this->getRequest()->method();
if ( ! in_array($requestMethod, $this->getRequest()->allowedHttpVerbs())) {
return $this->response->send(null, HttpResponse::HTTP_METHOD_NOT_ALLOWED);
}
$clientV... | php | {
"resource": ""
} |
q20089 | Server.applyMiddleware | train | protected function applyMiddleware()
{
$middleware = $this->middleware()->list();
foreach ($middleware as $m) {
| php | {
"resource": ""
} |
q20090 | Server.handleOptions | train | protected function handleOptions() : HttpResponse
{
$headers = [
'Allow' => implode(',', $this->request->allowedHttpVerbs()),
'Tus-Version' => self::TUS_PROTOCOL_VERSION,
'Tus-Extension' => implode(',', self::TUS_EXTENSIONS),
'Tus-Checksum-Algorithm' => $this-... | php | {
"resource": ""
} |
q20091 | Server.handleHead | train | protected function handleHead() : HttpResponse
{
$key = $this->request->key();
if ( ! $fileMeta = $this->cache->get($key)) {
return $this->response->send(null, HttpResponse::HTTP_NOT_FOUND);
}
$offset = $fileMeta['offset'] ?? false;
if (false === $offset) | php | {
"resource": ""
} |
q20092 | Server.handlePost | train | protected function handlePost() : HttpResponse
{
$fileName = $this->getRequest()->extractFileName();
$uploadType = self::UPLOAD_TYPE_NORMAL;
if (empty($fileName)) {
return $this->response->send(null, HttpResponse::HTTP_BAD_REQUEST);
}
if ( ! $this->verifyUploa... | php | {
"resource": ""
} |
q20093 | Server.handleConcatenation | train | protected function handleConcatenation(string $fileName, string $filePath) : HttpResponse
{
$partials = $this->getRequest()->extractPartials();
$uploadKey = $this->getUploadKey();
$files = $this->getPartialsMeta($partials);
$filePaths = array_column($files, 'file_path');
... | php | {
"resource": ""
} |
q20094 | Server.handlePatch | train | protected function handlePatch() : HttpResponse
{
$uploadKey = $this->request->key();
if ( ! $meta = $this->cache->get($uploadKey)) {
return $this->response->send(null, HttpResponse::HTTP_GONE);
}
$status = $this->verifyPatchRequest($meta);
if (HttpResponse::HT... | php | {
"resource": ""
} |
q20095 | Server.verifyPatchRequest | train | protected function verifyPatchRequest(array $meta) : int
{
if (self::UPLOAD_TYPE_FINAL === $meta['upload_type']) {
return HttpResponse::HTTP_FORBIDDEN;
}
$uploadOffset = $this->request->header('upload-offset');
if ($uploadOffset && $uploadOffset !== (string) $meta['offs... | php | {
"resource": ""
} |
q20096 | Server.handleDownload | train | protected function handleDownload()
{
$path = explode('/', str_replace('/get', '', $this->request->path()));
$key = end($path);
if ( ! $fileMeta = $this->cache->get($key)) {
return $this->response->send('404 upload not found.', HttpResponse::HTTP_NOT_FOUND);
}
... | php | {
"resource": ""
} |
q20097 | Server.handleDelete | train | protected function handleDelete() : HttpResponse
{
$key = $this->request->key();
$fileMeta = $this->cache->get($key);
$resource = $fileMeta['file_path'] ?? null;
if ( ! $resource) {
return $this->response->send(null, HttpResponse::HTTP_NOT_FOUND);
}
... | php | {
"resource": ""
} |
q20098 | Server.getHeadersForHeadRequest | train | protected function getHeadersForHeadRequest(array $fileMeta) : array
{
$headers = [
'Upload-Length' => (int) $fileMeta['size'],
'Upload-Offset' => (int) $fileMeta['offset'],
'Cache-Control' => 'no-store',
];
if (self::UPLOAD_TYPE_FINAL === $fileMeta['uplo... | php | {
"resource": ""
} |
q20099 | Server.buildFile | train | protected function buildFile(array $meta) : File
{
$file = new File($meta['name'], $this->cache);
if | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.