<commit_before>//===----------------------------------------------------------------------===//
//
//                         Peloton
//
// types.cpp
//
// Identification: src/common/types.cpp
//
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//

#include "common/types.h"
#include "common/exception.h"
#include "common/logger.h"
#include "common/macros.h"
#include "common/value_factory.h"

#include <algorithm>
#include <cstring>
#include <sstream>

namespace peloton {

ItemPointer INVALID_ITEMPOINTER;

FileHandle INVALID_FILE_HANDLE;

// WARNING: It will limit scalability if tuples per tile group is too small,
// When a tile group is full, a new tile group needs to be allocated, until
// then no new insertion of new versions or tuples are available in the table.
int DEFAULT_TUPLES_PER_TILEGROUP = 1000;
int TEST_TUPLES_PER_TILEGROUP = 5;

// For threads
size_t QUERY_THREAD_COUNT = 1;
size_t LOGGING_THREAD_COUNT = 1;
size_t GC_THREAD_COUNT = 1;
size_t EPOCH_THREAD_COUNT = 1;

//===--------------------------------------------------------------------===//
// Type utilities
//===--------------------------------------------------------------------===//
/*
bool IsNumeric(ValueType type) {
  switch (type) {
    case VALUE_TYPE_TINYINT:
    case VALUE_TYPE_SMALLINT:
    case VALUE_TYPE_INTEGER:
    case VALUE_TYPE_BIGINT:
    case VALUE_TYPE_DECIMAL:
    case VALUE_TYPE_DOUBLE:
      return true;
    case VALUE_TYPE_VARCHAR:
    case VALUE_TYPE_VARBINARY:
    case VALUE_TYPE_DATE:
    case VALUE_TYPE_TIMESTAMP:
    case VALUE_TYPE_NULL:
    case VALUE_TYPE_INVALID:
    case VALUE_TYPE_ARRAY:
      return false;
    default:
      throw Exception("IsNumeric");
  }
  throw Exception("IsNumeric");
}

bool IsIntegralType(ValueType type) {
  switch (type) {
    case VALUE_TYPE_TINYINT:
    case VALUE_TYPE_SMALLINT:
    case VALUE_TYPE_INTEGER:
    case VALUE_TYPE_BIGINT:
      return true;
    case VALUE_TYPE_REAL:
    case VALUE_TYPE_DOUBLE:
    case VALUE_TYPE_VARCHAR:
    case VALUE_TYPE_VARBINARY:
    case VALUE_TYPE_DATE:
    case VALUE_TYPE_TIMESTAMP:
    case VALUE_TYPE_NULL:
    case VALUE_TYPE_DECIMAL:
    case VALUE_TYPE_ARRAY:
      return false;
    default:
      throw Exception("IsIntegralType");
  }
  throw Exception("IsIntegralType");
}

// Works only for fixed-length types
std::size_t GetTypeSize(ValueType type) {
  switch (type) {
    case VALUE_TYPE_TINYINT:
      return 1;
    case VALUE_TYPE_SMALLINT:
      return 2;
    case VALUE_TYPE_INTEGER:
      return 4;
    case VALUE_TYPE_BIGINT:
      return 8;
    case VALUE_TYPE_REAL:
    case VALUE_TYPE_DOUBLE:
      return 8;
    case VALUE_TYPE_VARCHAR:
      return 0;
    case VALUE_TYPE_VARBINARY:
      return 0;
    case VALUE_TYPE_DATE:
      return 4;
    case VALUE_TYPE_TIMESTAMP:
      return 8;
    case VALUE_TYPE_DECIMAL:
      return sizeof(TTInt);
    case VALUE_TYPE_INVALID:
      return 0;
    case VALUE_TYPE_NULL:
      return 0;
    default: { return 0; }
  }
}
*/
//===--------------------------------------------------------------------===//
// BackendType <--> String Utilities
//===--------------------------------------------------------------------===//

std::string BackendTypeToString(BackendType type) {
  std::string ret;

  switch (type) {
    case (BACKEND_TYPE_MM):
      return "MM";
    case (BACKEND_TYPE_NVM):
      return "NVM";
    case (BACKEND_TYPE_SSD):
      return "SSD";
    case (BACKEND_TYPE_HDD):
      return "HDD";
    case (BACKEND_TYPE_INVALID):
      return "INVALID";
    default: { return "UNKNOWN " + std::to_string(type); }
  }
  return (ret);
}

BackendType StringToBackendType(std::string str) {
  if (str == "INVALID") {
    return BACKEND_TYPE_INVALID;
  } else if (str == "MM") {
    return BACKEND_TYPE_MM;<commit_msg>Removed more code that is not needed in types.cpp<commit_after>//===----------------------------------------------------------------------===//
//
//                         Peloton
//
// types.cpp
//
// Identification: src/common/types.cpp
//
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//

#include "common/types.h"
#include "common/exception.h"
#include "common/logger.h"
#include "common/macros.h"
#include "common/value_factory.h"

#include <algorithm>
#include <cstring>
#include <sstream>

namespace peloton {

ItemPointer INVALID_ITEMPOINTER;

FileHandle INVALID_FILE_HANDLE;

// WARNING: It will limit scalability if tuples per tile group is too small,
// When a tile group is full, a new tile group needs to be allocated, until
// then no new insertion of new versions or tuples are available in the table.
int DEFAULT_TUPLES_PER_TILEGROUP = 1000;
int TEST_TUPLES_PER_TILEGROUP = 5;

// For threads
size_t QUERY_THREAD_COUNT = 1;
size_t LOGGING_THREAD_COUNT = 1;
size_t GC_THREAD_COUNT = 1;
size_t EPOCH_THREAD_COUNT = 1;

//===--------------------------------------------------------------------===//
// BackendType <--> String Utilities
//===--------------------------------------------------------------------===//

std::string BackendTypeToString(BackendType type) {
  std::string ret;

  switch (type) {
    case (BACKEND_TYPE_MM):
      return "MM";
    case (BACKEND_TYPE_NVM):
      return "NVM";
    case (BACKEND_TYPE_SSD):
      return "SSD";
    case (BACKEND_TYPE_HDD):
      return "HDD";
    case (BACKEND_TYPE_INVALID):
      return "INVALID";
    default: { return "UNKNOWN " + std::to_string(type); }
  }
  return (ret);
}

BackendType StringToBackendType(std::string str) {
  if (str == "INVALID") {
    return BACKEND_TYPE_INVALID;
  } else if (str == "MM") {
    return BACKEND_TYPE_MM;
{'fraction_non_alphanumeric': 0.21715171344928536, 'fraction_numerical': 0.0072326502496986396, 'mean_word_length': 2.082802547770701, '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': '2090034', 'n_tokens_mistral': 1849, 'n_tokens_neox': 1795, 'n_words': 446}