# Module db_hanoidb

- Description
- Data Types
- Function Index
- Function Details

DB back-end using HanoiDB.

Copyright © 2013 scalaris project http://scalaris.zib.de

Behaviours: `db_backend_beh`.

Authors: Pierre M., Jan Skrzypczak (`skrzypczak@zib.de`).

## Description

DB back-end using HanoiDB. HanoiDB is a memory-cached disk backend. As disks are large (TB) HanoiDB can hold data much larger than RAM (GB). As disks persist data HanoiDB can be stoped and restarted without data loss. It is a pure Erlang implementation of Google's LevelDB disk-backed K/V store. See http://code.google.com/p/leveldb/ for background about storage levels. How to use scalaris with this hanoidb backend: -download https://github.com/krestenkrab/hanoidb and compile HanoiDB -make sure this db_hanoidb.erl file is in src/ (right with db_ets.erl) -rerun scalaris' configure with --enable-hanoidb ./configure --enable-hanoidb=/path/to/hanoidb -rerun make to rebuild scalaris and run tests ./make ./make test -enjoy Two keys K and L are considered equal if they match, i.e. K =:= L Made after v0.6.1 svn rev 5666.

## Data Types

### db()

    db() = {DB :: pid(), FileName :: nonempty_string()}

### entry()

    entry() = db_backend_beh:entry()

### key()

    key() = db_backend_beh:key()

'$end_of_table' is not allowed as key() or else iterations won't work!

## Function Index

close/1 | Closes the DB named DBName keeping its data on disk.
close_and_delete/1 | Closes and deletes the DB named DBName.
delete/2 | Deletes the tuple saved under Key and returns the new DB.
foldl/3 | Returns a potentially larger-than-memory dataset.
foldl/4 | Returns a potentially larger-than-memory dataset.
foldl/5 | foldl iterates over DB and applies Fun(Entry, AccIn) to every element encountered in Interval.
foldl_unordered/3 | Works similar to foldl/3 but uses hanoidb:fold instead of our own implementation.
foldr/3 | makes a foldr over the whole dataset.
foldr/4 | Returns a potentially larger-than-memory dataset.
foldr/5 | foldr iterates over DB and applies Fun(Entry, AccIn) to every element encountered in Interval.
get/2 | Returns the entry that corresponds to Key or {} if no such tuple exists.
get_load/1 | Returns the number of stored keys.
get_name/1 | Returns the name of the DB specified in @see new/1 and open/1.
get_persisted_tables/0 | Gets a list of persisted tables.
is_available/0 | Checks for modules required for this DB backend.
new/1 | Creates new DB handle named DBName.
open/1 | Re-opens an existing-on-disk database.
put/2 | Saves arbitrary tuple Entry in DB DBName and returns the new DB.
supports_feature/1 | Returns true if the DB support a specific feature (e.g.
tab2list/1 | Returns a list of all objects in the table Table_name.

## Function Details

### new/1

    new(DBName :: nonempty_string()) -> db()

Creates new DB handle named DBName.

### open/1

    open(DBName :: nonempty_string()) -> db()

Re-opens an existing-on-disk database.

### close/1

    close(DB :: db()) -> true

Closes the DB named DBName keeping its data on disk.

### close_and_delete/1

    close_and_delete(DB :: db()) -> true

Closes and deletes the DB named DBName

### put/2

    put(DB :: db(), Entry :: entry()) -> db()

Saves arbitrary tuple Entry in DB DBName and returns the new DB. The key is expected to be the first element of Entry.

### get/2

    get(DB :: db(), Key :: key()) -> entry() | {}

Returns the entry that corresponds to Key or {} if no such tuple exists.

### delete/2

    delete(DB :: db(), Key :: key()) -> db()

Deletes the tuple saved under Key and returns the new DB. If such a tuple does not exists nothing is changed.

### get_persisted_tables/0

    get_persisted_tables() -> [nonempty_string()]

Gets a list of persisted tables.

### is_available/0

    is_available() -> boolean() | [atom()]

Checks for modules required for this DB backend. Returns true if no modules are missing, or else a list of missing modules

### supports_feature/1

    supports_feature(Feature :: atom()) -> boolean()

Returns true if the DB support a specific feature (e.g. recovery), false otherwise.

### get_name/1

    get_name(DB :: db()) -> nonempty_string()

Returns the name of the DB specified in @see new/1 and open/1.

### get_load/1

    get_load(DB :: db()) -> non_neg_integer()

Returns the number of stored keys.

### foldl/3

    foldl(DB :: db(),
          Fun :: fun((Key :: key(), AccIn :: A) -> AccOut :: A),
          Acc0 :: A) ->
             Acc1 :: A

Equivalent to `hanoidb:fold_range(DB, Fun, Acc0, #key_range{from_key = <<>>, to_key = undefined})`.

Returns a potentially larger-than-memory dataset. Use with care.

### foldl/4

    foldl(DB :: db(),
          Fun :: fun((Key :: key(), AccIn :: A) -> AccOut :: A),
          Acc0 :: A,
          Interval :: db_backend_beh:interval()) ->
             Acc1 :: A

Equivalent to `foldl(DB, Fun, Acc0, Interval, get_load(DB))`.

Returns a potentially larger-than-memory dataset. Use with care.

### foldl/5

    foldl(DB :: db(),
          Fun :: fun((Key :: key(), AccIn :: A) -> AccOut :: A),
          Acc0 :: A,
          Intervall :: db_backend_beh:interval(),
          MaxNum :: non_neg_integer()) ->
             Acc1 :: A

foldl iterates over DB and applies Fun(Entry, AccIn) to every element encountered in Interval. On the first call AccIn == Acc0. The iteration stops as soon as MaxNum elements have been encountered. Returns a potentially larger-than-memory dataset. Use with care.

### foldr/3

    foldr(DB :: db(),
          Fun :: fun((Key :: key(), AccIn :: A) -> AccOut :: A),
          Acc0 :: A) ->
             Acc1 :: A

makes a foldr over the whole dataset. Returns a potentially larger-than-memory dataset. Use with care.

### foldr/4

    foldr(DB :: db(),
          Fun :: fun((Key :: key(), AccIn :: A) -> AccOut :: A),
          Acc0 :: A,
          Interval :: db_backend_beh:interval()) ->
             Acc1 :: A

Equivalent to `foldr(DB, Fun, Acc0, Interval, get_load(DB))`.

Returns a potentially larger-than-memory dataset. Use with care.

### foldr/5

    foldr(DB :: db(),
          Fun :: fun((Key :: key(), AccIn :: A) -> AccOut :: A),
          Acc0 :: A,
          Intervall :: db_backend_beh:interval(),
          MaxNum :: non_neg_integer()) ->
             Acc1 :: A

foldr iterates over DB and applies Fun(Entry, AccIn) to every element encountered in Interval. On the first call AccIn == Acc0. The iteration stops as soon as MaxNum elements have been encountered. Returns a potentially larger-than-memory dataset. Use with care.

### foldl_unordered/3

    foldl_unordered(DB :: db(),
                    Fun ::
                        fun((Entry :: entry(), AccIn :: A) ->
                                AccOut :: A),
                    Acc0 :: A) ->
                       Acc1 :: A

Works similar to foldl/3 but uses hanoidb:fold instead of our own implementation. The order in which will be iterated over is unspecified, but using this fuction might be faster than foldl/3 if it does not matter.

### tab2list/1

    tab2list(Table_name :: db()) -> [Entries :: entry()]

Returns a list of all objects in the table Table_name.

Generated by EDoc, Feb 29 2016, 16:12:18.