|
|
@ -129,9 +129,7 @@ impl Reader { |
|
|
|
let data: Vec<_> = match &self.0 { |
|
|
|
let data: Vec<_> = match &self.0 { |
|
|
|
InnerReader::Simple(reader) => { |
|
|
|
InnerReader::Simple(reader) => { |
|
|
|
let trees = reader.read().unwrap(); |
|
|
|
let trees = reader.read().unwrap(); |
|
|
|
let tree = if let Some(tree) = trees.get(column_family) { |
|
|
|
let Some(tree) = trees.get(column_family) else { |
|
|
|
tree |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return Ok(Iter { |
|
|
|
return Ok(Iter { |
|
|
|
iter: Vec::new().into_iter(), |
|
|
|
iter: Vec::new().into_iter(), |
|
|
|
current: None, |
|
|
|
current: None, |
|
|
@ -147,28 +145,25 @@ impl Reader { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
InnerReader::Transaction(reader) => { |
|
|
|
InnerReader::Transaction(reader) => { |
|
|
|
if let Some(reader) = reader.upgrade() { |
|
|
|
let Some(reader) = reader.upgrade() else { |
|
|
|
let trees = (*reader).borrow(); |
|
|
|
|
|
|
|
let tree = if let Some(tree) = trees.get(column_family) { |
|
|
|
|
|
|
|
tree |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return Ok(Iter { |
|
|
|
|
|
|
|
iter: Vec::new().into_iter(), |
|
|
|
|
|
|
|
current: None, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
if prefix.is_empty() { |
|
|
|
|
|
|
|
tree.iter().map(|(k, v)| (k.clone(), v.clone())).collect() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
tree.range(prefix.to_vec()..) |
|
|
|
|
|
|
|
.take_while(|(k, _)| k.starts_with(prefix)) |
|
|
|
|
|
|
|
.map(|(k, v)| (k.clone(), v.clone())) |
|
|
|
|
|
|
|
.collect() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return Err(StorageError::Other( |
|
|
|
return Err(StorageError::Other( |
|
|
|
"The transaction is already ended".into(), |
|
|
|
"The transaction is already ended".into(), |
|
|
|
)); |
|
|
|
)); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
let trees = (*reader).borrow(); |
|
|
|
|
|
|
|
let Some(tree) = trees.get(column_family) else { |
|
|
|
|
|
|
|
return Ok(Iter { |
|
|
|
|
|
|
|
iter: Vec::new().into_iter(), |
|
|
|
|
|
|
|
current: None, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
if prefix.is_empty() { |
|
|
|
|
|
|
|
tree.iter().map(|(k, v)| (k.clone(), v.clone())).collect() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
tree.range(prefix.to_vec()..) |
|
|
|
|
|
|
|
.take_while(|(k, _)| k.starts_with(prefix)) |
|
|
|
|
|
|
|
.map(|(k, v)| (k.clone(), v.clone())) |
|
|
|
|
|
|
|
.collect() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|