<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Cassandra and EventMachine</title>
	<atom:link href="http://www.mikeperham.com/2010/02/09/cassandra-and-eventmachine/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikeperham.com/2010/02/09/cassandra-and-eventmachine/</link>
	<description>On Ruby, software and the Internet</description>
	<lastBuildDate>Tue, 03 Jan 2012 09:53:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Mike Perham</title>
		<link>http://www.mikeperham.com/2010/02/09/cassandra-and-eventmachine/comment-page-1/#comment-1254</link>
		<dc:creator>Mike Perham</dc:creator>
		<pubDate>Fri, 14 Oct 2011 22:06:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikeperham.com/?p=413#comment-1254</guid>
		<description>This is not the right venue for detailed technical help.  One core issue with your impl is that you are still just doing one line at a time (because you only create a single fiber).  Why bother with EM + Fibers if you are still basically single threaded?</description>
		<content:encoded><![CDATA[<p>This is not the right venue for detailed technical help.  One core issue with your impl is that you are still just doing one line at a time (because you only create a single fiber).  Why bother with EM + Fibers if you are still basically single threaded?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.mikeperham.com/2010/02/09/cassandra-and-eventmachine/comment-page-1/#comment-1252</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Fri, 14 Oct 2011 21:17:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikeperham.com/?p=413#comment-1252</guid>
		<description>Hi Mike et al.,

I&#039;m relatively new to Cassandra and Eventmachine so I have to learn a lot ;-) My goal is really simple. I wanna read a large file (120 MB) line by line and insert every row into a Cassandra DB. Sounds simple but I&#039;m trying it for 2 days now :-(

#!/usr/bin/env ruby

require &#039;rubygems&#039;
require &#039;cassandra&#039;
require &#039;eventmachine&#039;
require &#039;thrift_client/event_machine&#039;

EM.run do
  Fiber.new do
    rm = Cassandra.new(&#039;RankMetrics&#039;, &quot;127.0.0.1:9160&quot;, :transport =&gt; Thrift::EventMachineTransport, :transport_wrapper =&gt; nil)
    rm.clear_keyspace!
    file = File.open(&quot;us_100000.txt&quot;)
    read_chunk = proc do
      10.times do
        if line = file.gets
          rm.insert(:Domains, &quot;#{line.downcase}&quot;, {&#039;domain&#039; =&gt; &quot;#{line}&quot;})
        else
          EM.stop
        end
      end
      EM.next_tick(read_chunk)
    end
    EM.next_tick(read_chunk)
  end.resume
end

AFAIK EventMachine doesnt support asynchronous fs read/write, right? So I tried it with the chunks of 10 lines per tick but the code seems to block. I&#039;m at my wit&#039;s end. Do you have a hint for me whats going wrong there?

Cheerio,
Chris</description>
		<content:encoded><![CDATA[<p>Hi Mike et al.,</p>
<p>I&#8217;m relatively new to Cassandra and Eventmachine so I have to learn a lot <img src='http://www.mikeperham.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  My goal is really simple. I wanna read a large file (120 MB) line by line and insert every row into a Cassandra DB. Sounds simple but I&#8217;m trying it for 2 days now <img src='http://www.mikeperham.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>#!/usr/bin/env ruby</p>
<p>require &#8216;rubygems&#8217;<br />
require &#8216;cassandra&#8217;<br />
require &#8216;eventmachine&#8217;<br />
require &#8216;thrift_client/event_machine&#8217;</p>
<p>EM.run do<br />
  Fiber.new do<br />
    rm = Cassandra.new(&#8216;RankMetrics&#8217;, &#8220;127.0.0.1:9160&#8243;, :transport =&gt; Thrift::EventMachineTransport, :transport_wrapper =&gt; nil)<br />
    rm.clear_keyspace!<br />
    file = File.open(&#8220;us_100000.txt&#8221;)<br />
    read_chunk = proc do<br />
      10.times do<br />
        if line = file.gets<br />
          rm.insert(:Domains, &#8220;#{line.downcase}&#8221;, {&#8216;domain&#8217; =&gt; &#8220;#{line}&#8221;})<br />
        else<br />
          EM.stop<br />
        end<br />
      end<br />
      EM.next_tick(read_chunk)<br />
    end<br />
    EM.next_tick(read_chunk)<br />
  end.resume<br />
end</p>
<p>AFAIK EventMachine doesnt support asynchronous fs read/write, right? So I tried it with the chunks of 10 lines per tick but the code seems to block. I&#8217;m at my wit&#8217;s end. Do you have a hint for me whats going wrong there?</p>
<p>Cheerio,<br />
Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian</title>
		<link>http://www.mikeperham.com/2010/02/09/cassandra-and-eventmachine/comment-page-1/#comment-711</link>
		<dc:creator>Christian</dc:creator>
		<pubDate>Mon, 09 Aug 2010 19:18:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikeperham.com/?p=413#comment-711</guid>
		<description>I have been investigating using Cassandra, Sinatra, EventMachine and Fibers for the purposes of building a highly scalable and distributed API.  I have fully enjoyed and learned quite a bit from your blog and presentations but I am finding it difficult to develop and Sinatra/Eventd application that pools Cassandra connections.  Can you provide a more detailed example that illustrates this?</description>
		<content:encoded><![CDATA[<p>I have been investigating using Cassandra, Sinatra, EventMachine and Fibers for the purposes of building a highly scalable and distributed API.  I have fully enjoyed and learned quite a bit from your blog and presentations but I am finding it difficult to develop and Sinatra/Eventd application that pools Cassandra connections.  Can you provide a more detailed example that illustrates this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mperham</title>
		<link>http://www.mikeperham.com/2010/02/09/cassandra-and-eventmachine/comment-page-1/#comment-496</link>
		<dc:creator>mperham</dc:creator>
		<pubDate>Sun, 14 Mar 2010 15:56:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikeperham.com/?p=413#comment-496</guid>
		<description>Blair, look at the Cassandra and thrift_client gems.  Their APIs are blocking - there&#039;s no way the gems could be used with the more traditional EM callback style.  You can certainly have a callback-based Cassandra client but you would need to start from scratch and develop a new API.</description>
		<content:encoded><![CDATA[<p>Blair, look at the Cassandra and thrift_client gems.  Their APIs are blocking &#8211; there&#8217;s no way the gems could be used with the more traditional EM callback style.  You can certainly have a callback-based Cassandra client but you would need to start from scratch and develop a new API.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blair</title>
		<link>http://www.mikeperham.com/2010/02/09/cassandra-and-eventmachine/comment-page-1/#comment-495</link>
		<dc:creator>Blair</dc:creator>
		<pubDate>Sun, 14 Mar 2010 07:01:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikeperham.com/?p=413#comment-495</guid>
		<description>Correct me if I am wrong, but looking at this, it seems to be a blocking implementation, that is using a separate thread to communicate with Cassandra.

Are there any Cassandra Protocols for EventMachine that can run within the Reactor thread?  Is that a silly thing to expect with Cassandra (I am new to Cassandra and Eventmachine)</description>
		<content:encoded><![CDATA[<p>Correct me if I am wrong, but looking at this, it seems to be a blocking implementation, that is using a separate thread to communicate with Cassandra.</p>
<p>Are there any Cassandra Protocols for EventMachine that can run within the Reactor thread?  Is that a silly thing to expect with Cassandra (I am new to Cassandra and Eventmachine)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan King</title>
		<link>http://www.mikeperham.com/2010/02/09/cassandra-and-eventmachine/comment-page-1/#comment-467</link>
		<dc:creator>Ryan King</dc:creator>
		<pubDate>Wed, 10 Feb 2010 17:43:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikeperham.com/?p=413#comment-467</guid>
		<description>I&#039;m glad we&#039;re going to have this support. Perhaps you can add an example like the above to the README or a wiki page?</description>
		<content:encoded><![CDATA[<p>I&#8217;m glad we&#8217;re going to have this support. Perhaps you can add an example like the above to the README or a wiki page?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

