| 56 | DeleteBitmapCache::~DeleteBitmapCache() = default; |
| 57 | |
| 58 | void DeleteBitmapCache::insert(const String & key, UInt64 version, ImmutableDeleteBitmapPtr bitmap) |
| 59 | { |
| 60 | if (bitmap == nullptr) |
| 61 | throw Exception("bitmap is null", ErrorCodes::BAD_ARGUMENTS); |
| 62 | |
| 63 | /// TODO improve accuracy of memory usage estimation |
| 64 | /// Currently we estimate the memory usage of the bitmap to be 2 bytes per elements, |
| 65 | /// which may be underestimated for sparse bitmap and overestimated for dense bitmap. |
| 66 | size_t charge = sizeof(CachedBitmap) + 2 * (bitmap->cardinality()); |
| 67 | CachedBitmap * value = new CachedBitmap(version, std::move(bitmap)); |
| 68 | auto * handle = cache->Insert(key, value, charge, &DeleteCachedBitmap); |
| 69 | if (handle) |
| 70 | cache->Release(handle); |
| 71 | else |
| 72 | delete value; /// insert failed |
| 73 | } |
| 74 | |
| 75 | size_t DeleteBitmapCache::totalCharge() |
| 76 | { |
no test coverage detected