_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15400 | KeyManagementServiceGapicClient.keyRingName | train | public static function keyRingName($project, $location, $keyRing)
{
return self::getKeyRingNameTemplate()->render([
'project' => $project,
'location' => $location,
'key_ring' => $keyRing,
]);
} | php | {
"resource": ""
} |
q15401 | KeyManagementServiceGapicClient.setIamPolicy | train | public function setIamPolicy($resource, $policy, array $optionalArgs = [])
{
$request = new SetIamPolicyRequest();
$request->setResource($resource);
$request->setPolicy($policy);
$requestParams = new RequestParamsHeaderDescriptor([
'resource' => $request->getResource(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();
return $this->startCall(
'SetIamPolicy',
Policy::class,
$optionalArgs,
$request,
Call::UNARY_CALL,
'google.iam.v1.IAMPolicy'
)->wait();
} | php | {
"resource": ""
} |
q15402 | KeyManagementServiceGapicClient.getIamPolicy | train | public function getIamPolicy($resource, array $optionalArgs = [])
{
$request = new GetIamPolicyRequest();
$request->setResource($resource);
$requestParams = new RequestParamsHeaderDescriptor([
'resource' => $request->getResource(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();
return $this->startCall(
'GetIamPolicy',
Policy::class,
$optionalArgs,
$request,
Call::UNARY_CALL,
'google.iam.v1.IAMPolicy'
)->wait();
} | php | {
"resource": ""
} |
q15403 | ReadStream.getSizeFromMetadata | train | private function getSizeFromMetadata()
{
foreach ($this->stream->getMetadata('wrapper_data') as $value) {
if (substr($value, 0, 15) == "Content-Length:") {
return (int) substr($value, 16);
}
}
return 0;
} | php | {
"resource": ""
} |
q15404 | ReadStream.read | train | public function read($length)
{
$data = '';
do {
$moreData = $this->stream->read($length);
$data .= $moreData;
$readLength = strlen($moreData);
$length -= $readLength;
} while ($length > 0 && $readLength > 0);
return $data;
} | php | {
"resource": ""
} |
q15405 | CommuteFilter.setCommuteMethod | train | public function setCommuteMethod($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\CommuteMethod::class);
$this->commute_method = $var;
return $this;
} | php | {
"resource": ""
} |
q15406 | CommuteFilter.setRoadTraffic | train | public function setRoadTraffic($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\CommuteFilter_RoadTraffic::class);
$this->writeOneof(5, $var);
return $this;
} | php | {
"resource": ""
} |
q15407 | DocGenerator.generate | train | public function generate($basePath, $pretty)
{
$fileReflectorRegister = new ReflectorRegister();
$rootPath = $this->executionPath;
foreach ($this->files as $file) {
$currentFileArr = $this->isComponent
? explode("/$basePath/", $file)
: explode("$rootPath", $file);
if (isset($currentFileArr[1])) {
$currentFile = str_replace('src/', '', $currentFileArr[1]);
} else {
throw new \Exception(
sprintf('Failed to determine currentFile: %s', $file)
);
}
$isPhp = strrpos($file, '.php') == strlen($file) - strlen('.php');
$pathInfo = pathinfo($currentFile);
$servicePath = $pathInfo['dirname'] === '.'
? strtolower($pathInfo['filename'])
: strtolower($pathInfo['dirname'] . '/' . $pathInfo['filename']);
$id = $this->isComponent
? strtolower($basePath) . '/' . $servicePath
: $servicePath;
if ($isPhp) {
$parser = new CodeParser(
$file,
$fileReflectorRegister,
$rootPath,
$this->componentId,
$this->manifestPath,
$this->release,
$this->output,
$id,
$this->isComponent
);
} else {
$content = file_get_contents($file);
$parser = new MarkdownParser($currentFile, $content, $id);
}
$document = $parser->parse();
if ($document) {
$writer = new Writer($document, $this->outputPath, $pretty);
$writer->write($currentFile);
$this->types->addType([
'id' => $id,
'title' => $document['title'],
'contents' => $servicePath . '.json'
]);
}
}
} | php | {
"resource": ""
} |
q15408 | Dictionary.setWordList | train | public function setWordList($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CustomInfoType_Dictionary_WordList::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15409 | Dictionary.setCloudStoragePath | train | public function setCloudStoragePath($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CloudStoragePath::class);
$this->writeOneof(3, $var);
return $this;
} | php | {
"resource": ""
} |
q15410 | FieldFilter.setValue | train | public function setValue($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Firestore\V1beta1\Value::class);
$this->value = $var;
return $this;
} | php | {
"resource": ""
} |
q15411 | BigQueryClient.runQuery | train | public function runQuery(JobConfigurationInterface $query, array $options = [])
{
$queryResultsOptions = $this->pluckArray([
'maxResults',
'startIndex',
'timeoutMs',
'maxRetries'
], $options);
$queryResultsOptions['initialTimeoutMs'] = 10000;
$queryResults = $this->startQuery(
$query,
$options
)->queryResults($queryResultsOptions + $options);
$queryResults->waitUntilComplete();
return $queryResults;
} | php | {
"resource": ""
} |
q15412 | BigQueryClient.startQuery | train | public function startQuery(JobConfigurationInterface $query, array $options = [])
{
$config = $query->toArray();
$response = $this->connection->insertJob($config + $options);
return new Job(
$this->connection,
$config['jobReference']['jobId'],
$this->projectId,
$this->mapper,
$response
);
} | php | {
"resource": ""
} |
q15413 | BigQueryClient.jobs | train | public function jobs(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false);
return new ItemIterator(
new PageIterator(
function (array $job) {
return new Job(
$this->connection,
$job['jobReference']['jobId'],
$this->projectId,
$this->mapper,
$job
);
},
[$this->connection, 'listJobs'],
$options + ['projectId' => $this->projectId],
[
'itemsKey' => 'jobs',
'resultLimit' => $resultLimit
]
)
);
} | php | {
"resource": ""
} |
q15414 | BigQueryClient.datasets | train | public function datasets(array $options = [])
{
$resultLimit = $this->pluck('resultLimit', $options, false);
return new ItemIterator(
new PageIterator(
function (array $dataset) {
return new Dataset(
$this->connection,
$dataset['datasetReference']['datasetId'],
$this->projectId,
$this->mapper,
$dataset
);
},
[$this->connection, 'listDatasets'],
$options + ['projectId' => $this->projectId],
[
'itemsKey' => 'datasets',
'resultLimit' => $resultLimit
]
)
);
} | php | {
"resource": ""
} |
q15415 | BigQueryClient.getServiceAccount | train | public function getServiceAccount(array $options = [])
{
$resp = $this->connection->getServiceAccount($options + ['projectId' => $this->projectId]);
return $resp['email'];
} | php | {
"resource": ""
} |
q15416 | DominantColorsAnnotation.setColors | train | public function setColors($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\ColorInfo::class);
$this->colors = $arr;
return $this;
} | php | {
"resource": ""
} |
q15417 | Filter.setPropertyFilter | train | public function setPropertyFilter($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\PropertyFilter::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q15418 | ProfileQuery.setWorkExperienceFilter | train | public function setWorkExperienceFilter($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Talent\V4beta1\WorkExperienceFilter::class);
$this->work_experience_filter = $arr;
return $this;
} | php | {
"resource": ""
} |
q15419 | ProfileQuery.setApplicationDateFilters | train | public function setApplicationDateFilters($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Talent\V4beta1\ApplicationDateFilter::class);
$this->application_date_filters = $arr;
return $this;
} | php | {
"resource": ""
} |
q15420 | ProfileQuery.setApplicationOutcomeNotesFilters | train | public function setApplicationOutcomeNotesFilters($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Talent\V4beta1\ApplicationOutcomeNotesFilter::class);
$this->application_outcome_notes_filters = $arr;
return $this;
} | php | {
"resource": ""
} |
q15421 | ProfileQuery.setApplicationLastStageFilters | train | public function setApplicationLastStageFilters($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Talent\V4beta1\ApplicationLastStageFilter::class);
$this->application_last_stage_filters = $arr;
return $this;
} | php | {
"resource": ""
} |
q15422 | ProfileQuery.setApplicationJobFilters | train | public function setApplicationJobFilters($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Talent\V4beta1\ApplicationJobFilter::class);
$this->application_job_filters = $arr;
return $this;
} | php | {
"resource": ""
} |
q15423 | ProfileQuery.setApplicationStatusFilters | train | public function setApplicationStatusFilters($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Talent\V4beta1\ApplicationStatusFilter::class);
$this->application_status_filters = $arr;
return $this;
} | php | {
"resource": ""
} |
q15424 | TimeEvent.setAnnotation | train | public function setAnnotation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\Span_TimeEvent_Annotation::class);
$this->writeOneof(2, $var);
return $this;
} | php | {
"resource": ""
} |
q15425 | ListNotificationChannelsResponse.setNotificationChannels | train | public function setNotificationChannels($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\NotificationChannel::class);
$this->notification_channels = $arr;
return $this;
} | php | {
"resource": ""
} |
q15426 | LikelihoodAdjustment.setFixedLikelihood | train | public function setFixedLikelihood($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Dlp\V2\Likelihood::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15427 | SpannerGapicClient.databaseName | train | public static function databaseName($project, $instance, $database)
{
return self::getDatabaseNameTemplate()->render([
'project' => $project,
'instance' => $instance,
'database' => $database,
]);
} | php | {
"resource": ""
} |
q15428 | SpannerGapicClient.sessionName | train | public static function sessionName($project, $instance, $database, $session)
{
return self::getSessionNameTemplate()->render([
'project' => $project,
'instance' => $instance,
'database' => $database,
'session' => $session,
]);
} | php | {
"resource": ""
} |
q15429 | AppProfile.setMultiClusterRoutingUseAny | train | public function setMultiClusterRoutingUseAny($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\AppProfile_MultiClusterRoutingUseAny::class);
$this->writeOneof(5, $var);
return $this;
} | php | {
"resource": ""
} |
q15430 | AppProfile.setSingleClusterRouting | train | public function setSingleClusterRouting($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\AppProfile_SingleClusterRouting::class);
$this->writeOneof(6, $var);
return $this;
} | php | {
"resource": ""
} |
q15431 | DatastoreClient.allocateId | train | public function allocateId(Key $key, array $options = [])
{
$res = $this->allocateIds([$key], $options);
return $res[0];
} | php | {
"resource": ""
} |
q15432 | DatastoreClient.transaction | train | public function transaction(array $options = [])
{
$transaction = $this->operation->beginTransaction([
// if empty, force request to encode as {} rather than [].
'readWrite' => $this->pluck('transactionOptions', $options, false) ?: (object) []
], $options);
return new Transaction(
$this->operation,
$this->projectId,
$transaction
);
} | php | {
"resource": ""
} |
q15433 | DatastoreClient.readOnlyTransaction | train | public function readOnlyTransaction(array $options = [])
{
$transaction = $this->operation->beginTransaction([
// if empty, force request to encode as {} rather than [].
'readOnly' => $this->pluck('transactionOptions', $options, false) ?: (object) []
], $options);
return new ReadOnlyTransaction(
$this->operation,
$this->projectId,
$transaction
);
} | php | {
"resource": ""
} |
q15434 | DatastoreClient.insert | train | public function insert(EntityInterface $entity, array $options = [])
{
$res = $this->insertBatch([$entity], $options);
return $this->parseSingleMutationResult($res);
} | php | {
"resource": ""
} |
q15435 | DatastoreClient.update | train | public function update(EntityInterface $entity, array $options = [])
{
$res = $this->updateBatch([$entity], $options);
return $this->parseSingleMutationResult($res);
} | php | {
"resource": ""
} |
q15436 | DatastoreClient.upsert | train | public function upsert(EntityInterface $entity, array $options = [])
{
$res = $this->upsertBatch([$entity], $options);
return $this->parseSingleMutationResult($res);
} | php | {
"resource": ""
} |
q15437 | DatastoreClient.deleteBatch | train | public function deleteBatch(array $keys, array $options = [])
{
$options += [
'baseVersion' => null
];
$mutations = [];
foreach ($keys as $key) {
$mutations[] = $this->operation->mutation('delete', $key, Key::class, $options['baseVersion']);
}
return $this->operation->commit($mutations, $options);
} | php | {
"resource": ""
} |
q15438 | DatastoreClient.lookup | train | public function lookup(Key $key, array $options = [])
{
$res = $this->lookupBatch([$key], $options);
return (isset($res['found'][0]))
? $res['found'][0]
: null;
} | php | {
"resource": ""
} |
q15439 | DatastoreClient.parseSingleMutationResult | train | private function parseSingleMutationResult(array $res)
{
$mutationResult = $res['mutationResults'][0];
if (isset($mutationResult['conflictDetected']) && $mutationResult['conflictDetected']) {
throw new DomainException(
'A conflict was detected in the mutation. ' .
'The operation failed.'
);
}
// cast to string for conformance between REST and gRPC.
return (string) $mutationResult['version'];
} | php | {
"resource": ""
} |
q15440 | ListInstancesResponse.setInstances | train | public function setInstances($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Bigtable\Admin\V2\Instance::class);
$this->instances = $arr;
return $this;
} | php | {
"resource": ""
} |
q15441 | Query.projection | train | public function projection($properties)
{
if (!is_array($properties)) {
$properties = [$properties];
}
foreach ($properties as $property) {
$this->query['projection'][] = [
'property' => $this->propertyName($property)
];
}
return $this;
} | php | {
"resource": ""
} |
q15442 | Query.kind | train | public function kind($kinds)
{
if (!is_array($kinds)) {
$kinds = [$kinds];
}
foreach ($kinds as $kind) {
$this->query['kind'][] = $this->propertyName($kind);
}
return $this;
} | php | {
"resource": ""
} |
q15443 | Query.filter | train | public function filter($property, $operator, $value)
{
if (!isset($this->query['filter']) || !isset($this->query['filter']['compositeFilter'])) {
$this->initializeFilter();
}
$this->query['filter']['compositeFilter']['filters'][] = [
'propertyFilter' => [
'property' => $this->propertyName($property),
'value' => $this->entityMapper->valueObject($value),
'op' => $this->mapOperator($operator)
]
];
return $this;
} | php | {
"resource": ""
} |
q15444 | Query.order | train | public function order($property, $direction = self::ORDER_DEFAULT)
{
$this->query['order'][] = [
'property' => $this->propertyName($property),
'direction' => $direction
];
return $this;
} | php | {
"resource": ""
} |
q15445 | Query.distinctOn | train | public function distinctOn($property)
{
if (!is_array($property)) {
$property = [$property];
}
foreach ($property as $prop) {
$this->query['distinctOn'][] = $this->propertyName($prop);
}
return $this;
} | php | {
"resource": ""
} |
q15446 | Query.mapOperator | train | private function mapOperator($operator)
{
if (array_key_exists($operator, $this->shortOperators)) {
$operator = $this->shortOperators[$operator];
}
if (!in_array($operator, $this->allowedOperators)) {
throw new InvalidArgumentException(sprintf(
'Invalid operator `%s` given. Valid operators are %s.',
$operator,
implode(', ', $this->allowedOperators)
));
}
return $operator;
} | php | {
"resource": ""
} |
q15447 | ListJobsResponse.setJobs | train | public function setJobs($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Scheduler\V1\Job::class);
$this->jobs = $arr;
return $this;
} | php | {
"resource": ""
} |
q15448 | CommitRequest.setMutations | train | public function setMutations($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\V1\Mutation::class);
$this->mutations = $arr;
return $this;
} | php | {
"resource": ""
} |
q15449 | OutputAudioConfig.setAudioEncoding | train | public function setAudioEncoding($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Dialogflow\V2\OutputAudioEncoding::class);
$this->audio_encoding = $var;
return $this;
} | php | {
"resource": ""
} |
q15450 | OutputAudioConfig.setSynthesizeSpeechConfig | train | public function setSynthesizeSpeechConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\SynthesizeSpeechConfig::class);
$this->synthesize_speech_config = $var;
return $this;
} | php | {
"resource": ""
} |
q15451 | TextClassificationDatasetMetadata.setClassificationType | train | public function setClassificationType($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\AutoMl\V1beta1\ClassificationType::class);
$this->classification_type = $var;
return $this;
} | php | {
"resource": ""
} |
q15452 | TextProperty.setDetectedLanguages | train | public function setDetectedLanguages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\TextAnnotation\DetectedLanguage::class);
$this->detected_languages = $arr;
return $this;
} | php | {
"resource": ""
} |
q15453 | TextProperty.setDetectedBreak | train | public function setDetectedBreak($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\TextAnnotation_DetectedBreak::class);
$this->detected_break = $var;
return $this;
} | php | {
"resource": ""
} |
q15454 | AnnotateImageResponse.setLandmarkAnnotations | train | public function setLandmarkAnnotations($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\EntityAnnotation::class);
$this->landmark_annotations = $arr;
return $this;
} | php | {
"resource": ""
} |
q15455 | AnnotateImageResponse.setLogoAnnotations | train | public function setLogoAnnotations($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\EntityAnnotation::class);
$this->logo_annotations = $arr;
return $this;
} | php | {
"resource": ""
} |
q15456 | AnnotateImageResponse.setLabelAnnotations | train | public function setLabelAnnotations($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\EntityAnnotation::class);
$this->label_annotations = $arr;
return $this;
} | php | {
"resource": ""
} |
q15457 | AnnotateImageResponse.setLocalizedObjectAnnotations | train | public function setLocalizedObjectAnnotations($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\LocalizedObjectAnnotation::class);
$this->localized_object_annotations = $arr;
return $this;
} | php | {
"resource": ""
} |
q15458 | AnnotateImageResponse.setSafeSearchAnnotation | train | public function setSafeSearchAnnotation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\SafeSearchAnnotation::class);
$this->safe_search_annotation = $var;
return $this;
} | php | {
"resource": ""
} |
q15459 | AnnotateImageResponse.setImagePropertiesAnnotation | train | public function setImagePropertiesAnnotation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\ImageProperties::class);
$this->image_properties_annotation = $var;
return $this;
} | php | {
"resource": ""
} |
q15460 | AnnotateImageResponse.setCropHintsAnnotation | train | public function setCropHintsAnnotation($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\CropHintsAnnotation::class);
$this->crop_hints_annotation = $var;
return $this;
} | php | {
"resource": ""
} |
q15461 | AnnotateImageResponse.setWebDetection | train | public function setWebDetection($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\WebDetection::class);
$this->web_detection = $var;
return $this;
} | php | {
"resource": ""
} |
q15462 | AnnotateImageResponse.setProductSearchResults | train | public function setProductSearchResults($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\ProductSearchResults::class);
$this->product_search_results = $var;
return $this;
} | php | {
"resource": ""
} |
q15463 | AnnotateImageResponse.setContext | train | public function setContext($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Vision\V1\ImageAnnotationContext::class);
$this->context = $var;
return $this;
} | php | {
"resource": ""
} |
q15464 | DatastoreSessionHandler.open | train | public function open($savePath, $sessionName)
{
$this->kind = $sessionName;
if (preg_match(self::NAMESPACE_ALLOWED_PATTERN, $savePath) !== 1 ||
preg_match(self::NAMESPACE_RESERVED_PATTERN, $savePath) === 1) {
throw new InvalidArgumentException(
sprintf('The given save_path "%s" not allowed', $savePath)
);
}
$this->namespaceId = $savePath;
$this->transaction = $this->datastore->transaction();
return true;
} | php | {
"resource": ""
} |
q15465 | DatastoreSessionHandler.read | train | public function read($id)
{
try {
$key = $this->datastore->key(
$this->kind,
$id,
['namespaceId' => $this->namespaceId]
);
$entity = $this->transaction->lookup($key);
if ($entity !== null && isset($entity['data'])) {
return $entity['data'];
}
} catch (Exception $e) {
trigger_error(
sprintf('Datastore lookup failed: %s', $e->getMessage()),
E_USER_WARNING
);
}
return '';
} | php | {
"resource": ""
} |
q15466 | DatastoreSessionHandler.write | train | public function write($id, $data)
{
try {
$key = $this->datastore->key(
$this->kind,
$id,
['namespaceId' => $this->namespaceId]
);
$entity = $this->datastore->entity(
$key,
[
'data' => $data,
't' => time()
],
$this->options['entityOptions']
);
$this->transaction->upsert($entity);
$this->transaction->commit();
} catch (Exception $e) {
trigger_error(
sprintf('Datastore upsert failed: %s', $e->getMessage()),
E_USER_WARNING
);
return false;
}
return true;
} | php | {
"resource": ""
} |
q15467 | DatastoreSessionHandler.destroy | train | public function destroy($id)
{
try {
$key = $this->datastore->key(
$this->kind,
$id,
['namespaceId' => $this->namespaceId]
);
$this->transaction->delete($key);
$this->transaction->commit();
} catch (Exception $e) {
trigger_error(
sprintf('Datastore delete failed: %s', $e->getMessage()),
E_USER_WARNING
);
return false;
}
return true;
} | php | {
"resource": ""
} |
q15468 | DatastoreSessionHandler.gc | train | public function gc($maxlifetime)
{
if ($this->gcLimit === 0) {
return true;
}
try {
$query = $this->datastore->query()
->kind($this->kind)
->filter('t', '<', time() - $maxlifetime)
->order('t')
->keysOnly()
->limit($this->gcLimit);
$result = $this->datastore->runQuery(
$query,
['namespaceId' => $this->namespaceId]
);
$keys = [];
/* @var Entity $e */
foreach ($result as $e) {
$keys[] = $e->key();
}
if (!empty($keys)) {
$this->datastore->deleteBatch($keys);
}
} catch (Exception $e) {
trigger_error(
sprintf('Session gc failed: %s', $e->getMessage()),
E_USER_WARNING
);
return false;
}
return true;
} | php | {
"resource": ""
} |
q15469 | BoundingPoly.setVertices | train | public function setVertices($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\Vertex::class);
$this->vertices = $arr;
return $this;
} | php | {
"resource": ""
} |
q15470 | BoundingPoly.setNormalizedVertices | train | public function setNormalizedVertices($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\NormalizedVertex::class);
$this->normalized_vertices = $arr;
return $this;
} | php | {
"resource": ""
} |
q15471 | FaceAnnotation.setLandmarks | train | public function setLandmarks($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\FaceAnnotation\Landmark::class);
$this->landmarks = $arr;
return $this;
} | php | {
"resource": ""
} |
q15472 | FaceAnnotation.setJoyLikelihood | train | public function setJoyLikelihood($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->joy_likelihood = $var;
return $this;
} | php | {
"resource": ""
} |
q15473 | FaceAnnotation.setSorrowLikelihood | train | public function setSorrowLikelihood($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->sorrow_likelihood = $var;
return $this;
} | php | {
"resource": ""
} |
q15474 | FaceAnnotation.setAngerLikelihood | train | public function setAngerLikelihood($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->anger_likelihood = $var;
return $this;
} | php | {
"resource": ""
} |
q15475 | FaceAnnotation.setSurpriseLikelihood | train | public function setSurpriseLikelihood($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->surprise_likelihood = $var;
return $this;
} | php | {
"resource": ""
} |
q15476 | FaceAnnotation.setUnderExposedLikelihood | train | public function setUnderExposedLikelihood($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->under_exposed_likelihood = $var;
return $this;
} | php | {
"resource": ""
} |
q15477 | FaceAnnotation.setBlurredLikelihood | train | public function setBlurredLikelihood($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->blurred_likelihood = $var;
return $this;
} | php | {
"resource": ""
} |
q15478 | FaceAnnotation.setHeadwearLikelihood | train | public function setHeadwearLikelihood($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Vision\V1\Likelihood::class);
$this->headwear_likelihood = $var;
return $this;
} | php | {
"resource": ""
} |
q15479 | BatchGetAssetsHistoryResponse.setAssets | train | public function setAssets($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Asset\V1\TemporalAsset::class);
$this->assets = $arr;
return $this;
} | php | {
"resource": ""
} |
q15480 | Result.rows | train | public function rows($format = self::RETURN_ASSOCIATIVE)
{
$bufferedResults = [];
$call = $this->call;
$generator = null;
$shouldRetry = false;
$backoff = new ExponentialBackoff($this->retries, function ($ex) {
if ($ex instanceof ServiceException) {
return $ex->getCode() === Grpc\STATUS_UNAVAILABLE;
}
return false;
});
$valid = $backoff->execute(function () use ($call, &$generator) {
$generator = $call();
return $generator->valid();
});
while ($valid) {
try {
$result = $generator->current();
$bufferedResults[] = $result;
$this->setResultData($result, $format);
$empty = false;
if (!isset($result['values']) || $this->columnCount === 0) {
$empty = true;
}
$hasResumeToken = $this->isSetAndTrue($result, 'resumeToken');
if ($hasResumeToken || count($bufferedResults) >= self::BUFFER_RESULT_LIMIT) {
$chunkedResult = null;
if (!$empty) {
list($yieldableRows, $chunkedResult) = $this->parseRowsFromBufferedResults($bufferedResults);
foreach ($yieldableRows as $row) {
yield $this->mapper->decodeValues($this->columns, $row, $format);
}
}
// Now that we've yielded all available rows, flush the buffer.
$bufferedResults = [];
$shouldRetry = $hasResumeToken;
// If the last item in the buffer had a chunked value let's
// hold on to it so we can stitch it together into a yieldable
// result.
if ($chunkedResult) {
$bufferedResults[] = $chunkedResult;
}
}
$generator->next();
$valid = $generator->valid();
} catch (ServiceException $ex) {
if ($shouldRetry && $ex->getCode() === Grpc\STATUS_UNAVAILABLE) {
// Attempt to resume using our last stored resume token. If we
// successfully resume, flush the buffer.
$generator = $backoff->execute($call, [$this->resumeToken]);
$bufferedResults = [];
continue;
}
throw $ex;
}
}
// If there are any results remaining in the buffer, yield them.
if ($bufferedResults) {
list($yieldableRows, $chunkedResult) = $this->parseRowsFromBufferedResults($bufferedResults);
foreach ($yieldableRows as $row) {
yield $this->mapper->decodeValues($this->columns, $row, $format);
}
}
} | php | {
"resource": ""
} |
q15481 | Result.mergeValues | train | private function mergeValues(array $set1, array $set2)
{
// `$set2` may be empty if an array value is chunked at the end of the
// list. Handling it normally results in an additional `null` value
// being pushed onto the list of values. Since this method is only
// called in cases where two chunks must be merged, we can safely
// short-circuit the operation of the second chunk is empty.
if (empty($set2)) {
return $set1;
}
$lastItemSet1 = array_pop($set1);
$firstItemSet2 = array_shift($set2);
$item = $firstItemSet2;
if (is_string($lastItemSet1) && is_string($firstItemSet2)) {
$item = $lastItemSet1 . $firstItemSet2;
} elseif (is_array($lastItemSet1)) {
$item = $this->mergeValues($lastItemSet1, $firstItemSet2);
} else {
array_push($set1, $lastItemSet1);
}
array_push($set1, $item);
return array_merge($set1, $set2);
} | php | {
"resource": ""
} |
q15482 | AliasContext.setKind | train | public function setKind($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\DevTools\Source\V1\AliasContext_Kind::class);
$this->kind = $var;
return $this;
} | php | {
"resource": ""
} |
q15483 | EntityType.setKind | train | public function setKind($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Dialogflow\V2\EntityType_Kind::class);
$this->kind = $var;
return $this;
} | php | {
"resource": ""
} |
q15484 | EntityType.setAutoExpansionMode | train | public function setAutoExpansionMode($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\Dialogflow\V2\EntityType_AutoExpansionMode::class);
$this->auto_expansion_mode = $var;
return $this;
} | php | {
"resource": ""
} |
q15485 | ListInstanceConfigsResponse.setInstanceConfigs | train | public function setInstanceConfigs($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig::class);
$this->instance_configs = $arr;
return $this;
} | php | {
"resource": ""
} |
q15486 | ListExclusionsResponse.setExclusions | train | public function setExclusions($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Logging\V2\LogExclusion::class);
$this->exclusions = $arr;
return $this;
} | php | {
"resource": ""
} |
q15487 | ReceivedMessage.setMessage | train | public function setMessage($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\PubSub\V1\PubsubMessage::class);
$this->message = $var;
return $this;
} | php | {
"resource": ""
} |
q15488 | ImportProductSetsResponse.setReferenceImages | train | public function setReferenceImages($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Vision\V1\ReferenceImage::class);
$this->reference_images = $arr;
return $this;
} | php | {
"resource": ""
} |
q15489 | InspectJobConfig.setStorageConfig | train | public function setStorageConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\StorageConfig::class);
$this->storage_config = $var;
return $this;
} | php | {
"resource": ""
} |
q15490 | InspectJobConfig.setInspectConfig | train | public function setInspectConfig($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InspectConfig::class);
$this->inspect_config = $var;
return $this;
} | php | {
"resource": ""
} |
q15491 | InspectJobConfig.setActions | train | public function setActions($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\Action::class);
$this->actions = $arr;
return $this;
} | php | {
"resource": ""
} |
q15492 | BatchRunner.registerJob | train | public function registerJob($identifier, $func, array $options = [])
{
if ($func instanceof \Closure) {
throw new \InvalidArgumentException('Closure is not allowed');
}
// Always work on the latest data
$result = $this->configStorage->lock();
if ($result === false) {
return false;
}
$this->config = $this->configStorage->load();
$this->config->registerJob(
$identifier,
function ($id) use ($identifier, $func, $options) {
return new BatchJob($identifier, $func, $id, $options);
}
);
try {
$result = $this->configStorage->save($this->config);
} finally {
$this->configStorage->unlock();
}
return $result;
} | php | {
"resource": ""
} |
q15493 | BatchRunner.submitItem | train | public function submitItem($identifier, $item)
{
$job = $this->getJobFromId($identifier);
if ($job === null) {
throw new \RuntimeException(
"The identifier does not exist: $identifier"
);
}
$idNum = $job->id();
return $this->processor->submit($item, $idNum);
} | php | {
"resource": ""
} |
q15494 | BatchRunner.loadConfig | train | public function loadConfig()
{
$result = $this->configStorage->lock();
if ($result === false) {
throw new \RuntimeException('Failed to lock the configStorage');
}
try {
$result = $this->configStorage->load();
} catch (\RuntimeException $e) {
$this->configStorage->clear();
throw $e;
} finally {
$this->configStorage->unlock();
}
$this->config = $result;
return true;
} | php | {
"resource": ""
} |
q15495 | SpeechHelpersTrait.createAudioStreamFromResource | train | public function createAudioStreamFromResource($resource, $chunkSize = 32000)
{
while (!feof($resource)) {
$chunk = fread($resource, $chunkSize);
if (strlen($chunk) > 0) {
yield $chunk;
}
}
} | php | {
"resource": ""
} |
q15496 | ImageRedactionConfig.setInfoType | train | public function setInfoType($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InfoType::class);
$this->writeOneof(1, $var);
return $this;
} | php | {
"resource": ""
} |
q15497 | ImageRedactionConfig.setRedactionColor | train | public function setRedactionColor($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Color::class);
$this->redaction_color = $var;
return $this;
} | php | {
"resource": ""
} |
q15498 | Debuggee.register | train | public function register(array $options = [])
{
$resp = $this->connection->registerDebuggee(['debuggee' => $this->info()] + $options);
if (array_key_exists('debuggee', $resp)) {
$this->id = $resp['debuggee']['id'];
return true;
}
return false;
} | php | {
"resource": ""
} |
q15499 | Debuggee.breakpointsWithWaitToken | train | public function breakpointsWithWaitToken(array $options = [])
{
$ret = $this->connection->listBreakpoints(['debuggeeId' => $this->id] + $options);
if (array_key_exists('breakpoints', $ret)) {
$ret['breakpoints'] = array_map(function ($breakpointData) {
return new Breakpoint($breakpointData);
}, $ret['breakpoints']);
} else {
$ret['breakpoints'] = [];
}
return $ret;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.