GithubHelp home page GithubHelp logo

asbisen / leveldb.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jerryzhenleicai/leveldb.jl

0.0 1.0 0.0 53 KB

Julia interface to Google's LevelDB key value database

License: Other

Julia 100.00%

leveldb.jl's Introduction

LevelDB

Build Status codecov.io

LevelDB is Google's open source on-disk key-value storage library that provides an ordered mapping from string keys to binary values. In many applications where only key based accesses are needed, it tends to be a faster alternative than databases. LevelDB was written in C++ with a C calling API included. This module provides a Julia interface to LevelDB using Julia's ccall mechanism.

Install LevelDB

You can build LevelDB from its source code at https://github.com/google/leveldb. Please install the final dynamic library into a system directory such as /usr/lib or make sure libleveldb.so is in one of your LD_LIBRARY_PATH directories. If libleveldb.so is not installed, Julia will try to download and build it automatically.

Run Testing Code

(v1.1) pkg> test LevelDB

This will exercise batched and non-batched writes and reads for string and float array values.

Create/Open/Close a LevelDB database

julia> db = LevelDB.DB(file_path; create_if_missing = false, error_if_exists = false)

Here file_path is the full path to a directory that hosts a LevelDB database. create_if_missing is a boolean flag when true the database will be created if it does not exist. error_if_exists is a boolean flag when true an error will be thrown if the database already exists. The return value is a database object for passing to read/write calls.

julia> close(db)

Close a database, db is the object returned from a LevelDB.DB call. A directory can only be opened by a single LevelDB.DB at a time.

Read and Write Operations

julia> db[key] = value

key and value are Array{UInt8}.

julia> db[key]

Return value is an Array{UInt8}, one can use the reinterpret function to cast it into the right array type (see test code).

julia> delete!(db, key)

Delete a key from db.

Batched Write

LevelDB supports grouping a number of put operations into a write batch, the batch will either succeed as a whole or fail altogether, behaving like an atomic update.

julia> db[keys] = values

keys and values must behave like iterators returning Array{UInt8}. Creates a write batch internally which is then commited to db.

Iterate

julia> for (key, value) in db
           #do something with the key value pair
       end

Iterate over all key => value pairs in a LevelDB.DB.

julia> for (key, value) in LevelDB.RangeView(db, key1, key2)
           #do something with the key value pair
       end

Iterate over a range between key1 and key2 (inclusive)

Authors

  • Jerry Zhenlei Cai ( jpenguin at gmail dot com )
  • Guido Kraemer

additional contributions by

  • @huwenshuo
  • @tmlbl

leveldb.jl's People

Contributors

gdkrmr avatar growler avatar huwenshuo avatar jerry-cai-chanjet avatar jerryzhenleicai avatar phelimb avatar tmlbl avatar wildart avatar

Watchers

 avatar

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.