Home | History | Annotate | Download | only in hadoop
      1 /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
      2 
      3 Licensed under the Apache License, Version 2.0 (the "License");
      4 you may not use this file except in compliance with the License.
      5 You may obtain a copy of the License at
      6 
      7     http://www.apache.org/licenses/LICENSE-2.0
      8 
      9 Unless required by applicable law or agreed to in writing, software
     10 distributed under the License is distributed on an "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 See the License for the specific language governing permissions and
     13 limitations under the License.
     14 ==============================================================================*/
     15 
     16 #ifndef TENSORFLOW_CORE_PLATFORM_HADOOP_HADOOP_FILE_SYSTEM_H_
     17 #define TENSORFLOW_CORE_PLATFORM_HADOOP_HADOOP_FILE_SYSTEM_H_
     18 
     19 #include "tensorflow/core/platform/env.h"
     20 
     21 extern "C" {
     22 struct hdfs_internal;
     23 typedef hdfs_internal* hdfsFS;
     24 }
     25 
     26 namespace tensorflow {
     27 
     28 class LibHDFS;
     29 
     30 class HadoopFileSystem : public FileSystem {
     31  public:
     32   HadoopFileSystem();
     33   ~HadoopFileSystem();
     34 
     35   Status NewRandomAccessFile(
     36       const string& fname, std::unique_ptr<RandomAccessFile>* result) override;
     37 
     38   Status NewWritableFile(const string& fname,
     39                          std::unique_ptr<WritableFile>* result) override;
     40 
     41   Status NewAppendableFile(const string& fname,
     42                            std::unique_ptr<WritableFile>* result) override;
     43 
     44   Status NewReadOnlyMemoryRegionFromFile(
     45       const string& fname,
     46       std::unique_ptr<ReadOnlyMemoryRegion>* result) override;
     47 
     48   Status FileExists(const string& fname) override;
     49 
     50   Status GetChildren(const string& dir, std::vector<string>* result) override;
     51 
     52   Status DeleteFile(const string& fname) override;
     53 
     54   Status CreateDir(const string& name) override;
     55 
     56   Status DeleteDir(const string& name) override;
     57 
     58   Status GetFileSize(const string& fname, uint64* size) override;
     59 
     60   Status RenameFile(const string& src, const string& target) override;
     61 
     62   Status Stat(const string& fname, FileStatistics* stat) override;
     63 
     64   string TranslateName(const string& name) const override;
     65 
     66  private:
     67   Status Connect(StringPiece fname, hdfsFS* fs);
     68   LibHDFS* hdfs_;
     69 };
     70 
     71 }  // namespace tensorflow
     72 
     73 #endif  // TENSORFLOW_CORE_PLATFORM_HADOOP_HADOOP_FILE_SYSTEM_H_
     74