# Module tx_tlog

- Description
- Data Types
- Function Index
- Function Details

operations on the end user transaction log.

Copyright © 2009-2013 Zuse Institute Berlin

Version: $Id$

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

## Description

operations on the end user transaction log

## Data Types

### client_key()

    client_key() = [unicode_char()]

### snap_number()

    snap_number() = non_neg_integer()

note: from all the value types, only ?value and ?value_dropped remain in the user tlog - the rest are intermediate states!

### tlog()

    tlog() = [tlog_entry()]

### tlog_entry()

    tlog_entry() = tlog_entry_read() | tlog_entry_write()

### tlog_entry_ext()

    tlog_entry_ext() =
        {Op :: 76,
         Key :: client_key(),
         Version :: non_neg_integer() | -1,
         Status :: tx_status(),
         SnapshotNumber :: snap_number(),
         ValueType :: 78,
         Value :: 78} |
        {Op :: 77,
         Key :: client_key(),
         Version :: non_neg_integer() | -1,
         Status :: tx_status(),
         SnapshotNumber :: snap_number(),
         ValueType :: 75,
         Value :: rdht_tx:encoded_value()}

-opaque tlog() :: [tlog_entry()]. % creates a false warning in add_or_update_status_by_key/3

### tlog_entry_read()

    tlog_entry_read() =
        {Op :: 76,
         Key :: tlog_key(),
         Version :: non_neg_integer() | -1,
         Status :: tx_status(),
         SnapshotNumber :: snap_number(),
         ValueType :: value_type_r(),
         Value :: rdht_tx:encoded_value() | 78}

### tlog_entry_write()

    tlog_entry_write() =
        {Op :: 77,
         Key :: tlog_key(),
         Version :: non_neg_integer() | -1,
         Status :: tx_status(),
         SnapshotNumber :: snap_number(),
         ValueType :: value_type_w(),
         Value :: rdht_tx:encoded_value() | 78}

### tlog_ext()

    tlog_ext() = [tlog_entry_ext()]

### tlog_key()

    tlog_key() = client_key() | rt_chord:key()

TODO this does not make sense anymore TLogEntry: {Operation, Key, Version, Status, Value} Sample: {?read,"key3",?value,"value3",0}

### tx_op()

    tx_op() = 76 | 77

### tx_status()

    tx_status() = 84 | 85

### unicode_char()

    unicode_char() = 0..55295 | 57344..65533 | 65536..1114111

### value_type_r()

    value_type_r() = 75 | 82 | 86 | {85, atom() | integer()} | 78

### value_type_w()

    value_type_w() = 75 | {85, atom() | integer()} | 78

## Function Index

add_entry/2 |
add_or_update_status_by_key/3 |
cleanup/1 | Strips the tlog from read values (sets those values to ?value_dropped).
drop_value/1 |
empty/0 | create an empty list.
find_entry_by_key/2 |
first_req_per_key_not_in_tlog/2 | Filters a request list with unique keys so that only operations reside that need data from the DHT which is not yet present in the TLog.
get_entry_key/1 |
get_entry_operation/1 |
get_entry_snapshot/1 |
get_entry_status/1 |
get_entry_value/1 |
get_entry_value_type/1 |
get_entry_version/1 |
get_insane_keys/1 |
is_sane_for_commit/1 |
merge/2 | Merge TLog entries from sorted translogs (see sort_by_key/1), if same key.
new_entry/5 |
new_entry/6 |
new_entry/7 |
set_entry_key/2 |
set_entry_operation/2 |
set_entry_snapshot/2 |
set_entry_status/2 |
set_entry_value/3 |
sort_by_key/1 |
update_entry/2 |

## Function Details

### empty/0

    empty() -> tlog()

create an empty list

### add_entry/2

    add_entry(TransLog :: tlog(), Entry :: tlog_entry()) -> tlog()

### add_or_update_status_by_key/3

    add_or_update_status_by_key(T :: tlog(),
                                Key :: tlog_key(),
                                Status :: tx_status()) ->
                                   tlog()

### update_entry/2

    update_entry(TLog :: tlog(), Entry :: tlog_entry()) -> tlog()

### sort_by_key/1

    sort_by_key(TLog :: tlog()) -> tlog()

### find_entry_by_key/2

    find_entry_by_key(TLog :: tlog(), Key :: tlog_key()) ->
                         tlog_entry() | false

### is_sane_for_commit/1

    is_sane_for_commit(TLog :: tlog()) -> boolean()

### get_insane_keys/1

    get_insane_keys(TLog :: tlog_ext()) -> [client_key()]

### merge/2

    merge(TLog1 :: tlog(), TLog2 :: tlog()) -> tlog()

Merge TLog entries from sorted translogs (see sort_by_key/1), if same key. Check for version mismatch, take over values. Duplicate keys are only allowedif the old TLog only read the value! SortedTlog is old TLog SortedRTlog is TLog received from newer RDHT operations

### first_req_per_key_not_in_tlog/2

    first_req_per_key_not_in_tlog(SortedTLog :: tlog(),
                                  SortedReqList ::
                                      [rdht_tx:request_on_key()]) ->
                                     [rdht_tx:request_on_key()]

Filters a request list with unique keys so that only operations reside that need data from the DHT which is not yet present in the TLog. Note: uses functions from rdht_tx to cope with requests.

### cleanup/1

    cleanup(TLog :: tlog()) -> tlog()

Strips the tlog from read values (sets those values to ?value_dropped).

### new_entry/5

    new_entry(Op :: tx_op(),
              Key :: rt_chord:key(),
              Vers :: non_neg_integer() | -1,
              ValType :: value_type_r() | value_type_w(),
              Val :: rdht_tx:encoded_value()) ->
                 tlog_entry()

### new_entry/6

    new_entry(Op :: tx_op(),
              Key :: rt_chord:key(),
              Vers :: non_neg_integer() | -1,
              Status :: tx_status(),
              ValType :: value_type_r() | value_type_w(),
              Val :: rdht_tx:encoded_value()) ->
                 tlog_entry()

### new_entry/7

    new_entry(Op :: tx_op(),
              Key :: rt_chord:key(),
              Vers :: non_neg_integer() | -1,
              Status :: tx_status(),
              SnapNumber :: snap_number(),
              ValType :: value_type_r() | value_type_w(),
              Val :: rdht_tx:encoded_value()) ->
                 tlog_entry()

### get_entry_operation/1

    get_entry_operation(Element :: tlog_entry()) -> tx_op()

### set_entry_operation/2

    set_entry_operation(Element :: tlog_entry(), Val :: tx_op()) ->
                           tlog_entry()

### get_entry_key/1

    get_entry_key(Element :: tlog_entry()) ->
                     client_key() | rt_chord:key()

### set_entry_key/2

    set_entry_key(Entry :: tlog_entry(),
                  Val :: client_key() | rt_chord:key()) ->
                     tlog_entry()

### get_entry_version/1

    get_entry_version(Element :: tlog_entry()) ->
                         non_neg_integer() | -1

### get_entry_status/1

    get_entry_status(Element :: tlog_entry()) -> tx_status()

### set_entry_status/2

    set_entry_status(Element :: tlog_entry(), Val :: tx_status()) ->
                        tlog_entry()

### get_entry_snapshot/1

    get_entry_snapshot(Element :: tlog_entry()) -> snap_number()

### set_entry_snapshot/2

    set_entry_snapshot(Element :: tlog_entry(), Val :: snap_number()) ->
                          tlog_entry()

### get_entry_value_type/1

    get_entry_value_type(Element :: tlog_entry()) ->
                            value_type_r() | value_type_w()

### get_entry_value/1

    get_entry_value(Element :: tlog_entry()) ->
                       {value_type_r() | value_type_w(),
                        rdht_tx:encoded_value()}

### set_entry_value/3

    set_entry_value(Element :: tlog_entry(),
                    ValType :: value_type_r() | value_type_w(),
                    Val :: rdht_tx:encoded_value()) ->
                       tlog_entry()

### drop_value/1

    drop_value(Element :: tlog_entry()) -> tlog_entry()

Generated by EDoc, Apr 22 2017, 15:58:19.