Logo ROOT   6.08/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 #ifndef ROOT_TFile
16 #include "TFile.h"
17 #endif
18 
19 #ifndef ROOT_TSystem
20 #include "TSystem.h"
21 #endif
22 
23 class THDFSFile : public TFile {
24 
25 private:
26  void *fHdfsFH; ///< HDFS file handle
27  void *fFS; ///< HDFS user handle
28  Long64_t fSize; ///< File size
29  Long64_t fSysOffset; ///< Seek offset in file
30  char *fPath; ///< HDFS path name
31 
32  Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
33  Int_t SysClose(Int_t fd);
34  Int_t SysRead(Int_t fd, void *buf, Int_t len);
35  Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
36  Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
37  Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
38  Int_t SysSync(Int_t fd);
39 
40 public:
41  THDFSFile(const char *path, Option_t *option="",
42  const char *ftitle="", Int_t compress=1);
43  virtual ~THDFSFile();
44 
45  void ResetErrno() const;
46 
47  ClassDef(THDFSFile, 0) //A ROOT file that reads/writes via HDFS
48 };
49 
50 
51 
52 class THDFSSystem : public TSystem {
53 
54 private:
55  void *fFH; ///< HDFS filesystem handle.
56  void *fDirp; ///< Pointer to the array of file information.
57  TUrl *fUrlp; ///< Pointer to the array of directory content URLs.
58  Int_t fDirEntries; ///< The number of entries in the fDirp array.
59  Int_t fDirCtr; ///< The current position in the fDirp array.
60 
61 public:
62  THDFSSystem();
63  virtual ~THDFSSystem() { }
64 
65  Int_t MakeDirectory(const char *name);
66  void *OpenDirectory(const char *name);
67  void FreeDirectory(void *dirp);
68  const char *GetDirEntry(void *dirp);
69  Int_t GetPathInfo(const char *path, FileStat_t &buf);
70  Bool_t AccessPathName(const char *path, EAccessMode mode);
71  Int_t Unlink(const char *path);
72 
73  ClassDef(THDFSSystem,0) // Directory handler for HDFS (THDFSFile)
74 };
75 
76 #endif
void * fDirp
Pointer to the array of file information.
Definition: THDFSFile.h:56
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:63
const char Option_t
Definition: RtypesCore.h:62
This class represents a WWW compatible URL.
Definition: TUrl.h:41
void * fFS
HDFS user handle.
Definition: THDFSFile.h:27
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
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:254
Long64_t fSysOffset
Seek offset in file.
Definition: THDFSFile.h:29
void ResetErrno() const
ResetErrno; simply calls TSystem::ResetErrno().
Definition: THDFSFile.cxx:290
Long64_t fSize
File size.
Definition: THDFSFile.h:28
Reads and writes its data via the HDFS protocols.
Definition: THDFSFile.h:23
unsigned int UInt_t
Definition: RtypesCore.h:42
Directory handler for HDFS (THDFSFile).
Definition: THDFSFile.h:52
Int_t fDirCtr
The current position in the fDirp array.
Definition: THDFSFile.h:59
void * fHdfsFH
HDFS file handle.
Definition: THDFSFile.h:26
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:30
EAccessMode
Definition: TSystem.h:54
TUrl * fUrlp
Pointer to the array of directory content URLs.
Definition: THDFSFile.h:57
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:55
Int_t fDirEntries
The number of entries in the fDirp array.
Definition: THDFSFile.h:58
Abstract base class defining a generic interface to the underlying Operating System.
Definition: TSystem.h:258
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
char name[80]
Definition: TGX11.cxx:109