MCPcopy Create free account
hub / github.com/apache/impala / DoReadFileToString

Function DoReadFileToString

be/src/kudu/util/env.cc:73–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73Status DoReadFileToString(Env* env, const std::string& fname, faststring* data, bool is_sensitive) {
74 data->clear();
75 unique_ptr<SequentialFile> file;
76 SequentialFileOptions opts;
77 opts.is_sensitive = is_sensitive;
78 Status s = env->NewSequentialFile(opts, fname, &file);
79 if (!s.ok()) {
80 return s;
81 }
82 static const int kBufferSize = 8192;
83 unique_ptr<uint8_t[]> scratch(new uint8_t[kBufferSize]);
84 while (true) {
85 Slice fragment(scratch.get(), kBufferSize);
86 s = file->Read(&fragment);
87 if (!s.ok()) {
88 break;
89 }
90 data->append(fragment.data(), fragment.size());
91 if (fragment.empty()) {
92 break;
93 }
94 }
95 return s;
96}
97
98Status ReadFileToString(Env* env, const std::string& fname, faststring* data) {
99 return DoReadFileToString(env, fname, data, false);

Callers 2

ReadFileToStringFunction · 0.85

Calls 9

NewSequentialFileMethod · 0.80
clearMethod · 0.65
getMethod · 0.65
okMethod · 0.45
ReadMethod · 0.45
appendMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected