MCPcopy Index your code
hub / github.com/apache/orc / readFile

Function readFile

c++/src/OrcFile.cc:105–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103 }
104
105 std::unique_ptr<InputStream> readFile(const std::string& path, ReaderMetrics* metrics) {
106#ifdef BUILD_LIBHDFSPP
107 if (strncmp(path.c_str(), "hdfs://", 7) == 0) {
108 return orc::readHdfsFile(std::string(path), metrics);
109 } else {
110#endif
111 return orc::readLocalFile(std::string(path), metrics);
112#ifdef BUILD_LIBHDFSPP
113 }
114#endif
115 }
116
117 DIAGNOSTIC_POP
118
119 std::unique_ptr<InputStream> readLocalFile(const std::string& path, ReaderMetrics* metrics) {
120 return std::make_unique<FileInputStream>(path, metrics);
121 }
122
123 OutputStream::~OutputStream(){
124 // PASS
125 };
126
127 class FileOutputStream : public OutputStream {
128 private:
129 std::string filename_;
130 int file_;
131 uint64_t bytesWritten_;
132 bool closed_;
133
134 public:
135 FileOutputStream(std::string filename) {
136 bytesWritten_ = 0;
137 filename_ = filename;
138 closed_ = false;
139 file_ = open(filename_.c_str(), O_BINARY | O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
140 if (file_ == -1) {
141 throw ParseError("Can't open " + filename_);
142 }
143 }
144
145 ~FileOutputStream() override;
146
147 uint64_t getLength() const override {
148 return bytesWritten_;
149 }
150
151 uint64_t getNaturalWriteSize() const override {
152 return 128 * 1024;
153 }
154
155 void write(const void* buf, size_t length) override {
156 if (closed_) {
157 throw std::logic_error("Cannot write to closed stream.");
158 }
159 ssize_t bytesWrite = ::write(file_, buf, length);
160 if (bytesWrite == -1) {
161 throw ParseError("Bad write of " + filename_);
162 }

Callers 7

printStatisticsFunction · 0.85
printContentsFunction · 0.85
printRawTailFunction · 0.85
printMetadataFunction · 0.85
processFileFunction · 0.85
scanFileFunction · 0.85
loadTZDBFunction · 0.85

Calls 1

readHdfsFileFunction · 0.85

Tested by

no test coverage detected