Documentation:Users:Versions - MdsWiki
Navigation
Personal tools

From MdsWiki

Jump to: navigation, search

Data Versions

A new feature was added to MDSplus in release 1.8-2 which enables users to retain older versions of data in the nodes of a tree. There are two new mdstcl commands added to support this feature. Additional commands will be added in future release to provide additional capability for managing the versions. Versioning of data can be enabled on an MDSplus tree bases. The following commands are used to enable versioning of data in a tree:

$ mdstcl
TCL> edit mytree
TCL> SET VERSIONS/SHOT
TCL> SET VERSIONS/MODEL
TCL> WRITE
TCL> EXIT

Versioning of data can be enabled for new data written into shot files (shot number > 0) or the model or both.

How does it work?

When versioning is enabled, the original data stored in a node is retained when new data is added to a node. The original node characteristics, such as who wrote the data and when, are also retained with the old data. See the following example of data versioning:

$ mdstcl
TCL> edit/new test
TCL> set version/model
TCL> add node mydata/usage=numeric
TCL> write
TCL> close
TCL> set tree test
TCL> put mydata 42
TCL> dir/full mydata
 
\TEST::TOP
 
 :MYDATA      
      Status: on,parent is on, usage numeric
      compress on put
      Data inserted:  4-JAN-2007 09:09:43    Owner: [1751,1750]
      Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes
 
Total of 1 node.
TCL> put mydata 43
TCL> dir/full mydata
  
\TEST::TOP
  
 :MYDATA      
      Status: on,parent is on, usage numeric
      compress on put
      Data inserted:  4-JAN-2007 09:09:55    Owner: [1751,1750]
      Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes

      Data inserted:  4-JAN-2007 09:09:43    Owner: [1751,1750]
      Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes
  
Total of 1 node.
TCL> show data mydata
\TEST::TOP:MYDATA
 DTYPE_L                       : 43

As you can see in the above mdstcl session, the directory command on MYDATA shows two entries for the data characteristics. The first stored at 9:43 and the second stored at 9:55. The show data command reveals the latest data stored in the node. To access older versions of data in MDSplus you must change your default time reference for retrieving data. In effect, you specify a time indicating that you want to retrieve the value of data as it was in the tree at that date. This is very different than retrieving versions by some index number. It lets you specify a reference time to use for retrieving data from any of the nodes. When expressions are evaluated, the results will reflect the data contents of the tree as it existed at that time frame. See the example below:

TCL> set tree test
TCL> dir/full mydata
 
\TEST::TOP
 
 :MYDATA      
      Status: on,parent is on, usage numeric
      compress on put
      Data inserted:  4-JAN-2007 09:09:55    Owner: [1751,1750]
      Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes

      Data inserted:  4-JAN-2007 09:09:43    Owner: [1751,1750]
      Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes
 
Total of 1 node.
TCL> decompile mydata
43
TCL> set view "4-JAN-2007 09:09:50"
TCL> decompile mydata
42
TCL> dir/full mydata
 
\TEST::TOP
 
 :MYDATA      
      Status: on,parent is on, usage numeric
      compress on put
      Data inserted:  4-JAN-2007 09:09:43    Owner: [1751,1750]
      Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes
 
Total of 1 node.
TCL> set view "now"
TCL> dir/full mydata
 
\TEST::TOP
 
 :MYDATA      
      Status: on,parent is on, usage numeric
      compress on put
      Data inserted:  4-JAN-2007 09:09:55    Owner: [1751,1750]
      Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes

      Data inserted:  4-JAN-2007 09:09:43    Owner: [1751,1750]
      Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes
 
Total of 1 node.

As you can see above when the view date was changed to 9:50 the data stored at that time in mydata was 42 which is not the latest version of the data. Similarly the mdstcl directory command displays the node information as one would have seen if the command was done at 9:50. You must specifiy the full date as it appears in the dir/full output enclosed in double quotes when using the set view command.

When trees with versioning enabled are cleaned or compressed the earlier versions are retained. If you disable versioning on a tree which was previously enabled for versioning the earlier versions are retained until a new version is stored in a node or the tree is cleaned or compressed.

As we get more experience with the use of versioning additional mdstcl commands and perhaps tdi functions may be added facilitate the management and use of versions. Some ideas for further enhancements are mdstcl commands for purging earlier versions or delete specific versions. Another idea would be to provide either tdi syntax (unlikely) or a tdi function (more likely) to refer to a particular version of a data item either by date or by index.