[ Home | Main Table Of Contents | Table Of Contents | Keyword Index ]

atom::memory(n) 1 doc "Atom. Packages for string interning and deduplication"

Name

atom::memory - Atom - In-memory storage backend

Table Of Contents

Synopsis

Description

Welcome to the Atom project, written by Andreas Kupries.

For availability please read Atom - How To Get The Sources.

This package provides an in-memory storage for string interning.

Class API

::atom::memory create obj

This constructor command creates a new instance obj of the class and returns the fully qualified name of that instance.

::atom::memory new

This constructor command creates a new instance of the class and returns the fully qualified name of that instance.

Standard API

As a derived class of atom instances of this class provide the following methods:

<instance> id string

This method adds the specified string to the instance, and returns its unique numeric identifier as the result of the method.

Multiple calls of this method for the same string all return the same identifier.

<instance> str id

This method maps the specified numeric id back to its string, and returns that string as the result of the method.

An error is thrown if the id is not known to the instance.

<instance> names

This method returns a list of all strings which have been interned into the instance.

<instance> exists string

This method tests if the specified string has been interned into the instance and returns a boolean flag as the result of the method. The result is true if the string is known, and false otherwise.

<instance> exists-id id

This method tests if the specified numeric id is known to the instance and returns a boolean flag as the result of the method. The result is true if the id is known, and false otherwise.

<instance> size

This method returns the number of interned strings known to the instance.

<instance> map string id

This method adds the specified string to the instance and forces an association with the specified numeric id. The result of the method is the empty string.

An error will be thrown however if the id is already used for a different string.

<instance> clear

This method drops all string/id mappings from the instance. After this method has run the instance is empty. The result of this method is the empty string.

<instance> serialize
<instance> -->

This method serializes the content of the instance, i.e. the string-to-id map and returns it as the result of the method.

The result is a Tcl dictionary with the strings as keys and the associated identifiers as the values.

<instance> deserialize serialization
<instance> <-- serialization

This method takes a serialization as generated by method serialize and adds it to the instance. It uses the method map for this, to preserve the exact string/id mapping found in the input. On the flip-side this means that existing mappings may interfere and cause an error to be thrown.

If the previous content is not relevant, use method load instead. If the exact mapping is not relevant, use method merge instead.

The result of the method is the empty string.

<instance> load serialization
<instance> := serialization

This method takes a serialization as generated by method serialize and uses it to replace previous content of the instance.

The result of the method is the empty string.

<instance> merge serialization
<instance> += serialization

This method takes a serialization as generated by method serialize and adds the strings it contains to the instance. The ids found in the serialization are ignored and do not transfer.

The result of the method is the empty string.

Bugs, Ideas, Feedback

Both the package(s) and this documentation will undoubtedly contain bugs and other problems. Please report such at Atom Tickets.

Please also report any ideas you may have for enhancements of either package(s) and/or documentation.

Keywords

deduplication, interning, storage, string deduplication, string interning, string storage