<commit_before>/**
 * This file is part of the CernVM File System.
 */

#include "upload_spooler_definition.h"

#include <vector>

#include "logging.h"
#include "util.h"

using namespace upload;

SpoolerDefinition::SpoolerDefinition(
                      const std::string& definition_string,
                      const bool         use_file_chunking,
                      const size_t       min_file_chunk_size,
                      const size_t       avg_file_chunk_size,
                      const size_t       max_file_chunk_size) :
  driver_type(Unknown),
  use_file_chunking(use_file_chunking),
  min_file_chunk_size(min_file_chunk_size),
  avg_file_chunk_size(avg_file_chunk_size),
  max_file_chunk_size(max_file_chunk_size),
  valid_(false)
{
  // check if given file chunking values are sane
  if (use_file_chunking && (min_file_chunk_size >= avg_file_chunk_size ||
                            avg_file_chunk_size >= max_file_chunk_size)) {
    LogCvmfs(kLogSpooler, kLogStderr, "file chunk size values are not sane");
    return;
  }

  // split the spooler driver definition into name and config part
  std::vector<std::string> upstream = SplitString(definition_string, ',');
  if (upstream.size() != 3) {
    LogCvmfs(kLogSpooler, kLogStderr, "Invalid spooler driver");
    return;
  }

  // recognize and configure the spooler driver
  if (upstream[0]        == "local") {
    driver_type = Local;
  } else if (upstream[0] == "riak") {
    driver_type = Riak;
  } else {
    LogCvmfs(kLogSpooler, kLogStderr, "unknown spooler driver: %s",
      upstream[0].c_str());
    return;
  }

  // save data
  temporary_path        = upstream[1];
  spooler_configuration = upstream[2];
  valid_ = true;
}
<commit_msg>add a 'mock' uploader type to allow for testing<commit_after>/**
 * This file is part of the CernVM File System.
 */

#include "upload_spooler_definition.h"

#include <vector>

#include "logging.h"
#include "util.h"

using namespace upload;

SpoolerDefinition::SpoolerDefinition(
                      const std::string& definition_string,
                      const bool         use_file_chunking,
                      const size_t       min_file_chunk_size,
                      const size_t       avg_file_chunk_size,
                      const size_t       max_file_chunk_size) :
  driver_type(Unknown),
  use_file_chunking(use_file_chunking),
  min_file_chunk_size(min_file_chunk_size),
  avg_file_chunk_size(avg_file_chunk_size),
  max_file_chunk_size(max_file_chunk_size),
  valid_(false)
{
  // check if given file chunking values are sane
  if (use_file_chunking && (min_file_chunk_size >= avg_file_chunk_size ||
                            avg_file_chunk_size >= max_file_chunk_size)) {
    LogCvmfs(kLogSpooler, kLogStderr, "file chunk size values are not sane");
    return;
  }

  // split the spooler driver definition into name and config part
  std::vector<std::string> upstream = SplitString(definition_string, ',');
  if (upstream.size() != 3) {
    LogCvmfs(kLogSpooler, kLogStderr, "Invalid spooler driver");
    return;
  }

  // recognize and configure the spooler driver
  if (upstream[0]        == "local") {
    driver_type = Local;
  } else if (upstream[0] == "riak") {
    driver_type = Riak;
  } else if (upstream[0] == "mock") {
    driver_type = Unknown; // for unit testing purpose only!
  } else {
    LogCvmfs(kLogSpooler, kLogStderr, "unknown spooler driver: %s",
      upstream[0].c_str());
    return;
  }

  // save data
  temporary_path        = upstream[1];
  spooler_configuration = upstream[2];
  valid_ = true;
}

{'fraction_non_alphanumeric': 0.099581589958159, 'fraction_numerical': 0.0036262203626220364, 'mean_word_length': 2.9105779716466738, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4606419', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1170, 'n_words': 265}