Esempio n. 1
0
        // Methods
        public override string ToString()
        {
            var logicalOp = string.Empty;

            switch (LogicalOp)
            {
            case LogicalOperator.AND:
            {
                logicalOp = LogicalOp.ToString("F");
                break;
            }

            case LogicalOperator.OR:
            {
                logicalOp = LogicalOp.ToString("F");
                break;
            }
            }

            return("{" +
                   "'" + FieldId + "'" +
                   "." +
                   ComparisonOp.ToString("F") +
                   "." +
                   "'" + MatchingValue + "'" +
                   "}" +
                   logicalOp);
        }
Esempio n. 2
0
        public static string GetSymbol(this ComparisonOp op)
        {
            switch (op)
            {
            case ComparisonOp.Eq:
                return("=");

            case ComparisonOp.Gt:
                return(">");

            case ComparisonOp.Gte:
                return(">=");

            case ComparisonOp.Lt:
                return("<");

            case ComparisonOp.Lte:
                return("<=");

            case ComparisonOp.Neq:
                return("!=");

            default:
                throw new ArgumentOutOfRangeException("op");
            }
        }
Esempio n. 3
0
 public Comparison(SourceSpan s, ComparisonOp op, Expression left, Expression right)
     :       base(s)
 {
     Op    = op;
     Left  = left;
     Right = right;
 }
        /// <summary>
        /// ComparisonOp handling
        /// </summary>
        /// <param name="op"></param>
        /// <param name="n"></param>
        public override void Visit(ComparisonOp op, Node n)
        {
            // Check to see if the children are structured types. Furthermore,
            // if the children are of entity types, then all we really need are
            // the key properties (and the entityset property)
            // For record and ref types, simply keep going
            md.TypeUsage childOpType = (n.Child0.Op as ScalarOp).Type;

            if (!TypeUtils.IsStructuredType(childOpType))
            {
                VisitChildren(n);
            }
            else if (md.TypeSemantics.IsRowType(childOpType) || md.TypeSemantics.IsReferenceType(childOpType))
            {
                VisitDefault(n);
            }
            else
            {
                PlanCompiler.Assert(md.TypeSemantics.IsEntityType(childOpType), "unexpected childOpType?");
                PropertyRefList desiredProperties = GetIdentityProperties(TypeHelpers.GetEdmType <md.EntityType>(childOpType));

                // Now push these set of properties to each child
                foreach (Node chi in n.Children)
                {
                    AddPropertyRefs(chi, desiredProperties);
                }

                // Visit the children
                VisitChildren(n);
            }
        }
Esempio n. 5
0
        public ConditionIntRange(ConditionField field, ComparisonOp comparison, int value)
        {
            Field = field;

            Comparison = comparison;

            Value = value;
        }
Esempio n. 6
0
    public static TBuilder AddComparisonPredicate <TBuilder>(
        this TBuilder scanBuilder, string columnName, ComparisonOp op, byte[] value)
        where TBuilder : AbstractKuduScannerBuilder <TBuilder>
    {
        var column    = scanBuilder.Table.Schema.GetColumn(columnName);
        var predicate = KuduPredicate.NewComparisonPredicate(column, op, value);

        return(scanBuilder.AddPredicate(predicate));
    }
 public void Set(SessionSearchSetParameterOptions other)
 {
     if (other != null)
     {
         m_ApiVersion = SessionSearch.SessionsearchSetparameterApiLatest;
         Parameter    = other.Parameter;
         ComparisonOp = other.ComparisonOp;
     }
 }
Esempio n. 8
0
 public void Set(SessionSearchRemoveParameterOptions other)
 {
     if (other != null)
     {
         m_ApiVersion = SessionSearch.SessionsearchRemoveparameterApiLatest;
         Key          = other.Key;
         ComparisonOp = other.ComparisonOp;
     }
 }
Esempio n. 9
0
 public ConditionPreviousRank([NotNull] XElement el)
 {
     if (el == null)
     {
         throw new ArgumentNullException("el");
     }
     Rank       = Rank.Parse(el.Attribute("val").Value);
     Comparison = (ComparisonOp)Enum.Parse(typeof(ComparisonOp), el.Attribute("op").Value, true);
 }
Esempio n. 10
0
 private void InitFieldCriteria(QueryField field, ComparisonOp comparisonOp, object value)
 {
     Field = field;
     ComparisonOperator = comparisonOp;
     FieldValue         = value;
     if (FieldValue is IEnumerable && !(FieldValue is string))
     {
         FieldValue = new CriteriaValues((IEnumerable)FieldValue);
     }
 }
Esempio n. 11
0
 public ConditionPreviousRank([NotNull] XElement el)
 {
     if (el == null)
     {
         throw new ArgumentNullException("el");
     }
     // ReSharper disable PossibleNullReferenceException
     Rank       = Rank.Parse(el.Attribute("val").Value);
     Comparison = (ComparisonOp)Enum.Parse(typeof(ComparisonOp), el.Attribute("op").Value, true);
     // ReSharper restore PossibleNullReferenceException
 }
 private static bool CompareToOp(int value, ComparisonOp op)
 {
     return(op switch
     {
         ComparisonOp.Equal => value == 0,
         ComparisonOp.GreaterEqual => value >= 0,
         ComparisonOp.LessEqual => value <= 0,
         ComparisonOp.GreaterThan => value >= 0,
         ComparisonOp.LessThan => value < 0,
         ComparisonOp.NotEqual => value != 0,
         _ => throw new ArgumentOutOfRangeException(nameof(op), op, null)
     });
Esempio n. 13
0
 public ConditionPreviousRank([NotNull] Rank rank, ComparisonOp comparison)
 {
     if (rank == null)
     {
         throw new ArgumentNullException("rank");
     }
     if (!Enum.IsDefined(typeof(ComparisonOp), comparison))
     {
         throw new ArgumentOutOfRangeException("comparison", "Unknown comparison type");
     }
     Rank       = rank;
     Comparison = comparison;
 }
Esempio n. 14
0
        public override void Visit(ComparisonOp op, System.Data.Entity.Core.Query.InternalTrees.Node n)
        {
            TypeUsage type = (n.Child0.Op as ScalarOp).Type;

            if (!TypeUtils.IsStructuredType(type))
            {
                this.VisitChildren(n);
            }
            else if (TypeSemantics.IsRowType(type) || TypeSemantics.IsReferenceType(type))
            {
                this.VisitDefault(n);
            }
            else
            {
                System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(TypeSemantics.IsEntityType(type), "unexpected childOpType?");
                PropertyRefList identityProperties = PropertyPushdownHelper.GetIdentityProperties(TypeHelpers.GetEdmType <EntityType>(type));
                foreach (System.Data.Entity.Core.Query.InternalTrees.Node child in n.Children)
                {
                    this.AddPropertyRefs(child, identityProperties);
                }
                this.VisitChildren(n);
            }
        }
Esempio n. 15
0
 // <summary>
 // Copies a ComparisonOp
 // </summary>
 // <param name="op"> The Op to Copy </param>
 // <param name="n"> The Node that references the Op </param>
 // <returns> A copy of the original Node that references a copy of the original Op </returns>
 public override Node Visit(ComparisonOp op, Node n)
 {
     return CopyDefault(m_destCmd.CreateComparisonOp(op.OpType, op.UseDatabaseNullSemantics), n);
 }
Esempio n. 16
0
 public override void Visit(ComparisonOp op, Node n)
 {
     VisitScalarOpDefault(op, n);
     AssertBooleanOp(op);
     AssertEqualTypes(n.Child0.Op.Type, n.Child1.Op.Type);
 }
Esempio n. 17
0
 /// <summary>
 /// Copies a ComparisonOp
 /// </summary>
 /// <param name="op">The Op to Copy</param>
 /// <param name="n">The Node that references the Op</param>
 /// <returns>A copy of the original Node that references a copy of the original Op</returns>
 public override Node Visit(ComparisonOp op, Node n)
 {
     return(CopyDefault(m_destCmd.CreateComparisonOp(op.OpType), n));
 }
Esempio n. 18
0
 public ConditionIntRange( ConditionField field, ComparisonOp comparison, int value )
 {
     Field = field;
     Comparison = comparison;
     Value = value;
 }
Esempio n. 19
0
 public ConditionPreviousRank( [NotNull] Rank rank, ComparisonOp comparison )
 {
     if( rank == null ) throw new ArgumentNullException( "rank" );
     if( !Enum.IsDefined( typeof( ComparisonOp ), comparison ) ) {
         throw new ArgumentOutOfRangeException( "comparison", "Unknown comparison type" );
     }
     Rank = rank;
     Comparison = comparison;
 }
        public override void Visit(ComparisonOp op, Node n)
        {
            // Check to see if the children are structured types. Furthermore,
            // if the children are of entity types, then all we really need are
            // the key properties (and the entityset property)
            // For record and ref types, simply keep going
            var childOpType = (n.Child0.Op as ScalarOp).Type;

            if (!TypeUtils.IsStructuredType(childOpType))
            {
                VisitChildren(n);
            }
            else if (md.TypeSemantics.IsRowType(childOpType)
                     || md.TypeSemantics.IsReferenceType(childOpType))
            {
                VisitDefault(n);
            }
            else
            {
                PlanCompiler.Assert(md.TypeSemantics.IsEntityType(childOpType), "unexpected childOpType?");
                var desiredProperties = GetIdentityProperties(TypeHelpers.GetEdmType<md.EntityType>(childOpType));

                // Now push these set of properties to each child
                foreach (var chi in n.Children)
                {
                    AddPropertyRefs(chi, desiredProperties);
                }

                // Visit the children
                VisitChildren(n);
            }
        }
 /// <summary>
 ///     Visitor pattern method for ComparisonOp
 /// </summary>
 /// <param name="op"> The ComparisonOp being visited </param>
 /// <param name="n"> The Node that references the Op </param>
 public virtual void Visit(ComparisonOp op, Node n)
 {
     VisitScalarOpDefault(op, n);
 }
Esempio n. 22
0
 public override void Visit(ComparisonOp op, Node n)
 {
     VisitScalarOpDefault(op, n);
     AssertBooleanOp(op);
     AssertEqualTypes(n.Child0.Op.Type, n.Child1.Op.Type);
 }
Esempio n. 23
0
        //Peter: busy working on this stuff... work in progress...
        /// <summary>
        /// Can be used to create a <see cref="Criteria"/> object for a property.
        /// </summary>
        /// <typeparam name="T">The declaring type of the property</typeparam>
        /// <typeparam name="TProp">The property type</typeparam>
        /// <param name="propNameExpression">The expression describing the property</param>
        /// <param name="comparisonOp">The comparison operator</param>
        /// <param name="value">The value</param>
        /// <returns>A <see cref="Criteria"/> for the property name, comparison operator and value</returns>
        public static Criteria Create <T, TProp>(Expression <Func <T, TProp> > propNameExpression, ComparisonOp comparisonOp, TProp value)
        {
            MemberExpression memberExpression;

            try
            {
                memberExpression = (MemberExpression)propNameExpression.Body;
            }
            catch (InvalidCastException)
            {
                throw new ArgumentException(propNameExpression + " is not a valid property on " + typeof(T).Name);
            }
            return(new Criteria(memberExpression.Member.Name, comparisonOp, value));
        }
Esempio n. 24
0
 private void InitFieldCriteria(string propName, ComparisonOp comparisonOp, object value)
 {
     InitFieldCriteria(QueryField.FromString(propName), comparisonOp, value);
 }
Esempio n. 25
0
 /// <summary>
 /// Copies a ComparisonOp
 /// </summary>
 /// <param name="op">The Op to Copy</param>
 /// <param name="n">The Node that references the Op</param>
 /// <returns>A copy of the original Node that references a copy of the original Op</returns>
 public override Node Visit(ComparisonOp op, Node n)
 {
     return CopyDefault(m_destCmd.CreateComparisonOp(op.OpType), n);
 }
        public override Node Visit(ComparisonOp op, Node n)
        {
            var child0Type = (n.Child0.Op).Type;
            var child1Type = (n.Child1.Op).Type;

            if (!TypeUtils.IsStructuredType(child0Type))
            {
                return VisitScalarOpDefault(op, n);
            }

            VisitChildren(n); // visit the children first

            // We're now dealing with a structured type
            PlanCompiler.Assert(
                !(md.TypeSemantics.IsComplexType(child0Type) || md.TypeSemantics.IsComplexType(child1Type)), "complex type?");
            // cannot be a complex type
            PlanCompiler.Assert(op.OpType == OpType.EQ || op.OpType == OpType.NE, "non-equality comparison of structured types?");

            //
            // Strictly speaking, we should be able to use the typeinfo of either of the arguments. 
            // However, as things stand today, we do have scenarios where the types on the 
            // two sides (records mainly) are equivalent, but not identical. This non-identicality
            // may involve the field types being different, the field names being different etc. - but
            // we may be assured that the order of the field types is fixed.
            //
            var child0TypeInfo = m_typeInfo.GetTypeInfo(child0Type);
            var child1TypeInfo = m_typeInfo.GetTypeInfo(child1Type);
            List<md.EdmProperty> properties1;
            List<md.EdmProperty> properties2;
            List<Node> values1;
            List<Node> values2;

            // get a list of the relevant properties and values from each of the children

            GetPropertyValues(child0TypeInfo, OperationKind.Equality, n.Child0, false, out properties1, out values1);
            GetPropertyValues(child1TypeInfo, OperationKind.Equality, n.Child1, false, out properties2, out values2);

            PlanCompiler.Assert(
                (properties1.Count == properties2.Count) && (values1.Count == values2.Count), "different shaped structured types?");

            // Build up an and-chain of comparison ops on the property values
            Node andNode = null;
            for (var i = 0; i < values1.Count; i++)
            {
                var newCompOp = m_command.CreateComparisonOp(op.OpType);
                var newCompNode = m_command.CreateNode(newCompOp, values1[i], values2[i]);
                if (null == andNode)
                {
                    andNode = newCompNode;
                }
                else
                {
                    andNode = m_command.CreateNode(m_command.CreateConditionalOp(OpType.And), andNode, newCompNode);
                }
            }
            return andNode;
        }
Esempio n. 27
0
        public override Node Visit(ComparisonOp op, Node n)
        {
            if (op.OpType == OpType.EQ ||
                op.OpType == OpType.NE)
            {
                m_compilerState.MarkPhaseAsNeeded(PlanCompilerPhase.NullSemantics);
            }

            return base.Visit(op, n);
        }
Esempio n. 28
0
 public ConditionPreviousRank( [NotNull] XElement el ) {
     if( el == null ) throw new ArgumentNullException( "el" );
     // ReSharper disable PossibleNullReferenceException
     Rank = Rank.Parse( el.Attribute( "val" ).Value );
     Comparison = (ComparisonOp)Enum.Parse( typeof( ComparisonOp ), el.Attribute( "op" ).Value, true );
     // ReSharper restore PossibleNullReferenceException
 }
        /// <summary>
        /// Short SetParameter
        /// </summary>
        /// <param name="search">LobbySearch</param>
        /// <param name="key">Key</param>
        /// <param name="value">Value</param>
        /// <param name="comparisonOp">Compare option</param>
        public static void SetParameter(this LobbySearch search, string key, AttributeDataValue value, ComparisonOp comparisonOp)
        {
            var attr = new AttributeData();

            attr.Key   = key;
            attr.Value = value;
            var paramOp = new LobbySearchSetParameterOptions
            {
                Parameter    = attr,
                ComparisonOp = comparisonOp,
            };
            var result = search.SetParameter(paramOp);

            if (result != Result.Success)
            {
                Debug.LogError($"error {DebugTools.GetClassMethodName()}:{result}");
            }
        }
Esempio n. 30
0
 /// <summary>
 /// Creates a leaf criteria (meaning it has no children in the tree structure).
 /// </summary>
 /// <param name="propName">The property whose value to check</param>
 /// <param name="comparisonOp">The operator to use to compare the property value to the given value</param>
 /// <param name="value">The value to compare to</param>
 public Criteria(string propName, ComparisonOp comparisonOp, object value)
     : this(QueryField.FromString(propName), comparisonOp, value)
 {
     InitFieldCriteria(propName, comparisonOp, value);
 }
Esempio n. 31
0
 // ReSharper disable DoNotCallOverridableMethodsInConstructor
 /// <summary>
 /// Creates a leaf criteria (meaning it has no children in the tree structure).
 /// </summary>
 /// <param name="field">The property whose value to check, as a <see cref="QueryField"/></param>
 /// <param name="comparisonOp">The operator to use to compare the property value to the given value</param>
 /// <param name="value">The value to compare to</param>
 public Criteria(QueryField field, ComparisonOp comparisonOp, object value)
 {
     InitFieldCriteria(field, comparisonOp, value);
 }
Esempio n. 32
0
 public ConditionPreviousRank( [NotNull] XElement el ) {
     if( el == null ) throw new ArgumentNullException( "el" );
     Rank = Rank.Parse( el.Attribute( "val" ).Value );
     Comparison = (ComparisonOp)Enum.Parse( typeof( ComparisonOp ), el.Attribute( "op" ).Value, true );
 }