Logo ROOT   6.16/01
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#include "TSystem.h"
17
18class THDFSFile : public TFile {
19
20private:
21 void *fHdfsFH; ///< HDFS file handle
22 void *fFS; ///< HDFS user handle
23 Long64_t fSize; ///< File size
24 Long64_t fSysOffset; ///< Seek offset in file
25 TUrl fUrl; ///< HDFS url
26 TString fPath; ///< HDFS path
27
28 Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
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);
35
36public:
37 THDFSFile(const char *path, Option_t *option="",
38 const char *ftitle="", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose);
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
48class THDFSSystem : public TSystem {
49
50private:
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
57public:
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
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
EAccessMode
Definition: TSystem.h:44
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
Reads and writes its data via the HDFS protocols.
Definition: THDFSFile.h:18
TString fPath
HDFS path.
Definition: THDFSFile.h:26
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.
Definition: THDFSFile.cxx:79
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
Int_t SysClose(Int_t fd)
Close the file in HDFS.
Definition: THDFSFile.cxx:263
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Open a file in HDFS.
Definition: THDFSFile.cxx:242
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
void ResetErrno() const
ResetErrno; simply calls TSystem::ResetErrno().
Definition: THDFSFile.cxx:316
TUrl fUrl
HDFS url.
Definition: THDFSFile.h:25
void * fFS
HDFS user handle.
Definition: THDFSFile.h:22
Int_t SysSync(Int_t fd)
Sync remaining data to disk; Not supported by HDFS.
Definition: THDFSFile.cxx:307
Long64_t fSize
File size.
Definition: THDFSFile.h:23
Long64_t fSysOffset
Seek offset in file.
Definition: THDFSFile.h:24
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Seek to a specified position in the file.
Definition: THDFSFile.cxx:203
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
virtual ~THDFSFile()
Close and clean-up HDFS file.
Definition: THDFSFile.cxx:164
void * fHdfsFH
HDFS file handle.
Definition: THDFSFile.h:21
Directory handler for HDFS (THDFSFile).
Definition: THDFSFile.h:48
void * OpenDirectory(const char *name)
Open a directory via hdfs.
Definition: THDFSFile.cxx:396
void * fFH
HDFS filesystem handle.
Definition: THDFSFile.h:51
void FreeDirectory(void *dirp)
Free a directory.
Definition: THDFSFile.cxx:429
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
Definition: THDFSFile.cxx:518
TUrl * fUrlp
Pointer to the array of directory content URLs.
Definition: THDFSFile.h:53
virtual ~THDFSSystem()
Definition: THDFSFile.h:59
Int_t fDirEntries
The number of entries in the fDirp array.
Definition: THDFSFile.h:54
Int_t MakeDirectory(const char *name)
Make a directory.
Definition: THDFSFile.cxx:376
const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
Definition: THDFSFile.cxx:449
Int_t fDirCtr
The current position in the fDirp array.
Definition: THDFSFile.h:55
void * fDirp
Pointer to the array of file information.
Definition: THDFSFile.h:52
Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
Definition: THDFSFile.cxx:487
Int_t Unlink(const char *path)
Unlink, i.e.
Definition: THDFSFile.cxx:540
Basic string class.
Definition: TString.h:131
Abstract base class defining a generic interface to the underlying Operating System.
Definition: TSystem.h:248
This class represents a WWW compatible URL.
Definition: TUrl.h:35
@ kUseGeneralPurpose
Use the recommended general-purpose setting; moderate read / write speed and compression ratio.
Definition: Compression.h:53