コード例 #1
0
        protected virtual IEnumerable <Field> GetFields(FieldTarget target)
        {
            switch (target)
            {
            case FieldTarget.KeyReference:

                return(LookupTableBuilder.Schema.Keys.Select(fp =>
                                                             fp.Value.Affix(PrefixName).Affix(ReferenceNameFormatter).AsNullableReference(Key ? FieldType.Key : FieldType.Dimension).ChangeSort(SortOrder.Unspecified)));


            case FieldTarget.Inline:

                var fields = FieldMappers.SelectMany(mapper => mapper.Fields.Select(field =>
                                                                                    field.Affix(PrefixName).Affix(ReferenceNameFormatter))).ToArray();

                if (!Key)
                {
                    foreach (var field in fields.Where(f => f.FieldType == FieldType.Key))
                    {
                        field.FieldType = FieldType.Dimension;
                    }
                }

                return(fields);

            case FieldTarget.Table:
                return(FieldMappers.SelectMany(mapper => mapper.Fields));
            }

            throw new ArgumentOutOfRangeException("target");
        }
コード例 #2
0
        public TableDataBuilder(string name, IEnumerable <IFieldMapper> fieldMappers)
            : base(new TableDataSchema(name))
        {
            FieldMappers = fieldMappers.ToArray();
            _fieldList.AddRange(FieldMappers.SelectMany(mapper => mapper.Fields));

            UpdateSchema();
        }
コード例 #3
0
        public TimeDimension(string fieldName, Func <ProcessingScope, DateTime?> selector, string tableName = null, bool inlineFields = false, bool useTimeForKey = false, TimeDetailLevel detailLevel = TimeDetailLevel.Minute, CultureInfo cultureInfo = null, bool key = false)
            : base(fieldName, tableName ?? fieldName, Enumerable.Empty <IFieldMapper>())
        {
            _selector      = selector;
            _useTimeForKey = useTimeForKey;
            _detailLevel   = detailLevel;
            _cultureInfo   = cultureInfo ?? CultureInfo.CurrentCulture;
            _mapper        = new TimeFields(this);
            Key            = key;

            InlineFields = inlineFields;
            FieldMappers.Add(_mapper);
        }
コード例 #4
0
        public DateDimension(string fieldName, Func <ProcessingScope, DateTime?> selector, string tableName = null, bool inlineFields = false, bool useDateForKey = true, DateDetailLevel detailLevel = DateDetailLevel.Date, CultureInfo cultureInfo = null, SortOrder sort = SortOrder.Ascending, bool key = false)
            : base(fieldName, tableName ?? fieldName, Enumerable.Empty <IFieldMapper>())
        {
            _selector      = selector;
            _useDateForKey = useDateForKey;
            _detailLevel   = detailLevel;
            _cultureInfo   = cultureInfo ?? CultureInfo.CurrentCulture;
            _sort          = sort;
            Key            = key;

            InlineFields = inlineFields;

            _mapper = new DateFields(this);

            FieldMappers.Add(_mapper);
        }
コード例 #5
0
        protected void UpdateSchema()
        {
            //Add fields to schema order by field type, then source index
            Schema.Fields =
                _fieldList.AsIndexed()
                .OrderBy(f => f.Value.FieldType == FieldType.Key ? 0 : f.Value.FieldType == FieldType.Fact ? 2 : 1)
                .ThenBy(f => f.Index)
                .Select(f => f.Value)
                .ToArray();



            Schema.CalculatedFields =
                FieldMappers.OfType <ICalculatedFieldContainer>().SelectMany(c => c.CalculatedFields).ToList();

            Iterator = new FieldMapperIterator(FieldMappers, Schema.Fields);

            _rowComparer = new RowComparer(Schema);

            RowMap = new Dictionary <object[], object[]>(_rowComparer);

            HashKey = _hashKeyField != null?Array.IndexOf(Schema.Fields, _hashKeyField) : (int?)null;

            if (HashKey.HasValue)
            {
                HashIndices = Schema.Keys.Concat(Schema.Dimensions).Where(fp => fp.Index != HashKey).Select(fp => fp.Index).ToArray();
            }

            _parentReferenceIndices.Clear();
            if (_parentReferences.Count > 0)
            {
                foreach (var field in Schema.Fields.AsIndexed())
                {
                    int parentIndex;
                    if (_parentReferences.TryGetValue(field.Value, out parentIndex))
                    {
                        _parentReferenceIndices.Add(new KeyValuePair <int, int>(parentIndex, field.Index));
                    }
                }
            }

            _emptyRow =
                Schema.Fields
                .Select(
                    f => f.DefaultValue ?? (f.ValueType.IsValueType ? Activator.CreateInstance(f.ValueType) : null))
                .ToArray();
        }