MCPcopy Create free account
hub / github.com/apache/arrow / ASSERT_OK_AND_ASSIGN

Function ASSERT_OK_AND_ASSIGN

cpp/src/arrow/memory_pool_test.cc:271–310  ·  view source on GitHub ↗

Read statistics into std::string

Source from the content-addressed store, hash-verified

269
270 // Read statistics into std::string
271 ASSERT_OK_AND_ASSIGN(std::string stats, jemalloc_stats_string("Jax"));
272
273 // Read statistics into std::string with a lambda
274 std::string stats2;
275 auto write_cb = [&stats2](const char* str) { stats2.append(str); };
276 ASSERT_OK(jemalloc_stats_print(write_cb, "Jax"));
277
278 ASSERT_EQ(stats.rfind("{\"jemalloc\":{\"version\"", 0), 0);
279 ASSERT_EQ(stats2.rfind("{\"jemalloc\":{\"version\"", 0), 0);
280 ASSERT_EQ(stats.substr(0, 100), stats2.substr(0, 100));
281#else
282 std::string stats;
283 auto write_cb = [&stats](const char* str) { stats.append(str); };
284 ASSERT_RAISES(NotImplemented, jemalloc_get_stat("thread.peak.read"));
285 ASSERT_RAISES(NotImplemented, jemalloc_get_stat("stats.allocated"));
286 ASSERT_RAISES(NotImplemented, jemalloc_get_stat("stats.allocated"));
287 ASSERT_RAISES(NotImplemented, jemalloc_get_stat("stats.allocatedp"));
288 ASSERT_RAISES(NotImplemented, jemalloc_peak_reset());
289 ASSERT_RAISES(NotImplemented, jemalloc_stats_print(write_cb, "Jax"));
290 ASSERT_RAISES(NotImplemented, jemalloc_stats_print("ax"));
291#endif
292}
293
294class TestCappedMemoryPool : public ::arrow::TestMemoryPoolBase {
295 public:
296 MemoryPool* memory_pool() override { return InitPool(/*limit=*/1'000'000'000LL); }
297
298 MemoryPool* InitPool(int64_t limit) {
299 proxy_memory_pool_ = std::make_shared<ProxyMemoryPool>(default_memory_pool());
300 capped_memory_pool_ =
301 std::make_shared<CappedMemoryPool>(proxy_memory_pool_.get(), limit);
302 return capped_memory_pool_.get();
303 }
304
305 protected:
306 std::shared_ptr<MemoryPool> proxy_memory_pool_;
307 std::shared_ptr<CappedMemoryPool> capped_memory_pool_;
308};
309
310TEST_F(TestCappedMemoryPool, MemoryTracking) { this->TestMemoryTracking(); }
311
312TEST_F(TestCappedMemoryPool, OOM) {
313 // CappedMemoryPool rejects the huge allocation without hitting the underlying

Callers 1

TESTFunction · 0.70

Calls 9

default_memory_poolFunction · 0.85
substrMethod · 0.80
TestMemoryTrackingMethod · 0.80
jemalloc_stats_printFunction · 0.70
jemalloc_get_statFunction · 0.70
jemalloc_peak_resetFunction · 0.70
memory_poolFunction · 0.50
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected