public void Merge(T newInstance, MergeStrategy strategy) { foreach (var item in newInstance) { if (ContainsKey(item.Key)) { switch (strategy) { case MergeStrategy.Normal: this[item.Key] = item.Value; break; case MergeStrategy.Recursive: if (item.Value is IMergeable) { (this[item.Key] as IMergeable).Merge(item.Value as IMergeable, strategy); } else { this[item.Key] = item.Value; } break; default: throw new ArgumentException("Unknown merge strategy", "strategy"); } } else { this[item.Key] = item.Value; } } }
public JsonEntityConverter(EntityManager entityManager, MergeStrategy mergeStrategy, Func<String, String> normalizeTypeNameFn = null) { _entityManager = entityManager; _metadataStore = entityManager.MetadataStore; _mergeStrategy = mergeStrategy; _normalizeTypeNameFn = normalizeTypeNameFn; _allEntities = new List<IEntity>(); }
public BlockGroupBuilder(Position position, Movement movement, MergeStrategy merging) { this.position = position; this.movement = movement; this.merging = merging; this.blocks = new List <Block>(); }
public void Merge(string filename, MergeStrategy strategy) { if (TryGetInstance(filename, out T newInstance)) { Merge(newInstance, strategy); } }
public AttachOperations <T> Merge <T>(IEnumerable <T> items, MergeStrategy mergeStrategy = MergeStrategy.UpdateIfUnchanged) where T : class { var itemsList = items.Where(p => p != null).ToList(); using (BeginAttach <T>()) { var resultItems = DoClean <T>(itemsList, mergeStrategy, out var totalTuples); var result = new AttachOperations <T>(resultItems); foreach (var item in totalTuples) { if (item.Value.Added) { result.TrackAdded(item.Value.Target); } if (item.Value.GetProperties().Any()) { result.TrackMerged(item.Value.Target, item.Value.GetProperties()); } } return(result); } }
public JsonEntityConverter(EntityManager entityManager, MergeStrategy mergeStrategy, Func <String, String> normalizeTypeNameFn = null) { _entityManager = entityManager; _metadataStore = entityManager.MetadataStore; _mergeStrategy = mergeStrategy; _normalizeTypeNameFn = normalizeTypeNameFn; _allEntities = new List <IEntity>(); }
public IEnumerable <T> Attach <T>(IEnumerable <T> items, MergeStrategy mergeStrategy = MergeStrategy.UpdateIfUnchanged) where T : class { using (BeginAttach <T>()) { return(DoClean(items, mergeStrategy, out var totalCleaned)); } }
internal Merger( IMetadataParser <TEntity> metadataParser, MergeStrategy strategy) { this.metadataParser = metadataParser; this.strategy = strategy; this.propertyGroups = new Lazy <IEnumerable <PropertyGroup> >(this.CreatePropertyGroups); }
/// <summary> /// Constructs a NoteMapMerger with custom /// <see cref="NoteMerger">NoteMerger</see> /// and custom /// <see cref="NGit.Merge.MergeStrategy">NGit.Merge.MergeStrategy</see> /// . /// </summary> /// <param name="db">Git repository</param> /// <param name="noteMerger">note merger for merging conflicting changes on a note</param> /// <param name="nonNotesMergeStrategy">merge strategy for merging non-note entries</param> public NoteMapMerger(Repository db, NoteMerger noteMerger, MergeStrategy nonNotesMergeStrategy ) { this.db = db; this.reader = db.NewObjectReader(); this.inserter = db.NewObjectInserter(); this.noteMerger = noteMerger; this.nonNotesMergeStrategy = nonNotesMergeStrategy; this.objectIdPrefix = new MutableObjectId(); }
public SDS MergeWith(SDS other, MergeStrategy strategy, EntityChange.ExecutionContext ctx) { if (Generation != other.Generation) { throw new IntegrityViolation("Generation mismatch: " + Generation + " != " + other.Generation); } SDS exclusiveSource = null; int exclusiveChoice = 0; if (strategy == MergeStrategy.Exclusive || strategy == MergeStrategy.ExclusiveWithPositionCorrection) { exclusiveChoice = SelectExclusiveSource(this, other); exclusiveSource = (exclusiveChoice == -1 ? this : other); } InconsistencyCoverage merged = InconsistencyCoverage.GetMinimum(IC, other.IC); EntityPool pool = new EntityPool(ctx); foreach (var e in this.FinalEntities) { if (IC.IsInconsistentR(ctx.LocalSpace.Relativate(e.ID.Position))) { continue; //for now } pool.Insert(e); } foreach (var e in other.FinalEntities) { if (other.IC.IsInconsistentR(ctx.LocalSpace.Relativate(e.ID.Position))) { continue; //for now } if (pool.Contains(e.ID.Guid)) { continue; } pool.Insert(e); } //at this point we merged all fully consistent entities from either. If the inconsistent areas did not overlap then the result should contain all entities in their consistent state if (!merged.IsFullyConsistent) { if (strategy == MergeStrategy.EntitySelective) { MergeInconsistentEntitiesComp(pool, this, other, merged, ctx); } else { MergeInconsistentEntitiesEx(pool, exclusiveSource, strategy == MergeStrategy.ExclusiveWithPositionCorrection, merged, ctx); } } return(new SDS(Generation, pool.ToArray(), merged)); }
/// <summary> /// Returns a clone of the query for the specified MergeStrategy /// </summary> /// <typeparam name="TQuery"></typeparam> /// <param name="query"></param> /// <param name="mergeStrategy"></param> /// <returns></returns> public static TQuery With <TQuery>(this TQuery query, MergeStrategy mergeStrategy) where TQuery : EntityQuery { if (query.QueryOptions.MergeStrategy == mergeStrategy) { return(query); } TQuery newQuery = (TQuery)query.Clone(); newQuery.QueryOptions.MergeStrategy = mergeStrategy; return(newQuery); }
public T AttachSingle <T>(T item, MergeStrategy mergeStrategy = MergeStrategy.UpdateIfUnchanged) where T : class { // null-Objekt kann nicht hinzugefügt werden if (item == null) { return(null); } return(Attach(new[] { item }, mergeStrategy).First()); }
public static T MergeOrLoad(T messageDictionary, string fileName, MergeStrategy mergeStrategy) { if (messageDictionary != null) { messageDictionary.Merge(fileName, mergeStrategy); } else { messageDictionary = GetInstance(fileName); } return(messageDictionary); }
/// <summary> /// Initializes a new instance of the <see cref="Agnes"/> class. /// </summary> /// <param name="clusters">The clusters.</param> /// <param name="distanceMetric">The distance metric.</param> /// <param name="strategy">The strategy.</param> public Agnes(ClusterSet clusters, DistanceMetric distanceMetric, MergeStrategy strategy) { _clusters = clusters; _initialNumberOfClusters = clusters.Count; _distanceMetric = distanceMetric; _strategy = strategy; // creating initial dissimilarity matrix from _clusters BuildDissimilarityMatrix(); _chValue = new List <double>(); _chIndex = new List <int>(); }
/// <summary> /// Handles the Click event of the calculateClusterCountButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="Clusterizer.CustomException">Не было выбрано ни одного показателя. - Ощибка при выборе показателей</exception> private void calculateClusterCountButton_Click(object sender, EventArgs e) { // gets selected parameters of clustering distanceMetric = (DistanceMetric)distanceSelectComboBox.SelectedIndex; strategy = (MergeStrategy)strategySelectComboBox.SelectedIndex; normalizeMethod = (NormalizeMethod)normalizeMethodSelectComboBox.SelectedIndex; // gets selected datapoints var isChosen = new bool[Tools.NumericDataHeadings.Length]; bool isAllFalse = true; int ind = 0; for (int i = 0; i < pointsSelectTreeView.Nodes.Count; i++) { for (int j = 0; j < pointsSelectTreeView.Nodes[i].Nodes.Count; j++) { isChosen[ind] = pointsSelectTreeView.Nodes[i].Nodes[j].Checked; if (isAllFalse) { isAllFalse = !isChosen[ind]; } ind++; } } // check if no datapoint is selected if (isAllFalse) { throw new CustomException("Не было выбрано ни одного показателя.", "Ощибка при выборе показателей"); } // gets cluster set from data var clusters = Tools.Data.GetClusterSet(Tools.isChosen); clusters.Normalize(normalizeMethod); // executes clustering for determining recomended count of clusters Agnes agnes = new Agnes(clusters, distanceMetric, strategy); agnes.ExecuteClustering(2, true); // gets recomended count of clusters countOfClusters = agnes.GetRecommendedCountOfClusters(); clusterCountTextBox.Text = $"{countOfClusters}"; }
/// <summary> /// Handles the Click event of the doClusteringButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="Clusterizer.CustomException"> /// Введите правилное количество кластеров. - Ошибка при вводе числа кластеров /// or /// Не было выбрано не одного показателя. - Ощибка при выборе показателей /// </exception> private void doClusteringButton_Click(object sender, EventArgs e) { // Gets selected parameters of clustering distanceMetric = (DistanceMetric)distanceSelectComboBox.SelectedIndex; strategy = (MergeStrategy)strategySelectComboBox.SelectedIndex; normalizeMethod = (NormalizeMethod)normalizeMethodSelectComboBox.SelectedIndex; // checks for correct cluster number if (int.TryParse(clusterCountTextBox.Text, out var tmp) && tmp > 0 && tmp < Tools.Data.Rows.Count) { countOfClusters = tmp; } else { throw new CustomException("Введите правилное количество кластеров.", "Ошибка при вводе числа кластеров"); } // gets selected datapoints var isChosen = new bool[Tools.NumericDataHeadings.Length]; bool isAllFalse = true; int ind = 0; for (int i = 0; i < pointsSelectTreeView.Nodes.Count; i++) { for (int j = 0; j < pointsSelectTreeView.Nodes[i].Nodes.Count; j++) { isChosen[ind] = pointsSelectTreeView.Nodes[i].Nodes[j].Checked; if (isAllFalse) { isAllFalse = !isChosen[ind]; } ind++; } } // check if no datapoint is selected if (isAllFalse) { throw new CustomException("Не было выбрано не одного показателя.", "Ощибка при выборе показателей"); } Tools.isChosen = isChosen; isParametersSelected = true; Close(); }
/// <param name="newHead">the object the head points at after the merge</param> /// <param name="base"> /// the common base which was used to produce a content-merge. May /// be <code>null</code> if the merge-result was produced without /// computing a common base /// </param> /// <param name="mergedCommits">all the commits which have been merged together</param> /// <param name="mergeStatus">the status the merge resulted in</param> /// <param name="mergeStrategy"> /// the used /// <see cref="NGit.Merge.MergeStrategy">NGit.Merge.MergeStrategy</see> /// </param> /// <param name="lowLevelResults"> /// merge results as returned by /// <see cref="NGit.Merge.ResolveMerger.GetMergeResults()">NGit.Merge.ResolveMerger.GetMergeResults() /// </see> /// </param> /// <param name="description">a user friendly description of the merge result</param> public MergeCommandResult(ObjectId newHead, ObjectId @base, ObjectId[] mergedCommits , MergeStatus mergeStatus, MergeStrategy mergeStrategy, IDictionary <string, NGit.Merge.MergeResult <Sequence> > lowLevelResults, string description) { this.newHead = newHead; this.mergedCommits = mergedCommits; this.@base = @base; this.mergeStatus = mergeStatus; this.mergeStrategy = mergeStrategy; this.description = description; if (lowLevelResults != null) { foreach (KeyValuePair <string, NGit.Merge.MergeResult <Sequence> > result in lowLevelResults .EntrySet()) { AddConflict(result.Key, result.Value); } } }
internal static void Process(GeoDataToHexagonDataArgs opts) { Stopwatch stopwatch = Stopwatch.StartNew(); LayersConfiguration layer = opts.GetLayersConfiguration(); MergeStrategy mergeStrategy = opts.Merge; ValueHandlerFactory valueHandlerFactory = new ValueHandlerFactory(); valueHandlerFactory.RegisterImplementation <WikimediaAltitudeHandler>("wikimedia_altitude"); HexagonDefinition hexagonDefinition = opts.GetHexagonDefinition(); HexagonProcessor hexagonProcessor = new HexagonProcessor(hexagonDefinition, valueHandlerFactory); BoundingBox bb = null; if (!string.IsNullOrEmpty(opts.East) && !string.IsNullOrEmpty(opts.West) && !string.IsNullOrEmpty(opts.North) && !string.IsNullOrEmpty(opts.South)) { bb = new BoundingBox { East = double.Parse(opts.East), West = double.Parse(opts.West), North = double.Parse(opts.North), South = double.Parse(opts.South) }; } using (IGeoDataParser geoParser = opts.GetGeoDataParser()) using (IHexagonDataExporter exporter = opts.GetResultExporter()) { IEnumerable <GeoData> geoDataList = geoParser.ParseGeodataFromSource(layer); IEnumerable <Hexagon> results = hexagonProcessor.ProcessHexagonsFromGeoData(geoDataList, layer.Targets, bb); ExportResults(exporter, results, hexagonDefinition, mergeStrategy); } stopwatch.Stop(); Console.WriteLine($"Process took {stopwatch.ElapsedMilliseconds} ms"); }
public static ICommandArgument Strategy(MergeStrategy strategy) { switch (strategy) { case MergeStrategy.Octopus: return(new CommandParameterValue("--strategy", "octopus", '=')); case MergeStrategy.Ours: return(new CommandParameterValue("--strategy", "ours", '=')); case MergeStrategy.Recursive: return(new CommandParameterValue("--strategy", "recursive", '=')); case MergeStrategy.Resolve: return(new CommandParameterValue("--strategy", "resolve", '=')); case MergeStrategy.Subtree: return(new CommandParameterValue("--strategy", "subtree", '=')); default: return(null); } }
public static ICommandArgument Strategy(MergeStrategy strategy) { switch(strategy) { case MergeStrategy.Octopus: return new CommandParameterValue("--strategy", "octopus", '='); case MergeStrategy.Ours: return new CommandParameterValue("--strategy", "ours", '='); case MergeStrategy.Recursive: return new CommandParameterValue("--strategy", "recursive", '='); case MergeStrategy.Resolve: return new CommandParameterValue("--strategy", "resolve", '='); case MergeStrategy.Subtree: return new CommandParameterValue("--strategy", "subtree", '='); default: return null; } }
private static void ExportResults(IHexagonDataExporter exporter, IEnumerable <Hexagon> results, HexagonDefinition hexagonDefinition, MergeStrategy mergeStrategy) { exporter.ExportResults(results, hexagonDefinition, mergeStrategy).Wait(); }
public QueryOptions(FetchStrategy fetchStrategy, MergeStrategy mergeStrategy) { FetchStrategy = fetchStrategy; MergeStrategy = mergeStrategy; }
public ImportOptions(MergeStrategy? mergeStrategy = null, bool shouldMergeMetadata=true) { MergeStrategy = mergeStrategy; ShouldMergeMetadata = shouldMergeMetadata; }
/// <summary> /// Computes the distance. /// </summary> /// <param name="cluster1">The cluster1.</param> /// <param name="cluster2">The cluster2.</param> /// <param name="dissimilarityMatrix">The dissimilarity matrix.</param> /// <param name="strategy">The strategy.</param> /// <returns>Distance between clusters</returns> public static double ComputeDistance(Cluster cluster1, Cluster cluster2, DissimilarityMatrix dissimilarityMatrix, MergeStrategy strategy) { double distance = 0; var distance1 = dissimilarityMatrix.ReturnClusterPairDistance(new ClusterPair(cluster1, cluster2.GetSubCluster(0))); var distance2 = dissimilarityMatrix.ReturnClusterPairDistance(new ClusterPair(cluster1, cluster2.GetSubCluster(1))); // computes distance by using merge strategy switch (strategy) { case MergeStrategy.SingleLinkage: distance = _MinValue(distance1, distance2); // Min(x, y) break; case MergeStrategy.CompleteLinkage: distance = _MaxValue(distance1, distance2); // Max(x, y) break; case MergeStrategy.AverageLinkageWpgma: distance = (distance1 + distance2) / 2; // Avg(x, y) break; case MergeStrategy.AverageLinkageUpgma: distance = ((cluster2.GetSubCluster(0).QuantityOfDataPoints * distance1) / cluster2.QuantityOfDataPoints) + ((cluster2.GetSubCluster(1).QuantityOfDataPoints * distance2) / cluster2.QuantityOfDataPoints); // WeightedAvg(x, y) break; case MergeStrategy.CentroidMethod: cluster1.SetCentroid(); cluster2.SetCentroid(); distance = Distance.GetDistance(cluster1.Centroid, cluster2.Centroid, DistanceMetric.SquareEuclidianDistance); // Distance of centroids break; case MergeStrategy.WardsMethod: Cluster newCluster = new Cluster(); newCluster.AddSubCluster(cluster1); newCluster.AddSubCluster(cluster2); newCluster.SetCentroid(); distance = newCluster.GetSumOfSquaredError(DistanceMetric.EuclidianDistance) - cluster1.GetSumOfSquaredError(DistanceMetric.EuclidianDistance) - cluster2.GetSumOfSquaredError(DistanceMetric.EuclidianDistance); // SEO(xy) - SEO(x) - SEO(y) break; } return distance; }
public Task <bool> ExportResults(IEnumerable <Hexagon> hexagons, HexagonDefinition hexagonDefinition, MergeStrategy mergeStrategy) { foreach (var hexagon in hexagons) { foreach (var key in hexagon.HexagonData.Data.Keys) { Console.WriteLine($"({hexagon.LocationUV.U}:{hexagon.LocationUV.U}) {key}:{hexagon.HexagonData[key]}"); } } return(Task.FromResult(true)); }
/// <summary>Initializes all attributes. If transitionDuration is set to 0, there won't be any animation (cursor value won't change over time)</summary> /// <param name="origin">Origin face state</param> /// <param name="objective">Objective face state</param> /// <param name="initialCursor">Initial cursor value</param> public MergeMeshState(MeshState origin, MeshState objective, float initialCursor = 0f, float transitionDuration = 1f, MergeStrategy mergeStrategy = MergeStrategy.Linear) { originWeights = origin.GetWeightSet(); objectiveWeights = objective.GetWeightSet(); this.transitionDuration = transitionDuration; switch (mergeStrategy) { default: case MergeStrategy.Linear: computationMethod = ComputeLinear; break; } SetCursor(initialCursor); }
/// <param name="newHead">the object the head points at after the merge</param> /// <param name="base"> /// the common base which was used to produce a content-merge. May /// be <code>null</code> if the merge-result was produced without /// computing a common base /// </param> /// <param name="mergedCommits">all the commits which have been merged together</param> /// <param name="mergeStatus">the status the merge resulted in</param> /// <param name="mergeStrategy"> /// the used /// <see cref="NGit.Merge.MergeStrategy">NGit.Merge.MergeStrategy</see> /// </param> /// <param name="lowLevelResults"> /// merge results as returned by /// <see cref="NGit.Merge.ResolveMerger.GetMergeResults()">NGit.Merge.ResolveMerger.GetMergeResults() /// </see> /// </param> /// <since>2.0</since> public MergeCommandResult(ObjectId newHead, ObjectId @base, ObjectId[] mergedCommits , MergeStatus mergeStatus, MergeStrategy mergeStrategy, IDictionary <string, MergeResult <Sequence> > lowLevelResults) : this(newHead, @base, mergedCommits, mergeStatus, mergeStrategy , lowLevelResults, null) { }
/// <summary> /// Returns a new QueryOptions based on this QueryOptions but with the specified MergeStrategy /// </summary> /// <param name="mergeStrategy"></param> /// <returns></returns> public QueryOptions With(MergeStrategy mergeStrategy) { return new QueryOptions(this.FetchStrategy, mergeStrategy); }
/// <summary> /// Merges the data of another config file into this instance. /// </summary> /// <param name="config"></param> /// <param name="strat"></param> public void Merge(ConfigBase config, MergeStrategy strat = MergeStrategy.Overwrite) { SuppressConfigChanged = true; switch (strat) { case MergeStrategy.Overwrite: foreach (var s in config.userconfig.Keys) { Set(s, config.userconfig[s], ConfigLevel.User); } foreach (var s in config.appconfig.Keys) { Set(s, config.appconfig[s], ConfigLevel.Application); } foreach (var s in config.instconfig.Keys) { Set(s, config.instconfig[s], ConfigLevel.Instance); } break; case MergeStrategy.AddNonExistingOnly: foreach (var s in config.userconfig.Keys) { if (!userconfig.ContainsKey(s)) { Set(s, config.userconfig[s], ConfigLevel.User); } } foreach (var s in config.appconfig.Keys) { if (!appconfig.ContainsKey(s)) { Set(s, config.appconfig[s], ConfigLevel.Application); } } foreach (var s in config.instconfig.Keys) { if (!instconfig.ContainsKey(s)) { Set(s, config.instconfig[s], ConfigLevel.Instance); } } break; case MergeStrategy.UpdateExistingOnly: foreach (var s in config.userconfig.Keys) { if (userconfig.ContainsKey(s)) { Set(s, config.userconfig[s], ConfigLevel.User); } } foreach (var s in config.appconfig.Keys) { if (appconfig.ContainsKey(s)) { Set(s, config.appconfig[s], ConfigLevel.Application); } } foreach (var s in config.instconfig.Keys) { if (instconfig.ContainsKey(s)) { Set(s, config.instconfig[s], ConfigLevel.Instance); } } break; } SuppressConfigChanged = false; if (ConfigChanged != null) { ConfigChanged(this, ConfigChangedEventArgs.Empty); } }
/// <summary> /// Returns a new QueryOptions based on this QueryOptions but with the specified MergeStrategy /// </summary> /// <param name="mergeStrategy"></param> /// <returns></returns> public QueryOptions With(MergeStrategy mergeStrategy) { return(new QueryOptions(this.FetchStrategy, mergeStrategy)); }
/// <param name="mergeStrategy"> /// the /// <see cref="NGit.Merge.MergeStrategy">NGit.Merge.MergeStrategy</see> /// to be used /// </param> /// <returns> /// /// <code>this</code> /// </returns> public virtual NGit.Api.MergeCommand SetStrategy(MergeStrategy mergeStrategy) { CheckCallable(); this.mergeStrategy = mergeStrategy; return(this); }
public BlockGroup(List <Block> blocks, Movement movement, MergeStrategy merging) { this.blocks = blocks; this.movement = movement; this.merging = merging; }
/// <summary> /// Merge the given branch into this Branch using the given merge strategy. /// </summary> /// <param name="other"></param> /// <param name="strategy"></param> public MergeResult Merge(Branch other, MergeStrategy strategy) { return MergeCommand.Execute(new MergeOptions { Branches = new[] { this, other }, MergeStrategy = strategy }); }
/// <summary> /// Merge the given branch into this Branch using the given merge strategy. /// </summary> /// <param name="other"></param> /// <param name="strategy"></param> public MergeResult Merge(Branch other, MergeStrategy strategy) { return(MergeCommand.Execute(new MergeOptions { Branches = new[] { this, other }, MergeStrategy = strategy })); }
public static List <string> ApplyDelta(Delta delta, string sourcePath, string ddbPath, MergeStrategy mergeStrategy) { try { string deltaJson = JsonConvert.SerializeObject(delta); if (_ApplyDelta(deltaJson, sourcePath, ddbPath, (int)mergeStrategy, out var conflictsPtr) != DDBError.DDBERR_NONE) { throw new DDBException(GetLastError()); } var conflicts = Marshal.PtrToStringAnsi(conflictsPtr); if (string.IsNullOrWhiteSpace(conflicts)) { throw new DDBException("Unable get applydelta result"); } return(JsonConvert.DeserializeObject <List <string> >(conflicts)); } catch (EntryPointNotFoundException ex) { throw new DDBException($"Error in calling ddb lib: incompatible versions ({ex.Message})", ex); } catch (Exception ex) { throw new DDBException( $"Error in calling ddb lib. Last error: \"{GetLastError()}\", check inner exception for details", ex); } }
public JsonEntityConverter(EntityManager entityManager, MergeStrategy mergeStrategy) { _entityManager = entityManager; _metadataStore = entityManager.MetadataStore; _mergeStrategy = mergeStrategy; }