66#define THDFSFile_TRACE 
   67#ifndef THDFSFile_TRACE 
   69  Debug("THDFSFile", "%s", x);
 
   80                     const char *ftitle, 
Int_t compress):
 
   81   TFile(path, 
"WEB", ftitle, compress)
 
   94   if (!create && !recreate && !
update && !read) {
 
  101   struct hdfsBuilder *bld = hdfsNewBuilder();
 
  103      SysError(
"THDFSFile", 
"Error creating hdfs builder");
 
  111      const char *user = (ugi->
fUser).Data();
 
  112      hdfsBuilderSetUserName(bld, user);
 
  116   fFS = hdfsBuilderConnect(bld);
 
  119      SysError(
"THDFSFile", 
"HDFS client for %s cannot open the filesystem",
 
  124   if (create || 
update || recreate) {
 
  125      Int_t mode = O_RDWR | O_CREAT;
 
  126      if (recreate) mode |= O_TRUNC;
 
  134         SysError(
"THDFSFile", 
"file %s can not be opened", path);
 
  145         SysError(
"THDFSFile", 
"file %s can not be opened for reading", path);
 
  151   Init(create || recreate);
 
  182   tSize num_read_total = 0;
 
  185      tSize num_read = hdfsRead((hdfsFS)
fFS, (hdfsFile)
fHdfsFH, (
char *)buf + num_read_total, len - num_read_total);
 
  186      num_read_total += num_read;
 
  190      } 
else if (num_read == 0) {
 
  193   } 
while (num_read_total < len);
 
  196   return num_read_total;
 
  206   if (whence == SEEK_SET)
 
  208   else if (whence == SEEK_CUR)
 
  210   else if (whence == SEEK_END) {
 
  212         SysError(
"THDFSFile", 
"Unable to seek past end of file");
 
  216         hdfsFileInfo *info = hdfsGetPathInfo((hdfsFS)
fFS, 
fPath);
 
  221            SysError(
"THDFSFile", 
"Unable to seek to end of file");
 
  227      SysError(
"THDFSFile", 
"Unknown whence!");
 
  232      SysError(
"THDFSFile", 
"Unable to seek to the given position");
 
  253   if ((
fHdfsFH = hdfsOpenFile((hdfsFS)
fFS, 
fPath, flags, 0, 0, 0)) == 0) {
 
  254      SysError(
"THDFSFile", 
"Unable to open file %s in HDFS", pathname);
 
  265   int result = hdfsCloseFile((hdfsFS)
fFS, (hdfsFile)
fHdfsFH);
 
  287   hdfsFileInfo *info = hdfsGetPathInfo((hdfsFS)
fFS, 
fPath);
 
  291      if (info->mKind == kObjectKindFile)
 
  293      else if (info->mKind == kObjectKindDirectory)
 
  295      *modtime = info->mLastMod;
 
  340   struct hdfsBuilder *bld = hdfsNewBuilder();
 
  342      SysError(
"THDFSSystem", 
"Error creating hdfs builder");
 
  350      const char *user = (ugi->
fUser).Data();
 
  351      hdfsBuilderSetUserName(bld, user);
 
  355   fFH = hdfsBuilderConnect(bld);
 
  358      SysError(
"THDFSSystem", 
"HDFS client cannot open the filesystem");
 
  379      Error(
"MakeDirectory", 
"No filesystem handle (should never happen)");
 
  399       Error(
"OpenDirectory", 
"No filesystem handle (should never happen)");
 
  411   hdfsFileInfo * dir = 0;
 
  415   if (dir->mKind != kObjectKindDirectory) {
 
  432      Error(
"FreeDirectory", 
"No filesystem handle (should never happen)");
 
  436      Error(
"FreeDirectory", 
"invalid directory pointer (should never happen)");
 
  452      Error(
"GetDirEntry", 
"No filesystem handle (should never happen)");
 
  456      Error(
"GetDirEntry", 
"invalid directory pointer (should never happen)");
 
  460      Error(
"GetDirEntry", 
"Passed an invalid directory pointer.");
 
  468   hdfsFileInfo *fileInfo = ((hdfsFileInfo *)dirp) + 
fDirCtr;
 
  472   tempUrl.
SetUrl(
"hdfs:///");
 
  490      Error(
"GetPathInfo", 
"No filesystem handle (should never happen)");
 
  503   buf.
fMode   = fileInfo->mPermissions;
 
  506   buf.
fSize   = fileInfo->mSize;
 
  507   buf.
fMtime  = fileInfo->mLastAccess;
 
  524      Error(
"AccessPathName", 
"No filesystem handle (should never happen)");
 
  543      Error(
"Unlink", 
"No filesystem handle (should never happen)");
 
  548      return hdfsDelete((hdfsFS)
fFH, path, 1);
 
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
static const int hdfs_default_port
static const char hdfs_default_host[]
static const Bool_t R__HDFS_ALLOW_CHANGES
R__EXTERN TSystem * gSystem
Bool_t fWritable
True if directory is writable.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
virtual void Init(Bool_t create)
Initialize a TFile object.
TString fOption
File options.
Reads and writes its data via the HDFS protocols.
THDFSFile(const char *path, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose)
Usual Constructor. See the TFile constructor for details.
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Write a buffer into the file; this is not supported currently.
Int_t SysClose(Int_t fd)
Close the file in HDFS.
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Open a file in HDFS.
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Perform a stat on the HDFS file; see TFile::SysStat().
void ResetErrno() const
ResetErrno; simply calls TSystem::ResetErrno().
void * fFS
HDFS user handle.
Int_t SysSync(Int_t fd)
Sync remaining data to disk; Not supported by HDFS.
Long64_t fSysOffset
Seek offset in file.
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Seek to a specified position in the file.
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Read specified number of bytes from current offset into the buffer.
virtual ~THDFSFile()
Close and clean-up HDFS file.
void * fHdfsFH
HDFS file handle.
Directory handler for HDFS (THDFSFile).
void * OpenDirectory(const char *name)
Open a directory via hdfs.
void * fFH
HDFS filesystem handle.
void FreeDirectory(void *dirp)
Free a directory.
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
TUrl * fUrlp
Pointer to the array of directory content URLs.
Int_t fDirEntries
The number of entries in the fDirp array.
Int_t MakeDirectory(const char *name)
Make a directory.
const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
Int_t fDirCtr
The current position in the fDirp array.
void * fDirp
Pointer to the array of file information.
Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
Int_t Unlink(const char *path)
Unlink, i.e.
virtual ULong_t Hash() const
Return hash value for this object.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TString & Insert(Ssiz_t pos, const char *s)
void ToUpper()
Change string to upper case.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Abstract base class defining a generic interface to the underlying Operating System.
virtual Int_t GetGid(const char *group=0)
Returns the group's id. If group = 0, returns current user's group.
static void ResetErrno()
Static function resetting system error number.
void SetErrorStr(const char *errstr)
Set the system error string.
virtual Int_t GetUid(const char *user=0)
Returns the user's id. If user = 0, returns current user's id.
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
This class represents a WWW compatible URL.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
const char * GetFile() const
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
void SetFile(const char *file)