<li><ahref="#command-line-tools">Command Line Tools</a></li>
<li><ahref="#sample-usage">Sample Usage</a></li>
<li><ahref="#api">API</a></li>
<li><ahref="#benchmark">Benchmark</a></li>
<li><ahref="#to-do">To Do</a></li>
<li><ahref="#licensing">Licensing</a></li>
<li><ahref="#citation">Citation</a></li>
<li><ahref="#references">References</a></li>
</ul>
</nav>
<h2id="what-is-xcdat">What is Xcdat?</h2>
<p>Xcdat is a C++ library that implements static compressed string dictionaries based on an improved double-array trie.</p>
<p>The double array (Aoe, 1989) is known as the fastest trie representation and has been used in many trie libraries. On the other hand, it has a space efficiency problem because of a pointer-based data structure. Xcdat solves the problem using the XOR-compressed double-array methods described in the following article.</p>
<p>Shunsuke Kanda, Kazuhiro Morita, and Masao Fuketa. Compressed double-array tries for string dictionaries supporting fast lookup. Knowledge and Information Systems, 51(3): 1023–1042, 2017. [<ahref="https://doi.org/10.1007/s10115-016-0999-8">doi</a>] [<ahref="https://sites.google.com/site/shnskknd/KAIS2016.pdf">pdf</a>]</p>
<p>Xcdat can implement trie dictionaries in smaller space compared to the other double-array libraries. In addition, the lookup speed is relatively fast in compressed data structures from the double-array advantage.</p>
<p>Xcdat is available at <ahref="https://github.com/kampersanda/xcdat">GitHub repsitory</a>.</p>
<h2id="features">Features</h2>
<ul>
<li><strong>Compressed Data Structure</strong>: Xcdat practically compresses double-array elements for representing node pointers by using the XCDA methods. While the original double array uses 8 bytes (or 16 bytes) per node, it uses about 3–4 bytes (but, depending on datasets). In addition, the dictionary is implemented using a minimal-prefix trie (Yata et al., 2007) that is effective for long strings in time and space.</li>
<li><strong>Two Compression Approaches</strong>: There are two approaches of compressing elements: using byte-oriented DACs (Brisaboa et al., 2013) and using pointer-based ones (Kanda et al., 2017). For characterless strings such as natural language keywords, the former will be slightly smaller and the latter will be slightly faster. For long strings such as URLs, the latter will outperform the former. Xcdat implements the two versions by using a static polymorphism with C++ template to avoid an overhead of virtual functions.</li>
<li><strong>64-bit Version</strong>: Although Xcdat represents node addresses using 32-bit integers in default configuration, we can allow for 64-bit integers by defining <code>XCDAT_X64</code>; therefore, the dictionary can be constructed from a very large dataset. The construction space becomes large, but the output dictionary size is nearly equal.</li>
<li><strong>NULL Character</strong>: The dictionary can be constructed from keys including the NULL character by setting the second parameter of <code>xcdat::TrieBuilder::build()</code> to <code>true</code>.</li>
<li><strong>Dictionary Encoding</strong>: Xcdat supports mapping N different strings to unique IDs in [0,N-1]. That is to say, it supports two basic dictionary operations: Lookup returns the ID corresponding to a given string and Access (also called ReverseLookup) returns the string corresponding to a given ID. Therefore, Xcdat is very useful in many applications for string precessing and indexing, such as described in (Martínez-Prieto et al., 2016).</li>
<li><strong>Fast Operations</strong>: Xcdat can provide lookup operations faster than other compressed trie libraries because it is based on the double-array trie. On the other hand, compared to the existing double-array libraries, the speed will be slower due to the compression.</li>
<li><strong>Prefix-based Lookup Operations</strong>: As with other trie libraries, Xcdat also provides prefix-based lookup operations required for natural language processing and so on.</li>
<p>If you want to use a 64-bit setting, please add <code>-DXCDAT_X64=ON</code> to the CMake option. In addition, you can use the SSE4.2 POPCNT instruction by adding <code>-DXCDAT_USE_POPCNT=ON</code> for Rank/Select operations. The code has been tested only on Mac OS X and Linux. That is, this library considers only UNIX-compatible OS.</p>
<h2id="command-line-tools">Command Line Tools</h2>
<p><code>xcdat</code> is a general-purpose command line tool to provide three modes as follows.</p>
<pre><code>$ xcdat
xcdat build <type><key><dict>
<type> 1: DACs, 2: FDACs
<key> Input file name of a set of keys (must be sorted)
<dict> Output file name of the dictionary (optional)
If omitted, <key>.dacs or <key>.fdacs is output
xcdat query <type><dict><limit>
<type> 1: DACs, 2: FDACs
<dict> Input file name of the dictionary
<limit> Limit of #results (optional, default=10)
xcdat bench <type><dict><key>
<type> 1: DACs, 2: FDACs
<dict> Input file name of the dictionary
<key> Input file name of keys for benchmark</code></pre>
<divclass="sourceLine"id="cb6-12"data-line-number="12"><spanclass="cf">for</span> (<spanclass="dt">size_t</span> i = <spanclass="dv">0</span>; i < keys.size(); ++i) {</div>
<divclass="sourceLine"id="cb6-56"data-line-number="56"><spanclass="bu">std::</span>cout <<<spanclass="st">"Performing a common prefix operation..."</span><<<spanclass="bu">std::</span>endl;</div>
<divclass="sourceLine"id="cb6-58"data-line-number="58"><spanclass="co">// Common prefix operation is implemented using PrefixIterator, created by</span></div>
<divclass="sourceLine"id="cb6-60"data-line-number="60"> Trie::PrefixIterator it = trie.make_prefix_iterator(<spanclass="st">"Nenecchi"</span>);</div>
<divclass="sourceLine"id="cb6-62"data-line-number="62"><spanclass="co">// next() continues to obtain the next key until false is returned.</span></div>
<divclass="sourceLine"id="cb6-68"data-line-number="68"><spanclass="bu">std::</span>cout <<<spanclass="st">"Performing a predictive operation..."</span><<<spanclass="bu">std::</span>endl;</div>
<divclass="sourceLine"id="cb6-70"data-line-number="70"><spanclass="co">// Predictive operation is implemented using PredictiveIterator, created by</span></div>
<divclass="sourceLine"id="cb6-72"data-line-number="72"> Trie::PredictiveIterator it = trie.make_predictive_iterator(<spanclass="st">"Ha"</span>);</div>
<divclass="sourceLine"id="cb6-74"data-line-number="74"><spanclass="co">// next() continues to obtain the next key until false is returned in</span></div>
<divclass="sourceLine"id="cb6-81"data-line-number="81"><spanclass="bu">std::</span>cout <<<spanclass="st">"Enumerating all registered keys..."</span><<<spanclass="bu">std::</span>endl;</div>
<divclass="sourceLine"id="cb6-83"data-line-number="83"><spanclass="co">// PredictiveIterator for an empty string provides enumeration of all</span></div>
<divclass="sourceLine"id="cb6-84"data-line-number="84"><spanclass="co">// registered keys in lexicographical order.</span></div>
<divclass="sourceLine"id="cb6-85"data-line-number="85"> Trie::PredictiveIterator it = trie.make_predictive_iterator(<spanclass="st">""</span>);</div>
<p>As shown in the output, <code>xcdat::Trie</code> assigns unique integer IDs to each registered key. The ID order is random, depending on node arrangement.</p>
<h2id="api">API</h2>
<p>You can build a dictionary using static member function <code>xcdat::TrieBuilder::build()</code>. This function receives a set of keywords and returns the resulting class object of <code>xcdat::Trie</code>. For the usage, refer to the header comments of <ahref="https://github.com/kampersanda/xcdat/blob/master/include/xcdat/TrieBuilder.hpp"><code>xcdat::TrieBuilder.hpp</code></a>. Also for the usage of <code>xcdat::Trie</code>, refer to the header comments of <ahref="https://github.com/kampersanda/xcdat/blob/master/include/xcdat/Trie.hpp"><code>xcdat::Trie</code></a>.</p>
<p>The detailed descriptions of AIP are under construction…</p>
<h2id="benchmark">Benchmark</h2>
<p>Work in progress…</p>
<h2id="to-do">To Do</h2>
<ul>
<li>Show benchmarks</li>
<li>Create AIP descriptions</li>
</ul>
<h2id="licensing">Licensing</h2>
<p>This library is free software provided under the MIT License.</p>
<h2id="citation">Citation</h2>
<p>If you use the library in academic settings, please cite the following paper.</p>
<divclass="sourceLine"id="cb8-2"data-line-number="2"><spanclass="dt">title</span>={Compressed double-array tries for string dictionaries supporting fast lookup},</div>
<divclass="sourceLine"id="cb8-3"data-line-number="3"><spanclass="dt">author</span>={Kanda, Shunsuke and Morita, Kazuhiro and Fuketa, Masao},</div>
<divclass="sourceLine"id="cb8-4"data-line-number="4"><spanclass="dt">journal</span>={Knowledge and Information Systems},</div>
<li>J. Aoe. An efficient digital search algorithm by using a double-array structure. IEEE Transactions on Software Engineering, 15(9):1066–1077, 1989.</li>
<li>N. R. Brisaboa, S. Ladra, and G. Navarro. DACs: Bringing direct access to variable-length codes. Information Processing & Management, 49(1):392–404, 2013.</li>
<li>S. Kanda, K. Morita, and M. Fuketa. Compressed double-array tries for string dictionaries supporting fast lookup. Knowledge and Information Systems, 51(3): 1023–1042, 2017.</li>
<li>M. A. Martínez-Prieto, N. Brisaboa, R. Cánovas, F. Claude, and G. Navarro. Practical compressed string dictionaries. Information Systems, 56:73–108, 2016</li>
<li>S. Yata, M. Oono, K. Morita, M. Fuketa, T. Sumitomo, and J. Aoe. A compact static double-array keeping character codes. Information Processing & Management, 43(1):237–247, 2007.</li>