fix(postgres): Fix additional clippy warnings in workers module

- Remove unnecessary cast in types/vector.rs:549
- Use div_ceil() instead of manual computation in workers/ipc.rs
- Replace redundant closure with function reference in workers/ipc.rs
- Derive Default for MaintenanceStats in workers/maintenance.rs
- Derive Default for TaskPriority enum in workers/queue.rs
- Use or_default() instead of or_insert_with(Vec::new) in workers/mod.rs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rUv 2025-12-26 17:49:54 +00:00
parent ab37d68cb8
commit 930305edcd
5 changed files with 10 additions and 34 deletions

View file

@ -546,7 +546,7 @@ pub extern "C" fn ruvector_send(fcinfo: pg_sys::FunctionCallInfo) -> pg_sys::Dat
let bytea_ptr = pg_sys::palloc(bytea_size) as *mut pg_sys::bytea;
// Set size
pgrx::varlena::set_varsize_4b(bytea_ptr as *mut pg_sys::varlena, bytea_size as i32);
pgrx::varlena::set_varsize_4b(bytea_ptr, bytea_size as i32);
// Copy data
let bytea_data = pgrx::varlena::vardata_any(bytea_ptr as *const pg_sys::varlena) as *mut u8;

View file

@ -406,7 +406,7 @@ impl LargePayloadSegment {
return None;
}
let slots_needed = (size + SLOT_SIZE - 1) / SLOT_SIZE;
let slots_needed = size.div_ceil(SLOT_SIZE);
// Find contiguous free slots
for start_slot in 0..=(NUM_SLOTS - slots_needed) {
@ -471,7 +471,7 @@ impl LargePayloadSegment {
/// Free a previously allocated payload
pub fn free(&self, payload_ref: &PayloadRef) {
let start_slot = payload_ref.offset as usize / SLOT_SIZE;
let slots = (payload_ref.length as usize + SLOT_SIZE - 1) / SLOT_SIZE;
let slots = (payload_ref.length as usize).div_ceil(SLOT_SIZE);
for slot in start_slot..(start_slot + slots) {
let word = slot / 64;
@ -896,7 +896,7 @@ fn prepare_operation(
shmem
.large_payload_segment
.write(payload_ref.offset as usize, &serialized)
.map_err(|e| IpcError::SharedMemoryError(e))?;
.map_err(IpcError::SharedMemoryError)?;
Ok((Operation::LargePayloadRef(payload_ref), Some(payload_ref)))
}

View file

@ -177,7 +177,7 @@ pub struct TierCandidate {
// ============================================================================
/// Maintenance operation statistics
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct MaintenanceStats {
/// Total cycles completed
pub cycles_completed: u64,
@ -203,24 +203,6 @@ pub struct MaintenanceStats {
pub last_cycle_at: u64,
}
impl Default for MaintenanceStats {
fn default() -> Self {
Self {
cycles_completed: 0,
indexes_maintained: 0,
compactions_performed: 0,
bytes_reclaimed: 0,
tier_promotions: 0,
tier_demotions: 0,
stats_collections: 0,
cleanup_operations: 0,
total_time_us: 0,
last_cycle_duration_us: 0,
last_cycle_at: 0,
}
}
}
/// Atomic maintenance statistics
pub struct MaintenanceStatsAtomic {
cycles_completed: AtomicU64,

View file

@ -131,10 +131,7 @@ impl WorkerRegistry {
/// Register a new worker
pub fn register(&self, worker_type: WorkerType, handle: WorkerHandle) {
let mut workers = self.workers.write();
workers
.entry(worker_type)
.or_insert_with(Vec::new)
.push(handle);
workers.entry(worker_type).or_default().push(handle);
self.total_spawned.fetch_add(1, Ordering::SeqCst);
}

View file

@ -74,24 +74,21 @@ impl std::fmt::Display for TaskType {
}
/// Task priority levels
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[derive(
Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
)]
pub enum TaskPriority {
/// Critical priority - processed immediately
Critical = 0,
/// High priority
High = 1,
/// Medium priority (default)
#[default]
Medium = 2,
/// Low priority - background tasks
Low = 3,
}
impl Default for TaskPriority {
fn default() -> Self {
TaskPriority::Medium
}
}
impl std::fmt::Display for TaskPriority {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {