reeywhaar / nut Goto Github PK
View Code? Open in Web Editor NEWPort of Bolt DB in Rust
License: MIT License
Port of Bolt DB in Rust
License: MIT License
let mut db = db_mock().build().unwrap();
let mut tx = db.begin_rw_tx().unwrap();
{
let bucket = tx.create_bucket(b"widgets").unwrap();
}
let bu = tx.bucket(b"widgets").unwrap();
tx.rollback().unwrap();
panic code
pub(crate) fn close(&self) -> Result<(), Error> {
let mut db = self.db()?;
let tx = db.remove_tx(self)?;
*tx.0.db.write() = WeakDB::new();
tx.0.root.try_write().unwrap().clear();
tx.0.pages.try_write().unwrap().clear();
Ok(())
}
Hi, I got this error:
thread 'tokio-runtime-worker' panicked at /home/user1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nut-0.1.1/src/db/db.rs:731:72:
range start index 57344 out of range for slice of length 32768
The error points to this line:
Line 731 in 0dac83c
Looking a the code of bbolt
, it uses int
for page size.
using a u32
in nut
breaks compatibility for some architectures:
Lines 26 to 27 in 0dac83c
In normal cases it is better to be platform independent but in this case the "official" implementation is platform dependent and I think we should stick with that in order to be compatible
I have use nut to open three different boltdb config files which generate by Go language, I only read data with transaction, the code like this:
fn main() -> Result<(), Box<dyn std::error::Error>> {
let db = DBBuilder::new("config.db").read_only(true).build()?;
let tx = db.begin_tx()?;
let b = tx.bucket(b"name")?;
let Some(value) = b.get(b"key") else {return Err(Box::new(Error::new(ErrorKind::Other, "can't get key from bucket"))); };
println!("{:?}", value);
Ok(())
}
but there were several panic when I read different database file as follows:
thread 'main' panicked at 'unknown flag', /home/jicky/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-be2141875385cea5/nut-0.1.1/src/consts/mod.rs:55:18
stack backtrace:
0: 0x4c1f14 - <unknown>
1: 0x466c8c - <unknown>
.....
thread 'main' panicked at 'range start index 36864 out of range for slice of length 32768', /home/jicky/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-be2141875385cea5/nut-0.1.1/src/db/db.rs:731:59
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted
Of course, I have also succeeded when I read the third database file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.