private void ExpandDomainsIfNeeded(Dictionary <MemberPath, CellConstantSet> domainMapForMembers) { // For the S-side, we always says that NOT(...) is // present. For example, if we are told "C", "P", we assume // that NOT(C, P) is possibly present in that column foreach (var path in domainMapForMembers.Keys) { var possibleValues = domainMapForMembers[path]; if (path.IsScalarType() && possibleValues.Any(c => c is NegatedConstant) == false) { if (MetadataHelper.HasDiscreteDomain(path.EdmType)) { // for a discrete domain, add all values that are not currently represented // in the domain var completeDomain = Domain.DeriveDomainFromMemberPath(path, m_edmItemCollection, true /* leaveDomainUnbounded */); possibleValues.Unite(completeDomain); } else { // for a non-discrete domain, add NOT("C", "P") var negatedConstant = new NegatedConstant(possibleValues); possibleValues.Add(negatedConstant); } } } }
internal bool ContainsNotNull() { NegatedConstant negatedConstant = Domain.GetNegatedConstant((IEnumerable <Constant>) this.m_domain); if (negatedConstant != null) { return(negatedConstant.Contains(Constant.Null)); } return(false); }
protected override bool IsEqualTo(Constant right) { NegatedConstant negatedConstant = right as NegatedConstant; if (negatedConstant == null) { return(false); } return(this.m_negatedDomain.SetEquals(negatedConstant.m_negatedDomain)); }
private static NegatedConstant GetNegatedConstant(IEnumerable <Constant> constants) { NegatedConstant negatedConstant1 = (NegatedConstant)null; foreach (Constant constant in constants) { NegatedConstant negatedConstant2 = constant as NegatedConstant; if (negatedConstant2 != null) { negatedConstant1 = negatedConstant2; } } return(negatedConstant1); }
// requires: constants has at most one NegatedCellConstant // effects: Returns the NegatedCellConstant in this if any. Else // returns null private static NegatedConstant GetNegatedConstant(IEnumerable <Constant> constants) { NegatedConstant result = null; foreach (var constant in constants) { var negated = constant as NegatedConstant; if (negated != null) { Debug.Assert(result == null, "Multiple negated cell constants?"); result = negated; } } return(result); }
private void AsCql( Action <NegatedConstant, IEnumerable <Constant> > negatedConstantAsCql, Action <Set <Constant> > varInDomain, Action varIsNotNull, Action varIsNull, bool skipIsNotNull) { NegatedConstant negatedConstant = (NegatedConstant)this.Domain.Values.FirstOrDefault <Constant>((Func <Constant, bool>)(c => c is NegatedConstant)); if (negatedConstant != null) { negatedConstantAsCql(negatedConstant, this.Domain.Values); } else { Set <Constant> set = new Set <Constant>(this.Domain.Values, Constant.EqualityComparer); bool flag1 = false; if (set.Contains(Constant.Null)) { flag1 = true; set.Remove(Constant.Null); } if (set.Contains(Constant.Undefined)) { flag1 = true; set.Remove(Constant.Undefined); } bool flag2 = !skipIsNotNull && this.RestrictedMemberSlot.MemberPath.IsNullable; if (set.Count > 0) { varInDomain(set); } if (flag2) { varIsNotNull(); } if (!flag1) { return; } varIsNull(); } }
private static Set <Constant> DeterminePossibleValues(IEnumerable <Constant> domain) { Set <Constant> set = new Set <Constant>(Constant.EqualityComparer); foreach (Constant element1 in domain) { NegatedConstant negatedConstant = element1 as NegatedConstant; if (negatedConstant != null) { foreach (Constant element2 in negatedConstant.Elements) { set.Add(element2); } } else { set.Add(element1); } } return(set); }
private void ExpandDomainsIfNeeded( Dictionary <MemberPath, Set <Constant> > domainMapForMembers) { foreach (MemberPath key in domainMapForMembers.Keys) { Set <Constant> domainMapForMember = domainMapForMembers[key]; if (key.IsScalarType() && !domainMapForMember.Any <Constant>((Func <Constant, bool>)(c => c is NegatedConstant))) { if (MetadataHelper.HasDiscreteDomain(key.EdmType)) { Set <Constant> set = Domain.DeriveDomainFromMemberPath(key, this.m_edmItemCollection, true); domainMapForMember.Unite((IEnumerable <Constant>)set); } else { NegatedConstant negatedConstant = new NegatedConstant((IEnumerable <Constant>)domainMapForMember); domainMapForMember.Add((Constant)negatedConstant); } } } }
internal static Set <Constant> ExpandNegationsInDomain( IEnumerable <Constant> domain, IEnumerable <Constant> otherPossibleValues) { Set <Constant> possibleValues = Domain.DeterminePossibleValues(domain, otherPossibleValues); Set <Constant> set1 = new Set <Constant>(Constant.EqualityComparer); foreach (Constant element in domain) { NegatedConstant negatedConstant = element as NegatedConstant; if (negatedConstant != null) { set1.Add((Constant) new NegatedConstant((IEnumerable <Constant>)possibleValues)); Set <Constant> set2 = possibleValues.Difference(negatedConstant.Elements); set1.AddRange((IEnumerable <Constant>)set2); } else { set1.Add(element); } } return(set1); }
private void ExpandDomainsIfNeeded(Dictionary<MemberPath, CellConstantSet> domainMapForMembers) { // For the S-side, we always says that NOT(...) is // present. For example, if we are told "C", "P", we assume // that NOT(C, P) is possibly present in that column foreach (var path in domainMapForMembers.Keys) { var possibleValues = domainMapForMembers[path]; if (path.IsScalarType() && possibleValues.Any(c => c is NegatedConstant) == false) { if (MetadataHelper.HasDiscreteDomain(path.EdmType)) { // for a discrete domain, add all values that are not currently represented // in the domain var completeDomain = Domain.DeriveDomainFromMemberPath(path, m_edmItemCollection, true /* leaveDomainUnbounded */); possibleValues.Unite(completeDomain); } else { // for a non-discrete domain, add NOT("C", "P") var negatedConstant = new NegatedConstant(possibleValues); possibleValues.Add(negatedConstant); } } } }