<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/aiplatform/v1/feature_online_store_service.proto

namespace Google\Cloud\AIPlatform\V1;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * A query to find a number of similar entities.
 *
 * Generated from protobuf message <code>google.cloud.aiplatform.v1.NearestNeighborQuery</code>
 */
class NearestNeighborQuery extends \Google\Protobuf\Internal\Message
{
    /**
     * Optional. The number of similar entities to be retrieved from feature view
     * for each query.
     *
     * Generated from protobuf field <code>int32 neighbor_count = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    protected $neighbor_count = 0;
    /**
     * Optional. The list of string filters.
     *
     * Generated from protobuf field <code>repeated .google.cloud.aiplatform.v1.NearestNeighborQuery.StringFilter string_filters = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    private $string_filters;
    /**
     * Optional. The list of numeric filters.
     *
     * Generated from protobuf field <code>repeated .google.cloud.aiplatform.v1.NearestNeighborQuery.NumericFilter numeric_filters = 8 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    private $numeric_filters;
    /**
     * Optional. Crowding is a constraint on a neighbor list produced by nearest
     * neighbor search requiring that no more than
     * sper_crowding_attribute_neighbor_count of the k neighbors returned have the
     * same value of crowding_attribute. It's used for improving result diversity.
     *
     * Generated from protobuf field <code>int32 per_crowding_attribute_neighbor_count = 5 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    protected $per_crowding_attribute_neighbor_count = 0;
    /**
     * Optional. Parameters that can be set to tune query on the fly.
     *
     * Generated from protobuf field <code>.google.cloud.aiplatform.v1.NearestNeighborQuery.Parameters parameters = 7 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    protected $parameters = null;
    protected $instance;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $entity_id
     *           Optional. The entity id whose similar entities should be searched for.
     *           If embedding is set, search will use embedding instead of
     *           entity_id.
     *     @type \Google\Cloud\AIPlatform\V1\NearestNeighborQuery\Embedding $embedding
     *           Optional. The embedding vector that be used for similar search.
     *     @type int $neighbor_count
     *           Optional. The number of similar entities to be retrieved from feature view
     *           for each query.
     *     @type array<\Google\Cloud\AIPlatform\V1\NearestNeighborQuery\StringFilter>|\Google\Protobuf\Internal\RepeatedField $string_filters
     *           Optional. The list of string filters.
     *     @type array<\Google\Cloud\AIPlatform\V1\NearestNeighborQuery\NumericFilter>|\Google\Protobuf\Internal\RepeatedField $numeric_filters
     *           Optional. The list of numeric filters.
     *     @type int $per_crowding_attribute_neighbor_count
     *           Optional. Crowding is a constraint on a neighbor list produced by nearest
     *           neighbor search requiring that no more than
     *           sper_crowding_attribute_neighbor_count of the k neighbors returned have the
     *           same value of crowding_attribute. It's used for improving result diversity.
     *     @type \Google\Cloud\AIPlatform\V1\NearestNeighborQuery\Parameters $parameters
     *           Optional. Parameters that can be set to tune query on the fly.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Aiplatform\V1\FeatureOnlineStoreService::initOnce();
        parent::__construct($data);
    }

    /**
     * Optional. The entity id whose similar entities should be searched for.
     * If embedding is set, search will use embedding instead of
     * entity_id.
     *
     * Generated from protobuf field <code>string entity_id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return string
     */
    public function getEntityId()
    {
        return $this->readOneof(1);
    }

    public function hasEntityId()
    {
        return $this->hasOneof(1);
    }

    /**
     * Optional. The entity id whose similar entities should be searched for.
     * If embedding is set, search will use embedding instead of
     * entity_id.
     *
     * Generated from protobuf field <code>string entity_id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param string $var
     * @return $this
     */
    public function setEntityId($var)
    {
        GPBUtil::checkString($var, True);
        $this->writeOneof(1, $var);

        return $this;
    }

    /**
     * Optional. The embedding vector that be used for similar search.
     *
     * Generated from protobuf field <code>.google.cloud.aiplatform.v1.NearestNeighborQuery.Embedding embedding = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return \Google\Cloud\AIPlatform\V1\NearestNeighborQuery\Embedding|null
     */
    public function getEmbedding()
    {
        return $this->readOneof(2);
    }

    public function hasEmbedding()
    {
        return $this->hasOneof(2);
    }

    /**
     * Optional. The embedding vector that be used for similar search.
     *
     * Generated from protobuf field <code>.google.cloud.aiplatform.v1.NearestNeighborQuery.Embedding embedding = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param \Google\Cloud\AIPlatform\V1\NearestNeighborQuery\Embedding $var
     * @return $this
     */
    public function setEmbedding($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\AIPlatform\V1\NearestNeighborQuery\Embedding::class);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * Optional. The number of similar entities to be retrieved from feature view
     * for each query.
     *
     * Generated from protobuf field <code>int32 neighbor_count = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return int
     */
    public function getNeighborCount()
    {
        return $this->neighbor_count;
    }

    /**
     * Optional. The number of similar entities to be retrieved from feature view
     * for each query.
     *
     * Generated from protobuf field <code>int32 neighbor_count = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param int $var
     * @return $this
     */
    public function setNeighborCount($var)
    {
        GPBUtil::checkInt32($var);
        $this->neighbor_count = $var;

        return $this;
    }

    /**
     * Optional. The list of string filters.
     *
     * Generated from protobuf field <code>repeated .google.cloud.aiplatform.v1.NearestNeighborQuery.StringFilter string_filters = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getStringFilters()
    {
        return $this->string_filters;
    }

    /**
     * Optional. The list of string filters.
     *
     * Generated from protobuf field <code>repeated .google.cloud.aiplatform.v1.NearestNeighborQuery.StringFilter string_filters = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param array<\Google\Cloud\AIPlatform\V1\NearestNeighborQuery\StringFilter>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setStringFilters($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AIPlatform\V1\NearestNeighborQuery\StringFilter::class);
        $this->string_filters = $arr;

        return $this;
    }

    /**
     * Optional. The list of numeric filters.
     *
     * Generated from protobuf field <code>repeated .google.cloud.aiplatform.v1.NearestNeighborQuery.NumericFilter numeric_filters = 8 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getNumericFilters()
    {
        return $this->numeric_filters;
    }

    /**
     * Optional. The list of numeric filters.
     *
     * Generated from protobuf field <code>repeated .google.cloud.aiplatform.v1.NearestNeighborQuery.NumericFilter numeric_filters = 8 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param array<\Google\Cloud\AIPlatform\V1\NearestNeighborQuery\NumericFilter>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setNumericFilters($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AIPlatform\V1\NearestNeighborQuery\NumericFilter::class);
        $this->numeric_filters = $arr;

        return $this;
    }

    /**
     * Optional. Crowding is a constraint on a neighbor list produced by nearest
     * neighbor search requiring that no more than
     * sper_crowding_attribute_neighbor_count of the k neighbors returned have the
     * same value of crowding_attribute. It's used for improving result diversity.
     *
     * Generated from protobuf field <code>int32 per_crowding_attribute_neighbor_count = 5 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return int
     */
    public function getPerCrowdingAttributeNeighborCount()
    {
        return $this->per_crowding_attribute_neighbor_count;
    }

    /**
     * Optional. Crowding is a constraint on a neighbor list produced by nearest
     * neighbor search requiring that no more than
     * sper_crowding_attribute_neighbor_count of the k neighbors returned have the
     * same value of crowding_attribute. It's used for improving result diversity.
     *
     * Generated from protobuf field <code>int32 per_crowding_attribute_neighbor_count = 5 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param int $var
     * @return $this
     */
    public function setPerCrowdingAttributeNeighborCount($var)
    {
        GPBUtil::checkInt32($var);
        $this->per_crowding_attribute_neighbor_count = $var;

        return $this;
    }

    /**
     * Optional. Parameters that can be set to tune query on the fly.
     *
     * Generated from protobuf field <code>.google.cloud.aiplatform.v1.NearestNeighborQuery.Parameters parameters = 7 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return \Google\Cloud\AIPlatform\V1\NearestNeighborQuery\Parameters|null
     */
    public function getParameters()
    {
        return $this->parameters;
    }

    public function hasParameters()
    {
        return isset($this->parameters);
    }

    public function clearParameters()
    {
        unset($this->parameters);
    }

    /**
     * Optional. Parameters that can be set to tune query on the fly.
     *
     * Generated from protobuf field <code>.google.cloud.aiplatform.v1.NearestNeighborQuery.Parameters parameters = 7 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param \Google\Cloud\AIPlatform\V1\NearestNeighborQuery\Parameters $var
     * @return $this
     */
    public function setParameters($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\AIPlatform\V1\NearestNeighborQuery\Parameters::class);
        $this->parameters = $var;

        return $this;
    }

    /**
     * @return string
     */
    public function getInstance()
    {
        return $this->whichOneof("instance");
    }

}

