# Module db_entry

- Description
- Data Types
- Function Index
- Function Details

Abstract datatype of a single DB entry.

Copyright © 2010-2012 Zuse Institute Berlin and onScale solutions GmbH

Version: $Id$

Authors: Florian Schintke (`schintke@onscale.de`).

## Description

Abstract datatype of a single DB entry.

## Data Types

### client_version()

    client_version() = non_neg_integer()

only for unit tests:

### entry()

    entry() = entry_ex() | entry_empty()

### entry_empty()

    entry_empty() =
        {Key :: rt_chord:key(),
         empty_val | db_dht:value(),
         WriteLock :: false | -1 | client_version(),
         ReadLock :: non_neg_integer(),
         Version :: -1}

### entry_ex()

    entry_ex() =
        {Key :: rt_chord:key(),
         Value :: db_dht:value(),
         WriteLock :: false | client_version(),
         ReadLock :: non_neg_integer(),
         Version :: client_version()}

## Function Index

dec_readlock/1 |
dec_version/1 |
get_key/1 |
get_readlock/1 |
get_value/1 |
get_version/1 |
get_writelock/1 |
inc_readlock/1 |
inc_version/1 |
is_empty/1 | Returns whether the item is an empty_val item with version -1.
is_locked/1 |
is_null/1 | Returns whether the item is an empty_val item with version -1 and no read or write locks.
lockcount/1 | Returns how many read and write locks are currently set.
new/1 |
new/3 |
reset_locks/1 |
set_value/3 |
set_writelock/2 |
unset_writelock/1 |

## Function Details

### new/1

    new(Key :: rt_chord:key()) ->
           {rt_chord:key(), empty_val, false, 0, -1}

### new/3

    new(Key :: rt_chord:key(),
        Value :: db_dht:value(),
        Version :: client_version()) ->
           {Key :: rt_chord:key(),
            Value :: db_dht:value(),
            WriteLock :: false,
            ReadLock :: 0,
            Version :: client_version()}

### get_key/1

    get_key(DBEntry :: entry()) -> rt_chord:key()

### get_value/1

    get_value(DBEntry :: entry()) -> db_dht:value()

### set_value/3

    set_value(DBEntry :: entry(),
              Value :: db_dht:value(),
              Version :: client_version()) ->
                 entry()

### get_writelock/1

    get_writelock(DBEntry :: entry()) ->
                     WriteLock :: false | -1 | client_version()

### set_writelock/2

    set_writelock(DBEntry :: entry_ex(),
                  WriteLock :: false | client_version()) ->
                     entry_ex()

### unset_writelock/1

    unset_writelock(DBEntry :: entry()) -> entry()

### get_readlock/1

    get_readlock(DBEntry :: entry()) -> ReadLock :: non_neg_integer()

### inc_readlock/1

    inc_readlock(DBEntry :: entry()) -> entry()

### dec_readlock/1

    dec_readlock(DBEntry :: entry()) -> entry()

### get_version/1

    get_version(DBEntry :: entry()) -> client_version() | -1

### inc_version/1

    inc_version(DBEntry :: entry()) -> entry()

### dec_version/1

    dec_version(DBEntry :: entry()) -> entry()

### reset_locks/1

    reset_locks(DBEntry :: entry()) ->
                   {Key :: rt_chord:key(),
                    Value :: db_dht:value(),
                    WriteLock :: false,
                    ReadLock :: 0,
                    Version :: client_version()} |
                   {Key :: rt_chord:key(),
                    empty_val | db_dht:value(),
                    WriteLock :: false,
                    ReadLock :: 0,
                    Version :: -1}

### is_locked/1

    is_locked(DBEntry :: entry()) -> boolean()

### is_empty/1

    is_empty(X1 :: entry()) -> boolean()

Returns whether the item is an empty_val item with version -1. Note: The number of read or write locks does not matter here!

### is_null/1

    is_null(X1 :: entry()) -> boolean()

Returns whether the item is an empty_val item with version -1 and no read or write locks.

### lockcount/1

    lockcount(Entry :: db_entry:entry()) -> integer()

Returns how many read and write locks are currently set.

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