Imageomics / Imageomics/bioclip-vector-db
Image Retrieval Latency Optimization
- Dominant language
- Python
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
# Image Retrieval Optimization
## Overview
This document describes the architecture and algorithm for the Flask Image Retrieval Server, which efficiently serves images stored across multiple HDF5 files.
## Storage Architecture
| Component | Description |
|-----------|-------------|
| **Images** | WEBP-encoded images stored in HDF5 files, indexed by UUID |
| **Lookup Table** | SQLite database mapping UUIDs to HDF5 file paths (indexed on UUID for fast queries) |
## Retrieval Algorithm
**Input:** List of UUIDs
**Output:** Dictionary mapping each UUID to its retrieved image (or `null` if not found)
### Step 1: Lookup Phase
Locate all HDF5 files containing the requested images.
```
1. Query SQLite DB for all input UUIDs (batch querying)
2. Build uuid → h5_path mapping:
{
uuid_1: h5_path_a,
uuid_2: h5_path_b,
...
}
3. Invert to h5_path → [uuids] mapping (groups UUIDs by file):
{
h5_path_a: [uuid_1, uuid_3, uuid_5],
h5_path_b: [uuid_2],
...
}
4. Track unmatched UUIDs separately
```
### Step 2: Retrieval Phase
A simple iterative approach
```
results = {}
for (h5_path, uuid_list) in h5_uuid_groups:
with open(h5_path) as h5_file:
for uuid in uuid_list:
image = h5_file.get(uuid) # Returns null if not found
results[uuid] = image
return results
```
### Output Format
```json
{
"uuid_1": "",
"uuid_2": null,
"uuid_3": "",
...
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.