• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    C#
  • Created over 12 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

high performance .NET driver for Apache Cassandra

NOTE

I've stopped working on this driver. For better support, please gear towards the official .net Cassandra driver.

cassandra-sharp - high performance .NET driver for Apache Cassandra

build status

The philosophy of cassandra-sharp is to be really simple and fast: no Linq provider, no complex API. Just CQL, simple object mapping and great performance :)

With version 4, cassandra-sharp is only speaking native protocol 4 - basically, this means you are required to use Cassandra 3.

cassandra-sharp supports async operations exposed as Rx subscriptions or TPL tasks. Efficient memory usage can be achieve using the push model of Rx.

A command line tool is also available (cqlplus) to access a Cassandra cluster. It's also a great tool to understand what's happening under the cover.

Getting binaries

Binaries are available through NuGet : http://www.nuget.org/packages/cassandra-sharp

Copyright & License

cassandra-sharp - high performance .NET driver for Apache Cassandra
Copyright (c) 2011-2017 Pierre Chalamet

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
 
http://www.apache.org/licenses/LICENSE-2.0
 
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Features

  • async operations (TPL tasks / Rx subscriptions)
  • Rx interface (IObservable / IObserver) for result streaming
  • TPL Task for future operations
  • Linq friendly
  • extensible rowset mapping (poco and map provided out of the box)
  • blazing fast object marshaler (dynamic gen'ed code)
  • robust connection handling (connection recovery supported)
  • ability to understand performance issues (client and server side)
  • multiple extension points
  • command line tool (cqlplus)
  • .NET 4.0+ support (Microsoft .NET / Mono)

How to build

To build cassandra-sharp, load cassandra-sharp.sln in Visual Studio 2017. To build from command line and to regenerate thrift proxy, use Build.cmd.

Sample configuration

<configSections>
	<section name="CassandraSharp" type="CassandraSharp.SectionHandler, CassandraSharp.Interfaces" />
</configSections>

<CassandraSharp>
	<Cluster name="TestCassandra">
		<Endpoints>
			<Server>localhost</Server>
		</Endpoints>
	</Cluster>
</CassandraSharp>

Sample client

public class SchemaKeyspaces
{
    public string KeyspaceName { get; set; }
    public bool DurableWrites { get; set; }
    public Dictionary<string, string> Replication { get; set; }
}
	
public static class Sample
{
    private static void DisplayKeyspace(SchemaKeyspaces ks)
    {
        Console.WriteLine("KeyspaceName={0} DurableWrites={1} Class={2} ReplicationFactor={3}",
                          ks.KeyspaceName,
                          ks.DurableWrites,
                          ks.Replication["class"],
                          ks.Replication["replication_factor"]);
    }
	
    public static async Task QueryKeyspaces()
    {
        XmlConfigurator.Configure();
        using (ICluster cluster = ClusterManager.GetCluster("TestCassandra"))
        {
            var cmd = cluster.CreatePocoCommand();
            const string cqlKeyspaces = "SELECT * from system_schema.keyspaces";

            // async operation with streaming
            cmd.WithConsistencyLevel(ConsistencyLevel.ONE)
               .Execute<SchemaKeyspaces>(cqlKeyspaces)
               .Subscribe(DisplayKeyspace);

            // future
            var kss = await cmd.Execute<SchemaKeyspaces>(cqlKeyspaces).AsFuture();
            foreach (var ks in kss)
                DisplayKeyspace(ks);
        }

        ClusterManager.Shutdown();
    }
}

Thanks

JetBrains provided a free licence of Resharper for the cassandra-sharp project. Big thanks for the awesome product. ReSharper

This projects also relies on the following third parties:

Thanks to all contributors for ideas, bug fix and feedbacks!

githalytics.com alpha