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

Function ValidateAndReadData

be/src/kudu/util/pb_util.cc:197–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195// NOTE: the data in 'result' may be modified even in the case of a failed read.
196template<typename ReadableFileType>
197Status ValidateAndReadData(ReadableFileType* reader, uint64_t file_size,
198 uint64_t* offset, uint64_t length,
199 faststring* result) {
200 // Validate the read length using the file size.
201 if (*offset + length > file_size) {
202 return Status::Incomplete("File size not large enough to be valid",
203 Substitute("Proto container file $0: "
204 "Tried to read $1 bytes at offset "
205 "$2 but file size is only $3 bytes",
206 reader->filename(), length,
207 *offset, file_size));
208 }
209
210 // Perform the read.
211 result->resize(length);
212 RETURN_NOT_OK(reader->Read(*offset, Slice(*result)));
213 *offset += length;
214 return Status::OK();
215}
216
217// Helper macro for use with ParseAndCompareChecksum(). Example usage:
218// RETURN_NOT_OK_PREPEND(ParseAndCompareChecksum(checksum.data(), { data }),

Callers 2

ReadPBStartingAtFunction · 0.85
ParsePBFileHeaderFunction · 0.85

Calls 7

IncompleteFunction · 0.85
SubstituteFunction · 0.85
OKFunction · 0.85
resizeMethod · 0.80
SliceClass · 0.70
filenameMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected