Logo ROOT   6.12/07
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  TUrl fUrl; ///< HDFS url
27  TString fPath; ///< HDFS path
28 
29  Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
30  Int_t SysClose(Int_t fd);
31  Int_t SysRead(Int_t fd, void *buf, Int_t len);
32  Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
33  Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
34  Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
35  Int_t SysSync(Int_t fd);
36 
37 public:
38  THDFSFile(const char *path, Option_t *option="",
39  const char *ftitle="", Int_t compress=1);
40  virtual ~THDFSFile();
41 
42  void ResetErrno() const;
43 
44  ClassDef(THDFSFile, 0) //A ROOT file that reads/writes via HDFS
45 };
46 
47 
48 
49 class THDFSSystem : public TSystem {
50 
51 private:
52  void *fFH; ///< HDFS filesystem handle.
53  void *fDirp; ///< Pointer to the array of file information.
54  TUrl *fUrlp; ///< Pointer to the array of directory content URLs.
55  Int_t fDirEntries; ///< The number of entries in the fDirp array.
56  Int_t fDirCtr; ///< The current position in the fDirp array.
57 
58 public:
59  THDFSSystem();
60  virtual ~THDFSSystem() { }
61 
62  Int_t MakeDirectory(const char *name);
63  void *OpenDirectory(const char *name);
64  void FreeDirectory(void *dirp);
65  const char *GetDirEntry(void *dirp);
66  Int_t GetPathInfo(const char *path, FileStat_t &buf);
67  Bool_t AccessPathName(const char *path, EAccessMode mode);
68  Int_t Unlink(const char *path);
69 
70  ClassDef(THDFSSystem,0) // Directory handler for HDFS (THDFSFile)
71 };
72 
73 #endif
void * fDirp
Pointer to the array of file information.
Definition: THDFSFile.h:53
Int_t SysClose(Int_t fd)
Close the file in HDFS.
Definition: THDFSFile.cxx:263
Int_t SysSync(Int_t fd)
Sync remaining data to disk; Not supported by HDFS.
Definition: THDFSFile.cxx:307
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:79
long long Long64_t
Definition: RtypesCore.h:69
virtual ~THDFSSystem()
Definition: THDFSFile.h:60
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:164
Basic string class.
Definition: TString.h:125
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:283
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:320
Long64_t fSysOffset
Seek offset in file.
Definition: THDFSFile.h:25
void ResetErrno() const
ResetErrno; simply calls TSystem::ResetErrno().
Definition: THDFSFile.cxx:316
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:49
Int_t fDirCtr
The current position in the fDirp array.
Definition: THDFSFile.h:56
TUrl fUrl
HDFS url.
Definition: THDFSFile.h:26
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:242
TString fPath
HDFS path.
Definition: THDFSFile.h:27
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:203
EAccessMode
Definition: TSystem.h:44
TUrl * fUrlp
Pointer to the array of directory content URLs.
Definition: THDFSFile.h:54
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:179
void * fFH
HDFS filesystem handle.
Definition: THDFSFile.h:52
Int_t fDirEntries
The number of entries in the fDirp array.
Definition: THDFSFile.h:55
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:274
char name[80]
Definition: TGX11.cxx:109