<commit_before>// Jubatus: Online machine learning framework for distributed environment
// Copyright (C) 2011,2012,2014 Preferred Infrastructure and Nippon Telegraph and Telephone Corporation.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License version 2.1 as published by the Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

#ifndef JUBATUS_CORE_FRAMEWORK_MIXABLE_HELPER_HPP_
#define JUBATUS_CORE_FRAMEWORK_MIXABLE_HELPER_HPP_

#include <iostream>
#include <string>
#include <vector>

#include <msgpack.hpp>
#include "jubatus/util/lang/shared_ptr.h"
#include "../common/exception.hpp"
#include "model.hpp"
#include "linear_mixable.hpp"
#include "push_mixable.hpp"

namespace jubatus {
namespace core {
namespace framework {

// This CRTP delegation helper makes a class linear mixable
// which has get_diff and put_diff functions.
// This helper doesn't inherit `model` interface.
// MUST NOT create inheritance the `model`.
template <typename Model, typename Diff>
class linear_mixable_helper : public linear_mixable {
 public:
  typedef Model model_type;
  typedef Diff diff_type;
  typedef jubatus::util::lang::shared_ptr<Model> model_ptr;

  linear_mixable_helper() {
  }

  linear_mixable_helper(model_ptr model)
    : model_(model) {
    if (!model) {
      throw JUBATUS_EXCEPTION(common::config_not_set());
    }
  }

  // TODO: Implement set_model function for temporal core separation
  void set_model(model_ptr m) __attribute__ ((deprecated)) {
    model_ = m;
  }

  virtual ~linear_mixable_helper() {
  }

  model_ptr get_model() const {
    return model_;
  }

  // TODO: Implement set_model function for temporal core separation
  void clear() __attribute__ ((deprecated)) {
    model_->clear();
  }

  diff_object convert_diff_object(const msgpack::object& obj) const {<commit_msg>Add deprecated attribute to construcutor of mixable helper<commit_after>// Jubatus: Online machine learning framework for distributed environment
// Copyright (C) 2011,2012,2014 Preferred Infrastructure and Nippon Telegraph and Telephone Corporation.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License version 2.1 as published by the Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

#ifndef JUBATUS_CORE_FRAMEWORK_MIXABLE_HELPER_HPP_
#define JUBATUS_CORE_FRAMEWORK_MIXABLE_HELPER_HPP_

#include <iostream>
#include <string>
#include <vector>

#include <msgpack.hpp>
#include "jubatus/util/lang/shared_ptr.h"
#include "../common/exception.hpp"
#include "model.hpp"
#include "linear_mixable.hpp"
#include "push_mixable.hpp"

namespace jubatus {
namespace core {
namespace framework {

// This CRTP delegation helper makes a class linear mixable
// which has get_diff and put_diff functions.
// This helper doesn't inherit `model` interface.
// MUST NOT create inheritance the `model`.
template <typename Model, typename Diff>
class linear_mixable_helper : public linear_mixable {
 public:
  typedef Model model_type;
  typedef Diff diff_type;
  typedef jubatus::util::lang::shared_ptr<Model> model_ptr;

  linear_mixable_helper() __attribute__ ((deprecated)) {
  }

  linear_mixable_helper(model_ptr model)
    : model_(model) {
    if (!model) {
      throw JUBATUS_EXCEPTION(common::config_not_set());
    }
  }

  // TODO: Implement set_model function for temporal core separation
  void set_model(model_ptr m) __attribute__ ((deprecated)) {
    model_ = m;
  }

  virtual ~linear_mixable_helper() {
  }

  model_ptr get_model() const {
    return model_;
  }

  // TODO: Implement set_model function for temporal core separation
  void clear() __attribute__ ((deprecated)) {
    model_->clear();
  }

  diff_object convert_diff_object(const msgpack::object& obj) const {
{'fraction_non_alphanumeric': 0.08560637851447755, 'fraction_numerical': 0.01049097775912715, 'mean_word_length': 4.392533936651584, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '4879955', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1339, 'n_words': 503}