<commit_before>#ifndef _SQLDB_DATASTREAM_H_
#define _SQLDB_DATASTREAM_H_

#include "ColumnType.h"

#include <string>
#include <vector>

namespace sqldb {  
  class DataStream {
  public:
    DataStream() { }
    DataStream(const DataStream & other) = delete;
    DataStream(const DataStream && other) = delete;

    DataStream & operator=(const DataStream & other) = delete;
    DataStream & operator=(const DataStream && other) = delete;
    
    virtual ~DataStream() { }

    virtual size_t execute() = 0;

    virtual std::vector<uint8_t> getBlob(int column_index) = 0;
    virtual std::string getText(int column_index, std::string default_value) = 0;

    virtual bool isNull(int column_index) const = 0;
    virtual int getNumFields() const = 0;
    virtual bool next() = 0;

    virtual ColumnType getColumnType(int column_index) const {
      return column_index >= 0 && column_index < getNumFields() ? ColumnType::TEXT : ColumnType::UNDEF;
    }
    virtual std::string getColumnName(int column_index) const { return ""; }
    
    virtual bool getBool(int column_index, bool default_value = false) {
      return getInt(column_index, default_value ? 1 : 0) ? true : false;
    }

    virtual double getDouble(int column_index, double default_value = 0.0) {
      auto s = getText(column_index);
      if (!s.empty()) {
	try { return stof(s); } catch (...) { }
      }
      return default_value;
    }
    virtual float getFloat(int column_index, float default_value = 0.0f) {
      auto s = getText(column_index);<commit_msg>make getColumnName() absract<commit_after>#ifndef _SQLDB_DATASTREAM_H_
#define _SQLDB_DATASTREAM_H_

#include "ColumnType.h"

#include <string>
#include <vector>

namespace sqldb {  
  class DataStream {
  public:
    DataStream() { }
    DataStream(const DataStream & other) = delete;
    DataStream(const DataStream && other) = delete;

    DataStream & operator=(const DataStream & other) = delete;
    DataStream & operator=(const DataStream && other) = delete;
    
    virtual ~DataStream() { }

    virtual size_t execute() = 0;

    virtual std::vector<uint8_t> getBlob(int column_index) = 0;
    virtual std::string getText(int column_index, std::string default_value) = 0;
    virtual bool isNull(int column_index) const = 0;
    virtual int getNumFields() const = 0;
    virtual bool next() = 0;
    virtual std::string getColumnName(int column_index) const = 0;

    virtual ColumnType getColumnType(int column_index) const {
      return column_index >= 0 && column_index < getNumFields() ? ColumnType::TEXT : ColumnType::UNDEF;
    }
    
    virtual bool getBool(int column_index, bool default_value = false) {
      return getInt(column_index, default_value ? 1 : 0) ? true : false;
    }

    virtual double getDouble(int column_index, double default_value = 0.0) {
      auto s = getText(column_index);
      if (!s.empty()) {
	try { return stof(s); } catch (...) { }
      }
      return default_value;
    }
    virtual float getFloat(int column_index, float default_value = 0.0f) {
      auto s = getText(column_index);
{'fraction_non_alphanumeric': 0.10955786736020806, 'fraction_numerical': 0.00942782834850455, 'mean_word_length': 3.606287425149701, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3907634', 'n_tokens_mistral': 976, 'n_tokens_neox': 941, 'n_words': 255}