From 088b6b323130b0a9509c76f395c7ed4bf5609234 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 26 Jan 2026 23:54:20 +0100 Subject: small renamed --- database/src/query.rs | 4 ++-- database/src/sort/value.rs | 8 ++++---- database/src/table.rs | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'database/src') diff --git a/database/src/query.rs b/database/src/query.rs index aef6338..41f4b83 100644 --- a/database/src/query.rs +++ b/database/src/query.rs @@ -16,11 +16,11 @@ pub struct Query { pub enum Sort { #[default] None, - Value(ValueSortComponent), + Value(ValueSort), TextSearch(Path, String), Count, } -pub struct ValueSortComponent { +pub struct ValueSort { pub order: SortOrder, pub path: Path, pub multi: MultiBehaviour, diff --git a/database/src/sort/value.rs b/database/src/sort/value.rs index bd79db9..79bdc0b 100644 --- a/database/src/sort/value.rs +++ b/database/src/sort/value.rs @@ -6,7 +6,7 @@ use crate::{ filter::binning::Binning, - query::{MultiBehaviour, ValueSortComponent}, + query::{MultiBehaviour, ValueSort}, sort::Index, table::{RowNum, TableNum}, }; @@ -17,11 +17,11 @@ use jellyobject::Object; pub struct ValueIndex { id: TableNum, binning: Binning, - sort: ValueSortComponent, + sort: ValueSort, } impl ValueIndex { - pub fn new(id: TableNum, binning: Binning, sort: ValueSortComponent) -> Self { + pub fn new(id: TableNum, binning: Binning, sort: ValueSort) -> Self { Self { id, binning, sort } } fn keys(&self, id: RowNum, ob: Object) -> Vec> { @@ -51,7 +51,7 @@ impl Index for ValueIndex { self.keys(0, before) == self.keys(0, after) } } -impl ValueSortComponent { +impl ValueSort { fn apply(&self, ob: Object, keys: &mut Vec>) { match self.multi { MultiBehaviour::First => { diff --git a/database/src/table.rs b/database/src/table.rs index a96f96c..ad3775a 100644 --- a/database/src/table.rs +++ b/database/src/table.rs @@ -8,13 +8,14 @@ use crate::{query::Query, sort::Index}; use anyhow::{Result, anyhow}; use jellykv::{ReadTransaction, WriteTransaction}; use jellyobject::ObjectBuffer; +use std::collections::HashMap; pub type TableNum = u64; pub type RowNum = u64; pub struct Table { id: u32, - pub(crate) indices: Vec>, + pub(crate) indices: HashMap>, } impl Table { pub fn new(id: u32) -> Self { @@ -80,10 +81,10 @@ impl Table { txn.set(&self.key(row), bytemuck::cast_slice(entry.0.as_slice()))?; - for idx in &self.indices { - if !idx.compare(before, after) { - idx.remove(txn, row, before)?; - idx.add(txn, row, after)?; + for index in &self.indices { + if !index.compare(before, after) { + index.remove(txn, row, before)?; + index.add(txn, row, after)?; } } -- cgit v1.3