Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 66 lines (55 sloc) 1.871 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 65
using FluentCassandra.Types;
using System;

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

public class CassandraSuperColumnFamily : BaseCassandraColumnFamily
{
private CassandraColumnFamilySchema _cachedSchema;

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

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

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

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

public override CassandraColumnFamilySchema GetSchema()
{
if (_cachedSchema == null) {
var schema = Context.Keyspace.GetColumnFamilySchema(FamilyName);
_cachedSchema = (schema == null)
? new CassandraColumnFamilySchema(FamilyName, ColumnType.Super)
: 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.