carpenter/table

Types

pub type Privacy {
  Private
  Protected
  Public
}

Constructors

  • Private
  • Protected
  • Public
pub type Set(k, v) {
  Set(table: Table(k, v))
}

Constructors

  • Set(table: Table(k, v))
pub type Table(k, v) {
  Table(name: atom.Atom)
}

Constructors

  • Table(name: atom.Atom)
pub type TableBuilder(k, v) {
  TableBuilder(
    name: String,
    privacy: Option(Privacy),
    write_concurrency: Option(WriteConcurrency),
    read_concurrency: Option(Bool),
    decentralized_counters: Option(Bool),
    compressed: Bool,
  )
}

Constructors

  • TableBuilder(
      name: String,
      privacy: Option(Privacy),
      write_concurrency: Option(WriteConcurrency),
      read_concurrency: Option(Bool),
      decentralized_counters: Option(Bool),
      compressed: Bool,
    )
pub type WriteConcurrency {
  WriteConcurrency
  NoWriteConcurrency
  AutoWriteConcurrency
}

Constructors

  • WriteConcurrency
  • NoWriteConcurrency
  • AutoWriteConcurrency

Functions

pub fn build(name: String) -> TableBuilder(a, b)

Begin building a new table with the given name. Ensure your table names are unique, otherwise you will encounter a badarg failure at runtime when attempting to build it.

pub fn compression(
  builder: TableBuilder(a, b),
  compressed: Bool,
) -> TableBuilder(a, b)

Whether or not the table is compressed.

pub fn contains(set: Set(a, b), key: a) -> Bool

Returns a boolean based on the existence of a key within the table

pub fn decentralized_counters(
  builder: TableBuilder(a, b),
  counters: Bool,
) -> TableBuilder(a, b)

Whether or not the table uses decentralized_counters. Acceptable values are True or False.

You should probably choose True unless you are going to be polling the table for its size and memory usage frequently.

pub fn delete(set: Set(a, b), key: a) -> Nil

Delete all objects with key key from the table.

pub fn delete_all(set: Set(a, b)) -> Nil

Delete all objects belonging to a table

pub fn delete_object(set: Set(a, b), object: #(a, b)) -> Nil

Delete an exact object from the table

pub fn drop(set: Set(a, b)) -> Nil

Deletes the entire table.

pub fn give_away(set: Set(a, b), pid: Pid, gift_data: c) -> Nil

Give the table to another process.

pub fn insert(set: Set(a, b), objects: List(#(a, b))) -> Nil

Insert a list of objects into the set

pub fn insert_new(set: Set(a, b), objects: List(#(a, b))) -> Bool

Insert a list of objects without overwriting any existing keys.

This will not insert ANY object unless ALL keys do not exist.

pub fn lookup(set: Set(a, b), key: a) -> List(#(a, b))

Retrieve a list of objects from the table.

pub fn ordered_set(
  builder: TableBuilder(a, b),
) -> Result(Set(a, b), Nil)

Specify table as an ordered_set

pub fn privacy(
  builder: TableBuilder(a, b),
  privacy: Privacy,
) -> TableBuilder(a, b)

Set the privacy of the table. Acceptable values are Private, Protected, and Public.

pub fn read_concurrency(
  builder: TableBuilder(a, b),
  con: Bool,
) -> TableBuilder(a, b)

Whether or not the table uses read_concurrency. Acceptable values are True or `False.

pub fn ref(name: String) -> Result(Set(a, b), Nil)

Get a reference to an existing table

pub fn set(builder: TableBuilder(a, b)) -> Result(Set(a, b), Nil)

Specify table as a set

pub fn take(set: Set(a, b), key: a) -> List(#(a, b))

Return and remove a list of objects with the given key

pub fn write_concurrency(
  builder: TableBuilder(a, b),
  con: WriteConcurrency,
) -> TableBuilder(a, b)

Set the write_concurrency of the table. Acceptable values are WriteConcurrency, NoWriteConcurrency, or AutoWriteConcurrency.

Search Document