Retrieving LTPDA objects from a repository

Objects can be retrieved from the repository either by specifying an object ID or a collection ID. The LTPDA Toolbox provides class construtors to retrieve objects. In additon, to retrieve a collection of objects, the collection class can be used.

The retrieval process

When an object is retrieved, the following steps are taken:

  1. The object type for the requested ID is retrieved from the objmeta table
  2. A call is made to the appropriate class constructor
  3. The class constructor retrieves the XML string from the objs table
  4. The XML string is then converted into an XML Xdoc object
  5. The Xdoc object is then parsed to recreate the desired object

Retrieving objects

To retrieve an object, you must know its object ID, or the ID of the collection that contains that object. If you don't know the class of the object, you can use the collection class as a container, as follows:

      a = collection(plist('hostname', 'localhost', 'database', 'ltpda_test', 'id', 1))
      ---- collection 1 ----
      name: none
      num objs: 1
      01: ao | New Block/tsdataNdata=[10x1], fs=1, nsecs=10, t0=1970-01-01 00:00:00.000
      UUID: 9ec7a613-9442-4451-9b40-af18f4afea00

If you already know the class of the object (for example, ao), you can directly call the class constructor method:

      % Define the hostname and database
      hostname = 'localhost';
      database = 'ltpda_test';
      % Retrieve the object
      q = ao(plist('hostname', hostname, 'database', dbname, 'ID', 12));

Multiple objects can be retrieved simultaneously by giving a list of object IDs. For example

      a = ao(plist('hostname', 'localhost', 'database', 'ltpda_test', 'id', [1 2 3]));

Retrieving object collections

Collections of objects can be retrieved by specifying the collection ID. The following script retrieves a collection:

      a = collection(plist('hostname', 'localhost', 'database', 'ltpda_test', 'cid', 1));
The output is a collection object containing the objects retrieved.

Retrieving binary objects

The retrieval process may be speeded up by taking advantage of the fact that the objects are stored in the databases also in binary form. This can be achieved by using the parameter 'binary', that will build the object from the corresponding binary representation, if stored in the database.

      % Retrieve the collection
      q = ao(plist('hostname', hostname, 'database', dbname, 'ID', 12, 'binary', 'yes'));
If the binary representation is not in the database, the object will be built from the XML one.

©LTP Team