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);
			}
		}
Пример #2
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 0:
         if (field.Type == TType.Struct) {
           Success = new CqlResult();
           Success.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 1:
         if (field.Type == TType.Struct) {
           Ire = new InvalidRequestException();
           Ire.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.Struct) {
           Ue = new UnavailableException();
           Ue.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 3:
         if (field.Type == TType.Struct) {
           Te = new TimedOutException();
           Te.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 4:
         if (field.Type == TType.Struct) {
           Sde = new SchemaDisagreementException();
           Sde.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }