Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 68 lines (53 sloc) 1.733 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 66 67
using System;
using System.Collections.Generic;
using System.Linq;
using Apache.Cassandra;
using FluentCassandra.Types;

namespace FluentCassandra
{
public class CassandraCqlRowSchema
{
#if DEBUG
private CqlMetadata _def;
#endif

public CassandraCqlRowSchema(CqlResult result, string familyName)
{
#if DEBUG
_def = result.Schema;
#endif

var def = result.Schema;
var colNameType = CassandraType.GetCassandraType(def.Default_name_type);
var colValueType = CassandraType.GetCassandraType(def.Default_value_type);

FamilyName = familyName;
DefaultColumnNameType = colNameType;
DefaultColumnValueType = colValueType;
Columns = new List<CassandraColumnSchema>();

var colNameTypes = new Dictionary<CassandraObject, CassandraType>();

foreach (var c in def.Name_types)
{
var type = CassandraType.GetCassandraType(c.Value);
var name = CassandraObject.GetCassandraObjectFromDatabaseByteArray(c.Key, CassandraType.BytesType);

colNameTypes.Add(name, type);
}

// columns returned
foreach (var c in def.Value_types)
{
var type = CassandraType.GetCassandraType(c.Value);
var nameType = colNameType;
var name = CassandraObject.GetCassandraObjectFromDatabaseByteArray(c.Key, CassandraType.BytesType);

if (colNameTypes.ContainsKey(name))
nameType = colNameTypes[name];

var colSchema = new CassandraColumnSchema {
NameType = nameType,
Name = name,
ValueType = type
};

Columns.Add(colSchema);
}
}

public string FamilyName { get; set; }

public CassandraType DefaultColumnNameType { get; set; }
public CassandraType DefaultColumnValueType { get; set; }

public IList<CassandraColumnSchema> Columns { get; set; }
}
}
Something went wrong with that request. Please try again.