THDFSFile.h

Go to the documentation of this file.
00001 // @(#)root/hdfs:$Id: THDFSFile.h 35358 2010-09-17 09:58:04Z rdm $
00002 // Author: Brian Bockelman 29/09/2009
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_THDFSFile
00013 #define ROOT_THDFSFile
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // THDFSFile                                                            //
00018 //                                                                      //
00019 // A THDFSFile is like a normal TFile except that it reads and writes   //
00020 // its data via the HDFS protocols.  For more information, see          //
00021 // http://hadoop.apache.org/hdfs/.                                      //
00022 //                                                                      //
00023 //////////////////////////////////////////////////////////////////////////
00024 
00025 #ifndef ROOT_TFile
00026 #include "TFile.h"
00027 #endif
00028 
00029 #ifndef ROOT_TSystem
00030 #include "TSystem.h"
00031 #endif
00032 
00033 class THDFSFile : public TFile {
00034 
00035 private:
00036    void     *fHdfsFH;    // HDFS file handle
00037    void     *fFS;        // HDFS user handle
00038    Long64_t  fSize;      // file size
00039    Long64_t  fSysOffset; // Seek offset in file
00040    char     *fPath;      // HDFS path name
00041 
00042    Int_t    SysOpen(const char *pathname, Int_t flags, UInt_t mode);
00043    Int_t    SysClose(Int_t fd);
00044    Int_t    SysRead(Int_t fd, void *buf, Int_t len);
00045    Int_t    SysWrite(Int_t fd, const void *buf, Int_t len);
00046    Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
00047    Int_t    SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
00048    Int_t    SysSync(Int_t fd);
00049 
00050 public:
00051    THDFSFile(const char *path, Option_t *option="",
00052              const char *ftitle="", Int_t compress=1);
00053    virtual ~THDFSFile();
00054 
00055    void ResetErrno() const;
00056 
00057    ClassDef(THDFSFile, 0) //A ROOT file that reads/writes via HDFS
00058 };
00059 
00060 
00061 
00062 class THDFSSystem : public TSystem {
00063 
00064 private:
00065    void  *fFH;           // HDFS filesystem handle.
00066    void  *fDirp;         // Pointer to the array of file information.
00067    TUrl  *fUrlp;         // Pointer to the array of directory content URLs.
00068    Int_t  fDirEntries;   // The number of entries in the fDirp array.
00069    Int_t  fDirCtr;       // The current position in the fDirp array.
00070 
00071 public:
00072     THDFSSystem();
00073     virtual ~THDFSSystem() { }
00074 
00075     Int_t       MakeDirectory(const char *name);
00076     void       *OpenDirectory(const char *name);
00077     void        FreeDirectory(void *dirp);
00078     const char *GetDirEntry(void *dirp);
00079     Int_t       GetPathInfo(const char *path, FileStat_t &buf);
00080     Bool_t      AccessPathName(const char *path, EAccessMode mode);
00081     Int_t       Unlink(const char *path);
00082 
00083     ClassDef(THDFSSystem,0)   // Directory handler for HDFS (THDFSFile)
00084 };
00085 
00086 #endif

Generated on Tue Jul 5 14:28:35 2011 for ROOT_528-00b_version by  doxygen 1.5.1