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

Method Allocate

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

Allocates a chunk of 'len' bytes in this file. The cache partition's lock 'partition_lock' must be held when calling this function. Returns the byte offset into the file for insertion. 'len' is expected to be multiples of PAGE_SIZE. Returns -1 if the file doesn't have enough space for insertion.

Source from the content-addressed store, hash-verified

240 // into the file for insertion. 'len' is expected to be multiples of PAGE_SIZE.
241 // Returns -1 if the file doesn't have enough space for insertion.
242 int64_t Allocate(int64_t len, const std::unique_lock<SpinLock>& partition_lock) {
243 DCHECK(partition_lock.owns_lock());
244 DCHECK_EQ(len % PAGE_SIZE, 0);
245 int64_t current_offset = current_offset_.Load();
246 DCHECK_EQ(current_offset % PAGE_SIZE, 0);
247 // Hold the lock in shared mode to check if 'file_' is not closed already.
248 kudu::shared_lock<rw_spinlock> lock(lock_.get_lock());
249 if (!allow_append_ || (current_offset + len > FLAGS_data_cache_file_max_size_bytes &&
250 current_offset > 0)) {
251 allow_append_ = false;
252 return -1;
253 }
254 DCHECK(file_);
255 int64_t insertion_offset = current_offset;
256 current_offset_.Add(len);
257 return insertion_offset;
258 }
259
260 // Reads from byte offset 'offset' for 'bytes_to_read' bytes into 'buffer'.
261 // Returns true iff read succeeded. Returns false on error or if the file

Callers 3

InsertIntoCacheMethod · 0.45
StoreMethod · 0.45
LoadMetaCacheMethod · 0.45

Calls 4

owns_lockMethod · 0.80
LoadMethod · 0.45
get_lockMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected