/**
  * @param TokenSequencerInterface $query
  *
  * @throws InterpretationException
  * @return CompiledQuery
  */
 public function interpret(TokenSequencerInterface $query)
 {
     if (empty($this->metadataProvider)) {
         throw new InterpretationException("Cannot interpret any queries without an Entity Metadata Provider");
     }
     $this->tokenParser->parseTokenSequence($query);
     // select interpreter
     $selectedInterpreter = null;
     $queryType = $query->getType();
     foreach ($this->queryTypeInterpreters as $interpreter) {
         /** @var AbstractSqlQueryTypeInterpreter $interpreter */
         if ($interpreter->supportedQueryType() == $queryType) {
             $selectedInterpreter = $interpreter;
             break;
         }
     }
     if (empty($selectedInterpreter)) {
         throw new InterpretationException("Cannot interpret query. The query type '{$queryType}' is not supported by any of the installed QueryTypeInterpreters");
     }
     $compiledQuery = new CompiledQuery();
     $compiledQuery->setQuery($selectedInterpreter->interpretQuery($query));
     $compiledQuery->setArguments($selectedInterpreter->getValues());
     $compiledQuery->setPrimaryKeySequence($selectedInterpreter->getPrimaryKeySequence());
     return $compiledQuery;
 }
 public function recordQueryStart(CompiledQuery $query)
 {
     $this->extra = ["collection" => $query->getCollection(), "query" => $query->getQuery(), "method" => $query->getMethod(), "arguments" => $query->getArguments(), "calls" => $query->getCalls()];
     $this->startTime = microtime(true);
 }