Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TMPWorkerTree Class Reference

This class works in conjunction with TTreeProcessorMP, reacting to messages received from it as specified by the Notify and HandleInput methods.

Definition at line 34 of file TMPWorkerTree.h.

Public Member Functions

 TMPWorkerTree ()
 Class constructors.
 TMPWorkerTree (const std::vector< std::string > &fileNames, TEntryList *entries, const std::string &treeName, UInt_t nWorkers, ULong64_t maxEntries, ULong64_t firstEntry)
 TMPWorkerTree (const TMPWorkerTree &)=delete
 TMPWorkerTree (TTree *tree, TEntryList *entries, UInt_t nWorkers, ULong64_t maxEntries, ULong64_t firstEntry)
 ~TMPWorkerTree () override
unsigned GetNWorker () const
pid_t GetPid ()
TSocketGetSocket ()
virtual void Init (int fd, unsigned workerN)
 This method is called by children processes right after forking.
TMPWorkerTreeoperator= (const TMPWorkerTree &)=delete
void Run ()

Protected Member Functions

void CloseFile ()
 Handle file closing.
ULong64_t EvalMaxEntries (ULong64_t maxEntries)
 Max entries evaluation.
void HandleInput (MPCodeBufPair &msg) override
 Execute instructions received from a MP client.
void Init (int fd, UInt_t workerN) override
 Init overload defining max entries.
Int_t LoadTree (UInt_t code, MPCodeBufPair &msg, Long64_t &start, Long64_t &finish, TEntryList **enl, std::string &errmsg)
 Load the required tree and evaluate the processing range.
TFileOpenFile (const std::string &fileName)
 Handle file opening.
virtual void Process (UInt_t, MPCodeBufPair &)
TTreeRetrieveTree (TFile *fp)
 Retrieve a tree from an open file.
void SendError (const std::string &errmsg, unsigned int code=MPCode::kError)
 Error sender.
virtual void SendResult ()
void Setup ()
 Auxiliary method for common initialization.
void SetupTreeCache (TTree *tree)
 Tree cache handling.

Protected Attributes

TEntryListfEntryList
 entrylist
TFilefFile
 last open file
std::vector< std::string > fFileNames
 the files to be processed by all workers
ULong64_t fFirstEntry
 first entry to br processed
std::string fId
 identifier string in the form W<nwrk>|P<proc id>
ULong64_t fMaxNEntries
 the maximum number of entries to be processed by this worker
unsigned fNWorkers
 the number of workers spawned
ULong64_t fProcessedEntries
 the number of entries processed by this worker so far
TTreefTree
 pointer to the tree to be processed. It is only used if the tree is directly passed to TProcessExecutor::Process as argument
std::string fTreeName
 the name of the tree to be processed

Private Attributes

Long64_t fCacheSize
 Cache size.
unsigned fNWorker
 the ordinal number of this worker (0 to nWorkers-1)
pid_t fPid
 the PID of the process in which this worker is running
std::unique_ptr< TSocketfS
 This worker's socket. The unique_ptr makes sure resources are released.
TTreeCachefTreeCache
 instance of the tree cache for the tree
bool fTreeCacheIsLearning
 Whether cache is in learning phase.
bool fUseTreeCache
 Control usage of the tree cache.

#include <TMPWorkerTree.h>

Inheritance diagram for TMPWorkerTree:
TMPWorker TMPWorkerTreeFunc< F > TMPWorkerTreeSel

Constructor & Destructor Documentation

◆ TMPWorkerTree() [1/4]

TMPWorkerTree::TMPWorkerTree ( )

Class constructors.

Note that this does not set variables like fPid or fS (worker's socket).
These operations are handled by the Init method, which is called after forking.
This separation is in place because the instantiation of a worker must be done once before forking, while the initialization of the members must be done after forking by each of the children processes.

Definition at line 46 of file TMPWorkerTree.cxx.

◆ TMPWorkerTree() [2/4]

TMPWorkerTree::TMPWorkerTree ( const std::vector< std::string > & fileNames,
TEntryList * entries,
const std::string & treeName,
UInt_t nWorkers,
ULong64_t maxEntries,
ULong64_t firstEntry )

Definition at line 53 of file TMPWorkerTree.cxx.

◆ TMPWorkerTree() [3/4]

TMPWorkerTree::TMPWorkerTree ( TTree * tree,
TEntryList * entries,
UInt_t nWorkers,
ULong64_t maxEntries,
ULong64_t firstEntry )

Definition at line 62 of file TMPWorkerTree.cxx.

◆ ~TMPWorkerTree()

TMPWorkerTree::~TMPWorkerTree ( )
override

Definition at line 70 of file TMPWorkerTree.cxx.

◆ TMPWorkerTree() [4/4]

TMPWorkerTree::TMPWorkerTree ( const TMPWorkerTree & )
delete

Member Function Documentation

◆ CloseFile()

void TMPWorkerTree::CloseFile ( )
protected

Handle file closing.

Definition at line 88 of file TMPWorkerTree.cxx.

◆ EvalMaxEntries()

ULong64_t TMPWorkerTree::EvalMaxEntries ( ULong64_t maxEntries)
protected

Max entries evaluation.

Definition at line 190 of file TMPWorkerTree.cxx.

◆ GetNWorker()

unsigned TMPWorker::GetNWorker ( ) const
inlineinherited

Definition at line 41 of file TMPWorker.h.

◆ GetPid()

pid_t TMPWorker::GetPid ( )
inlineinherited

Definition at line 40 of file TMPWorker.h.

◆ GetSocket()

TSocket * TMPWorker::GetSocket ( )
inlineinherited

Definition at line 39 of file TMPWorker.h.

◆ HandleInput()

void TMPWorkerTree::HandleInput ( MPCodeBufPair & msg)
overrideprotectedvirtual

Execute instructions received from a MP client.

Generic input handling.

Reimplemented from TMPWorker.

Definition at line 204 of file TMPWorkerTree.cxx.

◆ Init() [1/2]

void TMPWorker::Init ( int fd,
unsigned workerN )
virtualinherited

This method is called by children processes right after forking.

Initialization of worker properties that must be delayed until after forking must be done here.
For example, Init saves the pid into fPid, and adds the TMPWorker to the main eventloop (as a TFileHandler).
Make sure this operations are performed also by overriding implementations, e.g. by calling TMPWorker::Init explicitly.

Definition at line 52 of file TMPWorker.cxx.

◆ Init() [2/2]

void TMPWorkerTree::Init ( int fd,
UInt_t workerN )
overrideprotected

Init overload defining max entries.

Definition at line 180 of file TMPWorkerTree.cxx.

◆ LoadTree()

Int_t TMPWorkerTree::LoadTree ( UInt_t code,
MPCodeBufPair & msg,
Long64_t & start,
Long64_t & finish,
TEntryList ** enl,
std::string & errmsg )
protected

Load the required tree and evaluate the processing range.

Definition at line 276 of file TMPWorkerTree.cxx.

◆ OpenFile()

TFile * TMPWorkerTree::OpenFile ( const std::string & fileName)
protected

Handle file opening.

Definition at line 101 of file TMPWorkerTree.cxx.

◆ operator=()

TMPWorkerTree & TMPWorkerTree::operator= ( const TMPWorkerTree & )
delete

◆ Process()

virtual void TMPWorkerTree::Process ( UInt_t ,
MPCodeBufPair &  )
inlineprotectedvirtual

Reimplemented in TMPWorkerTreeFunc< F >, and TMPWorkerTreeSel.

Definition at line 56 of file TMPWorkerTree.h.

◆ RetrieveTree()

TTree * TMPWorkerTree::RetrieveTree ( TFile * fp)
protected

Retrieve a tree from an open file.

Definition at line 119 of file TMPWorkerTree.cxx.

◆ Run()

void TMPWorker::Run ( )
inherited

Definition at line 61 of file TMPWorker.cxx.

◆ SendError()

void TMPWorker::SendError ( const std::string & errmsg,
unsigned int code = MPCode::kError )
protectedinherited

Error sender.

Definition at line 112 of file TMPWorker.cxx.

◆ SendResult()

virtual void TMPWorkerTree::SendResult ( )
inlineprotectedvirtual

Reimplemented in TMPWorkerTreeFunc< F >, and TMPWorkerTreeSel.

Definition at line 58 of file TMPWorkerTree.h.

◆ Setup()

void TMPWorkerTree::Setup ( )
protected

Auxiliary method for common initialization.

Definition at line 78 of file TMPWorkerTree.cxx.

◆ SetupTreeCache()

void TMPWorkerTree::SetupTreeCache ( TTree * tree)
protected

Tree cache handling.

Definition at line 151 of file TMPWorkerTree.cxx.

Member Data Documentation

◆ fCacheSize

Long64_t TMPWorkerTree::fCacheSize
private

Cache size.

Definition at line 75 of file TMPWorkerTree.h.

◆ fEntryList

TEntryList* TMPWorkerTree::fEntryList
protected

entrylist

Definition at line 66 of file TMPWorkerTree.h.

◆ fFile

TFile* TMPWorkerTree::fFile
protected

last open file

Definition at line 65 of file TMPWorkerTree.h.

◆ fFileNames

std::vector<std::string> TMPWorkerTree::fFileNames
protected

the files to be processed by all workers

Definition at line 62 of file TMPWorkerTree.h.

◆ fFirstEntry

ULong64_t TMPWorkerTree::fFirstEntry
protected

first entry to br processed

Definition at line 67 of file TMPWorkerTree.h.

◆ fId

std::string TMPWorker::fId
protectedinherited

identifier string in the form W<nwrk>|P<proc id>

Definition at line 44 of file TMPWorker.h.

◆ fMaxNEntries

ULong64_t TMPWorker::fMaxNEntries
protectedinherited

the maximum number of entries to be processed by this worker

Definition at line 46 of file TMPWorker.h.

◆ fNWorker

unsigned TMPWorker::fNWorker
privateinherited

the ordinal number of this worker (0 to nWorkers-1)

Definition at line 56 of file TMPWorker.h.

◆ fNWorkers

unsigned TMPWorker::fNWorkers
protectedinherited

the number of workers spawned

Definition at line 45 of file TMPWorker.h.

◆ fPid

pid_t TMPWorker::fPid
privateinherited

the PID of the process in which this worker is running

Definition at line 55 of file TMPWorker.h.

◆ fProcessedEntries

ULong64_t TMPWorker::fProcessedEntries
protectedinherited

the number of entries processed by this worker so far

Definition at line 47 of file TMPWorker.h.

◆ fS

std::unique_ptr<TSocket> TMPWorker::fS
privateinherited

This worker's socket. The unique_ptr makes sure resources are released.

Definition at line 54 of file TMPWorker.h.

◆ fTree

TTree* TMPWorkerTree::fTree
protected

pointer to the tree to be processed. It is only used if the tree is directly passed to TProcessExecutor::Process as argument

Definition at line 64 of file TMPWorkerTree.h.

◆ fTreeCache

TTreeCache* TMPWorkerTree::fTreeCache
private

instance of the tree cache for the tree

Definition at line 72 of file TMPWorkerTree.h.

◆ fTreeCacheIsLearning

bool TMPWorkerTree::fTreeCacheIsLearning
private

Whether cache is in learning phase.

Definition at line 73 of file TMPWorkerTree.h.

◆ fTreeName

std::string TMPWorkerTree::fTreeName
protected

the name of the tree to be processed

Definition at line 63 of file TMPWorkerTree.h.

◆ fUseTreeCache

bool TMPWorkerTree::fUseTreeCache
private

Control usage of the tree cache.

Definition at line 74 of file TMPWorkerTree.h.


The documentation for this class was generated from the following files: