public override IndexDefinitionCompareDifferences Compare(IndexDefinitionBase other) { var otherDefinition = other as AutoMapIndexDefinition; if (otherDefinition == null) { return(IndexDefinitionCompareDifferences.All); } if (ReferenceEquals(this, other)) { return(IndexDefinitionCompareDifferences.None); } var result = IndexDefinitionCompareDifferences.None; if (Collections.SetEquals(otherDefinition.Collections) == false || DictionaryExtensions.ContentEquals(MapFields, otherDefinition.MapFields) == false) { result |= IndexDefinitionCompareDifferences.Maps; } if (LockMode != other.LockMode) { result |= IndexDefinitionCompareDifferences.LockMode; } if (Priority != other.Priority) { result |= IndexDefinitionCompareDifferences.Priority; } return(result); }
public IndexDefinitionCompareDifferences Compare(AutoIndexDefinition other) { if (other == null) { return(IndexDefinitionCompareDifferences.All); } if (ReferenceEquals(this, other)) { return(IndexDefinitionCompareDifferences.None); } var result = IndexDefinitionCompareDifferences.None; if (string.Equals(Collection, other.Collection) == false || DictionaryExtensions.ContentEquals(MapFields, other.MapFields) == false) { result |= IndexDefinitionCompareDifferences.Maps; } if (DictionaryExtensions.ContentEquals(GroupByFields, other.GroupByFields) == false) { result |= IndexDefinitionCompareDifferences.Reduce; } if (Priority != other.Priority) { result |= IndexDefinitionCompareDifferences.Priority; } return(result); }
public bool Equals(Stats other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(CountOfConflicts == other.CountOfConflicts && CountOfDocuments == other.CountOfDocuments && CountOfIndexes == other.CountOfIndexes && CountOfIndexingErrors == other.CountOfIndexingErrors && LastEtag == other.LastEtag && CountOfStaleIndexes == other.CountOfStaleIndexes && GlobalChangeVector == other.GlobalChangeVector && DictionaryExtensions.ContentEquals(Collections, other.Collections)); }
/// <summary> /// Equals the specified other. /// </summary> /// <param name="other">The other.</param> /// <param name="compareIndexIds">allow caller to choose whether to include the index Id in the comparison</param> /// <returns></returns> public bool Equals(IndexDefinition other, bool compareIndexIds = true, bool ignoreFormatting = false, bool ignoreMaxIndexOutput = false) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } if (compareIndexIds && !Equals(other.IndexId, IndexId)) { return(false); } bool mapsReduceEquals; if (ignoreFormatting) { #if !DNXCORE50 var comparer = new IndexPrettyPrinterEqualityComparer(); mapsReduceEquals = Maps.SequenceEqual(other.Maps, comparer) && comparer.Equals(Reduce, other.Reduce); #else mapsReduceEquals = Maps.SequenceEqual(other.Maps) && Reduce.Equals(other.Reduce); #endif } else { mapsReduceEquals = Maps.SequenceEqual(other.Maps) && Equals(other.Reduce, Reduce); } return(mapsReduceEquals && (ignoreMaxIndexOutput || other.MaxIndexOutputsPerDocument == MaxIndexOutputsPerDocument) && DictionaryExtensions.ContentEquals(other.Stores, Stores) && DictionaryExtensions.ContentEquals(other.Indexes, Indexes) && DictionaryExtensions.ContentEquals(other.Analyzers, Analyzers) && DictionaryExtensions.ContentEquals(other.SortOptions, SortOptions) && DictionaryExtensions.ContentEquals(other.Suggestions, Suggestions) && DictionaryExtensions.ContentEquals(other.TermVectors, TermVectors) && DictionaryExtensions.ContentEquals(other.SpatialIndexes, SpatialIndexes)); }
/// <summary> /// Equals the specified other. /// </summary> /// <param name="other">The other.</param> /// <returns></returns> public bool Equals(IndexDefinition other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Maps.SequenceEqual(other.Maps) && Equals(other.IndexId, IndexId) && Equals(other.Reduce, Reduce) && Equals(other.MaxIndexOutputsPerDocument, MaxIndexOutputsPerDocument) && DictionaryExtensions.ContentEquals(other.Stores, Stores) && DictionaryExtensions.ContentEquals(other.Indexes, Indexes) && DictionaryExtensions.ContentEquals(other.Analyzers, Analyzers) && DictionaryExtensions.ContentEquals(other.SortOptions, SortOptions) && DictionaryExtensions.ContentEquals(other.Suggestions, Suggestions) && DictionaryExtensions.ContentEquals(other.TermVectors, TermVectors) && DictionaryExtensions.ContentEquals(other.SpatialIndexes, SpatialIndexes)); }
public override bool Equals(IndexQuery <Dictionary <string, RavenJToken> > other) { return(base.Equals(other) && DictionaryExtensions.ContentEquals(TransformerParameters, other.TransformerParameters)); }
private IndexMergeResults CreateMergeIndexDefinition(List <MergeProposal> indexDataForMerge) { var indexMergeResults = new IndexMergeResults(); foreach (var mergeProposal in indexDataForMerge.Where(m => m.ProposedForMerge.Count == 0 && m.MergedData != null)) { indexMergeResults.Unmergables.Add(mergeProposal.MergedData.IndexName, mergeProposal.MergedData.Comment); } foreach (var mergeProposal in indexDataForMerge) { if (mergeProposal.ProposedForMerge.Count == 0) { continue; } var mergeSuggestion = new MergeSuggestions(); var selectExpressionDict = new Dictionary <string, Expression>(); foreach (var curProposedData in mergeProposal.ProposedForMerge) { foreach (var curExpr in curProposedData.SelectExpressions) { selectExpressionDict[curExpr.Key] = curExpr.Value; } mergeSuggestion.CanMerge.Add(curProposedData.IndexName); DataDictionaryMerge(mergeSuggestion.MergedIndex.Stores, curProposedData.Stores); DataDictionaryMerge(mergeSuggestion.MergedIndex.Indexes, curProposedData.Indexes); DataDictionaryMerge(mergeSuggestion.MergedIndex.Analyzers, curProposedData.Analyzers); DataDictionaryMerge(mergeSuggestion.MergedIndex.SortOptions, curProposedData.SortOptions); DataDictionaryMerge(mergeSuggestion.MergedIndex.Suggestions, curProposedData.Suggestions); DataDictionaryMerge(mergeSuggestion.MergedIndex.TermVectors, curProposedData.TermVectors); DataDictionaryMerge(mergeSuggestion.MergedIndex.SpatialIndexes, curProposedData.SpatialIndexes); var fields1 = mergeSuggestion.MergedIndex.Fields; var fields2 = curProposedData.Index.Fields; mergeSuggestion.MergedIndex.Fields = fields1.Union(fields2).ToList(); } mergeSuggestion.Collection = mergeProposal.ProposedForMerge[0].Collection ?? mergeProposal.ProposedForMerge[0].FromExpression.ToString(); mergeSuggestion.MergedIndex.Map = mergeProposal.ProposedForMerge[0].BuildExpression(selectExpressionDict); if (mergeProposal.ProposedForMerge.Count > 1) { var matchingExistingIndexes = mergeProposal.ProposedForMerge.Where(x => AreSelectClausesTheSame(x, selectExpressionDict) && DictionaryExtensions.ContentEquals(x.Stores, mergeSuggestion.MergedIndex.Stores) && DictionaryExtensions.ContentEquals(x.Indexes, mergeSuggestion.MergedIndex.Indexes) && DictionaryExtensions.ContentEquals(x.Analyzers, mergeSuggestion.MergedIndex.Analyzers) && DictionaryExtensions.ContentEquals(x.SortOptions, mergeSuggestion.MergedIndex.SortOptions) && DictionaryExtensions.ContentEquals(x.Suggestions, mergeSuggestion.MergedIndex.Suggestions) && DictionaryExtensions.ContentEquals(x.TermVectors, mergeSuggestion.MergedIndex.TermVectors) && DictionaryExtensions.ContentEquals(x.SpatialIndexes, mergeSuggestion.MergedIndex.SpatialIndexes)) .OrderBy(x => x.IndexName.StartsWith("Auto/", StringComparison.InvariantCultureIgnoreCase)) .ToList(); if (matchingExistingIndexes.Count > 0) { var surpassingIndex = matchingExistingIndexes.First(); mergeSuggestion.SurpassingIndex = surpassingIndex.IndexName; mergeSuggestion.MergedIndex = null; mergeSuggestion.CanMerge.Clear(); mergeSuggestion.CanDelete = mergeProposal.ProposedForMerge.Except(new[] { surpassingIndex }).Select(x => x.IndexName).ToList(); } indexMergeResults.Suggestions.Add(mergeSuggestion); } if ((mergeProposal.ProposedForMerge.Count == 1) && (mergeProposal.ProposedForMerge[0].IsSuitedForMerge == false)) { const string comment = "Can't find any other index to merge this with"; indexMergeResults.Unmergables.Add(mergeProposal.ProposedForMerge[0].IndexName, comment); } } indexMergeResults = ExcludePartialResults(indexMergeResults); return(indexMergeResults); }
protected bool Equals(IndexConfiguration other) { return(DictionaryExtensions.ContentEquals(this, other)); }
public IndexDefinitionCompareDifferences Compare(IndexDefinition other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } var result = IndexDefinitionCompareDifferences.None; if (ReferenceEquals(this, other)) { return(result); } if (Equals(IndexId, other.IndexId) == false) { result |= IndexDefinitionCompareDifferences.IndexId; } if (Maps.SequenceEqual(other.Maps) == false) { if (Maps.SequenceEqual(other.Maps, IndexPrettyPrinterEqualityComparer.Instance)) { result |= IndexDefinitionCompareDifferences.MapsFormatting; } else { result |= IndexDefinitionCompareDifferences.Maps; } } if (Equals(Reduce, other.Reduce) == false) { if (IndexPrettyPrinterEqualityComparer.Instance.Equals(Reduce, other.Reduce)) { result |= IndexDefinitionCompareDifferences.ReduceFormatting; } else { result |= IndexDefinitionCompareDifferences.Reduce; } } if (DictionaryExtensions.ContentEquals(other.Fields, Fields) == false) { result |= IndexDefinitionCompareDifferences.Fields; } bool configurationEquals; if (other._configuration == null && _configuration == null) { configurationEquals = true; } else if (other._configuration != null) { configurationEquals = other._configuration.Equals(_configuration); } else { configurationEquals = _configuration.Equals(other._configuration); } if (configurationEquals == false) { result |= IndexDefinitionCompareDifferences.Configuration; } return(result); }