<commit_before>////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author <NAME>
////////////////////////////////////////////////////////////////////////////////

#ifndef ARANGOD_AQL_QUERY_H
#define ARANGOD_AQL_QUERY_H 1

#include "Basics/Common.h"

#include <velocypack/Builder.h>

#include "Aql/BindParameters.h"
#include "Aql/Collections.h"
#include "Aql/Graphs.h"
#include "Aql/QueryExecutionState.h"
#include "Aql/QueryOptions.h"
#include "Aql/QueryResources.h"
#include "Aql/QueryResultV8.h"
#include "Aql/QueryString.h"
#include "Aql/RegexCache.h"
#include "Aql/ResourceUsage.h"
#include "Aql/types.h"
#include "Basics/Common.h"
#include "V8Server/V8Context.h"
#include "VocBase/voc-types.h"

struct TRI_vocbase_t;

namespace arangodb {

namespace transaction {
class Context;
class Methods;
}

namespace velocypack {
class Builder;
}

namespace aql {

struct AstNode;
class Ast;
class ExecutionEngine;
class ExecutionPlan;
class Query;
struct QueryProfile;
class QueryRegistry;

/// @brief equery part
enum QueryPart { PART_MAIN, PART_DEPENDENT };

/// @brief an AQL query
class Query {
 private:
  Query(Query const&) = delete;
  Query& operator=(Query const&) = delete;

 public:
  /// Used to construct a full query
  Query(
    bool contextOwnedByExterior,
    TRI_vocbase_t& vocbase,
    QueryString const& queryString,
    std::shared_ptr<arangodb::velocypack::Builder> const& bindParameters,
    std::shared_ptr<arangodb::velocypack::Builder> const& options,
    QueryPart part
  );

  /// Used to put together query snippets in RestAqlHandler
  Query(
    bool contextOwnedByExterior,
    TRI_vocbase_t& vocbase,
    std::shared_ptr<arangodb::velocypack::Builder> const& queryStruct,
    std::shared_ptr<arangodb::velocypack::Builder> const& options,
    QueryPart
  );

  TEST_VIRTUAL ~Query();

  /// @brief clone a query
  /// note: as a side-effect, this will also create and start a transaction for
  /// the query
  TEST_VIRTUAL Query* clone(QueryPart, bool);

 public:

  QueryString const& queryString() const { return _queryString; }

  /// @brief Inject a transaction from outside. Use with care!
  void injectTransaction(transaction::Methods* trx) {
    _trx = trx;
    init();
  }

  QueryProfile* profile() const {
    return _profile.get();
  }

  TEST_VIRTUAL QueryOptions const& queryOptions() const { return _queryOptions; }

  void increaseMemoryUsage(size_t value) { _resourceMonitor.increaseMemoryUsage(value); }
  void decreaseMemoryUsage(size_t value) { _resourceMonitor.decreaseMemoryUsage(value); }

  ResourceMonitor* resourceMonitor() { return &_resourceMonitor; }
<commit_msg>make dtor always virtual<commit_after>////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author <NAME>
////////////////////////////////////////////////////////////////////////////////

#ifndef ARANGOD_AQL_QUERY_H
#define ARANGOD_AQL_QUERY_H 1

#include "Basics/Common.h"

#include <velocypack/Builder.h>

#include "Aql/BindParameters.h"
#include "Aql/Collections.h"
#include "Aql/Graphs.h"
#include "Aql/QueryExecutionState.h"
#include "Aql/QueryOptions.h"
#include "Aql/QueryResources.h"
#include "Aql/QueryResultV8.h"
#include "Aql/QueryString.h"
#include "Aql/RegexCache.h"
#include "Aql/ResourceUsage.h"
#include "Aql/types.h"
#include "Basics/Common.h"
#include "V8Server/V8Context.h"
#include "VocBase/voc-types.h"

struct TRI_vocbase_t;

namespace arangodb {

namespace transaction {
class Context;
class Methods;
}

namespace velocypack {
class Builder;
}

namespace aql {

struct AstNode;
class Ast;
class ExecutionEngine;
class ExecutionPlan;
class Query;
struct QueryProfile;
class QueryRegistry;

/// @brief equery part
enum QueryPart { PART_MAIN, PART_DEPENDENT };

/// @brief an AQL query
class Query {
 private:
  Query(Query const&) = delete;
  Query& operator=(Query const&) = delete;

 public:
  /// Used to construct a full query
  Query(
    bool contextOwnedByExterior,
    TRI_vocbase_t& vocbase,
    QueryString const& queryString,
    std::shared_ptr<arangodb::velocypack::Builder> const& bindParameters,
    std::shared_ptr<arangodb::velocypack::Builder> const& options,
    QueryPart part
  );

  /// Used to put together query snippets in RestAqlHandler
  Query(
    bool contextOwnedByExterior,
    TRI_vocbase_t& vocbase,
    std::shared_ptr<arangodb::velocypack::Builder> const& queryStruct,
    std::shared_ptr<arangodb::velocypack::Builder> const& options,
    QueryPart
  );

  virtual ~Query();

  /// @brief clone a query
  /// note: as a side-effect, this will also create and start a transaction for
  /// the query
  TEST_VIRTUAL Query* clone(QueryPart, bool);

 public:

  QueryString const& queryString() const { return _queryString; }

  /// @brief Inject a transaction from outside. Use with care!
  void injectTransaction(transaction::Methods* trx) {
    _trx = trx;
    init();
  }

  QueryProfile* profile() const {
    return _profile.get();
  }

  TEST_VIRTUAL QueryOptions const& queryOptions() const { return _queryOptions; }

  void increaseMemoryUsage(size_t value) { _resourceMonitor.increaseMemoryUsage(value); }
  void decreaseMemoryUsage(size_t value) { _resourceMonitor.decreaseMemoryUsage(value); }

  ResourceMonitor* resourceMonitor() { return &_resourceMonitor; }

{'fraction_non_alphanumeric': 0.15492546039169833, 'fraction_numerical': 0.0070154925460391695, 'mean_word_length': 3.331012658227848, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4358644', 'n_tokens_mistral': 2144, 'n_tokens_neox': 2042, 'n_words': 609}