<commit_before>#ifndef _NDB_VARKEY_H_
#define _NDB_VARKEY_H_

#include <endian.h>
#include <stdint.h>
#include <string.h>

#include <iostream>
#include <string>
#include <type_traits>
#include <limits>

#include "imstring.h"
#include "macros.h"
#include "util.h"

#include "varstr.h"

#if NDB_MASSTREE
#include "prefetch.h"
#include "masstree/config.h"
#include "masstree/string_slice.hh"
#endif

class varkey {
  friend std::ostream &operator<<(std::ostream &o, const varkey &k);
public:
  inline varkey() : p(NULL), l(0) {}
  inline varkey(const varkey &that) = default;
  inline varkey(varkey &&that) = default;
  inline varkey &operator=(const varkey &that) = default;

  inline varkey(const uint8_t *p, size_t l)
    : p(p), l(l)
  {
  }

  inline varkey(const varstr *s)
    : p(s->data()), l(s->size())
  {
  }

#if 0
  explicit inline varkey(const std::string &s)
    : p((const uint8_t *) s.data()), l(s.size())
  {
  }
#endif

  explicit inline varkey(const char *s)
    : p((const uint8_t *) s), l(strlen(s))
  {
  }

#if 0
  explicit inline varkey(const imstring &s)
    : p(s.data()), l(s.size())
  {
  }
#endif

  inline bool
  operator==(const varkey &that) const
  {
    if (size() != that.size())
      return false;<commit_msg>disable "dangerous" varkey ctors that might be accidentally used wrongly.<commit_after>#ifndef _NDB_VARKEY_H_
#define _NDB_VARKEY_H_

#include <endian.h>
#include <stdint.h>
#include <string.h>

#include <iostream>
#include <string>
#include <type_traits>
#include <limits>

#include "imstring.h"
#include "macros.h"
#include "util.h"

#include "varstr.h"

#if NDB_MASSTREE
#include "prefetch.h"
#include "masstree/config.h"
#include "masstree/string_slice.hh"
#endif

class varkey {
  friend std::ostream &operator<<(std::ostream &o, const varkey &k);
public:
  inline varkey() : p(NULL), l(0) {}
  inline varkey(const varkey &that) = default;
  inline varkey(varkey &&that) = default;
  inline varkey &operator=(const varkey &that) = default;

  inline varkey(const uint8_t *p, size_t l)
    : p(p), l(l)
  {
  }

  inline varkey(const varstr *s)
    : p(s->data()), l(s->size())
  {
  }

#if 0
  explicit inline varkey(const std::string &s)
    : p((const uint8_t *) s.data()), l(s.size())
  {
  }

  explicit inline varkey(const char *s)
    : p((const uint8_t *) s), l(strlen(s))
  {
  }

  explicit inline varkey(const imstring &s)
    : p(s.data()), l(s.size())
  {
  }
#endif

  inline bool
  operator==(const varkey &that) const
  {
    if (size() != that.size())
      return false;
{'fraction_non_alphanumeric': 0.16594402837997635, 'fraction_numerical': 0.0043358297201418995, 'mean_word_length': 3.976470588235294, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '3882121', 'n_tokens_mistral': 1018, 'n_tokens_neox': 1007, 'n_words': 245}