<commit_before>#ifndef VAST_ACTOR_SINK_BASE_H
#define VAST_ACTOR_SINK_BASE_H

#include "vast/concept/printable/vast/error.h"
#include "vast/concept/printable/vast/event.h"
#include "vast/concept/printable/vast/time.h"
#include "vast/concept/printable/vast/uuid.h"
#include "vast/actor/actor.h"
#include "vast/event.h"
#include "vast/time.h"
#include "vast/uuid.h"

namespace vast {
namespace sink {

/// The base class for event sinks.
template <typename Derived>
class base : public default_actor
{
public:
  base(char const* name = "sink")
    : default_actor{name}
  {
    trap_exit(true);
  }

  void on_exit() override
  {
    static_cast<Derived*>(this)->flush();
    accountant_ = caf::invalid_actor;
  }

  caf::behavior make_behavior() override
  {
    using namespace caf;
    last_flush_ = time::snapshot();
    return
    {
      [=](exit_msg const& msg)
      {
        quit(msg.reason);
      },
      [=](limit_atom, uint64_t max)
      {
        VAST_DEBUG(this, "caps event export at", max, "events");
        if (processed_ < max)
          limit_ = max;
        else
          VAST_WARN(this, "ignores new limit of", max,
                    "(already processed", processed_, " events)");
      },
      [=](accountant_atom, actor const& accountant)
      {
        VAST_DEBUG(this, "registers accountant", accountant);
        accountant_ = accountant;
        send(accountant_, label() + "-events", time::now());
      },
      [=](uuid const&, event const& e)
      {
        handle(e);
      },
      [=](uuid const&, std::vector<event> const& v)
      {
        assert(! v.empty());
        for (auto& e : v)
          if (! handle(e))
            return;
        if (accountant_)
          send(accountant_, static_cast<uint64_t>(v.size()), time::snapshot());
      },
      [=](uuid const& id, progress_atom, double progress, uint64_t total_hits)
      {<commit_msg>Fix accountant registration for sinks<commit_after>#ifndef VAST_ACTOR_SINK_BASE_H
#define VAST_ACTOR_SINK_BASE_H

#include "vast/concept/printable/vast/error.h"
#include "vast/concept/printable/vast/event.h"
#include "vast/concept/printable/vast/time.h"
#include "vast/concept/printable/vast/uuid.h"
#include "vast/actor/actor.h"
#include "vast/event.h"
#include "vast/time.h"
#include "vast/uuid.h"

namespace vast {
namespace sink {

/// The base class for event sinks.
template <typename Derived>
class base : public default_actor
{
public:
  base(char const* name = "sink")
    : default_actor{name}
  {
    trap_exit(true);
  }

  void on_exit() override
  {
    static_cast<Derived*>(this)->flush();
    accountant_ = caf::invalid_actor;
  }

  caf::behavior make_behavior() override
  {
    using namespace caf;
    last_flush_ = time::snapshot();
    return
    {
      [=](exit_msg const& msg)
      {
        quit(msg.reason);
      },
      [=](limit_atom, uint64_t max)
      {
        VAST_DEBUG(this, "caps event export at", max, "events");
        if (processed_ < max)
          limit_ = max;
        else
          VAST_WARN(this, "ignores new limit of", max,
                    "(already processed", processed_, " events)");
      },
      [=](put_atom, accountant_atom, actor const& accountant)
      {
        VAST_DEBUG(this, "registers accountant", accountant);
        accountant_ = accountant;
        send(accountant_, label() + "-events", time::now());
      },
      [=](uuid const&, event const& e)
      {
        handle(e);
      },
      [=](uuid const&, std::vector<event> const& v)
      {
        assert(! v.empty());
        for (auto& e : v)
          if (! handle(e))
            return;
        if (accountant_)
          send(accountant_, static_cast<uint64_t>(v.size()), time::snapshot());
      },
      [=](uuid const& id, progress_atom, double progress, uint64_t total_hits)
      {
{'fraction_non_alphanumeric': 0.14431639601885804, 'fraction_numerical': 0.003143006809848088, 'mean_word_length': 2.644083969465649, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4523513', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1247, 'n_words': 277}