Ejemplo n.º 1
0
        /// <summary>
        /// <see cref="Equals(object)"/>
        /// </summary>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(obj, null))
            {
                return(false);
            }
            if (ReferenceEquals(obj, this))
            {
                return(true);
            }
            if (obj.GetType() != typeof(MapField))
            {
                return(false);
            }

            MapField other = (MapField)obj;

            return(Name.Equals(other.Name) && Key.Equals(other.Key) && Value.Equals(other.Value));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a flat list of all data fields in this schema
        /// </summary>
        /// <returns></returns>
        public DataField[] GetDataFields()
        {
            var result = new List <DataField>();

            void analyse(Field f)
            {
                switch (f.SchemaType)
                {
                case SchemaType.Data:
                    result.Add((DataField)f);
                    break;

                case SchemaType.List:
                    analyse(((ListField)f).Item);
                    break;

                case SchemaType.Map:
                    MapField mf = (MapField)f;
                    analyse(mf.Key);
                    analyse(mf.Value);
                    break;

                case SchemaType.Struct:
                    StructField sf = (StructField)f;
                    traverse(sf.Fields);
                    break;
                }
            }

            void traverse(IEnumerable <Field> fields)
            {
                foreach (Field f in fields)
                {
                    analyse(f);
                }
            }

            traverse(Fields);

            return(result.ToArray());
        }
Ejemplo n.º 3
0
        public static void Append(
            Dictionary <string, IList> columns,
            IReadOnlyList <Field> schema,
            Row row)
        {
            DataSetValidator.ValidateRow(row, schema);

            for (int i = 0; i < schema.Count; i++)
            {
                Field  field = schema[i];
                object value = row[i];
                switch (field.SchemaType)
                {
                case SchemaType.Map:
                    MapField mapField = (MapField)field;

                    IList keys   = GetValues(columns, mapField.Key, true, true);
                    IList values = GetValues(columns, mapField.Value, true, true);

                    ((MapField)field).AddElement(keys, values, value as IDictionary);
                    break;

                case SchemaType.Struct:
                    AddStructure(columns, field as StructField, value as Row);
                    break;

                case SchemaType.List:
                    AddList(columns, field as ListField, value);
                    break;

                default:
                    values = GetValues(columns, (DataField)field, true);
                    values.Add(value);
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        public override bool Equals(Object obj)
        {
            MapField other = (MapField)obj;

            return(Name.Equals(other.Name) && KeyType.Equals(other.KeyType) && ValueType.Equals(other.ValueType));
        }