protected override IEnumerable<Field> CreateFields() { _iterator = new FieldMapperIterator(FieldMappers); if (!InlineFields) { LookupTableBuilder = CreateLookupBuilder(); if (LookupTableBuilder.Schema.Keys.Length == 0) { LookupTableBuilder.AddHashKey(HashKeyFactory); } } return GetFields(InlineFields ? FieldTarget.Inline : FieldTarget.KeyReference).ToArray(); }
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(); }
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(); }