<commit_before>#ifndef RDB_PROTOCOL_TERMS_OBJ_OR_SEQ_HPP_
#define RDB_PROTOCOL_TERMS_OBJ_OR_SEQ_HPP_

#include <string>

#include "rdb_protocol/op.hpp"
#include "rdb_protocol/error.hpp"
#include "rdb_protocol/pb_utils.hpp"

namespace ql {

// This term is used for functions that are polymorphic on objects and
// sequences, like `pluck`.  It will handle the polymorphism; terms inheriting
// from it just need to implement evaluation on objects (`obj_eval`).
class obj_or_seq_op_term_t : public op_term_t {
public:
    // SAMRSI: Does op_term_t (and term_t) really need a protob_t<>?  It would be cool if it didn't.
    obj_or_seq_op_term_t(env_t *env, protob_t<const Term> term, argspec_t argspec)
        : op_term_t(env, term, argspec), map_func(make_counted_term()) {
        int varnum = env->gensym();
        // SAMRSI: Check the pb::set_func lifetiming here...
        Term *body = pb::set_func(map_func.get(), varnum);
        *body = *term;
        // SAMRSI: Check the lifetiming here too.
        pb::set_var(pb::reset(body->mutable_args(0)), varnum);
        // SAMRSI: Also check the lifetiming here.
        prop_bt(map_func.get());
    }
private:
    virtual counted_t<val_t> obj_eval() = 0;
    virtual counted_t<val_t> eval_impl() {
        counted_t<val_t> v0 = arg(0);
        if (v0->get_type().is_convertible(val_t::type_t::DATUM)) {
            if (v0->as_datum()->get_type() == datum_t::R_OBJECT) return obj_eval();
        }
        if (v0->get_type().is_convertible(val_t::type_t::SEQUENCE)) {<commit_msg>Removed SAMRSIs in obj_or_seq.hpp.<commit_after>#ifndef RDB_PROTOCOL_TERMS_OBJ_OR_SEQ_HPP_
#define RDB_PROTOCOL_TERMS_OBJ_OR_SEQ_HPP_

#include <string>

#include "rdb_protocol/op.hpp"
#include "rdb_protocol/error.hpp"
#include "rdb_protocol/pb_utils.hpp"

namespace ql {

// This term is used for functions that are polymorphic on objects and
// sequences, like `pluck`.  It will handle the polymorphism; terms inheriting
// from it just need to implement evaluation on objects (`obj_eval`).
class obj_or_seq_op_term_t : public op_term_t {
public:
    obj_or_seq_op_term_t(env_t *env, protob_t<const Term> term, argspec_t argspec)
        : op_term_t(env, term, argspec), map_func(make_counted_term()) {
        int varnum = env->gensym();
        Term *body = pb::set_func(map_func.get(), varnum);
        *body = *term;
        pb::set_var(pb::reset(body->mutable_args(0)), varnum);
        prop_bt(map_func.get());
    }
private:
    virtual counted_t<val_t> obj_eval() = 0;
    virtual counted_t<val_t> eval_impl() {
        counted_t<val_t> v0 = arg(0);
        if (v0->get_type().is_convertible(val_t::type_t::DATUM)) {
            if (v0->as_datum()->get_type() == datum_t::R_OBJECT) return obj_eval();
        }
        if (v0->get_type().is_convertible(val_t::type_t::SEQUENCE)) {
{'fraction_non_alphanumeric': 0.12827781715095676, 'fraction_numerical': 0.004961020552799433, 'mean_word_length': 3.825641025641026, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 26, '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': '6872358', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1041, 'n_words': 225}