/// <summary> /// Добавить активный булевый параметр агрегата /// </summary> /// <param name="luaName">Lua-имя</param> /// <param name="name">Имя</param> /// <param name="defaultValue">Значение по-умолчанию</param> public void AddActiveBoolParameter(string luaName, string name, string defaultValue) { var par = new ActiveBoolParameter(luaName, name, defaultValue); par.Owner = this; AggregateParameters.Add(par); }
public static HistogramOperationParameters GetHistogramOperationParameters(HistogramOperationModel model, int sampleSize) { var psm = model.SchemaModel as IDEASchemaModel; var filter = ""; var filterModels = new List <FilterModel>(); filter = FilterModel.GetFilterModelsRecursive(model, new List <IFilterProviderOperationModel>(), filterModels, true); var brushes = new List <string>(); foreach (var brushOperationModel in model.BrushOperationModels) { filterModels = new List <FilterModel>(); var brush = ""; if ((brushOperationModel as IFilterProviderOperationModel).FilterModels.Any()) { brush = FilterModel.GetFilterModelsRecursive(brushOperationModel, new List <IFilterProviderOperationModel>(), filterModels, false); } brushes.Add(brush); } var nrOfBins = new List <double>(); nrOfBins = new[] { MainViewController.Instance.MainModel.NrOfXBins, MainViewController.Instance.MainModel.NrOfYBins }.Concat( model.GetAttributeUsageTransformationModel(AttributeUsage.Group).Select(qom => MainViewController.Instance.MainModel.NrOfGroupBins)).ToList(); if ((model.GetAttributeUsageTransformationModel(AttributeUsage.X).First().AttributeModel.RawName == "long") || (model.GetAttributeUsageTransformationModel(AttributeUsage.X).First().AttributeModel.RawName == "lat")) { nrOfBins[0] = 20; } if ((model.GetAttributeUsageTransformationModel(AttributeUsage.Y).First().AttributeModel.RawName == "long") || (model.GetAttributeUsageTransformationModel(AttributeUsage.Y).First().AttributeModel.RawName == "lat")) { nrOfBins[0] = 20; } var aggregates = model.GetAttributeUsageTransformationModel(AttributeUsage.Value).Concat( model.GetAttributeUsageTransformationModel(AttributeUsage.DefaultValue)).Concat( model.GetAttributeUsageTransformationModel(AttributeUsage.X).Where(aom => aom.AggregateFunction != AggregateFunction.None)).Concat( model.GetAttributeUsageTransformationModel(AttributeUsage.Y).Where(aom => aom.AggregateFunction != AggregateFunction.None)).Distinct().ToList(); var xIom = model.GetAttributeUsageTransformationModel(AttributeUsage.X).FirstOrDefault(); var yIom = model.GetAttributeUsageTransformationModel(AttributeUsage.Y).FirstOrDefault(); var xBinning = xIom.AggregateFunction == AggregateFunction.None ? new EquiWidthBinningParameters { Dimension = xIom.AttributeModel.Index, RequestedNrOfBins = MainViewController.Instance.MainModel.NrOfXBins, } : (BinningParameters) new SingleBinBinningParameters { Dimension = xIom.AttributeModel.Index }; var yBinning = yIom.AggregateFunction == AggregateFunction.None ? new EquiWidthBinningParameters { Dimension = yIom.AttributeModel.Index, RequestedNrOfBins = MainViewController.Instance.MainModel.NrOfYBins } : (BinningParameters) new SingleBinBinningParameters { Dimension = yIom.AttributeModel.Index }; AggregateParameters sortAggregateParam = null; var aggregateParameters = new List <AggregateParameters>(); foreach (var agg in aggregates) { AggregateParameters aggParam = null; if (agg.AggregateFunction == AggregateFunction.Avg) { aggParam = new AverageAggregateParameters { Dimension = agg.AttributeModel.Index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }; } else if (agg.AggregateFunction == AggregateFunction.Count) { aggParam = new CountAggregateParameters { Dimension = agg.AttributeModel.Index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }; } else if (agg.AggregateFunction == AggregateFunction.Sum) { aggParam = new SumAggregateParameters() { Dimension = agg.AttributeModel.Index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }; } else if (agg.AggregateFunction == AggregateFunction.SumE) { aggParam = new SumEstimationAggregateParameters() { Dimension = agg.AttributeModel.Index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }; } aggregateParameters.Add(aggParam); if (agg == model.GetAttributeUsageTransformationModel(AttributeUsage.Value).Concat(model.GetAttributeUsageTransformationModel(AttributeUsage.DefaultValue)).FirstOrDefault()) { sortAggregateParam = aggParam; } aggregateParameters.Add(new MarginAggregateParameters { Dimension = agg.AttributeModel.Index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension, AggregateFunction = agg.AggregateFunction.ToString() }); } var kdeDatatypes = new[] { InputDataTypeConstants.INT, InputDataTypeConstants.FLOAT }.ToList(); var globalAggregates = new List <AggregateParameters>(); foreach (var index in new[] { xIom, yIom }.Where(a => kdeDatatypes.Contains((a.AttributeModel as AttributeFieldModel).InputDataType)).Select(a => a.AttributeModel.Index).Distinct()) { globalAggregates.Add(new KDEAggregateParameters { Dimension = index, NrOfSamples = 50, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }); globalAggregates.Add(new CountAggregateParameters { Dimension = index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }); } var parameters = new HistogramOperationParameters { AdapterName = psm.RootOriginModel.DatasetConfiguration.Schema.RawName, Filter = filter, Brushes = brushes, BinningParameters = Extensions.Yield(xBinning, yBinning).ToList(), SampleStreamBlockSize = sampleSize, PerBinAggregateParameters = aggregateParameters, SortPerBinAggregateParameter = sortAggregateParam, GlobalAggregateParameters = globalAggregates }; return(parameters); }