use crate::{
MAX_INDEX_FIELDS,
db::{
data::StorageKey,
index::{IndexId, key::codec::IndexKey},
},
};
pub(super) const KEY_KIND_TAG_SIZE: usize = 1;
pub(super) const COMPONENT_COUNT_SIZE: usize = 1;
pub(super) const SEGMENT_LEN_SIZE: usize = 2;
pub(super) const INDEX_ID_SIZE: usize = IndexId::STORED_SIZE_USIZE;
pub(super) const KEY_PREFIX_SIZE: usize = KEY_KIND_TAG_SIZE + INDEX_ID_SIZE + COMPONENT_COUNT_SIZE;
#[expect(clippy::cast_possible_truncation)]
impl IndexKey {
pub(crate) const MAX_COMPONENT_SIZE: usize = 4 * 1024;
pub(crate) const MAX_PK_SIZE: usize = StorageKey::STORED_SIZE_USIZE;
const MIN_SEGMENT_SIZE: usize = 1;
pub(crate) const MAX_INDEX_KEY_BYTES: u64 = (KEY_PREFIX_SIZE
+ (MAX_INDEX_FIELDS * (SEGMENT_LEN_SIZE + Self::MAX_COMPONENT_SIZE))
+ (SEGMENT_LEN_SIZE + Self::MAX_PK_SIZE))
as u64;
pub(crate) const STORED_SIZE_BYTES: u64 = Self::MAX_INDEX_KEY_BYTES;
pub(crate) const STORED_SIZE_USIZE: usize = Self::STORED_SIZE_BYTES as usize;
pub(crate) const MIN_STORED_SIZE_BYTES: u64 =
(KEY_PREFIX_SIZE + SEGMENT_LEN_SIZE + Self::MIN_SEGMENT_SIZE) as u64;
pub(crate) const MIN_STORED_SIZE_USIZE: usize = Self::MIN_STORED_SIZE_BYTES as usize;
#[must_use]
pub(crate) fn wildcard_low_component() -> Vec<u8> {
vec![0]
}
#[must_use]
pub(crate) fn wildcard_high_component() -> Vec<u8> {
vec![0xFF; Self::MAX_COMPONENT_SIZE]
}
#[must_use]
pub(crate) fn wildcard_low_pk() -> Vec<u8> {
vec![0]
}
#[must_use]
pub(crate) fn wildcard_high_pk() -> Vec<u8> {
vec![0xFF; Self::MAX_PK_SIZE]
}
}