Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / 000604.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml" />
11
12    <title>Status for Andrew DeFaria: Mkcc.pm and mkvob</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/000603.html" title="Reworking GPDB tables, mkview" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/000606.html" title="Site Admins" />
17
18    
19
20    
21
22    <script type="text/javascript" src="http://defaria.com/blogs/Status/mt-site.js"></script>
23 </head>
24 <body class="layout-one-column" onload="individualArchivesOnLoad(commenter_name)">
25    <div id="container">
26       <div id="container-inner" class="pkg">
27
28          <div id="banner">
29             <div id="banner-inner" class="pkg">
30                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
31                <h2 id="banner-description">Searchable status reports and work log</h2>
32             </div>
33          </div>
34
35          <div id="pagebody">
36             <div id="pagebody-inner" class="pkg">
37                <div id="alpha">
38                   <div id="alpha-inner" class="pkg">
39
40                      <p class="content-nav">
41                         <a href="http://defaria.com/blogs/Status/archives/000603.html">&laquo; Reworking GPDB tables, mkview</a> |
42                         <a href="http://defaria.com/blogs/Status/">Main</a>
43                         | <a href="http://defaria.com/blogs/Status/archives/000606.html">Site Admins &raquo;</a>
44                      </p>
45
46                      <a id="a000604"></a>
47                      <div class="entry" id="entry-604">
48                         <h3 class="entry-header">Mkcc.pm and mkvob</h3>
49                         <div class="entry-content">
50                            <div class="entry-body">
51                               <ul>
52   <li>Pulled out common code from mkview that will be needed for mkvob into Mkcc.pm Perl module</li>
53
54   <li>Re-engineered mkview to use Mkcc.pm</li>
55
56   <li>Started recoding mkvob to use GPDB and the new Mkcc.pm</li>
57
58   <li>Code complete on mkvob - need to test</li>
59
60   <li><b>Issue</b>: It seems that we have multiple versions of mkview_linked and that UK has continued development of their version of mkview_linked while we've been developing on mkview_linked here in Dallas. IOW there are two versions in separate vobs!</li>
61 </ul>
62                            </div>
63                            <div id="more" class="entry-more">
64                               <h3>The old mkvob_db</h3>
65
66 <p>There are some oddities in the old mkvob_db code. For example, there is an insistence in setting umask to 0 before creating directories, which are created with specific permissions. Setting umask is only for the new creation of a directory or file. One could, instead, simply make the directory then chmod it to whatever you really wanted the permissions to be. The new subroutine MakeDir in Mkcc.pm does just that, as well as chown if owner and group are passed in as well as only making the directory if it is needed. This simplifies the code a lot and removes the need to save, set and restore umask.</p>
67
68 <p>Another oddity of the old code can be seen in the following:</p>
69
70 <div class=code><pre>
71 foreach $rgn (@regionList) {
72   $debug && print "DEBUG: Checking tag in $rgn\n";
73
74   $cmd = 'lsvob -s -region $rgn';
75
76   @output = ctcmd($cmd);
77
78   foreach $item (@output)
79   {
80     if ($item =~ /^$tag$/)
81       {
82         print "VOB tag $tag already exists in $rgn\n\n";
83         exit (1);
84       }
85   }
86 }
87 </pre></div>
88
89 <p>Looks innocuous enough - run through a list of regions looking to see if this newly requested vob tag already exists in any of the regions. However there are bugs and inefficiencies in the above code. For starters the single quote on the setting of $cmd says to <b>not</b> expand the variable $rgn. The resulting command then becomes "cleartool lsvob -s region $rgn" which, of course, would return an error, which, of course, is not checked for here. So the code, while trying to verify that this vob tag does not exist in any of the regions, fails to actually check it!</p>
90
91 <p>However if we just correct that by using double quotes we will now incur a performance penalty. Now the registry server will be required to return all the vob tags for each and every region which can take some time. Is there any way we can make this faster? Why yes there is! Specify the actual vob tag (as in cleartool lsvob -s -region &lt;region name&gt; &lt;vob tag&gt;)! You know sometimes people say that Clearcase always returns all of the registry data which is then parsed locally. Then again, sometimes it's the programmer who asks for it!</p>
92
93 <p>So the new code looks like:</p>
94
95 <div class=code><pre>
96 foreach (@regionList) {
97   debug "Checking for $tag in region $_";
98
99   @output = ctcmd "lsvob -s -region $_ $tag";
100
101   error "VOB tag $tag already exists in region $_", 1 if !grep /Error/, @output;
102 } # foreach
103 </pre></div>
104
105 <p>Note the simplifications for debug (now a subroutine from Mkcc.pm), usage of the default variable ($_) and error reporting (also a subroutine from Mkcc.pm). This algorithm performs the same task, correctly and orders of magnitude quicker.
106                            </div>
107                         </div>
108                         <p class="entry-footer">
109                            <span class="post-footers">Posted by  on December 28, 2006  4:50 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000604.html">Permalink</a>
110                         </p>
111                      </div>
112
113                      
114
115                      
116                   </div>
117                </div>
118             </div>
119          </div>
120       </div>
121    </div>
122 </body>
123 </html>