View Source KrakenDB (DetsPlus v2.1.5)

Alpha version of a sharded DetsPlus

Summary

Functions

Syncs pending writes to the persistent file and closes the table.

Returns the number of object in the table. This is an estimate.

Deletes all objects with key Key from table Name.

Deletes all objects from a table in almost constant time.

Deletes all instances of a specified object from a table.

Returns information about table Name as a list of objects

Returns the information associated with item for the table. The following items are allowed

Inserts one or more objects into the table. If there already exists an object with a key matching the key of some of the given objects, the old object will be replaced.

Inserts one object into the table if it doesn't already exists.

Returns a list of all objects with key Key stored in the table.

Works like lookup/2, but does not return the objects. Returns true if one or more table elements has the key key, otherwise false.

Reducer function following the Enum protocol.

Starts a sync of all changes to the disk. Same as sync/1 but doesn't block

Ensures that all updates made to table are written to disk. While the sync is running the table can still be used for reads and writes, but writes issued after the sync/1 call will not be part of the persistent file. These new changes will only be included in the next sync call.

Types

@type t() :: %KrakenDB{
  dets: term(),
  hashfun: term(),
  keyfun: term(),
  keyhashfun: term(),
  keypos: term()
}

Functions

Syncs pending writes to the persistent file and closes the table.

Returns the number of object in the table. This is an estimate.

Deletes all objects with key Key from table Name.

Deletes all objects from a table in almost constant time.

Link to this function

delete_object(kdb, object)

View Source

Deletes all instances of a specified object from a table.

Returns information about table Name as a list of objects:

  • {file_size, integer() >= 0}} - The file size sum, in bytes.
  • {directory, file:name()} - The name of the directory where objects are stored.
  • {keypos, keypos()} - The key position.
  • {size, integer() >= 0} - The number of objects estimated in the table.
  • {type, type()} - The table type.
@spec info(
  t(),
  :file_size
  | :header_size
  | :directory
  | :keypos
  | :size
  | :type
  | :creation_stats
  | :bloom_bytes
  | :hashtable_bytes
) :: any()

Returns the information associated with item for the table. The following items are allowed:

  • {file_size, integer() >= 0}} - The file size, in bytes.
  • {header_size, integer() >= 0}} - The size of erlang term encoded header.
  • {bloom_bytes, integer() >= 0}} - The size of the in-memory and on-disk bloom filter, in bytes.
  • {hashtable_bytes, integer() >= 0}} - The size of the on-disk lookup hashtable, in bytes.
  • {filename, file:name()} - The name of the file where objects are stored.
  • {keypos, keypos()} - The key position.
  • {size, integer() >= 0} - The number of objects estimated in the table.
  • {type, type()} - The table type.

Inserts one or more objects into the table. If there already exists an object with a key matching the key of some of the given objects, the old object will be replaced.

Inserts one object into the table if it doesn't already exists.

Returns a list of all objects with key Key stored in the table.

Example:

2> KrakenDB.open_directory(:abc)
{ok,:abc}
3> KrakenDB.insert(:abc, {1,2,3})
ok
4> KrakenDB.insert(:abc, {1,3,4})
ok
5> KrakenDB.lookup(:abc, 1).
[{1,3,4}]

If the table type is set, the function returns either the empty list or a list with one object, as there cannot be more than one object with a given key. If the table type is bag or duplicate_bag, the function returns a list of arbitrary length.

Notice that the order of objects returned is unspecified. In particular, the order in which objects were inserted is not reflected.

Works like lookup/2, but does not return the objects. Returns true if one or more table elements has the key key, otherwise false.

Link to this function

open_directory(name, args \\ [])

View Source

Reducer function following the Enum protocol.

Starts a sync of all changes to the disk. Same as sync/1 but doesn't block

Ensures that all updates made to table are written to disk. While the sync is running the table can still be used for reads and writes, but writes issued after the sync/1 call will not be part of the persistent file. These new changes will only be included in the next sync call.