Migration from ver 0.6

Change Cassandra Key string to byte[]

Cassandra ver 0.7 changes type of key string to byte[]. So type of CassandraEntity.Key change string to CassandraBinary too.

You must fix the point that is used CassandraEntity.Key. But LINQ is exception. CassandraBinary overload some operator, so you don't have to call ToCassandraByte method in LINQ.

using(var context = new CassandraContext("localhost", 9160, "KeySpace1"))
{
	var entitys = from x in context.ColumnList
      		      where x.Key == "key1" &&    // You don't have to call ToCassandraByte method
		            x.ColumnFamily == "Product" &&
		            x.Column >= 1L 
		      select x;
				   
	foreach(CassandraEntity<List<Column>> e in entitys)
	{
		foreach(Column c in e.Data)
		{
			// Console.WriteLine(e.Key + " " + c.Name.ToInt64());
			Console.WriteLine(e.Key.ToUTF8() + " " + c.Name.ToInt64());    // You must transform into string
		}
	}
}

LINQ style compatible ver 0.6 and 0.7. So you should fix point that is not LINQ and CassandraEntity.Key is used.

Ttl and TimeStamp

List<Column> and SuperColumn have confusing extension methods. You give int type to third argument, then ttl set. Otherwise you give long type, then timestamp set. If you use these method for set timestamp in ver 0.6, ttl is set when you upgrade ver 0.7. So you should change third argument "10" to "10L".

List<Column>
  • Add (object name, object value, long unixTime)
  • Add (object name, object value, int ttl)

SuperColumn
  • SetColumn (object name, object value, long unixTime)
  • SetColumn (object name, object value, int ttl)
  • AddColumn (object name, object value, long unixTime)
  • AddColumn (object name, object value, int ttl)

List<Column> list = new List<Column>();

// list.Add("name", "value", 10);
list.Add("name", "value", 10L);    // change into long type to set timestamp

CassandraContext changes

CassandraContext.KeySpace change unsettable.

class CassandraContext
{
	public string KeySpace { get; private set; }
}

Some CassandraContext constructor is added "isFramed" parameter. If this parameter set true, then TFramedTransport is used. Default value of "isFramed" is true.

class CassandraContext
{
	public CassandraContext(string host, int port, string keySpace) 
	public CassandraContext(string host, int port, string keySpace, ConsistencyLevel consistencyLevel)
	public CassandraContext(string host, int port, string keySpace, ConsistencyLevel consistencyLevel, bool isFramed)
	public CassandraContext(string host, 
			        int port, 
			        string keySpace, 
			        ConsistencyLevel consistencyLevel, 
			        bool isFramed,
			        int retryCount,
			        int timeoutMillisecond, 
			        int minPoolCountPerHost, 
			        int maxPoolCountPerHost)
}

Last edited Apr 5, 2011 at 11:42 AM by sabro, version 2

Comments

No comments yet.