Assembles Result instance from server response.

@param Query $query
@param \Psr\Http\Message\ResponseInterface $response

@return \Tinderbox\Clickhouse\Query\Result
328606
protected function assembleResult(Query $query, ResponseInterface $response): Result
    {
        $response = $response->getBody()->getContents();

        try {
            $result = \GuzzleHttp\json_decode($response, true);

            $statistic = new QueryStatistic(
                $result['statistics']['rows_read'] ?? 0,
                $result['statistics']['bytes_read'] ?? 0,
                $result['statistics']['elapsed'] ?? 0,
                $result['rows_before_limit_at_least'] ?? null
            );

            return new Result($query, $result['data'] ?? [], $statistic);
        } catch (\Exception $e) {
            throw TransportException::malformedResponseFromServer($response);
        }
    }
67382
public function processResponse(ResponseInterface $response)
    {
        if (!$response instanceof Response
            || !$this->getRequest()
        ) {
            return;
        }

        $response = $this->handleResponse($response);
        $this->renderResponse($response);
        $this->terminateApp();
    }
429640
final protected function process(\SelectQueryInterface $select, Query $query)
    {
        $sortField = null;

        if ($query->hasSortField()) {
            $sortField = $query->getSortField();

            $select->orderBy($this->fields[$sortField]['column'], Query::SORT_DESC === $query->getSortOrder() ? 'desc' : 'asc');
        }

        // Add a predictible ordering column
        if ($sortField !== $this->idColumn) {
            $select->orderBy($this->idColumn, Query::SORT_DESC === $query->getSortOrder() ? 'desc' : 'asc');
        }

        if ($this->fulltextField) {
            if ($searchstring = $query->getSearchString()) {
                $select->condition($this->fulltextField, '%'.db_like($searchstring).'%', 'LIKE');
            }
        }

        $this->applyFilters($select, $query);

        return $select;
    }
958907
public function handle(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
    {
        $type = 'psr-7';
        $this->cors->setRequest($type, $request);
        $this->cors->setResponse($type, $response);
        $this->cors->handle();

        return $this->cors->getResponse();
    }
1136326
public static function createResponseWithAnswersForQuery(Query $query, array $answers)
    {
        $response = new Message();
        $response->header->set('id', self::generateId());
        $response->header->set('qr', 1);
        $response->header->set('opcode', Message::OPCODE_QUERY);
        $response->header->set('rd', 1);
        $response->header->set('rcode', Message::RCODE_OK);

        $response->questions[] = (array) $query;

        foreach ($answers as $record) {
            $response->answers[] = $record;
        }

        $response->prepare();

        return $response;
    }
170255
public function execute(ServerRequestInterface $request, ResponseInterface $response) : ResponseInterface {
		$httpRequestResponse = new HTTPRequestResponseContainer($request, $response);

		$this->dispatchRequestFilters($httpRequestResponse);

		$this->dispatchResponseFilters($httpRequestResponse);

		return $httpRequestResponse->getResponse();
	}
598973
public function processRequest(RequestInterface $request, ResponseInterface $response)
    {
        $this->result = new AjaxResult;

        try {
            $this->processRequestParent($request, $response);
        } catch (Exception $exception) {
            if (false === $this->protectedRequestMode) {
                throw $exception;
            }

            $this->result->clear();

            $errorMessage = ExtensionService::get()->isInDebugMode()
                ? $this->getDebugMessageForException($exception)
                : ContextService::get()->translate(self::DEFAULT_ERROR_MESSAGE_KEY);

            $error = new Error($errorMessage, 1490176818);
            $this->result->addError($error);
            $this->result->setData('errorCode', $exception->getCode());
        }

        // Cleaning every external message.
        ob_clean();

        $this->injectResultInResponse();
    }
219174
public function query(
        Query $query,
        array $parameters = []
    ): Result {
        $response = $this
            ->httpClient
            ->get(
                sprintf(
                    '/%s/indices/%s',
                    $this->getAppUUID()->composeUUID(),
                    $this->getIndexUUID()->composeUUID()
                ),
                'get',
                [
                    Http::QUERY_FIELD => urlencode(json_encode($query->toArray())),
                ] + $parameters,
                [],
                Http::getApisearchHeaders($this)
            );

        self::throwTransportableExceptionIfNeeded($response);

        return Result::createFromArray($response['body']);
    }
879326
protected function configureResponse(ResponseInterface $Response){
        $Response->setRequest($this->Request);
        $Response->extract();
        return $Response;
    }
979897
protected function doQuery(Query $query)
    {
        $result = static::db()->query($query);

        $this->where = null;

        return $result;
    }
42481
public function buildResultSet(Response $response, Query $query): ResultSet
    {
        $results = $this->buildResults($response);
        $resultSet = new ResultSet($response, $query, $results);

        return $resultSet;
    }
596311
public function process(QueryInterface $query)
    {
        /* @var $query SelectQuery */
        if (!$query->isType(QueryInterface::TYPE_SELECT)) {
            return null;
        }

        $field = $query->getFirstField();

        if ($field->getType() !== Expression::TYPE_FUNCTION
            || $field->getExpression() !== Expression::EXPR_CONNECTION_ID) {
            return null;
        }

        return $this->getResultFromData(self::$data, self::$fields);
    }
276241
public function responseToResultTransformer(ResponseInterface $response, RequestInterface $request)
    {
        $data = json_decode($response->getBody(), true);

        return new Result($data);
    }
740558
public function process(QueryInterface $query)
    {
        if (!$query instanceof DropQuery || $query->getObject() !== DropQuery::EXPRESSION_TABLE) {
            return null;
        }

        $command = new ApplySchema($query->getSql());
        $this->client->executeCommand($command);

        return new EmptyResult();
    }
600717
public function run(Query $query)
    {
        return $this->getDisconnectRetry()->run(function () use ($query) {
            $statement = $this->prepare($query);
            $query->getValueBinder()->attachTo($statement);
            $statement->execute();

            return $statement;
        });
    }
892227
protected function handle(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
    {
        $cors = $this->cors->getCors();
        $cors->setRequest('psr-7', $request);
        $cors->setResponse('psr-7', $response);
        $cors->handle();

        return $cors->getResponse();
    }
1244449
public function processResponse(\Amp\Artax\Response $response) {
        $instance = $this->api->instantiateResult($response, $this);

        return $instance;
    }