<commit_before>// Copyright 2015, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: <NAME> (<EMAIL>)
#pragma once

#include <list>
#include <utility>
#include <vector>
#include "./Operation.h"
#include "./QueryExecutionTree.h"
#include "../parser/ParsedQuery.h"

using std::list;
using std::pair;
using std::vector;

class Filter : public Operation {
  public:
    virtual size_t getResultWidth() const;

  public:

    Filter(QueryExecutionContext *qec, std::shared_ptr<QueryExecutionTree> subtree,
           SparqlFilter::FilterType type, size_t var1Column, size_t var2Column,
           Id rhsId = std::numeric_limits<Id>::max());

    virtual string asString(size_t indent=0) const;

    virtual size_t resultSortedOn() const {
      return _subtree->resultSortedOn();
    }

    virtual void setTextLimit(size_t limit) {
      _subtree->setTextLimit(limit);
    }

    virtual size_t getSizeEstimate() {
      // TODO: return a better estimate
      if (_rhsId == std::numeric_limits<Id>::max()) {
        if (_type == SparqlFilter::FilterType::EQ) {
          return _subtree->getSizeEstimate() / 1000;
        }
        if (_type == SparqlFilter::FilterType::NE) {
          return _subtree->getSizeEstimate() / 4;
        } else {
          return _subtree->getSizeEstimate() / 2;
        }
      } else {
        if (_type == SparqlFilter::FilterType::EQ) {
          return _subtree->getSizeEstimate() / 1000;
        }
        if (_type == SparqlFilter::FilterType::NE) {
          return _subtree->getSizeEstimate() / 4;
        } else {
          return _subtree->getSizeEstimate() / 50;
        }
      }<commit_msg>improved size estimates for FILTER<commit_after>// Copyright 2015, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: <NAME> (<EMAIL>)
#pragma once

#include <list>
#include <utility>
#include <vector>
#include "./Operation.h"
#include "./QueryExecutionTree.h"
#include "../parser/ParsedQuery.h"

using std::list;
using std::pair;
using std::vector;

class Filter : public Operation {
  public:
    virtual size_t getResultWidth() const;

  public:

    Filter(QueryExecutionContext *qec, std::shared_ptr<QueryExecutionTree> subtree,
           SparqlFilter::FilterType type, size_t var1Column, size_t var2Column,
           Id rhsId = std::numeric_limits<Id>::max());

    virtual string asString(size_t indent=0) const;

    virtual size_t resultSortedOn() const {
      return _subtree->resultSortedOn();
    }

    virtual void setTextLimit(size_t limit) {
      _subtree->setTextLimit(limit);
    }

    virtual size_t getSizeEstimate() {
      // TODO: return a better estimate
      if (_rhsId == std::numeric_limits<Id>::max()) {
        if (_type == SparqlFilter::FilterType::EQ) {
          return _subtree->getSizeEstimate() / 1000;
        }
        if (_type == SparqlFilter::FilterType::NE) {
          return _subtree->getSizeEstimate() / 4;
        } else {
          return _subtree->getSizeEstimate() / 2;
        }
      } else {
        if (_type == SparqlFilter::FilterType::EQ) {
          return _subtree->getSizeEstimate() / 1000;
        }
        if (_type == SparqlFilter::FilterType::NE) {
          return _subtree->getSizeEstimate();
        } else {
          return _subtree->getSizeEstimate() / 50;
        }
      }
{'fraction_non_alphanumeric': 0.12735990410548398, 'fraction_numerical': 0.011687144141444412, 'mean_word_length': 2.8545034642032334, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1027829', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1006, 'n_words': 239}