#[repr(C)]pub struct TemplateKey {
pub primary: u64,
pub secondary: u64,
pub tertiary: u64,
pub name_hash_upper: u64,
}Expand description
Extended key for template-coordinate sorting.
Template-coordinate requires comparing multiple fields:
tid1, tid2, pos1, pos2, neg1, neg2, library, MI, name, is_upper
We pack these into 4 u64 values for efficient comparison.
The name_hash_upper field packs both name_hash and is_upper:
- Upper 63 bits: name hash (groups same names together)
- Lowest bit:
is_upper(false=0, true=1)
This ensures reads from the same template stay together (same hash),
with is_upper=false sorting before is_upper=true.
Fields§
§primary: u64Packed: (tid1 << 48) | (tid2 << 32) | pos1 Comparison order matches samtools: tid1, tid2, pos1
secondary: u64Packed: (pos2 << 32) | (!neg1 << 1) | !neg2 neg flags inverted so reverse (neg=true) sorts before forward (neg=false)
tertiary: u64Packed: (library << 48) | (mi_value << 1) | mi_suffix
name_hash_upper: u64Packed: (name_hash << 1) | is_upper
This ensures same-name records group together, with is_upper as tie-breaker.
Implementations§
Source§impl TemplateKey
impl TemplateKey
Sourcepub fn new(
tid1: i32,
pos1: i32,
neg1: bool,
tid2: i32,
pos2: i32,
neg2: bool,
library: u32,
mi: (u64, bool),
name_hash: u64,
is_upper: bool,
) -> Self
pub fn new( tid1: i32, pos1: i32, neg1: bool, tid2: i32, pos2: i32, neg2: bool, library: u32, mi: (u64, bool), name_hash: u64, is_upper: bool, ) -> Self
Create a new template key from extracted fields.
Source§impl TemplateKey
impl TemplateKey
Trait Implementations§
Source§impl Clone for TemplateKey
impl Clone for TemplateKey
Source§fn clone(&self) -> TemplateKey
fn clone(&self) -> TemplateKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TemplateKey
impl Debug for TemplateKey
Source§impl Default for TemplateKey
impl Default for TemplateKey
Source§impl Ord for TemplateKey
impl Ord for TemplateKey
Source§impl PartialEq for TemplateKey
impl PartialEq for TemplateKey
Source§impl PartialOrd for TemplateKey
impl PartialOrd for TemplateKey
Source§impl RawSortKey for TemplateKey
impl RawSortKey for TemplateKey
Source§const SERIALIZED_SIZE: Option<usize>
const SERIALIZED_SIZE: Option<usize>
None for variable-length keys. Read moreSource§fn extract(_bam: &[u8], _ctx: &SortContext) -> Self
fn extract(_bam: &[u8], _ctx: &SortContext) -> Self
impl Copy for TemplateKey
impl Eq for TemplateKey
impl Pod for TemplateKey
impl StructuralPartialEq for TemplateKey
Auto Trait Implementations§
impl Freeze for TemplateKey
impl RefUnwindSafe for TemplateKey
impl Send for TemplateKey
impl Sync for TemplateKey
impl Unpin for TemplateKey
impl UnsafeUnpin for TemplateKey
impl UnwindSafe for TemplateKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more