Code Monkey home page Code Monkey logo

oxide's Introduction

travis

About

Oxide is a cache like library that stores tabular data values that are indexed with bitmap index, thus allows lookup in the fashion of "columnA = valueA and columnB = valueB". Usually you'd use database and/or SQL, occasionally it is better to do it in memory, hopefully.

This project is mostly to learn and experiment with Rust. The implementation uses roaring bitmap's Rust port roaring-rs.

It also features a very random name.

Usage

#[macro_use]
extern crate oxide;
use oxide::Match;

fn main() {
    let mut c = oxide::Cache::new();
    {
        let mut bb = oxide::BucketBuilder::new("my_bucket");
        bb = bb.add_column(oxide::ColumnBuilder::Boolean);
        bb = bb.add_column(oxide::ColumnBuilder::UInt);
        bb = bb.add_column(oxide::ColumnBuilder::Str);
        bb = bb.add_column(oxide::ColumnBuilder::Int);
        bb = bb.add_column(oxide::ColumnBuilder::OwnedStr);
        c.new_bucket(bb).unwrap();
    };

    let n = "my_bucket";
    let mut s = "hi";
    c.bucket_mut(n, |w| {
        let mut w = w.unwrap();
        let vals = vals![true, 1usize, s, -2isize, "yes".to_string()];
        match w.insert(vals) {
            Ok(_) => println!("inserted 1"),
            Err(e) => println!("{:?}", e),
        };

        let vals = vals![false, 2usize, s, -2isize, "nope".to_string()];
        match w.insert(vals) {
            Ok(_) => println!("inserted 2"),
            Err(e) => println!("{:?}", e),
        };

        let m = matches![true, Match::Any, "hi", -2isize, "yes".to_string()];

        if let Some(res) = w.find(&m).unwrap() {
            for r in res.iter() {
                print!("row:");
                for f in r.iter() {
                    print!(" {} ", f)
                }
                print!("\n");
            }
        } else {
            println!("no match");
        }
    });

}

License

Licensed under either of

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.