<commit_before>/*
 * author: <NAME> <<EMAIL>>
 */

#include "istream_unlock.hxx"
#include "istream/ForwardIstream.hxx"
#include "cache.hxx"

#include <assert.h>

class UnlockIstream final : public ForwardIstream {
    struct cache &cache;
    struct cache_item &item;

public:
    UnlockIstream(struct pool &p, Istream &_input,
                  struct cache &_cache, struct cache_item &_item)
        :ForwardIstream(p, _input,
                        MakeIstreamHandler<UnlockIstream>::handler, this),
         cache(_cache), item(_item) {
        cache_item_lock(&item);
    }

    virtual ~UnlockIstream() {
        cache_item_unlock(&cache, &item);
    }
};

Istream *
istream_unlock_new(struct pool &pool, Istream &input,
                   struct cache &cache, struct cache_item &item)
{
    return NewIstream<UnlockIstream>(pool, input, cache, item);
}
<commit_msg>istream_unlock: implement _FillBucketList()<commit_after>/*
 * author: <NAME> <<EMAIL>>
 */

#include "istream_unlock.hxx"
#include "istream/ForwardIstream.hxx"
#include "cache.hxx"

#include <assert.h>

class UnlockIstream final : public ForwardIstream {
    struct cache &cache;
    struct cache_item &item;

public:
    UnlockIstream(struct pool &p, Istream &_input,
                  struct cache &_cache, struct cache_item &_item)
        :ForwardIstream(p, _input,
                        MakeIstreamHandler<UnlockIstream>::handler, this),
         cache(_cache), item(_item) {
        cache_item_lock(&item);
    }

    virtual ~UnlockIstream() {
        cache_item_unlock(&cache, &item);
    }

    bool _FillBucketList(IstreamBucketList &list, GError **error_r) override {
        return input.FillBucketList(list, error_r);
    }

    size_t _ConsumeBucketList(size_t nbytes) override {
        auto consumed = input.ConsumeBucketList(nbytes);
        Consumed(consumed);
        return consumed;
    }
};

Istream *
istream_unlock_new(struct pool &pool, Istream &input,
                   struct cache &cache, struct cache_item &item)
{
    return NewIstream<UnlockIstream>(pool, input, cache, item);
}

{'fraction_non_alphanumeric': 0.1126018207954001, 'fraction_numerical': 0.0, 'mean_word_length': 3.1510934393638173, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4403267', 'n_tokens_mistral': 663, 'n_tokens_neox': 648, 'n_words': 147}