Giter Site home page Giter Site logo

unqlite.rs's Introduction

unqlite

A high-level UnQLite database engine wrapper.

travis-badge release-badge downloads docs-badge license-badge

NOTE: Some of the documents is stolen from UnQLite Official Website.

What is UnQLite?

UnQLite is a software library which implements a self-contained, serverless, zero-configuration, transactional NoSQL database engine. UnQLite is a document store database similar to [MongoDB], [Redis], [CouchDB] etc. as well a standard Key/Value store similar to [BerkeleyDB], [LevelDB], etc.

UnQLite is an embedded NoSQL (Key/Value store and Document-store) database engine. Unlike most other NoSQL databases, UnQLite does not have a separate server process. UnQLite reads and writes directly to ordinary disk files. A complete database with multiple collections, is contained in a single disk file. The database file format is cross-platform, you can freely copy a database between 32-bit and 64-bit systems or between big-endian and little-endian architectures.

Port to Rust

This crate is high-level UnQLite database wrapper for Rust. A low-level bindings wrapper is available as a seperated crate: unqlite-sys.

Usage

You can start with UnQLite constructors:

extern crate unqlite;

use unqlite::{UnQLite, Config, KV, Cursor};

fn main() {
    // The database memory is not handled by Rust, and the database is on-disk,
    // so `mut` is not neccessary.
    let unqlite = UnQLite::create_temp();
    // Use any type that can use as `[u8]`
    unqlite.kv_store("key", "a long length value").unwrap();
    unqlite.kv_store("abc", [1,2,3]).unwrap();

    let mut entry = unqlite.first();
    // Iterate records
    loop {
        if entry.is_none() { break; }

        let record = entry.expect("valid entry");
        let (key, value) = record.key_value();
        println!("* Go through {:?} --> {:?}", key, value);

        if value.len() > 10 {
            println!("** Delete key {:?} by value length", key);
            entry = record.delete();
        } else {
            entry = record.next();
        }
    }
    //panic!("for test");
}

Contributors

  • @bemyak
  • @chritchens
  • @wolandr
  • @timlyo
  • @dariusc93

unqlite.rs's People

Contributors

bemyak avatar chritchens avatar dariusc93 avatar kant avatar timlyo avatar waylon531 avatar wolandr avatar zitsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

unqlite.rs's Issues

Can't build on latest (2aeb5930f 2017-08-25) nightly

$ rustup run nightly-x86_64-unknown-linux-gnu cargo build
   Compiling unqlite v1.3.0 (file:///home/sergey/projects/unqlite.rs-1.3.0)
error[E0308]: mismatched types
   --> src/lib.rs:149:49
    |
149 |             .map(|_| UnQLite { engine: unsafe { Shared::new(db) } })
    |                                                 ^^^^^^^^^^^^^^^ expected struct `std::ptr::Shared`, found enum `std::option::Option`
    |
    = note: expected type `std::ptr::Shared<_>`
               found type `std::option::Option<std::ptr::Shared<_>>`

error[E0308]: mismatched types
   --> src/kv_cursor.rs:220:34
    |
220 |                 cursor: unsafe { Unique::new(cursor) },
    |                                  ^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::Unique`, found enum `std::option::Option`
    |
    = note: expected type `std::ptr::Unique<_>`
               found type `std::option::Option<std::ptr::Unique<_>>`

error[E0308]: mismatched types
  --> src/document/doc_store.rs:99:30
   |
99 |             native: unsafe { Shared::new(vm) }, 
   |                              ^^^^^^^^^^^^^^^ expected struct `std::ptr::Shared`, found enum `std::option::Option`
   |
   = note: expected type `std::ptr::Shared<_>`
              found type `std::option::Option<std::ptr::Shared<_>>`

error: aborting due to 3 previous errors

error: Could not compile `unqlite`.

Publish 1.4.2 to crates.io

The latest version of unqlite on crates.io is 1.4.1, which requires the concat_ident feature, which won't work on stable Rust. I configured a project to import v1.4.2 directly from the head of this repository and on cursory inspection, it seems work fine and appears ready for release. If there isn't a problem, could you publish 1.4.2? I'd much appreciate having all my dependencies archived in crates.io.

Roadmap

  • Database Engine Handle
    • unqlite_open
    • unqlite_config
    • unqlite_close
  • Key/Value Store Interfaces
    • unqlite_kv_store
    • unqlite_kv_append
    • unqlite_kv_store_fmt
    • unqlite_kv_append_fmt
    • unqlite_kv_fetch
    • unqlite_kv_fetch_callback
    • unqlite_kv_delete
    • unqlite_kv_config
  • Document Store (JSON via Jx9) Interfaces
    • unqlite_compile
    • unqlite_compile_file
    • unqlite_vm_config
    • unqlite_vm_exec
    • unqlite_vm_reset
    • unqlite_vm_release
    • unqlite_vm_extract_variable
    • unqlite_vm_dump
  • Cursor Iterator Interfaces
    • unqlite_kv_cursor_init
    • unqlite_kv_cursor_release
    • unqlite_kv_cursor_seek
    • unqlite_kv_cursor_first_entry
    • unqlite_kv_cursor_last_entry
    • unqlite_kv_cursor_valid_entry
    • unqlite_kv_cursor_next_entry
    • unqlite_kv_cursor_prev_entry
    • unqlite_kv_cursor_key
    • unqlite_kv_cursor_key_callback
    • unqlite_kv_cursor_data
    • unqlite_kv_cursor_data_callback
    • unqlite_kv_cursor_delete_entry
    • unqlite_kv_cursor_reset
  • Manual Transaction Manager
    • unqlite_begin
    • unqlite_commit
    • unqlite_rollback
  • Utility Interfaces
    • unqlite_util_load_mmaped_file
    • unqlite_util_release_mmaped_file
    • unqlite_util_random_string
    • unqlite_util_random_num
  • In-process Extending Interfaces
    • unqlite_create_function
    • unqlite_delete_function
    • unqlite_create_constant
    • unqlite_delete_constant
  • To be continued

Is the project still maintained?

Hello ๐Ÿ‘‹

I'm looking for an embedded DB (sql, nosql, graph, but not key/value) to store a moderate amount of data for a Tauri app.

It looks like the document interface is not yet complete when having a look at the roadmap (#1), and the last commit was two years ago.

Is it something you think is going to be done at some point, or is this project on life support? :)

Failed to run custom build command for `unqlite v1.5.0`

Hi ,

I copy & paste the Example code provided in readme usage section and then did cargo run .

Found Following Error error: failed to run custom build command for unqlite v1.5.0

Screen Shot with RUST_BACKTRACE=1
unqlite_error

Complete Error Log With RUST_BACKTRACE=full
unqlite_error.txt

Rust Version - rustc 1.57.0 (f1edd0429 2021-11-29)
Cargo Version - cargo 1.57.0 (b2e52d7ca 2021-10-21)
Operating System -Windows, version 10.0.19042 X64

I would greatly appreciate your assistance if I am missing something.

Add an example of creating DB at a path

The example is on creating the DB in a temporary file.
Is there any possibility to add an example when creating the db on a file path?
There is lot of confusion for a new bie.

Thanks.

Crash when getting key-value pairs during iteration

OS: windows 8.1
Rust toolchain: nightly-1.29.0-x86_64-pc-windows-gnu
Clang:
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-w64-windows-gnu
Thread model: posix
unqlite.rs: 1.4.1

gdb trace info:
...
warning: HEAP[test_db.exe]:
warning: Invalid address specified to RtlFreeHeap( 0000000000AC0000, 0000000000024830 )
Program received signal SIGTRAP, Trace/breakpoint trap.
0x00007ff8b7413af2 in ntdll!RtlpNtMakeTemporaryKey ()
from C:\WINDOWS\SYSTEM32\ntdll.dll
(gdb) bt
bt
#0 0x00007ff8b7413af2 in ntdll!RtlpNtMakeTemporaryKey ()
from C:\WINDOWS\SYSTEM32\ntdll.dll
#1 0x00007ff8b73cd876 in ntdll!memset () from C:\WINDOWS\SYSTEM32\ntdll.dll
#2 0x00007ff8b7412984 in ntdll!RtlpNtMakeTemporaryKey ()
from C:\WINDOWS\SYSTEM32\ntdll.dll
#3 0x00007ff8b73ca8d5 in ntdll!memset () from C:\WINDOWS\SYSTEM32\ntdll.dll
#4 0x00007ff8b7355a38 in ntdll!RtlFreeHeap ()
from C:\WINDOWS\SYSTEM32\ntdll.dll
#5 0x0000000000419282 in alloc::alloc::dealloc (
ptr=0x24830 "SALDKFJ;098787t5k,.mcv,xmc.ckpo&^%IOU_)K<jlknksafd;alkmds7t6r57k()&^%$#@$%^&<mhlsmv,s.mdf;lasdfya967sdjl;867546KHHGLK;", '\253' <repeats 16 times>, "\356\376\356\376\356\376\000", layout=...)
at C:\projects\rust\src\liballoc/alloc.rs:80
#6 0x000000000041906b in <alloc::alloc::Global as core::alloc::Alloc>::dealloc (self=0x23fb60, ptr=..., layout=...)
at C:\projects\rust\src\liballoc/alloc.rs:128
#7 0x000000000041ad3a in <alloc::raw_vec::RawVec<T, A>>::dealloc_buffer (
self=0x23fb60) at C:\projects\rust\src\liballoc/raw_vec.rs:720
#8 0x000000000041c813 in <alloc::raw_vec::RawVec<T, A> as core::ops::drop::Drop>::drop (self=0x23fb60) at C:\projects\rust\src\liballoc/raw_vec.rs:729
#9 0x0000000000403ab3 in core::ptr::drop_in_place ()
at C:\projects\rust\src\libcore/ptr.rs:59
#10 0x0000000000403b02 in core::ptr::drop_in_place ()
at C:\projects\rust\src\libcore/ptr.rs:59
#11 0x0000000000406a16 in test_db::main () at src\main.rs:38
(gdb)

#0  0x00007ff8b7413af2 in ntdll!RtlpNtMakeTemporaryKey ()
   from C:\WINDOWS\SYSTEM32\ntdll.dll
#1  0x00007ff8b73cd876 in ntdll!memset () from C:\WINDOWS\SYSTEM32\ntdll.dll
#2  0x00007ff8b7412984 in ntdll!RtlpNtMakeTemporaryKey () from C:\WINDOWS\SYSTEM32\ntdll.dll
#3  0x00007ff8b73ca8d5 in ntdll!memset () from C:\WINDOWS\SYSTEM32\ntdll.dll
#4  0x00007ff8b7355a38 in ntdll!RtlFreeHeap ()
   from C:\WINDOWS\SYSTEM32\ntdll.dll
#5  0x0000000000419282 in alloc::alloc::dealloc (
    ptr=0x24830 "SALDKFJ;098787t5k,.mcv,xmc.ckpo&*^%*IOU_)K<jlknksafd;alkmds7t6r57k()*&^%$#@$%^&*<mhlsmv,s.mdf;lasdfya967sdjl;867546KHHGLK;", '\253' <repeats 16 times>, "\356\376\356\376\356\376\000", layout=...)
    at C:\projects\rust\src\liballoc/alloc.rs:80
#6  0x000000000041906b in <alloc::alloc::Global as core::alloc::Alloc>::dealloc (self=0x23fb60, ptr=..., layout=...)
    at C:\projects\rust\src\liballoc/alloc.rs:128
#7  0x000000000041ad3a in <alloc::raw_vec::RawVec<T, A>>::dealloc_buffer (self=0x23fb60) at C:\projects\rust\src\liballoc/raw_vec.rs:720
#8  0x000000000041c813 in <alloc::raw_vec::RawVec<T, A> as core::ops::drop::Drop>::drop (self=0x23fb60) at C:\projects\rust\src\liballoc/raw_vec.rs:729
#9  0x0000000000403ab3 in core::ptr::drop_in_place ()
    at C:\projects\rust\src\libcore/ptr.rs:59
#10 0x0000000000403b02 in core::ptr::drop_in_place ()
    at C:\projects\rust\src\libcore/ptr.rs:59
#11 0x0000000000406a16 in test_db::main () at src\main.rs:38

Make error codes available

Right now, the only way I see for a program calling the UnQLite wrapper to know the nature of an error is to compare the error string associated with the error with the string literals in UnQLite's error.rs. This seems unsafe.

The Custom struct that is returned for the error contains UnQLite's numeric error code and the ErrorKind enum variant that the wrapper assigned to it. However, even though the ErrorKind enum is public, the fields of the UnQLite struct are private and there is no way for the calling program to access this.

Please add methods to access the fields of a Custom struct:

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Custom {
    kind: ErrorKind,
    raw: i32,
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.