<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Xavier Llorà &#187; tokyo tyrant</title>
	<atom:link href="http://www.xavierllora.net/tag/tokyo-tyrant/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xavierllora.net</link>
	<description>A notebook on data-intensive computing, genetics-based machine learning &#38; more.</description>
	<lastBuildDate>Sun, 08 Jan 2012 19:39:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Easy, reliable, and flexible storage for Python</title>
		<link>http://www.xavierllora.net/2009/08/13/easy-reliable-and-flexible-storage-for-python/</link>
		<comments>http://www.xavierllora.net/2009/08/13/easy-reliable-and-flexible-storage-for-python/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 22:01:32 +0000</pubDate>
		<dc:creator>Xavier</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[pytc]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tokyo cabinet]]></category>
		<category><![CDATA[tokyo tyrant]]></category>

		<guid isPermaLink="false">http://www.xavierllora.net/?p=573</guid>
		<description><![CDATA[A while ago I wrote a little post about alternative column stores. One that I mentioned was Tokyo Cabinet (and its associated server Tokyo Tyrant. Tokyo Cabinet it is a key-value store written in C and with bindings for multiple languages (including Python and Java). It can maintain data bases in memory or spin them [...]
Related posts:<ol>
<li><a href='http://www.xavierllora.net/2008/01/16/a-simple-and-flexible-ga-loop-in-python/' rel='bookmark' title='A simple and flexible GA loop in Python'>A simple and flexible GA loop in Python</a></li>
<li><a href='http://www.xavierllora.net/2008/07/01/efficient-storage-for-python/' rel='bookmark' title='Efficient storage for Python'>Efficient storage for Python</a></li>
<li><a href='http://www.xavierllora.net/2009/09/29/temporary-storage-for-meandres-distribute-flow-execution/' rel='bookmark' title='Temporary storage for Meandre&#8217;s distributed flow execution'>Temporary storage for Meandre&#8217;s distributed flow execution</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>A while ago I wrote a little post about <a href="/2008/06/05/the-next-generation-of-data-bases/">alternative column stores</a>. One that I mentioned was <a hef="http://tokyocabinet.sourceforge.net/">Tokyo Cabinet</a> (and its associated server <a href="http://tokyocabinet.sourceforge.net/tyrantdoc/">Tokyo Tyrant</a>. Tokyo Cabinet it is a key-value store written in C and with bindings for multiple languages (including Python and Java). It can maintain data bases in memory or spin them to disk (you can pick between hash or B-tree based stores). </p>
<p>Having heard a bunch of good things, I finally gave it a try. I just installed both Cabinet and Tyrant (you may find useful installation instructions <a href="http://openwferu.rubyforge.org/tokyo.html">here</a> using the usual configure, make, make install cycle). Another nice feature of Tyrant is that it also supports HTTP gets and puts. So having all this said, I just wanted to check how easy it was to use it from Python. And the answer was very simple. <a href="http://github.com/turian/pytc-example/tree/master">Joseph Turian&#8217;s examples</a> got me running in less than 2 minutes&#8212;see the piece of code below&#8212;when dealing with a particular data base. Using Tyrant over HTTP is quite simple too&#8212;see <a href="http://petewarden.typepad.com/searchbrowser/2009/03/tokyo-tyrant-tutorial.html">PeteSearch blog post</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> pytc,<span style="color: #dc143c;">pickle</span>
<span style="color: #ff7700;font-weight:bold;">from</span> numpy <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #66cc66;">*</span>
&nbsp;
hdb = pytc.<span style="color: black;">HDB</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
hdb.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'casket.tch'</span>,pytc.<span style="color: black;">HDBOWRITER</span>|pytc.<span style="color: black;">HDBOCREAT</span><span style="color: black;">&#41;</span>
&nbsp;
a = arange<span style="color: black;">&#40;</span><span style="color: #ff4500;">100</span><span style="color: black;">&#41;</span>
hdb.<span style="color: black;">put</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'test'</span>,<span style="color: #dc143c;">pickle</span>.<span style="color: black;">dumps</span><span style="color: black;">&#40;</span>a<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
b = <span style="color: #dc143c;">pickle</span>.<span style="color: black;">loads</span><span style="color: black;">&#40;</span>hdb.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'test'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>a==b<span style="color: black;">&#41;</span>.<span style="color: #008000;">all</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> :
     <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'OK'</span>
hdb.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Related posts:<ol>
<li><a href='http://www.xavierllora.net/2008/01/16/a-simple-and-flexible-ga-loop-in-python/' rel='bookmark' title='A simple and flexible GA loop in Python'>A simple and flexible GA loop in Python</a></li>
<li><a href='http://www.xavierllora.net/2008/07/01/efficient-storage-for-python/' rel='bookmark' title='Efficient storage for Python'>Efficient storage for Python</a></li>
<li><a href='http://www.xavierllora.net/2009/09/29/temporary-storage-for-meandres-distribute-flow-execution/' rel='bookmark' title='Temporary storage for Meandre&#8217;s distributed flow execution'>Temporary storage for Meandre&#8217;s distributed flow execution</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.xavierllora.net/2009/08/13/easy-reliable-and-flexible-storage-for-python/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

