diff options
author | Alex Auvolat <alex@adnab.me> | 2018-09-01 16:06:23 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-09-01 16:06:23 +0200 |
commit | c6ec33d6e612168e14d77007915a4ea423c55a2e (patch) | |
tree | 8b5645651a0cc991b8ac9c68c388d84c8dbe73d2 /lib/data/data.ex | |
parent | 1a0ef154a421af60f6d57dfe861dacb844a7d142 (diff) | |
download | shard-c6ec33d6e612168e14d77007915a4ea423c55a2e.tar.gz shard-c6ec33d6e612168e14d77007915a4ea423c55a2e.zip |
Move everything to subdirectory
Diffstat (limited to 'lib/data/data.ex')
-rw-r--r-- | lib/data/data.ex | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/lib/data/data.ex b/lib/data/data.ex deleted file mode 100644 index c2c659d..0000000 --- a/lib/data/data.ex +++ /dev/null @@ -1,49 +0,0 @@ -defmodule SData do - @moduledoc """ - Utility functions - - Compare functions are functions that compares stored items and provides a total order. - They must return: - - `:after` if the first argument is more recent - - `:duplicate` if the two items are the same - - `:before` if the first argument is older - These functions must only return :duplicate for equal items. - """ - - @doc """ - Calculate the hash of an Erlang term by first converting it to its - binary representation. - """ - def term_hash(term, algo \\ :sha256) do - :crypto.hash(algo, (:erlang.term_to_binary term)) - end - - @doc""" - Compare function for arbitrary terms using the Erlang order - """ - def cmp_term(a, b) do - cond do - a > b -> :after - a < b -> :before - a == b -> :duplicate - end - end - - @doc""" - Compare function for timestamped strings - """ - def cmp_ts_str({ts1, str1}, {ts2, str2}) do - cond do - ts1 > ts2 -> :after - ts1 < ts2 -> :before - str1 > str2 -> :after - str1 < str2 -> :before - true -> :duplicate - end - end - - @doc""" - Merge function for nils - """ - def merge_true(true, true), do: true -end |