aboutsummaryrefslogtreecommitdiff
path: root/database/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-26 23:54:20 +0100
committermetamuffin <metamuffin@disroot.org>2026-01-26 23:54:20 +0100
commit088b6b323130b0a9509c76f395c7ed4bf5609234 (patch)
tree5f0e6480e68d61dd3b58d4ce986ef7f57adf589e /database/src
parentf59c6f472d25084aa5f8a116f8cf92f81df09c50 (diff)
downloadjellything-088b6b323130b0a9509c76f395c7ed4bf5609234.tar
jellything-088b6b323130b0a9509c76f395c7ed4bf5609234.tar.bz2
jellything-088b6b323130b0a9509c76f395c7ed4bf5609234.tar.zst
small renamed
Diffstat (limited to 'database/src')
-rw-r--r--database/src/query.rs4
-rw-r--r--database/src/sort/value.rs8
-rw-r--r--database/src/table.rs11
3 files changed, 12 insertions, 11 deletions
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<Vec<u8>> {
@@ -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<Vec<u8>>) {
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<Box<dyn Index>>,
+ pub(crate) indices: HashMap<IndexKey, Box<dyn Index>>,
}
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)?;
}
}