<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Architecture</title>
        <link>http://www.ridgway.co.za/category/10.aspx</link>
        <description>Architecture</description>
        <language>en-ZA</language>
        <copyright>Eden Ridgway</copyright>
        <managingEditor>eden@ridgway.co.za</managingEditor>
        <generator>Subtext Version 1.9.5.176</generator>
        <item>
            <title>.Net Developer's Guide to Getting Started with Cassandra</title>
            <link>http://ridgway.co.za/archive/2009/11/06/net-developers-guide-to-getting-started-with-cassandra.aspx</link>
            <description>&lt;p&gt;I've been quite curious about the various &lt;a href="http://en.wikipedia.org/wiki/BigTable" target="_blank"&gt;BigTable&lt;/a&gt; like implementations as they could have some bearing on what I am involved with at work. After reading various write ups about the competing approaches (e.g. &lt;a href="http://www.vimeo.com/5198661" target="_blank"&gt;HyperTable&lt;/a&gt;, HBase, Dynomite, Voldemort, &lt;a href="http://www.vimeo.com/5184456" target="_blank"&gt;Mongodb&lt;/a&gt;) I decided that &lt;a href="http://incubator.apache.org/cassandra/" target="_blank"&gt;Cassandra&lt;/a&gt; looked like the best option for what I'm after. What I didn't realise was that it wasn't going to be as straight forward as it appears to set it all up as there is no end-to-end guide of getting started with it. So the objective of this post is not to explain Cassandra but save you several hours of jumping all over the web trying to work out what you should do next and how to generate the necessary C# Cassandra Thrift client code. If parts of the post don't apply, e.g. VM setup, simply skip ahead to the parts that do. If you want more information about Cassandra you should check out the following posts: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://blog.evanweaver.com/articles/2009/07/06/up-and-running-with-cassandra/" target="_blank"&gt;Up and running with Cassandra&lt;/a&gt; &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://arin.me/code/wtf-is-a-supercolumn-cassandra-data-model" target="_blank"&gt;WTF is a SuperColumn? An Intro to the Cassandra Data Model&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;So to get Cassandra up and running in a Virtual Machine (or physical if you choose) you should follow the following steps (valid as at 5 Nov 2010):&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Create a virtual machine to host &lt;a href="http://www.ubuntu.com/getubuntu/download" target="_blank"&gt;Ubuntu 9.10 x86 Desktop&lt;/a&gt;. I use &lt;a href="http://www.virtualbox.org/" target="_blank"&gt;VirtualBox&lt;/a&gt; as my VM host on windows so I will refer to this here but feel free to substitute it with you favourite VM software. The VM I created has 384MB allocated to it with an 8GB virtual hard drive using a bridged network adapter (so it can be accessed from the Windows XP host). Once you've gone through the install process install the client tools so that you change the screen resolution, share folders, etc. To do this with virtual box go to &lt;strong&gt;Devices &amp;gt; Install Guest Additions&lt;/strong&gt; and then open up a terminal window and execute       &lt;br /&gt;
    &lt;br /&gt;
    &lt;div style="background: black none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: white;"&gt;&lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; /media/cdrom/VBoxLinuxAdditions-x86.run&lt;/div&gt;
    &lt;br /&gt;
    Once this is complete you will need to reboot your VM.       &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Now it is time to install Cassandra/Thrift prerequisites and software that we will to set everything up:      &lt;br /&gt;
    &lt;br /&gt;
    &lt;div style="background: black none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: white;"&gt;&lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; apt-get install libboost-dev automake libtool flex bison pkg-config g++ -y         &lt;br /&gt;
    &lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; apt-get install sun-java6-jdk -y         &lt;br /&gt;
    &lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; apt-get apt-get install ant -y         &lt;br /&gt;
    &lt;/div&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Once that is done we can install other useful Ubuntu software that we will use:      &lt;br /&gt;
    &lt;br /&gt;
    &lt;div style="background: black none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: white;"&gt;&lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; apt-get install rapidsvn -y         &lt;br /&gt;
    &lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; apt-get install monodevelop -y &lt;/div&gt;
    &lt;br /&gt;
    I also like to install the following:       &lt;br /&gt;
    &lt;br /&gt;
    &lt;div style="background: black none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: white;"&gt;&lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; apt-get install nautilus-open-terminal -y         &lt;br /&gt;
    &lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; apt-get install samba smbfs smbclient winbind -y         &lt;br /&gt;
    &lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; apt-get install nautilus-share -y&lt;/div&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;You may discover that there is an issue with your Java runtime home directory. If that occurs, select Sun's Java Runtime as the default Java version by running the following command from the terminal window and selecting the third option:      &lt;br /&gt;
    &lt;br /&gt;
    &lt;div style="background: black none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: white;"&gt;&lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; update-alternatives --config java &lt;/div&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Now open up Nautilus by going to &lt;strong&gt;Places &amp;gt; Home&lt;/strong&gt; Folder. Right click and create a Development folder. Within the Development folder create another two folders: Cassandra and Thrift. &lt;/li&gt;
    &lt;li&gt;We can now get the source for Cassandra and Thrift. Run RapidSVN by going to &lt;strong&gt;Applications &amp;gt; Programming &amp;gt; RapidSVN&lt;/strong&gt;. Check out the source from SVN by going to the RapidSVN menu option &lt;strong&gt;Repository &amp;gt; Checkout&lt;/strong&gt;. In the URL enter &lt;a href="http://svn.apache.org/repos/asf/incubator/thrift/trunk" target="_blank"&gt;http://svn.apache.org/repos/asf/incubator/thrift/trunk&lt;/a&gt; and for the Destination Directory browse to the Thrift development folder. So it should look like this:       &lt;br /&gt;
    &lt;br /&gt;
    &lt;a href="http://www.ridgway.co.za/images/ridgway_co_za/WindowsLiveWriter/8fe.NetDevelopersGuidetoGettingStartedwi_4F37/image_4.png"&gt;&lt;img border="0" width="244" height="126" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" alt="image" src="http://www.ridgway.co.za/images/ridgway_co_za/WindowsLiveWriter/8fe.NetDevelopersGuidetoGettingStartedwi_4F37/image_thumb_1.png" /&gt;&lt;/a&gt;       &lt;br /&gt;
    Now get the Cassandra code by doing the same thing but entering &lt;a href="http://svn.apache.org/repos/asf/incubator/cassandra/trunk" target="_blank"&gt;http://svn.apache.org/repos/asf/incubator/cassandra/trunk&lt;/a&gt; as the URL and selecting the Cassandra directory. &lt;/li&gt;
    &lt;li&gt;Once we have all the code we are ready to compile Cassandra, so let's do that by executing the following commands from the terminal window:      &lt;br /&gt;
    &lt;br /&gt;
    &lt;div style="background: black none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: white;"&gt;&lt;span style="color: rgb(0, 128, 255);"&gt;cd&lt;/span&gt; ~/Development/Cassandra         &lt;br /&gt;
    ant         &lt;br /&gt;
    &lt;/div&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Start the Cassandra server by opening a new terminal window and running the following commands:      &lt;br /&gt;
    &lt;br /&gt;
    &lt;div style="background: black none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: white;"&gt;&lt;span style="color: rgb(0, 128, 255);"&gt;sudo&lt;/span&gt; ~/Development/Cassandra/bin/cassandra -f         &lt;br /&gt;
    &lt;/div&gt;
    &lt;br /&gt;
    The running server will look like the screenshot below. You should take note of the thrift binding address of localhost/127.0.0.1:9160.       &lt;br /&gt;
    &lt;br /&gt;
    &lt;a href="http://ridgway.co.za/images/ridgway_co_za/WindowsLiveWriter/8fe.NetDevelopersGuidetoGettingStartedwi_4F37/image_5.png"&gt;&lt;img border="0" width="367" height="218" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" alt="image" src="http://www.ridgway.co.za/images/ridgway_co_za/WindowsLiveWriter/8fe.NetDevelopersGuidetoGettingStartedwi_4F37/image_thumb.png" /&gt;&lt;/a&gt;       &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Now we want to get communicating with the server, so we will need to compile Thrift so that we can use it to generate our C# client:      &lt;br /&gt;
    &lt;br /&gt;
    &lt;div style="background: black none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: white;"&gt;&lt;span style="color: rgb(0, 128, 255);"&gt;cd&lt;/span&gt; ~/Development/Thrift         &lt;br /&gt;
    ./bootstrap.sh         &lt;br /&gt;
    ./configure         &lt;br /&gt;
    make         &lt;br /&gt;
    sudo make install         &lt;br /&gt;
    &lt;/div&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Now we can finally generate a C# client for the Thrift calls to Cassandra:      &lt;br /&gt;
    &lt;br /&gt;
    &lt;div style="background: black none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: white;"&gt;&lt;span style="color: rgb(0, 128, 255);"&gt;cd&lt;/span&gt; ~/Development/Cassandra/interface/         &lt;br /&gt;
    ~/Development/Thrift/compiler/cpp/thrift -gen csharp cassandra.thrift         &lt;br /&gt;
    &lt;/div&gt;
    &lt;br /&gt;
    This will create the following directories inside of the Cassandra/interface folder: &lt;strong&gt;gen-csharp/Apache/Cassandra&lt;/strong&gt;. These files along with the Thrift.dll will be copied into a new demo project we will create using MonoDevelop in the Development folder. So again in the terminal window execute:       &lt;br /&gt;
    &lt;br /&gt;
    &lt;div style="background: black none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: white;"&gt;&lt;span style="color: rgb(0, 128, 255);"&gt;mkdir&lt;/span&gt; ~/Development/CassandraDemo         &lt;br /&gt;
    &lt;span style="color: rgb(0, 128, 255);"&gt;cp &lt;/span&gt;~/Development/Cassandra/interface/gen-csharp ~/Development/CassandraDemo -R         &lt;br /&gt;
    &lt;span style="color: rgb(0, 128, 255);"&gt;cp &lt;/span&gt;~/Development/Thrift/lib/csharp/Thrift.dll ~/Development/CassandraDemo         &lt;br /&gt;
    &lt;/div&gt;
    &lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Open up MonoDevelop and create a new console application by going to &lt;strong&gt;File &amp;gt; New &amp;gt; Solution&lt;/strong&gt;. Now do the following:
    &lt;ol&gt;
        &lt;li&gt;Select Console project &lt;/li&gt;
        &lt;li&gt;Enter CassandraDemo as the name &lt;/li&gt;
        &lt;li&gt;For the location browse to the Development folder that we created in your home directory. &lt;/li&gt;
        &lt;li&gt;Uncheck the 'Create separate Solution directory' check box. &lt;/li&gt;
        &lt;li&gt;Click the Forward button &lt;/li&gt;
        &lt;li&gt;Don't make any changes on the next screen and just click Ok. &lt;/li&gt;
        &lt;li&gt;Right click on the CassandraDemo project in the left tree view and select &lt;strong&gt;Add &amp;gt; Add Files...&lt;/strong&gt;. Navigate to ~/Development/CassandraDemo/gen-csharp/Apache/Cassandra and select all the files in the folder. You will now have a project that looks like this:         &lt;br /&gt;
        &lt;br /&gt;
        &lt;a href="http://ridgway.co.za/images/ridgway_co_za/WindowsLiveWriter/8fe.NetDevelopersGuidetoGettingStartedwi_4F37/image_7.png"&gt;&lt;img border="0" width="186" height="264" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" alt="image" src="http://www.ridgway.co.za/images/ridgway_co_za/WindowsLiveWriter/8fe.NetDevelopersGuidetoGettingStartedwi_4F37/image_thumb_2.png" /&gt;&lt;/a&gt; &lt;/li&gt;
        &lt;li&gt;Add a reference to the Thrift assembly by right clicking on References and selecting Edit References. Change to the .Net Assembly tab and double click on the Thrift.dll and click OK. &lt;/li&gt;
        &lt;li&gt;Now we can add the sample code to test it all out. So double click on Main.cs to ensure that is the class in focus in the editor. Replace the contents of the file with this:        &lt;br /&gt;
        &lt;div class="code"&gt;&lt;font color="#0000ff"&gt;namespace &lt;/font&gt;&lt;font color="#000000"&gt;CassandraDemo           &lt;br /&gt;
        {            &lt;br /&gt;
            &lt;/font&gt;&lt;font color="#0000ff"&gt;using &lt;/font&gt;&lt;font color="#000000"&gt;System&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
            using &lt;/font&gt;&lt;font color="#000000"&gt;System.Collections.Generic&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
            using &lt;/font&gt;&lt;font color="#000000"&gt;System.Diagnostics&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
            using &lt;/font&gt;&lt;font color="#000000"&gt;Apache.Cassandra&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
            using &lt;/font&gt;&lt;font color="#000000"&gt;Thrift.Protocol&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
            using &lt;/font&gt;&lt;font color="#000000"&gt;Thrift.Transport&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
            class &lt;/font&gt;&lt;font color="#000000"&gt;Program           &lt;br /&gt;
            {            &lt;br /&gt;
                &lt;/font&gt;&lt;font color="#0000ff"&gt;static void &lt;/font&gt;&lt;font color="#000000"&gt;Main(&lt;/font&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;font color="#000000"&gt;[] args)           &lt;br /&gt;
                {            &lt;br /&gt;
                    TTransport transport &lt;/font&gt;&lt;font color="#0000ff"&gt;= new &lt;/font&gt;&lt;font color="#000000"&gt;TSocket(&lt;/font&gt;&lt;font color="#808080"&gt;"localhost"&lt;/font&gt;&lt;font color="#000000"&gt;, &lt;/font&gt;&lt;font color="#800000"&gt;9160&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;TProtocol protocol &lt;/font&gt;&lt;font color="#0000ff"&gt;= new &lt;/font&gt;&lt;font color="#000000"&gt;TBinaryProtocol(transport)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;Cassandra.Client client &lt;/font&gt;&lt;font color="#0000ff"&gt;= new &lt;/font&gt;&lt;font color="#000000"&gt;Cassandra.Client(protocol)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                     &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;Console.WriteLine(&lt;/font&gt;&lt;font color="#808080"&gt;"Opening connection"&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;transport.Open()&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;System.Text.Encoding utf8Encoding &lt;/font&gt;&lt;font color="#0000ff"&gt;= &lt;/font&gt;&lt;font color="#000000"&gt;System.Text.Encoding.UTF8&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                    long &lt;/font&gt;&lt;font color="#000000"&gt;timeStamp &lt;/font&gt;&lt;font color="#0000ff"&gt;= &lt;/font&gt;&lt;font color="#000000"&gt;DateTime.Now.Millisecond&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;ColumnPath nameColumnPath &lt;/font&gt;&lt;font color="#0000ff"&gt;= new &lt;/font&gt;&lt;font color="#000000"&gt;ColumnPath()  &lt;br /&gt;
                                                {  &lt;br /&gt;
                                                    Column_family &lt;/font&gt;&lt;font color="#0000ff"&gt;= &lt;/font&gt;&lt;font color="#808080"&gt;"Standard1"&lt;/font&gt;&lt;font color="#000000"&gt;,  &lt;br /&gt;
                                                    Column &lt;/font&gt;&lt;font color="#0000ff"&gt;= &lt;/font&gt;&lt;font color="#000000"&gt;utf8Encoding.GetBytes(&lt;/font&gt;&lt;font color="#808080"&gt;"name"&lt;/font&gt;&lt;font color="#000000"&gt;)           &lt;br /&gt;
                                                }&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;Console.WriteLine(&lt;/font&gt;&lt;font color="#808080"&gt;"Inserting name columns"&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#006400"&gt;//Insert the data into the column 'name'           &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;client.insert(&lt;/font&gt;&lt;font color="#808080"&gt;"Keyspace1"&lt;/font&gt;&lt;font color="#000000"&gt;,           &lt;br /&gt;
                                  &lt;/font&gt;&lt;font color="#808080"&gt;"1"&lt;/font&gt;&lt;font color="#000000"&gt;,           &lt;br /&gt;
                                  nameColumnPath,            &lt;br /&gt;
                                  utf8Encoding.GetBytes(&lt;/font&gt;&lt;font color="#808080"&gt;"Joe Bloggs"&lt;/font&gt;&lt;font color="#000000"&gt;),           &lt;br /&gt;
                                  timeStamp,            &lt;br /&gt;
                                  ConsistencyLevel.ONE)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;client.insert(&lt;/font&gt;&lt;font color="#808080"&gt;"Keyspace1"&lt;/font&gt;&lt;font color="#000000"&gt;,           &lt;br /&gt;
                                  &lt;/font&gt;&lt;font color="#808080"&gt;"2"&lt;/font&gt;&lt;font color="#000000"&gt;,           &lt;br /&gt;
                                  nameColumnPath,            &lt;br /&gt;
                                  utf8Encoding.GetBytes(&lt;/font&gt;&lt;font color="#808080"&gt;"Joe Soap"&lt;/font&gt;&lt;font color="#000000"&gt;),           &lt;br /&gt;
                                  timeStamp,            &lt;br /&gt;
                                  ConsistencyLevel.ONE)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#006400"&gt;//Simple single value get using the key to get column 'name'           &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;ColumnOrSuperColumn returnedColumn &lt;/font&gt;&lt;font color="#0000ff"&gt;= &lt;/font&gt;&lt;font color="#000000"&gt;client.&lt;/font&gt;&lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;font color="#808080"&gt;"Keyspace1"&lt;/font&gt;&lt;font color="#000000"&gt;, &lt;/font&gt;&lt;font color="#808080"&gt;"1"&lt;/font&gt;&lt;font color="#000000"&gt;, nameColumnPath, ConsistencyLevel.ONE)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;Console.WriteLine(&lt;/font&gt;&lt;font color="#808080"&gt;"Column Data in Keyspace1/Standard1: name: {0}, value: {1}"&lt;/font&gt;&lt;font color="#000000"&gt;,           &lt;br /&gt;
                                      utf8Encoding.GetString(returnedColumn.Column.Name),            &lt;br /&gt;
                                      utf8Encoding.GetString(returnedColumn.Column.Value))&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;Console.WriteLine(&lt;/font&gt;&lt;font color="#808080"&gt;"Getting splice range"&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#006400"&gt;//Read an entire row           &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;SlicePredicate predicate &lt;/font&gt;&lt;font color="#0000ff"&gt;= new &lt;/font&gt;&lt;font color="#000000"&gt;SlicePredicate()           &lt;br /&gt;
                                               {            &lt;br /&gt;
                                                  Slice_range &lt;/font&gt;&lt;font color="#0000ff"&gt;= new &lt;/font&gt;&lt;font color="#000000"&gt;SliceRange()           &lt;br /&gt;
                                                                {            &lt;br /&gt;
                                                                    &lt;/font&gt;&lt;font color="#006400"&gt;//Start and Finish cannot be null           &lt;br /&gt;
                                                                    &lt;/font&gt;&lt;font color="#000000"&gt;Start &lt;/font&gt;&lt;font color="#0000ff"&gt;= new byte&lt;/font&gt;&lt;font color="#000000"&gt;[&lt;/font&gt;&lt;font color="#800000"&gt;0&lt;/font&gt;&lt;font color="#000000"&gt;],  &lt;br /&gt;
                                                                    Finish &lt;/font&gt;&lt;font color="#0000ff"&gt;= new byte&lt;/font&gt;&lt;font color="#000000"&gt;[&lt;/font&gt;&lt;font color="#800000"&gt;0&lt;/font&gt;&lt;font color="#000000"&gt;],           &lt;br /&gt;
                                                                    Count  &lt;/font&gt;&lt;font color="#0000ff"&gt;= &lt;/font&gt;&lt;font color="#800000"&gt;10&lt;/font&gt;&lt;font color="#000000"&gt;,           &lt;br /&gt;
                                                                    Reversed &lt;/font&gt;&lt;font color="#0000ff"&gt;= false           &lt;br /&gt;
                                                                &lt;/font&gt;&lt;font color="#000000"&gt;}           &lt;br /&gt;
                                               }&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;ColumnParent parent &lt;/font&gt;&lt;font color="#0000ff"&gt;= new &lt;/font&gt;&lt;font color="#000000"&gt;ColumnParent() { Column_family &lt;/font&gt;&lt;font color="#0000ff"&gt;= &lt;/font&gt;&lt;font color="#808080"&gt;"Standard1" &lt;/font&gt;&lt;font color="#000000"&gt;}&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;Dictionary&amp;lt;&lt;/font&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;&lt;font color="#000000"&gt;, List&amp;lt;ColumnOrSuperColumn&amp;gt;&amp;gt; results &lt;/font&gt;&lt;font color="#0000ff"&gt;= &lt;/font&gt;&lt;font color="#000000"&gt;client.multiget_slice(&lt;/font&gt;&lt;font color="#808080"&gt;"Keyspace1"&lt;/font&gt;&lt;font color="#000000"&gt;,  &lt;br /&gt;
                                                                              &lt;/font&gt;&lt;font color="#0000ff"&gt;new &lt;/font&gt;&lt;font color="#000000"&gt;List&amp;lt;&lt;/font&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;font color="#000000"&gt;&amp;gt;() { &lt;/font&gt;&lt;font color="#808080"&gt;"1"&lt;/font&gt;&lt;font color="#000000"&gt;, &lt;/font&gt;&lt;font color="#808080"&gt;"2"&lt;/font&gt;&lt;font color="#000000"&gt;},  &lt;br /&gt;
                                                                              parent,  &lt;br /&gt;
                                                                              predicate,  &lt;br /&gt;
                                                                              ConsistencyLevel.ONE)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                    foreach &lt;/font&gt;&lt;font color="#000000"&gt;(KeyValuePair&amp;lt;&lt;/font&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;font color="#000000"&gt;, List&amp;lt;ColumnOrSuperColumn&amp;gt;&amp;gt; resultPair &lt;/font&gt;&lt;font color="#0000ff"&gt;in &lt;/font&gt;&lt;font color="#000000"&gt;results)           &lt;br /&gt;
                    {            &lt;br /&gt;
                        Console.WriteLine(&lt;/font&gt;&lt;font color="#808080"&gt;"Key: {0}"&lt;/font&gt;&lt;font color="#000000"&gt;, resultPair.Key)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
        &lt;br /&gt;
                        foreach &lt;/font&gt;&lt;font color="#000000"&gt;(ColumnOrSuperColumn resultColumn &lt;/font&gt;&lt;font color="#0000ff"&gt;in &lt;/font&gt;&lt;font color="#000000"&gt;resultPair.Value)           &lt;br /&gt;
                        {            &lt;br /&gt;
                            Column column &lt;/font&gt;&lt;font color="#0000ff"&gt;= &lt;/font&gt;&lt;font color="#000000"&gt;resultColumn.Column&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                            &lt;/font&gt;&lt;font color="#000000"&gt;Console.WriteLine(&lt;/font&gt;&lt;font color="#808080"&gt;"name: {0}, value: {1}"&lt;/font&gt;&lt;font color="#000000"&gt;, utf8Encoding.GetString(column.Name), utf8Encoding.GetString(column.Value))&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                        &lt;/font&gt;&lt;font color="#000000"&gt;}           &lt;br /&gt;
                    }            &lt;br /&gt;
        &lt;br /&gt;
                    Console.WriteLine(&lt;/font&gt;&lt;font color="#808080"&gt;"Closing connection"&lt;/font&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                    &lt;/font&gt;&lt;font color="#000000"&gt;transport.Close()&lt;/font&gt;&lt;font color="#0000ff"&gt;;           &lt;br /&gt;
                &lt;/font&gt;&lt;font color="#000000"&gt;}           &lt;br /&gt;
            }            &lt;br /&gt;
        }&lt;/font&gt; &lt;/div&gt;
        &lt;/li&gt;
        &lt;li&gt;Hit F5 and watch the Application Output window. This is what you should see:&lt;br /&gt;
        &lt;br /&gt;
        &lt;a href="http://ridgway.co.za/images/ridgway_co_za/WindowsLiveWriter/8fe.NetDevelopersGuidetoGettingStartedwi_4F37/image_9.png"&gt;&lt;img border="0" width="619" height="466" style="border: 0px none ; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" alt="image" src="http://www.ridgway.co.za/images/ridgway_co_za/WindowsLiveWriter/8fe.NetDevelopersGuidetoGettingStartedwi_4F37/image_thumb_3.png" /&gt;&lt;/a&gt; &lt;/li&gt;
    &lt;/ol&gt;
    &lt;/li&gt;
    &lt;br /&gt;
    Hopefully this is enough to get you going and have you fill in the remaining gaps. If you found it useful please post a comment. If the Cassandra guys would like to use the C# example they are welcome to it. Good luck!&lt;br /&gt;
&lt;/ol&gt;&lt;img src="http://ridgway.co.za/aggbug/196.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Eden Ridgway</dc:creator>
            <guid>http://ridgway.co.za/archive/2009/11/06/net-developers-guide-to-getting-started-with-cassandra.aspx</guid>
            <pubDate>Thu, 05 Nov 2009 22:32:51 GMT</pubDate>
            <comments>http://ridgway.co.za/archive/2009/11/06/net-developers-guide-to-getting-started-with-cassandra.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://ridgway.co.za/comments/commentRss/196.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Design By Contract Using XC#</title>
            <link>http://ridgway.co.za/archive/2005/09/24/designbycontractusingxc.aspx</link>
            <description>&lt;p&gt;
&lt;a href="http://en.wikipedia.org/wiki/Design_by_contract"&gt;Design by contract&lt;/a&gt; is
an approach to programming where one establishes pre and post conditions when calling
methods or modules.  The idea is that by asserting that by defining and validating
the interface in this manner bugs are reduced and are easier to find.
&lt;/p&gt;
&lt;p&gt;
I found a framework for doing this called &lt;a href="http://www.resolvecorp.com/products.aspx"&gt;eXtensible
C#&lt;/a&gt; (XC#) which allows for pre and post conditions using attributes.  They
use a compiler of sorts to do compilation after the C# compiler for you code has been
invoked from VS.Net.  Here is an example of how one would use XC#:
&lt;/p&gt;
&lt;div class="code"&gt;&lt;font color="black"&gt;[Requires (&lt;/font&gt;&lt;font color="#808080"&gt;"app != null"&lt;/font&gt;&lt;font color="black"&gt;)] &lt;br /&gt;
&lt;/font&gt;&lt;font color="blue"&gt;void &lt;/font&gt;&lt;font color="black"&gt;UpdateApplication (Application app)&lt;/font&gt; 
&lt;/div&gt;
&lt;p&gt;
XC# comes as an add-in to VS.Net that appears to hook into the post build event. 
You can also add obfuscation to your project by simply adding an Obfuscate attribute
to the assembly.
&lt;/p&gt;
&lt;p&gt;
Some of the alternatives to this approach are:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Using &lt;a href="http://en.wikipedia.org/wiki/Aspect_oriented_programming"&gt;Aspect Oriented
Programming&lt;/a&gt; (AOP) to automatically intercept the calls.  One should be aware
that this is most likely quite slow.  Here are some example open source AOP frameworks
for .Net: 
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.castleproject.org/index.php/AspectSharp"&gt;Aspect#&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;
&lt;a href="http://sourceforge.net/projects/aspectdng/"&gt;AspectDNG&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;
&lt;a href="http://theagiledeveloper.com/articles/Encase.aspx"&gt;Encase&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;
Manually coding the rules at the beginning or the end of each method call.  There
is a 2002 CodeProject &lt;a href="http://www.codeproject.com/csharp/designbycontract.asp"&gt;Design
by Contract&lt;/a&gt; article about doing this. 
&lt;/li&gt;&lt;li&gt;
Using a home brewed attribute validation system [which is really what XC# is doing
in any case]&lt;/li&gt;
&lt;/ol&gt;
&lt;img src="http://ridgway.co.za/aggbug/138.aspx" width="1" height="1" /&gt;</description>
            <guid>http://ridgway.co.za/archive/2005/09/24/designbycontractusingxc.aspx</guid>
            <pubDate>Sat, 24 Sep 2005 00:35:18 GMT</pubDate>
            <comments>http://ridgway.co.za/archive/2005/09/24/designbycontractusingxc.aspx#feedback</comments>
            <wfw:commentRss>http://ridgway.co.za/comments/commentRss/138.aspx</wfw:commentRss>
        </item>
        <item>
            <title>CSLA.Net</title>
            <link>http://ridgway.co.za/archive/2005/07/08/cslanet.aspx</link>
            <description>&lt;p&gt;
I bought Rockford Lhotka's Expert Business Objects book a while ago.  In
my current project, I'm considering using a domain design model that may include
CSLA.Net elements, so I thought I'd quickly bookmark some useful resources:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Dave Hayden has a chapter by chapter &lt;a href="http://davidhayden.com/blog/dave/archive/2004/09/11/471.aspx "&gt;summary
of the book&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;
&lt;a href="http://www.lhotka.net/Articles.aspx?id=bd7a0904-e76d-48c3-a3ab-a8e9d9645c91"&gt;Rockford's
web site&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;
A &lt;a href="http://www.gotdotnet.com/workspaces/workspace.aspx?id=ea87d1c9-27b7-4dc2-b65d-e6f48d77232b"&gt;Got
Dot Net CodeSmith Template collection&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;
&lt;a href="http://csla.kozul.info/ "&gt;ActiveObjects&lt;/a&gt; for CSLA.Net - handles things
like custom windows forms databinding&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I also read an interesting &lt;a href="http://weblogs.asp.net/pwilson/archive/2004/10/13/241957.aspx"&gt;blog
posting by Paul Wilson&lt;/a&gt;, where he said the following about CSLA.Net: 
&lt;/p&gt;
&lt;div class="Quote"&gt;
&lt;p&gt;
"There are many styles and possible solutions in .NET -- I have used CSLA on a major
project and do not want to do so again -- but I can say the same about many other
techniques I have used in the past too...
&lt;/p&gt;
&lt;p&gt;
...I would say it didn't work -- although it was a heck of a lot of work in my opinion
(still ongoing when I left). Part of that work was in removing a lot of the features
that we simply did not need and which were causing excessive memory use. Granted our
system was not typical (lots of large recordsets and on Citrix), and I blame management
for not listening better there. But the real "work" to me was in creating my business
objects, and making sure that all the dependencies were correct also. Some of that
can certainly be alleviated in many projects with code gen, but I simply believe there
are simpler ways to do things...
&lt;/p&gt;
&lt;p&gt;
So I want something simple for my teams to use and learn and maintain, while still
being flexible and easy to extend. I'm simply at the place in my career where I'm
tired of the same old things -- and I strongly believe I've found better ways."
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
For me, there are two aspects that I'm interested in taking from CSLA.Net, the business
rules approach and the collection of errors.  I am prone to changing my mind
so don't hold me to that.  I want to have a framework that is obvious and simple
but where the logic lives in the business logic layer as opposed to the UI. 
Our current Active Record style design pattern however tends to promote the coding
of logic in the wrong place and this is a product that has a fair amount of logic
that cannot reside in the UI.  I get accused of making things too complicated,
but what I want us to create reusable (where it makes sense) and structured
solutions.  Sometimes that involves a little more complexity than a Transaction
Script type design pattern.
&lt;/p&gt;
&lt;p&gt;
I try to keep things as simple as is possible while still achieving reusability and modularity. 
I'm only too happy to get someone over to my desk to take a look at the structure
and tell me if they find it understandable.  If you call copying and pasting
the same errors err... I mean code all over the application simple, you will pay a
maintenance tax later.  It's that simple.  Also it appears that some people
are unable to grasp relatively simple concepts like inheritance.  As soon as
you use inheritance you get told you are making the solution too complicated even
though you've reduced the delivery time and maintenance complexity (to some) dramatically. 
Come on, if all the classes inherit from a base class and you can't find the logic,
have you thought of looking in the base class?  That big comment telling you
that the base class collects shared information about the process surely must be a
big give away.
&lt;/p&gt;
&lt;img src="http://ridgway.co.za/aggbug/96.aspx" width="1" height="1" /&gt;</description>
            <guid>http://ridgway.co.za/archive/2005/07/08/cslanet.aspx</guid>
            <pubDate>Fri, 08 Jul 2005 01:59:31 GMT</pubDate>
            <comments>http://ridgway.co.za/archive/2005/07/08/cslanet.aspx#feedback</comments>
            <wfw:commentRss>http://ridgway.co.za/comments/commentRss/96.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>