public void Union(PredicateList other) { if (DC == null) { DC = other.DC; } Positive.UnionWith(other.Positive); Negative.UnionWith(other.Negative); }
/// <summary>Returns all file names referenced by SegmentInfo /// instances matching the provided Directory (ie files /// associated with any "external" segments are skipped). /// The returned collection is recomputed on each /// invocation. /// </summary> public System.Collections.Generic.ICollection <string> Files(Directory dir, bool includeSegmentsFile) { System.Collections.Generic.HashSet <string> files = new System.Collections.Generic.HashSet <string>(); if (includeSegmentsFile) { files.Add(GetCurrentSegmentFileName()); } int size = Count; for (int i = 0; i < size; i++) { SegmentInfo info = Info(i); if (info.dir == dir) { files.UnionWith(Info(i).Files()); } } return(files); }
/// <summary> /// Determines whether a column set is covered by an index. /// </summary> /// <param name="columns">A set of columns.</param> /// <param name="indexColumns">The index columns.</param> /// <param name="indexIncludedColumns">The index columns.</param> /// <returns><c>true</c> if <paramref name="columns"/> is covered by <paramref name="indexColumns"/>; otherwise <c>false</c>.</returns> /// <exception cref="ArgumentNullException"><paramref name="columns"/> or <paramref name="indexColumns"/> or <paramref name="indexIncludedColumns"/> is <c>null</c>.</exception> protected static bool ColumnsHaveIndexWithIncludedColumns(IEnumerable <IDatabaseColumn> columns, IEnumerable <IDatabaseIndexColumn> indexColumns, IEnumerable <IDatabaseColumn> indexIncludedColumns) { if (columns == null) { throw new ArgumentNullException(nameof(columns)); } if (indexColumns == null) { throw new ArgumentNullException(nameof(indexColumns)); } if (indexIncludedColumns == null) { throw new ArgumentNullException(nameof(indexIncludedColumns)); } if (indexIncludedColumns.Empty()) { return(false); } var columnList = columns.ToList(); var indexColumnList = indexColumns.ToList(); var dependentColumns = indexColumnList.SelectMany(ic => ic.DependentColumns).ToList(); var includedColumnList = indexIncludedColumns.ToList(); // can only check for regular indexes, not functional ones (functions may be composed of multiple columns) if (indexColumnList.Count != dependentColumns.Count) { return(false); } var columnNames = new System.Collections.Generic.HashSet <Identifier>(columnList.Select(c => c.Name)); var indexColumnNames = new System.Collections.Generic.HashSet <Identifier>(dependentColumns.Select(ic => ic.Name)); // index won't be completely used or there are extra columns in it if (indexColumnNames.Count > columnNames.Count || indexColumnNames.Any(ic => !columnNames.Contains(ic))) { return(false); } indexColumnNames.UnionWith(includedColumnList.Select(ic => ic.Name)); return(columnNames.IsSubsetOf(indexColumnNames)); }