Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["codegen", "examples", "performance_measurement", "performance_measur

[package]
name = "worktable"
version = "0.6.5"
version = "0.6.7"
edition = "2024"
authors = ["Handy-caT"]
license = "MIT"
Expand All @@ -22,17 +22,17 @@ tokio = { version = "1", features = ["full"] }
tracing = "0.1"
rkyv = { version = "0.8.9", features = ["uuid-1"] }
lockfree = { version = "0.5.1" }
worktable_codegen = { path = "codegen", version = "0.6.5" }
worktable_codegen = { path = "codegen", version = "0.6.7" }
fastrand = "2.3.0"
futures = "0.3.30"
uuid = { version = "1.10.0", features = ["v4", "v7"] }
data_bucket = "0.2.6"
data_bucket = "0.2.7"
# data_bucket = { git = "https://github.com/pathscale/DataBucket", branch = "main" }
# data_bucket = { path = "../DataBucket", version = "0.2.6" }
performance_measurement_codegen = { path = "performance_measurement/codegen", version = "0.1.0", optional = true }
performance_measurement = { path = "performance_measurement", version = "0.1.0", optional = true }
indexset = { version = "0.12.2", features = ["concurrent", "cdc", "multimap"] }
# indexset = { path = "../indexset", version = "0.12.0", features = ["concurrent", "cdc", "multimap"] }
indexset = { version = "0.12.3", features = ["concurrent", "cdc", "multimap"] }
# indexset = { path = "../indexset", version = "0.12.2", features = ["concurrent", "cdc", "multimap"] }
# indexset = { git = "https://github.com/Handy-caT/indexset", branch = "multimap-range-fix", version = "0.12.0", features = ["concurrent", "cdc", "multimap"] }
convert_case = "0.6.0"
ordered-float = "5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "worktable_codegen"
version = "0.6.5"
version = "0.6.7"
edition = "2024"
license = "MIT"
description = "WorkTable codegeneration crate"
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/mem_stat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn gen_mem_fn_body(
}
Fields::Unnamed(fields) => {
let bindings: Vec<_> = (0..fields.unnamed.len())
.map(|i| syn::Ident::new(&format!("f{}", i), variant.ident.span()))
.map(|i| syn::Ident::new(&format!("f{i}"), variant.ident.span()))
.collect();

let calls = bindings
Expand Down
5 changes: 3 additions & 2 deletions codegen/src/worktable/generator/index/cdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ impl Generator {
let index_variant: TokenStream = camel_case_name.parse().unwrap();

quote! {
let (exists, events) = self.#index_field_name.insert_cdc(row.#i, link);
if exists.is_some() {
let (exists, events) = self.#index_field_name.insert_cdc(row.#i.clone(), link);
if let Some(link) = exists {
self.#index_field_name.insert_cdc(row.#i, link);
return Err(IndexError::AlreadyExists {
at: #available_index_ident::#index_variant,
inserted_already: inserted_indexes.clone(),
Expand Down
8 changes: 5 additions & 3 deletions codegen/src/worktable/generator/index/usual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ impl Generator {
}
};
quote! {
self.#index_field_name.insert(#row, link)
.map_or(Ok(()), |_| Err(IndexError::AlreadyExists {
if let Some(link) = self.#index_field_name.insert(#row.clone(), link) {
self.#index_field_name.insert(#row, link);
return Err(IndexError::AlreadyExists {
at: #available_index_ident::#index_variant,
inserted_already: inserted_indexes.clone(),
}))?;
})
}
inserted_indexes.push(#available_index_ident::#index_variant);
}
})
Expand Down
4 changes: 2 additions & 2 deletions codegen/src/worktable/generator/locks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Generator {
.columns_map
.keys()
.map(|col| {
let col = Ident::new(format!("{}_lock", col).as_str(), Span::mixed_site());
let col = Ident::new(format!("{col}_lock").as_str(), Span::mixed_site());
quote! {
if let Some(lock) = &self.#col {
futures.push(lock.as_ref());
Expand All @@ -135,7 +135,7 @@ impl Generator {
.columns_map
.keys()
.map(|col| {
let col = Ident::new(format!("{}_lock", col).as_str(), Span::mixed_site());
let col = Ident::new(format!("{col}_lock").as_str(), Span::mixed_site());
quote! {
if let Some(#col) = &self.#col {
#col.unlock();
Expand Down
6 changes: 3 additions & 3 deletions codegen/src/worktable/generator/queries/locks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl Generator {
let inner = columns
.iter()
.map(|col| {
let col = Ident::new(format!("{}_lock", col).as_str(), Span::mixed_site());
let col = Ident::new(format!("{col}_lock").as_str(), Span::mixed_site());
quote! {
if let Some(#col) = &self.#col {
#col.unlock();
Expand All @@ -167,7 +167,7 @@ impl Generator {
let inner = columns
.iter()
.map(|col| {
let col = Ident::new(format!("{}_lock", col).as_str(), Span::mixed_site());
let col = Ident::new(format!("{col}_lock").as_str(), Span::mixed_site());
quote! {
if self.#col.is_none() {
self.#col = Some(std::sync::Arc::new(Lock::new()));
Expand All @@ -187,7 +187,7 @@ impl Generator {
let inner = columns
.iter()
.map(|col| {
let col = Ident::new(format!("{}_lock", col).as_str(), Span::mixed_site());
let col = Ident::new(format!("{col}_lock").as_str(), Span::mixed_site());
quote! {
if let Some(lock) = &self.#col {
futures.push(lock.as_ref());
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/worktable/generator/queries/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Generator {
.updates
.keys()
.map(|v| {
let ident = Ident::new(format!("{}Query", v).as_str(), Span::mixed_site());
let ident = Ident::new(format!("{v}Query").as_str(), Span::mixed_site());
let rows = queries
.updates
.get(v)
Expand Down
6 changes: 3 additions & 3 deletions codegen/src/worktable/generator/queries/unsized_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Generator {
}
})
.map(|f| {
let fn_ident = Ident::new(format!("get_{}_size", f).as_str(), Span::call_site());
let fn_ident = Ident::new(format!("get_{f}_size").as_str(), Span::call_site());
quote! {
fn #fn_ident(&self, link: Link) -> core::result::Result<usize, WorkTableError> {
self.0.data
Expand Down Expand Up @@ -64,7 +64,7 @@ impl Generator {
})
.map(|(i, op)| {
let archived_ident =
Ident::new(format!("Archived{}Query", i).as_str(), Span::call_site());
Ident::new(format!("Archived{i}Query").as_str(), Span::call_site());
let unsized_fields: Vec<_> = op
.columns
.iter()
Expand All @@ -73,7 +73,7 @@ impl Generator {
})
.map(|c| {
let fn_ident =
Ident::new(format!("get_{}_size", c).as_str(), Span::call_site());
Ident::new(format!("get_{c}_size").as_str(), Span::call_site());
quote! {
pub fn #fn_ident(&self) -> usize {
self.#c.len()
Expand Down
6 changes: 2 additions & 4 deletions codegen/src/worktable/generator/queries/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ impl Generator {
let fields_check: Vec<_> = f
.iter()
.map(|f| {
let fn_ident =
Ident::new(format!("get_{}_size", f).as_str(), Span::call_site());
let fn_ident = Ident::new(format!("get_{f}_size").as_str(), Span::call_site());
quote! {
if !need_to_reinsert {
need_to_reinsert = archived_row.#fn_ident() > self.#fn_ident(link)?
Expand Down Expand Up @@ -464,8 +463,7 @@ impl Generator {
let fields_check: Vec<_> = f
.iter()
.map(|f| {
let fn_ident =
Ident::new(format!("get_{}_size", f).as_str(), Span::call_site());
let fn_ident = Ident::new(format!("get_{f}_size").as_str(), Span::call_site());
quote! {
if !need_to_reinsert {
need_to_reinsert = archived_row.#fn_ident() > self.#fn_ident(link)?
Expand Down
12 changes: 6 additions & 6 deletions codegen/src/worktable/generator/table/select_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ impl Generator {
let ty_ident = Ident::new(&type_name.to_string(), Span::call_site());
let variants: Vec<_> = RANGE_VARIANTS
.iter()
.map(|v| {
.map(|variant| {
let variant_ident = Ident::new(
&format!("{}{}", type_name.to_string().to_case(Case::Pascal), v),
&format!("{}{}", type_name.to_string().to_case(Case::Pascal), variant),
Span::call_site(),
);
let range_ident = Ident::new(&format!("Range{}", v), Span::call_site());
let range_ident = Ident::new(&format!("Range{variant}"), Span::call_site());
quote! {
#variant_ident(std::ops::#range_ident<#ty_ident>),
}
Expand All @@ -67,12 +67,12 @@ impl Generator {
let ty_ident = Ident::new(&type_name.to_string(), Span::call_site());
let variants: Vec<_> = RANGE_VARIANTS
.iter()
.map(|v| {
.map(|variant| {
let variant_ident = Ident::new(
&format!("{}{}", type_name.to_string().to_case(Case::Pascal), v),
&format!("{}{}", type_name.to_string().to_case(Case::Pascal), variant),
Span::call_site(),
);
let range_ident = Ident::new(&format!("Range{}", v), Span::call_site());
let range_ident = Ident::new(&format!("Range{variant}"), Span::call_site());
quote! {
impl From<std::ops::#range_ident<#ty_ident>> for #column_range_type {
fn from(range: std::ops::#range_ident<#ty_ident>) -> Self {
Expand Down
8 changes: 4 additions & 4 deletions codegen/src/worktable/parser/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ impl Parser {
pub fn parse_configs(&mut self) -> syn::Result<Config> {
let ident = self.input_iter.next().ok_or(syn::Error::new(
self.input.span(),
format!("Expected `{}` field in declaration", CONFIG_FIELD_NAME),
format!("Expected `{CONFIG_FIELD_NAME}` field in declaration"),
))?;

if let TokenTree::Ident(ident) = ident {
if ident.to_string().as_str() != CONFIG_FIELD_NAME {
return Err(syn::Error::new(
ident.span(),
format!("Expected `{}` field in declaration", CONFIG_FIELD_NAME),
format!("Expected `{CONFIG_FIELD_NAME}` field in declaration"),
));
}
} else {
Expand All @@ -34,7 +34,7 @@ impl Parser {
let tt = {
let group = self.input_iter.next().ok_or(syn::Error::new(
self.input.span(),
format!("Expected `{}` declarations", CONFIG_FIELD_NAME),
format!("Expected `{CONFIG_FIELD_NAME}` declarations"),
))?;
if let TokenTree::Group(group) = group {
if group.delimiter() != Delimiter::Brace {
Expand All @@ -44,7 +44,7 @@ impl Parser {
} else {
return Err(syn::Error::new(
group.span(),
format!("Expected `{}` declarations", CONFIG_FIELD_NAME),
format!("Expected `{CONFIG_FIELD_NAME}` declarations"),
));
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/in_memory/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ mod tests {

let elapsed = now.elapsed();

println!("wt2 {:?}", elapsed)
println!("wt2 {elapsed:?}")
}

#[test]
Expand Down Expand Up @@ -522,7 +522,7 @@ mod tests {

let elapsed = now.elapsed();

println!("set {:?}", elapsed)
println!("set {elapsed:?}")
}

#[test]
Expand Down Expand Up @@ -553,6 +553,6 @@ mod tests {

let elapsed = now.elapsed();

println!("vec {:?}", elapsed)
println!("vec {elapsed:?}")
}
}
4 changes: 2 additions & 2 deletions src/index/unsized_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ mod test {
fn test_split_basic() {
let mut node = UnsizedNode::<String>::with_capacity(232);
for i in 0..10 {
let s = format!("{}_______", i);
let s = format!("{i}_______");
node.insert(s);
}
assert_eq!(node.length, node.length_capacity);
Expand Down Expand Up @@ -244,7 +244,7 @@ mod test {
}

for i in 1..200 {
let range = map.get(&format!("ValueNum{}", i)).collect::<Vec<_>>();
let range = map.get(&format!("ValueNum{i}")).collect::<Vec<_>>();
assert_eq!(range.len(), 10)
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/persistence/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,6 @@ where
let batch_data_op = batch_op.get_batch_data_op()?;

let (pk_evs, secondary_evs) = batch_op.get_indexes_evs()?;
// self.data.save_batch_data(batch_data_op).await?;
// self.primary_index
// .process_change_event_batch(pk_evs)
// .await?;
// self.secondary_indexes
// .process_change_event_batch(secondary_evs)
// .await?;
{
let mut futs = FuturesUnordered::new();
futs.push(Either::Left(Either::Right(
Expand Down
4 changes: 2 additions & 2 deletions src/persistence/space/index/table_of_contents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ where
return;
}
}
panic!("Page with key {:?} not found", old_key);
panic!("Page with key {old_key:?} not found");
}
}

Expand Down Expand Up @@ -259,7 +259,7 @@ mod tests {
}
}

assert!(keys.is_empty(), "Some keys was not inserted: {:?}", keys)
assert!(keys.is_empty(), "Some keys was not inserted: {keys:?}")
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions src/persistence/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,16 @@ impl<PrimaryKeyGenState, PrimaryKey, SecondaryKeys>
}

pub fn push(&self, value: Operation<PrimaryKeyGenState, PrimaryKey, SecondaryKeys>) {
self.len.fetch_add(1, Ordering::Release);
self.queue.push(value);
self.len.fetch_add(1, Ordering::Relaxed);
self.notify.notify_one();
}

pub async fn pop(&self) -> Operation<PrimaryKeyGenState, PrimaryKey, SecondaryKeys> {
loop {
// Drain values
if let Some(value) = self.queue.pop() {
self.len.fetch_sub(1, Ordering::Relaxed);
self.len.fetch_sub(1, Ordering::Release);
return value;
}

Expand All @@ -265,7 +265,7 @@ impl<PrimaryKeyGenState, PrimaryKey, SecondaryKeys>
&self,
) -> Option<Operation<PrimaryKeyGenState, PrimaryKey, SecondaryKeys>> {
if let Some(v) = self.queue.pop() {
self.len.fetch_sub(1, Ordering::Relaxed);
self.len.fetch_sub(1, Ordering::Release);
Some(v)
} else {
None
Expand All @@ -277,12 +277,12 @@ impl<PrimaryKeyGenState, PrimaryKey, SecondaryKeys>
) -> impl Iterator<Item = Operation<PrimaryKeyGenState, PrimaryKey, SecondaryKeys>> {
let iter_count = self.len.clone();
self.queue.pop_iter().inspect(move |_| {
iter_count.fetch_sub(1, Ordering::Relaxed);
iter_count.fetch_sub(1, Ordering::Release);
})
}

pub fn len(&self) -> usize {
self.len.load(Ordering::Relaxed) as usize
self.len.load(Ordering::Acquire) as usize
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/table/system_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ impl Display for SystemInfo {
)?;
writeln!(
f,
"Allocated Memory: {} (data) + {} (indexes) = {} total\n",
mem_fmt, idx_fmt, total_fmt
"Allocated Memory: {mem_fmt} (data) + {idx_fmt} (indexes) = {total_fmt} total\n"
)?;

let mut table = Table::new();
Expand Down Expand Up @@ -167,12 +166,12 @@ fn fmt_bytes(bytes: usize) -> String {
} else if b >= KB {
(b / KB, "KB")
} else {
return format!("{} B", bytes);
return format!("{bytes} B");
};

if (value.fract() * 100.0).round() == 0.0 {
format!("{:.0} {}", value, unit)
format!("{value:.0} {unit}")
} else {
format!("{:.2} {}", value, unit)
format!("{value:.2} {unit}")
}
}
Binary file not shown.
Loading
Loading