Exemplo n.º 1
0
        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 CassandraColumnFamilySchema(CfDef def)
        {
            _def = def;

            KeyspaceName = def.Keyspace;

            var familyType = ColumnType.Standard;

            Enum.TryParse <ColumnType>(def.Column_type, out familyType);

            var defaultKeyValueType    = CassandraType.GetCassandraType(def.Key_validation_class);
            var defaultColumnValueType = CassandraType.GetCassandraType(def.Default_validation_class);

            CassandraType columnNameType, superColumnNameType;

            if (familyType == ColumnType.Super)
            {
                superColumnNameType = CassandraType.GetCassandraType(def.Comparator_type);
                columnNameType      = CassandraType.GetCassandraType(def.Subcomparator_type);
            }
            else
            {
                superColumnNameType = null;
                columnNameType      = CassandraType.GetCassandraType(def.Comparator_type);
            }

            FamilyType        = familyType;
            FamilyName        = def.Name;
            FamilyDescription = def.Comment;

            KeyName      = CassandraObject.GetCassandraObjectFromDatabaseByteArray(def.Key_alias, DefaultKeyNameType);
            KeyValueType = defaultKeyValueType;

            SuperColumnNameType    = superColumnNameType;
            ColumnNameType         = columnNameType;
            DefaultColumnValueType = defaultColumnValueType;

            Columns = def.Column_metadata.Select(col => new CassandraColumnSchema(col, columnNameType)).ToList();
        }
Exemplo n.º 3
0
 public CassandraColumnSchema(ColumnDef def, CassandraType columnNameType)
 {
     NameType  = columnNameType;
     Name      = CassandraObject.GetCassandraObjectFromDatabaseByteArray(def.Name, columnNameType);
     ValueType = CassandraType.GetCassandraType(def.Validation_class);
 }