-r--r--r-- 6999 cdb-20251021/doc/html/cdbmake.html raw
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style type="text/css"> html{overflow-y:scroll;background-color:#35492a} body{font-family:"Noto Sans","Droid Sans","DejaVu Sans","Arial",sans-serif;line-height:1.5} tt,code{background-color:#f0f0f0;font-family:"Noto Sans Mono","Droid Sans Mono","DejaVu Sans Mono","Courier New",monospace,sans-serif;font-size:1em;} pre{margin-left:3em} p,ul,ol,blockquote,pre{font-size:1.0em;line-height:1.6} li p{font-size:1.0em} blockquote p{font-size:1.0em} h1{font-size:1.5em} h2{font-size:1.3em} h3{font-size:1.0em} h1 a{text-decoration:none} table{border-collapse:collapse} th,td{border:1px solid black} table a{text-decoration:none} table tr{font-size:1.0em;line-height:1.6em} table tr{font-size:1.0em;line-height:1.5} tbody tr:nth-child(12n+1){background-color:#f0ffff} tbody tr:nth-child(12n+2){background-color:#f0ffff} tbody tr:nth-child(12n+3){background-color:#f0ffff} tbody tr:nth-child(12n+4){background-color:#f0ffff} tbody tr:nth-child(12n+5){background-color:#f0ffff} tbody tr:nth-child(12n+6){background-color:#f0ffff} tbody tr:nth-child(12n+7){background-color:#fffff0} tbody tr:nth-child(12n+8){background-color:#fffff0} tbody tr:nth-child(12n+9){background-color:#fffff0} tbody tr:nth-child(12n+10){background-color:#fffff0} tbody tr:nth-child(12n+11){background-color:#fffff0} tbody tr:nth-child(12n+12){background-color:#fffff0} #headline{display:block;margin:0;padding:0;color:#ffffff;background-color:#35492a} #headline .text{font-weight:bold;font-size:1.0em} #headline input{display:none} #nav ul{margin:0;padding:0} #nav li{list-style-type:none;margin:0;padding:0} .navtop{padding-bottom:0.5em;font-weight:bold;font-size:1.0em} .navtop{background-color:#35492a;color:#ffffff} #nav .here{background-color:#35492a;color:#ffffff} #nav .away{background-color:#35492a;color:#ffffff} #nav .away a{text-decoration:none;display:block;color:#ffffff} #nav .away a:hover,.away a:active{text-decoration:underline} #hidemenu{visibility:hidden;display:none;overflow:hidden;position:fixed;top:0;left:0;height:100%;width:100%} .main{padding:5px} .main{background-color:#ffffff} .pagetitle{font-size:1.4em;font-weight:bold} @media only screen and (min-width:512px) { .navtop{padding-top:5px} #headline{top:0;margin:0;width:160px;height:100%;position:fixed;overflow:auto} #headline .noselect{display:none} #headline #nav{visibility:visible;display:block;width:auto;height:auto} .main{margin-left:170px} #headline #hidemenu{visibility:hidden} } @media not screen and (min-width:512px) { #headline .noselect{-webkit-user-select:none;-ms-user-select:none;user-select:none;} #headline #nav #navbot{visibility:hidden;position:fixed;top:0;left:-70%;z-index:2;transition:0.2s;margin:0;padding:0} #headline input:checked ~ #nav #navbot{height:100%;position:fixed;top:0;left:0;visibility:visible;display:block;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;vertical-align:center;font-size:1.0em;width:70%;overflow:auto} #headline input:checked ~ #hidemenu{visibility:visible;display:block;background:black;opacity:0.3;z-index:1} } </style> <title> cdb: cdbmake</title> </head> <body> <label id=headline> <input type=checkbox /> <nav id=nav> <div class=navtop> <span class=noselect>≡</span> cdb</div> <ul id=navbot> <li class=away><a href=index.html>Intro</a> </li><li class=away><a href=download.html>Download</a> </li><li class=away><a href=install.html>Install</a> </li><li class=away><a href=test.html>Test</a> </li><li class=away><a href=cdb.html>Read API</a> </li><li class=away><a href=cdbget.html>cdbget</a> </li><li class=away><a href=cdbdump.html>cdbdump</a> </li><li class=here>cdbmake </li><li class=away><a href=cdbmake-12.html>cdbmake-12</a> </li><li class=away><a href=cdbmake-sv.html>cdbmake-sv</a> </li><li class=away><a href=cdbstats.html>cdbstats</a> </li><li class=away><a href=cdbtest.html>cdbtest</a> </li><li class=away><a href=format.html>Format</a> </li><li class=away><a href=license.html>License</a> </li></ul></nav> <div id=hidemenu></div> </label> <div class=main> <div class=pagetitle>cdb: cdbmake</div> <h3>NAME</h3> <p>cdbmake - create a constant database</p> <h3>SYNOPSIS</h3> <p><code>cdbmake</code> <em>f</em> <em>ftmp</em></p> <h3>DESCRIPTION</h3> <p><code>cdbmake</code> reads a series of encoded records from its standard input and writes a constant database to a file named <em>f</em>, replacing any previous contents of <em>f</em>.</p> <p><code>cdbmake</code> ensures that <em>f</em> is updated atomically, so programs reading <em>f</em> never have to wait for <code>cdbmake</code> to finish. It does this by first writing the database to <em>ftmp</em> and then moving <em>ftmp</em> on top of <em>f</em>. If <em>ftmp</em> already exists, it is destroyed. The directories containing <em>ftmp</em> and <em>f</em> must be writable to <code>cdbmake</code>; they must also be on the same filesystem.</p> <p><code>cdbmake</code> always makes sure that <em>ftmp</em> is safely written to disk before it replaces <em>f</em>. If the input is in a bad format or if <code>cdbmake</code> has any trouble writing <em>ftmp</em> to disk, <code>cdbmake</code> complains and leaves f alone.</p> <p>There is also a <code>cdb64make</code> that uses cdb64 format instead of cdb format.</p> <h3>RECORD FORMAT</h3> <p>Records are indexed by keys. A key is a string. The file <em>f</em> is structured so that another program, starting from a key, can quickly find the relevant record. <code>cdbmake</code> allows several records with the same key, although</p> <ul> <li> <p>most readers take only the first record, and</p> </li> <li> <p><code>cdbmake</code> slows down somewhat if there are many records with the same key.</p> </li> </ul> <p><code>cdbmake</code> preserves the order of records.</p> <p>For the input provided to <code>cdbmake</code>, each record is encoded as +<em>klen</em>,<em>dlen</em>:<em>key</em>-&gt;<em>data</em> followed by a newline. Here <em>klen</em> is the number of bytes in <em>key</em> and <em>dlen</em> is the number of bytes in <em>data</em>. The end of all records is indicated by an extra newline. For example, here are two records:</p> <pre><code>+3,5:one-&gt;Hello +3,7:two-&gt;Goodbye </code></pre> <p><em>key</em> and <em>data</em> may contain any characters, including colons, dashes, newlines, and nulls.</p> <p>Keys and data do not have to fit into memory, but <code>cdbmake</code> needs roughly 16 bytes of memory per record. A database cannot exceed 4 gigabytes (or 1 exabyte for <code>cdb64make</code>).</p> <p><em>f</em> is portable across machines.</p> <h3>SEE ALSO</h3> <p><strong>cdbdump</strong>(1), <strong>cdbget</strong>(1), <strong>cdbmake-12</strong>(1), <strong>cdbmake-sv</strong>(1), <strong>cdbstats</strong>(1)</p><hr><font size=1><b>Version:</b> This is version 2025.10.21 of the "cdbmake" web page. </font> </div> </body> </html>