Module ocs_gtt

Global Title Table.

Copyright © 2017 - 2026 SigScale Global Inc.

Authors: Vance Shipley (vances@sigscale.com).

To do

Description

Global Title Table. This module implements generic prefix matching tables for digit strings using an //mnesia backing store. Prefix matching may be done effeciently because each unique prefix is stored in the table. A lookup for "1519" may be done in up to four steps. First find "1" as a key, if the key is not found the prefix does not exist in the table. If the value for the key is undefined lookup "15" and if that key's value is undefined lookup "151" This continues until either the key is not found or the value is not undefined.

The example below shows the table contents after an initial entry of the form:
1> ocs_gtt:insert(global_title, "1519240", "Bell Mobility").
  		{gtt, [1], undefined}
  		{gtt, [1,5], undefined}
  		{gtt, [1,5,1], undefined}
  		{gtt, [1,5,1,9], undefined}
  		{gtt, [1,5,1,9,2], undefined}
  		{gtt, [1,5,1,9,2,4], undefined}
  		{gtt, [1,5,1,9,2,4,0], "Bell Mobility"}
Note: There is no attempt made to clean the table properly when a prefix is deleted.

Data Types

gtt()

gtt() = #gtt{num = string() | '_' | '$1', value = tuple() | undefined | '_' | '$2'}

Function Index

new/2Create a new table.
new/3Create a new table and populate it from the supplied list of items.
insert/3Insert a table entry.
insert/2Insert a list of table entries.
delete/2Delete a table entry.
lookup_first/2Lookup the value of the first matching table entry.
lookup_last/2Lookup the value of the longest matching table entry.
lookup_all/2Lookup the values of matching table entries.
list/0List all tables.
list/2List all gtt entries.
query/3Paginated filtered query of table.
clear_table/1Clear a table.

Function Details

new/2

new(Table, Options) -> ok

Create a new table. The Options define table definitions used in //mnesia.

See also: //mnesia/mnesia:create_table/2.

new/3

new(Table, Options, Items) -> ok

Create a new table and populate it from the supplied list of items. This is the quickest way to build a new table as it performs all the insertions within one optimized transaction context.

The Options define table definitions used in //mnesia.

See also: //mnesia/mnesia:create_table/2.

insert/3

insert(Table, Number, Value) -> Result

Insert a table entry.

insert/2

insert(Table, Items) -> ok

Insert a list of table entries. The entries are inserted as a transaction, either all entries are added to the table or, if an entry insertion fails, none at all.

delete/2

delete(Table, Number) -> ok

Delete a table entry.

lookup_first/2

lookup_first(Table, Number) -> Result

Lookup the value of the first matching table entry.

lookup_last/2

lookup_last(Table, Number) -> Result

Lookup the value of the longest matching table entry.

lookup_all/2

lookup_all(Table, Number) -> Result

Lookup the values of matching table entries.

list/0

list() -> Tables

List all tables.

list/2

list(Cont, Table) -> Result

List all gtt entries.

query/3

query(Cont, Table, MatchPrefix) -> Result

Paginated filtered query of table.

clear_table/1

clear_table(Table) -> ok

Clear a table.


Generated by EDoc