Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 64 lines (54 sloc) 1.73 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
using System;
using System.Linq;
using FluentCassandra.Types;

namespace FluentCassandra
{
[Obsolete("Use \"CassandraColumnFamily\" class with out generic type")]
public class CassandraColumnFamily<CompareWith> : CassandraColumnFamily
where CompareWith : CassandraObject
{
public CassandraColumnFamily(CassandraContext context, string columnFamily)
: base(context, columnFamily)
{
SetSchema(new CassandraColumnFamilySchema {
FamilyName = columnFamily,
ColumnNameType = typeof(CompareWith)
});
}
}

public partial class CassandraColumnFamily : BaseCassandraColumnFamily
{
private CassandraColumnFamilySchema _cachedSchema;

public CassandraColumnFamily(CassandraContext context, string columnFamily)
: base(context, columnFamily) { }

public CassandraColumnFamily(CassandraContext context, CassandraColumnFamilySchema schema)
: base(context, schema.FamilyName)
{
_cachedSchema = schema;
}

public FluentColumnFamily CreateRecord(CassandraObject key)
{
if (key.GetValue<byte[]>().Length == 0)
throw new ArgumentException("'key' is not allowed to be zero length.", "key");

return new FluentColumnFamily(key, FamilyName, GetSchema());
}

public override CassandraColumnFamilySchema GetSchema()
{
if (_cachedSchema == null) {
var schema = Context.Keyspace.GetColumnFamilySchema(FamilyName);
_cachedSchema = (schema == null)
? new CassandraColumnFamilySchema(FamilyName, ColumnType.Standard)
: schema;
}

return _cachedSchema;
}

public override void SetSchema(CassandraColumnFamilySchema schema)
{
_cachedSchema = schema;
}

public override void ClearCachedColumnFamilySchema()
{
_cachedSchema = null;
}
}
}
Something went wrong with that request. Please try again.