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

Method Write

be/src/runtime/io/data-cache.cc:281–296  ·  view source on GitHub ↗

Writes 'buffer' of length 'buffer_len' into byte offset 'offset' in the file. Returns true iff write succeeded. Returns false on errors or if the file is already closed.

Source from the content-addressed store, hash-verified

279 // Returns true iff write succeeded. Returns false on errors or if the file is
280 // already closed.
281 bool Write(int64_t offset, const uint8_t* buffer, int64_t buffer_len) {
282 DCHECK_EQ(offset % PAGE_SIZE, 0);
283 DCHECK_LE(offset, current_offset_.Load());
284 if (UNLIKELY(readonly_.Load())) return false;
285 // Hold the lock in shared mode to check if 'file_' is not closed already.
286 kudu::shared_lock<rw_spinlock> lock(lock_.get_lock());
287 if (UNLIKELY(!file_ || readonly_.Load())) return false;
288 DCHECK_LE(offset + buffer_len, current_offset_.Load());
289 kudu::Status status = file_->Write(offset, Slice(buffer, buffer_len));
290 if (UNLIKELY(!status.ok())) {
291 LOG(ERROR) << Substitute("Failed to write to $0 at offset $1 for $2 bytes: $3",
292 path_, offset, PrettyPrinter::PrintBytes(buffer_len), status.ToString());
293 return false;
294 }
295 return true;
296 }
297
298 void PunchHole(int64_t offset, int64_t hole_size) {
299 DCHECK_EQ(offset % PAGE_SIZE, 0);

Callers 1

InsertIntoCacheMethod · 0.45

Calls 7

SubstituteFunction · 0.85
PrintBytesFunction · 0.85
SliceClass · 0.50
LoadMethod · 0.45
get_lockMethod · 0.45
okMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected