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

Method SubmitStoreTask

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

Source from the content-addressed store, hash-verified

1436}
1437
1438bool DataCache::SubmitStoreTask(const std::string& filename, int64_t mtime,
1439 int64_t offset, const uint8_t* buffer, int64_t buffer_len) {
1440 const int64_t charge_len = BitUtil::RoundUp(buffer_len, PAGE_SIZE);
1441 if (UNLIKELY(charge_len > per_partition_capacity_)) return false;
1442
1443 // Tries to increase the current_buffer_size_ by buffer_len before allocate buffer.
1444 // If new size exceeds store_buffer_capacity_, return false and current_buffer_size_ is
1445 // not changed.
1446 while (true) {
1447 int64_t current_size = current_buffer_size_.Load();
1448 int64_t new_size = current_size + buffer_len;
1449 if (UNLIKELY(new_size > store_buffer_capacity_)) {
1450 VLOG(2) << Substitute("Failed to create store task due to buffer size limitation, "
1451 "current buffer size: $0 size limitation: $1 require: $2",
1452 current_size, store_buffer_capacity_, buffer_len);
1453 ImpaladMetrics::IO_MGR_REMOTE_DATA_CACHE_ASYNC_WRITES_DROPPED_BYTES->
1454 Increment(buffer_len);
1455 ImpaladMetrics::IO_MGR_REMOTE_DATA_CACHE_ASYNC_WRITES_DROPPED_ENTRIES->Increment(1);
1456 return false;
1457 }
1458 if (LIKELY(current_buffer_size_.CompareAndSwap(current_size, new_size))) {
1459 ImpaladMetrics::IO_MGR_REMOTE_DATA_CACHE_ASYNC_WRITES_OUTSTANDING_BYTES->SetValue(
1460 current_buffer_size_.Load());
1461 break;
1462 }
1463 }
1464
1465 DCHECK(buffer != nullptr);
1466 // TODO: Should we use buffer pool instead of piecemeal memory allocate?
1467 uint8_t* task_buffer = new uint8_t[buffer_len];
1468 memcpy(task_buffer, buffer, buffer_len);
1469
1470 const StoreTask* task =
1471 new StoreTask(filename, mtime, offset, task_buffer, buffer_len, this);
1472 storer_pool_->Offer(StoreTaskHandle(task));
1473 ImpaladMetrics::IO_MGR_REMOTE_DATA_CACHE_NUM_ASYNC_WRITES_SUBMITTED->Increment(1);
1474 return true;
1475}
1476
1477void DataCache::CompleteStoreTask(const StoreTask& task) {
1478 current_buffer_size_.Add(-task.buffer_len());

Callers

nothing calls this directly

Calls 6

SubstituteFunction · 0.85
OfferMethod · 0.80
LoadMethod · 0.45
IncrementMethod · 0.45
CompareAndSwapMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected