Exemplo n.º 1
0
 void sync()
 {
     int result = hdfsSync(fs.get(), fout);
     if (result < 0)
         throwFromErrno("Cannot HDFS sync" + hdfs_uri.toString() + " " + std::string(hdfsGetLastError()),
             ErrorCodes::CANNOT_FSYNC);
 }
Exemplo n.º 2
0
 int write(const char * start, size_t size)
 {
     int bytes_written = hdfsWrite(fs.get(), fout, start, size);
     if (bytes_written < 0)
         throw Exception("Fail to write HDFS file: " + hdfs_uri.toString() + " " + std::string(hdfsGetLastError()),
             ErrorCodes::NETWORK_ERROR);
     return bytes_written;
 }
Exemplo n.º 3
0
 int read(char * start, size_t size)
 {
     int bytes_read = hdfsRead(fs.get(), fin, start, size);
     if (bytes_read < 0)
         throw Exception("Fail to read HDFS file: " + hdfs_uri.toString() + " " + std::string(hdfsGetLastError()),
             ErrorCodes::NETWORK_ERROR);
     return bytes_read;
 }
Exemplo n.º 4
0
    ReadBufferFromHDFSImpl(const std::string & hdfs_name_)
        : hdfs_uri(hdfs_name_)
        , builder(createHDFSBuilder(hdfs_uri))
        , fs(createHDFSFS(builder.get()))
    {

        auto & path = hdfs_uri.getPath();
        fin = hdfsOpenFile(fs.get(), path.c_str(), O_RDONLY, 0, 0, 0);

        if (fin == nullptr)
            throw Exception("Unable to open HDFS file: " + path + " error: " + std::string(hdfsGetLastError()),
                ErrorCodes::CANNOT_OPEN_FILE);
    }
Exemplo n.º 5
0
 ~WriteBufferFromHDFSImpl()
 {
     hdfsCloseFile(fs.get(), fout);
 }
Exemplo n.º 6
0
 ~ReadBufferFromHDFSImpl()
 {
     hdfsCloseFile(fs.get(), fin);
 }