Return (or create) a dedicated arena for `(tenant_id, collection)`. Idempotent: calling twice with the same key returns the same handle.
(&self, tenant_id: u64, collection: &str)
| 70 | /// |
| 71 | /// Idempotent: calling twice with the same key returns the same handle. |
| 72 | pub fn get_or_create(&self, tenant_id: u64, collection: &str) -> Result<CollectionArenaHandle> { |
| 73 | let key = (tenant_id, collection.to_string()); |
| 74 | let mut guard = self |
| 75 | .inner |
| 76 | .lock() |
| 77 | .map_err(|_| MemError::Jemalloc("collection arena registry lock poisoned".into()))?; |
| 78 | if let Some(h) = guard.handles.get(&key) { |
| 79 | return Ok(h.clone()); |
| 80 | } |
| 81 | let handle = allocate_handle(tenant_id, collection); |
| 82 | guard.handles.insert(key, handle.clone()); |
| 83 | Ok(handle) |
| 84 | } |
| 85 | |
| 86 | /// Look up an existing handle without creating one. Returns `None` when |
| 87 | /// the collection has no dedicated arena yet. |