Logo ROOT   6.10/09
Reference Guide
THDFSFile.h
Go to the documentation of this file.
1 // @(#)root/hdfs:$Id$
2 // Author: Brian Bockelman 29/09/2009
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_THDFSFile
13 #define ROOT_THDFSFile
14 
15 #include "TFile.h"
16 
17 #include "TSystem.h"
18 
19 class THDFSFile : public TFile {
20 
21 private:
22  void *fHdfsFH; ///< HDFS file handle
23  void *fFS; ///< HDFS user handle
24  Long64_t fSize; ///< File size
25  Long64_t fSysOffset; ///< Seek offset in file
26  char *fPath; ///< HDFS path name
27 
28  Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
29  Int_t SysClose(Int_t fd);
30  Int_t SysRead(Int_t fd, void *buf, Int_t len);
31  Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
32  Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
33  Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
34  Int_t SysSync(Int_t fd);
35 
36 public:
37  THDFSFile(const char *path, Option_t *option="",
38  const char *ftitle="", Int_t compress=1);
39  virtual ~THDFSFile();
40 
41  void ResetErrno() const;
42 
43  ClassDef(THDFSFile, 0) //A ROOT file that reads/writes via HDFS
44 };
45 
46 
47 
48 class THDFSSystem : public TSystem {
49 
50 private:
51  void *fFH; ///< HDFS filesystem handle.
52  void *fDirp; ///< Pointer to the array of file information.
53  TUrl *fUrlp; ///< Pointer to the array of directory content URLs.
54  Int_t fDirEntries; ///< The number of entries in the fDirp array.
55  Int_t fDirCtr; ///< The current position in the fDirp array.
56 
57 public:
58  THDFSSystem();
59  virtual ~THDFSSystem() { }
60 
61  Int_t MakeDirectory(const char *name);
62  void *OpenDirectory(const char *name);
63  void FreeDirectory(void *dirp);
64  const char *GetDirEntry(void *dirp);
65  Int_t GetPathInfo(const char *path, FileStat_t &buf);
66  Bool_t AccessPathName(const char *path, EAccessMode mode);
67  Int_t Unlink(const char *path);
68 
69  ClassDef(THDFSSystem,0) // Directory handler for HDFS (THDFSFile)
70 };
71 
72 #endif
void * fDirp
Pointer to the array of file information.
Definition: THDFSFile.h:52
Int_t SysClose(Int_t fd)
Close the file in HDFS.
Definition: THDFSFile.cxx:237
Int_t SysSync(Int_t fd)
Sync remaining data to disk; Not supported by HDFS.
Definition: THDFSFile.cxx:281
THDFSFile(const char *path, Option_t *option="", const char *ftitle="", Int_t compress=1)
Usual Constructor. See the TFile constructor for details.
Definition: THDFSFile.cxx:71
long long Long64_t
Definition: RtypesCore.h:69
virtual ~THDFSSystem()
Definition: THDFSFile.h:59
const char Option_t
Definition: RtypesCore.h:62
This class represents a WWW compatible URL.
Definition: TUrl.h:35
void * fFS
HDFS user handle.
Definition: THDFSFile.h:23
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
virtual ~THDFSFile()
Close and clean-up HDFS file.
Definition: THDFSFile.cxx:149
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().
Definition: THDFSFile.cxx:257
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:297
Long64_t fSysOffset
Seek offset in file.
Definition: THDFSFile.h:25
void ResetErrno() const
ResetErrno; simply calls TSystem::ResetErrno().
Definition: THDFSFile.cxx:290
Long64_t fSize
File size.
Definition: THDFSFile.h:24
Reads and writes its data via the HDFS protocols.
Definition: THDFSFile.h:19
unsigned int UInt_t
Definition: RtypesCore.h:42
Directory handler for HDFS (THDFSFile).
Definition: THDFSFile.h:48
Int_t fDirCtr
The current position in the fDirp array.
Definition: THDFSFile.h:55
void * fHdfsFH
HDFS file handle.
Definition: THDFSFile.h:22
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Open a file in HDFS.
Definition: THDFSFile.cxx:215
long Long_t
Definition: RtypesCore.h:50
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Seek to a specified position in the file.
Definition: THDFSFile.cxx:182
char * fPath
HDFS path name.
Definition: THDFSFile.h:26
EAccessMode
Definition: TSystem.h:44
TUrl * fUrlp
Pointer to the array of directory content URLs.
Definition: THDFSFile.h:53
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Read specified number of bytes from current offset into the buffer.
Definition: THDFSFile.cxx:167
void * fFH
HDFS filesystem handle.
Definition: THDFSFile.h:51
Int_t fDirEntries
The number of entries in the fDirp array.
Definition: THDFSFile.h:54
Abstract base class defining a generic interface to the underlying Operating System.
Definition: TSystem.h:248
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Write a buffer into the file; this is not supported currently.
Definition: THDFSFile.cxx:248