#![allow(deprecated)]
use qql_plan::types::MemoryPlacement;
use crate::qdrant_grpc::qdrant;
pub(crate) fn memory_to_proto(value: MemoryPlacement) -> i32 {
match value {
MemoryPlacement::Cold => qdrant::Memory::Cold as i32,
MemoryPlacement::Cached => qdrant::Memory::Cached as i32,
MemoryPlacement::Pinned => qdrant::Memory::Pinned as i32,
}
}
pub(crate) fn memory_from_str(value: &str) -> Option<i32> {
MemoryPlacement::parse(value).map(memory_to_proto)
}
pub(crate) fn memory_to_str(value: i32) -> Option<&'static str> {
match qdrant::Memory::try_from(value).ok()? {
qdrant::Memory::Cold => Some("cold"),
qdrant::Memory::Cached => Some("cached"),
qdrant::Memory::Pinned => Some("pinned"),
qdrant::Memory::Unknown => None,
}
}
pub(crate) fn json_memory(value: &serde_json::Value, key: &str) -> Option<i32> {
value
.get(key)
.and_then(serde_json::Value::as_str)
.and_then(memory_from_str)
}