Inserts an array into the cache for the given column and starting row ID Returns true if the array was inserted, false if it would exceed the cache size limit
(&mut self, column_idx: usize, batch_id: BatchID, array: ArrayRef)
| 86 | /// Inserts an array into the cache for the given column and starting row ID |
| 87 | /// Returns true if the array was inserted, false if it would exceed the cache size limit |
| 88 | pub fn insert(&mut self, column_idx: usize, batch_id: BatchID, array: ArrayRef) -> bool { |
| 89 | let array_size = get_array_memory_size_for_cache(&array); |
| 90 | |
| 91 | // Check if adding this array would exceed the cache size limit |
| 92 | if self.current_cache_size + array_size > self.max_cache_bytes { |
| 93 | return false; // Cache is full, don't insert |
| 94 | } |
| 95 | |
| 96 | let key = CacheKey { |
| 97 | column_idx, |
| 98 | batch_id, |
| 99 | }; |
| 100 | |
| 101 | let existing = self.cache.insert(key, array); |
| 102 | assert!(existing.is_none()); |
| 103 | self.current_cache_size += array_size; |
| 104 | true |
| 105 | } |
| 106 | |
| 107 | /// Retrieves a cached array for the given column and row ID |
| 108 | /// Returns None if not found in cache |