<commit_before>#ifndef __BETTER_CHAIN_H
#define __BETTER_CHAIN_H
#include <Python.h>
#include <string>
#include <iostream>
#include <TTree.h>
#include <TFile.h>
#include <TChain.h>
#include <TLeaf.h>
#include <map>

#include <cassert>
#include <set>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <TObject.h>

#include "Column.h"
#include "util.h"
using namespace std;

//correct TChain implementation with cache TLeaf*
class BetterChain{
public:
    class MiniNotify:public TObject{
    public:
        bool notified;
        TObject* oldnotify;
        MiniNotify(TObject* oldnotify):TObject(),notified(false),oldnotify(oldnotify){}
        virtual Bool_t Notify(){
            notified=true;
            if(oldnotify) oldnotify->Notify();
            return true;
        }
    };
    
    TTree* fChain;
    int fCurrent;
    int ientry;
    MiniNotify* notifier;
    BetterChain(TTree* fChain):fChain(fChain),ientry(0){
        fCurrent = -1;
        notifier = new MiniNotify(fChain->GetNotify());
        fChain->SetNotify(notifier);
        LoadTree(0);
        fChain->SetBranchStatus("*",0);//disable all branches
        //fChain->SetCacheSize(10000000);
    }
    ~BetterChain(){
        if (!fChain) return;//some how i need this(copy from make class)

        fChain->SetNotify(notifier->oldnotify);//do not switch these two lines!
        delete fChain->GetCurrentFile();//root does something funny

        LeafCache::iterator it;
        for(it=leafcache.begin();it!=leafcache.end();++it){<commit_msg>"Should" fix tree=None after reading....<commit_after>#ifndef __BETTER_CHAIN_H
#define __BETTER_CHAIN_H
#include <Python.h>
#include <string>
#include <iostream>
#include <TTree.h>
#include <TFile.h>
#include <TChain.h>
#include <TLeaf.h>
#include <map>

#include <cassert>
#include <set>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <TObject.h>

#include "Column.h"
#include "util.h"
using namespace std;

//correct TChain implementation with cache TLeaf*
class BetterChain{
public:
    class MiniNotify:public TObject{
    public:
        bool notified;
        TObject* oldnotify;
        MiniNotify(TObject* oldnotify):TObject(),notified(false),oldnotify(oldnotify){}
        virtual Bool_t Notify(){
            notified=true;
            if(oldnotify) oldnotify->Notify();
            return true;
        }
    };
    
    TTree* fChain;
    int fCurrent;
    int ientry;
    MiniNotify* notifier;
    BetterChain(TTree* fChain):fChain(fChain),ientry(0){
        fCurrent = -1;
        notifier = new MiniNotify(fChain->GetNotify());
        fChain->SetNotify(notifier);
        LoadTree(0);
        fChain->SetBranchStatus("*",0);//disable all branches
        //fChain->SetCacheSize(10000000);
    }
    
    ~BetterChain(){
        if (!fChain) return;//some how i need this(copy from make class)

        fChain->SetNotify(notifier->oldnotify);//do not switch these two lines!
        //delete fChain->GetCurrentFile();//root does something funny

        LeafCache::iterator it;
        for(it=leafcache.begin();it!=leafcache.end();++it){
{'fraction_non_alphanumeric': 0.13517811704834606, 'fraction_numerical': 0.007633587786259542, 'mean_word_length': 3.238544474393531, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '888985', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1023, 'n_words': 231}