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

path::sqlite(n) 1 doc "Path. Packages for path (list of string) interning and deduplication. Uses Atom."

Name

path::sqlite - Path - Sqlite storage backend

Table Of Contents

Synopsis

Description

Welcome to the Path project, written by Andreas Kupries.

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

This package provides storages for string interning which use a table in an sqlite database to hold their data.

Note and remember that sqlite databases may exist only in memory and not just with a backing file as usual. This is another way of getting an in-memory string storage.

Class API

::path::sqlite create obj db table

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

The named table in the sqlite database identified by its object command database is used to hold the mapping. The table will be created if it does not exist. If it exists its schema will be verified instead and an error thrown if the schema is not as expected.

::path::sqlite new db table

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

The named table in the sqlite database identified by its object command database is used to hold the mapping. The table will be created if it does not exist. If it exists its schema will be verified instead and an error thrown if the schema is not as expected.

Standard API

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

<instance> atom-store

This method returns the fully-qualified command name of the Atom store used to intern path elements.

<instance> id path
<instance> id* word...
<instance> id-from base path
<instance> id-from* base word...

These methods add the specified path to the instance, and then return its unique numeric identifier as their result.

Multiple calls for the same path all return the same identifier.

The methods whose name ends in * take the elements of the path to enter as separate word. The other methods take the elements as a list in a single argument.

The methods using from in their take an additional argument, the identifer of a known path and then enter the new path relative to this base. An error is thrown if base is not known.

<instance> path id

This method maps the specified numeric id back to its path, and returns that path 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 paths which have been interned into the instance.

<instance> exists path
<instance> exists* word...
<instance> exists-from base path
<instance> exists-from* base word...

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

The variants regarding * and from are the same as for method id. I.e. * takes the path to check as separate argument words, and from checks relative to a known base path, specified by its numeric identifier.

<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 paths known to the instance.

<instance> map path id

This method adds the specified path 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 path, or if path is already known under a different id.

<instance> clear

This method drops all path/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 path-to-id map and returns it as the result of the method.

The result is a Tcl dictionary with the paths as keys and the associated identifiers as the values. Note, order is important, parent paths are listed before their children.

<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 path/id mapping found in the input. On the flip-side this means that existing mappings may interfere and cause an error to be thrown. Note, order is important, parent paths have to be listed before their children for the forced mapping to work.

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 paths 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 Path Tickets.

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

Keywords

deduplication, hierarchical, interning, list(string) deduplication, list(string) interning, list(string) storage, path deduplication, path interning, path storage, storage, tree