FileConfig.Lib (file_config v0.7.1)

Copy Markdown View Source

Common functions

Summary

Functions

Get modification time of file, or Unix epoch on error

Uniformly allocate data to one of a fixed set of buckets.

Get nth element from reversed list

Functions

decode_json!(tid, name, key, value)

@spec decode_json!(:ets.tid(), atom(), term(), term()) :: term()

file_mtime(path)

@spec file_mtime(Path.t()) :: :calendar.datetime()

Get modification time of file, or Unix epoch on error

hash_to_bucket(e, buckets)

@spec hash_to_bucket(term(), pos_integer()) :: pos_integer()

Uniformly allocate data to one of a fixed set of buckets.

https://stats.stackexchange.com/questions/26344/how-to-uniformly-project-a-hash-to-a-fixed-number-of-buckets https://en.wikipedia.org/wiki/MurmurHash https://hex.pm/packages/murmur

def hash_to_bucket(e, B):
  i = murmurhash3.to_long128(str(e))
  p = i / float(2**128)
  for j in range(0, B):
    if j/float(B) <= p and (j+1)/float(B) > p:
      return j+1
  return B

make_fetch_fn(_)

make_fetch_fn(key_field, value_field)

rnth(n, list)

@spec rnth(non_neg_integer(), list()) :: term()

Get nth element from reversed list

rnth(n, list, l)

@spec rnth(non_neg_integer(), list(), non_neg_integer()) :: term()