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

namespace Google\Cloud\Datastore\V1;

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

/**
 * A batch of aggregation results produced by an aggregation query.
 *
 * Generated from protobuf message <code>google.datastore.v1.AggregationResultBatch</code>
 */
class AggregationResultBatch extends \Google\Protobuf\Internal\Message
{
    /**
     * The aggregation results for this batch.
     *
     * Generated from protobuf field <code>repeated .google.datastore.v1.AggregationResult aggregation_results = 1;</code>
     */
    private $aggregation_results;
    /**
     * The state of the query after the current batch.
     * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
     * expected result type is limited to `NO_MORE_RESULTS`.
     *
     * Generated from protobuf field <code>.google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2;</code>
     */
    private $more_results = 0;
    /**
     * Read timestamp this batch was returned from.
     * In a single transaction, subsequent query result batches for the same query
     * can have a greater timestamp. Each batch's read timestamp
     * is valid for all preceding batches.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp read_time = 3;</code>
     */
    private $read_time = null;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type array<\Google\Cloud\Datastore\V1\AggregationResult>|\Google\Protobuf\Internal\RepeatedField $aggregation_results
     *           The aggregation results for this batch.
     *     @type int $more_results
     *           The state of the query after the current batch.
     *           Only COUNT(*) aggregations are supported in the initial launch. Therefore,
     *           expected result type is limited to `NO_MORE_RESULTS`.
     *     @type \Google\Protobuf\Timestamp $read_time
     *           Read timestamp this batch was returned from.
     *           In a single transaction, subsequent query result batches for the same query
     *           can have a greater timestamp. Each batch's read timestamp
     *           is valid for all preceding batches.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Datastore\V1\AggregationResult::initOnce();
        parent::__construct($data);
    }

    /**
     * The aggregation results for this batch.
     *
     * Generated from protobuf field <code>repeated .google.datastore.v1.AggregationResult aggregation_results = 1;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getAggregationResults()
    {
        return $this->aggregation_results;
    }

    /**
     * The aggregation results for this batch.
     *
     * Generated from protobuf field <code>repeated .google.datastore.v1.AggregationResult aggregation_results = 1;</code>
     * @param array<\Google\Cloud\Datastore\V1\AggregationResult>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setAggregationResults($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Datastore\V1\AggregationResult::class);
        $this->aggregation_results = $arr;

        return $this;
    }

    /**
     * The state of the query after the current batch.
     * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
     * expected result type is limited to `NO_MORE_RESULTS`.
     *
     * Generated from protobuf field <code>.google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2;</code>
     * @return int
     */
    public function getMoreResults()
    {
        return $this->more_results;
    }

    /**
     * The state of the query after the current batch.
     * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
     * expected result type is limited to `NO_MORE_RESULTS`.
     *
     * Generated from protobuf field <code>.google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2;</code>
     * @param int $var
     * @return $this
     */
    public function setMoreResults($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\Datastore\V1\QueryResultBatch\MoreResultsType::class);
        $this->more_results = $var;

        return $this;
    }

    /**
     * Read timestamp this batch was returned from.
     * In a single transaction, subsequent query result batches for the same query
     * can have a greater timestamp. Each batch's read timestamp
     * is valid for all preceding batches.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp read_time = 3;</code>
     * @return \Google\Protobuf\Timestamp|null
     */
    public function getReadTime()
    {
        return $this->read_time;
    }

    public function hasReadTime()
    {
        return isset($this->read_time);
    }

    public function clearReadTime()
    {
        unset($this->read_time);
    }

    /**
     * Read timestamp this batch was returned from.
     * In a single transaction, subsequent query result batches for the same query
     * can have a greater timestamp. Each batch's read timestamp
     * is valid for all preceding batches.
     *
     * Generated from protobuf field <code>.google.protobuf.Timestamp read_time = 3;</code>
     * @param \Google\Protobuf\Timestamp $var
     * @return $this
     */
    public function setReadTime($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
        $this->read_time = $var;

        return $this;
    }

}

