47 const char *textfile,
Int_t nfiles,
Int_t firstfile)
81 Warning(
"Add",
"file: '%s' already in the list - ignoring",
127 Int_t ff = (!all && (firstfile < 1)) ? 1 : firstfile;
129 while (
f.good() && (all || nf < nfiles)) {
133 if (!
line.IsWhitespace() && !
line.BeginsWith(
"#")) {
135 if (all || nn >= ff) {
146 Error(
"AddFromFile",
"unable to open file %s (%s)", textfile, fn.
Data());
166 Error(
"Add",
"input dir undefined");
174 if (
gSystem->GetPathInfo(dir, st) == 0 ||
175 gSystem->GetPathInfo(baseDir, tmp) == 0) {
186 void *dataSetDir =
gSystem->OpenDirectory(
gSystem->GetDirName(dir).Data());
189 Error(
"Add",
"directory %s cannot be opened",
190 gSystem->GetDirName(dir).Data());
196 while ((ent =
gSystem->GetDirEntry(dataSetDir))) {
214 gSystem->FreeDirectory(dataSetDir);
247 Info(
"RemoveDuplicates",
"%d duplicates found and removed", nr);
266 subset->
Add(fileInfo);
290 Error(
"Add",
"attempt to add object of class: %s to a %s",
291 o->ClassName(),this->ClassName());
337 while ((fileInfo =
dynamic_cast<TFileInfo*
> (iter.
Next()))) {
356 while ((obj = metaDataIter.
Next())) {
406 TPMERegexp re(
"(^|;| )filter:([SsCc]+)( |;|$)", 4);
407 if (re.
Match(option) == 4) {
413 Printf(
"TFileCollection %s - %s contains: %lld files with a size of"
414 " %lld bytes, %.1f %% staged - default tree name: '%s'",
419 Printf(
"The files contain the following trees:");
432 Printf(
"The collection contains the following files:");
445 bS = bs = bC = bc =
kFALSE;
453 if (!bc && !bC) bc = bC =
kTRUE;
454 if (!bs && !bS) bs = bS =
kTRUE;
461 Printf(
"\033[1m #. SC | Entries | Size | URL\033[m");
475 if ( ((s && bS) || (!s && bs)) && ((
c && bC) || (!
c && bc)) ) {
487 const char *curUrlStr = curUrl ? curUrl->
GetUrl() :
"n.a.";
488 Printf(
"\033[1m%4u.\033[m %c%c | %-7s | %6.1lf %s | %s",
490 (s ?
'S' :
's'), (
c ?
'C' :
'c'),
491 ((entries > 0) ?
Form(
"% 7d", entries) :
"n.a."),
492 sz, um.
Data(), curUrlStr);
496 while ((url = info->
NextUrl())) {
507 Printf(
">> There are \033[1m%u\033[m file(s) in dataset: "
508 "\033[1m%u (%5.1f%%)\033[m matched your criteria (%s)",
509 countAll, countMatch,
513 Printf(
">> Total size : \033[1m%.1f %s\033[m", sz, um.
Data());
515 Printf(
">> Corrupted (C) : \033[1m%5.1f %%\033[m",
520 Printf(
">> No files in dataset");
524 Printf(
">> Default tree : \033[1m%s\033[m",
525 (treeName ? treeName :
"(no default tree)"));
535 static const char *ums[] = {
"byt",
"KiB",
"MiB",
"GiB",
"TiB" };
536 Int_t maxDiv =
sizeof(ums)/
sizeof(
const char *);
540 while ((
b >= 1024.) && (nDiv+1 < maxDiv)) {
562 while ((url = fileInfo->
NextUrl()))
623 if (!tree || !*tree) {
734 if (popt == 0) treeInfo.
Resize(25);
737 const char *unit[4] = {
"kB",
"MB",
"GB",
"TB"};
741 while (xsz > 1024 && k < 3) {
754 outs =
new TObjString(
Form(
"%s %lld files, %lld %s, staged %d %%, tree: %s", dsname.
Data(),
775 if (!server || strlen(server) <= 0) {
776 Info(
"GetFilesOnServer",
"server undefined - do nothing");
782 Info(
"GetFilesOnServer",
"the list is empty - do nothing");
788 TString srv, scheme(
"root"), port;
791 srv.
Form(
"%s://%s%s", scheme.Data(),
TUrl(server).GetHostFQDN(), port.
Data());
793 Info(
"GetFilesOnServer",
"searching for files on server: '%s' (input: '%s')",
800 title.Form(
"%s (subset on server %s)",
GetTitle(), srv.
Data());
802 title.Form(
"subset of '%s' on server %s",
GetName(), srv.
Data());
831 Info(
"GetFilesOnServer",
"adding: %s", xu->
GetUrl());
840 Info(
"GetFilesOnServer",
"dataset '%s' has no files on server: '%s' (searched for: '%s')",
866 TMap *dsmap =
nullptr;
870 Info(
"GetFilesPerServer",
"the list is empty - do nothing");
876 if (exclude && strlen(exclude) > 0) {
880 TString srvs(exclude), s, srv, scheme, port;
882 while (srvs.Tokenize(s, from,
",")) {
908 TUrl *xurl =
nullptr;
909 while ((xurl = (curronly) ? curl : fi->
NextUrl())) {
916 }
else if (excl && xurl->
GetPort() > 0) {
925 TPair *ent =
nullptr;
931 title.Form(
"%s (subset on server %s)",
GetTitle(), key.
Data());
933 title.Form(
"subset of '%s' on server %s",
GetName(), key.
Data());
942 Info(
"GetFilesPerServer",
"found server: '%s' (fc: %p)", key.
Data(), fc);
981 if (excl)
delete excl;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
long long Long64_t
Portable signed long integer 8 bytes.
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Bool_t R_ISREG(Int_t mode)
Collection abstract base class.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Bool_t IsEmpty() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file collection object.
TFileCollection * GetStagedSubset()
Creates a subset of the files that have the kStaged & !kCorrupted bit set.
TMap * GetFilesPerServer(const char *exclude=nullptr, Bool_t curronly=kFALSE)
Return a map of TFileCollections with the files on each data server, excluding servers in the comma-s...
TObjString * ExportInfo(const char *name=nullptr, Int_t popt=0)
Export the relevant info as a string; use 'name' as collection name, if defined, else use GetName().
Int_t RemoveDuplicates()
Remove duplicates based on the UUID, typically after a verification.
Int_t Update(Long64_t avgsize=-1)
Update accumulated information about the elements of the collection (e.g.
TFileCollection(const TFileCollection &)=delete
Long64_t GetTotalEntries(const char *tree) const
Returns the number of entries for the specified tree (retrieved from meta data).
void SetBitAll(UInt_t f)
Set the bit for all TFileInfos.
void Sort(Bool_t useindex=kFALSE)
Sort the collection.
void SetAnchor(const char *anchor)
Calls TUrl::SetAnchor() for all URLs contained in all TFileInfos.
void ResetBitAll(UInt_t f)
Reset the bit for all TFileInfos.
Float_t GetStagedPercentage() const
void FormatSize(Long64_t bytes, TString &um, Double_t &size) const
Format size.
void SetDefaultMetaData(const char *meta)
Moves the indicated meta data in the first position, so that it becomes effectively the default.
virtual ~TFileCollection()
Cleanup.
void SetDefaultTreeName(const char *treeName)
Long64_t GetNFiles() const
Long64_t GetTotalSize() const
void RemoveMetaData(const char *meta=nullptr)
Removes the indicated meta data object in all TFileInfos and this object If no name is given all meta...
Long64_t Merge(TCollection *list)
Merge all TFileCollection objects in li into this TFileCollection object.
Int_t AddFromFile(const char *file, Int_t nfiles=-1, Int_t firstfile=1)
Add file names contained in the specified text file.
void Print(Option_t *option="") const override
Prints the contents of the TFileCollection.
const char * GetDefaultTreeName() const
Returns the tree set with SetDefaultTreeName if set Returns the name of the first tree in the meta da...
Float_t GetCorruptedPercentage() const
Int_t Add(TFileInfo *info)
Add TFileInfo to the collection.
void PrintDetailed(TString &showOnly) const
Print detailed.
TFileCollection * GetFilesOnServer(const char *server)
Return the subset of files served by 'server'.
TFileInfoMeta * GetMetaData(const char *meta=nullptr) const
Returns the meta data object with the specified meta name.
Class describing a generic file including meta information.
TUrl * NextUrl()
Iterator function, start iteration by calling ResetUrl().
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file info object.
TList * GetMetaDataList() const
TFileInfoMeta * GetMetaData(const char *meta=nullptr) const
Get meta data object with specified name.
Bool_t RemoveMetaData(const char *meta=nullptr)
Remove the metadata object.
Bool_t SetCurrentUrl(const char *url)
Set 'url' as current URL, if in the list Return kFALSE if not in the list.
TUrl * FindByUrl(const char *url, Bool_t withDeflt=kFALSE)
Find an element from a URL. Returns 0 if not found.
TUrl * GetCurrentUrl() const
Return the current url.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
TObject * FindObject(const char *name) const override
Find object using its name.
void Add(TObject *obj) override
const char * AsString() const
Return message digest as string.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
void Add(TObject *obj) override
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
TObject * FindObject(const char *keyname) const override
Check if a (key,value) pair exists with keyname as name of the key.
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
Collectable string class.
Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TObject()
TObject constructor.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Int_t Match(const TString &s, UInt_t start=0)
Runs a match on s against the regex 'this' was created with.
Class used by TMap to store (key,value) pairs.
Regular expression class.
TString & Insert(Ssiz_t pos, const char *s)
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
This class represents a RFC 3986 compatible URI.
const TString GetPort() const
Bool_t SetUri(const TString &uri)
Parse URI and set the member variables accordingly, returns kTRUE if URI validates,...
const TString GetScheme() const
This class represents a WWW compatible URL.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
void SetAnchor(const char *anchor)
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
const char * GetProtocol() const