Inheritance: PropertyLiteral
Example #1
0
        private Query CompileBinaryExpression(PropertyLiteral left, Operator op, Literal right)
        {
            //PropertyLiteral left = expression.BinExp.LeftValue;
            //Operator op = expression.BinExp.Operator;
            //Literal right = expression.BinExp.RightValue;

            if (!right.IsValue)
                throw new NotSupportedException();

            var formatterName = left.DataType.ToString();
            if (left.Name == "Path" && op == Operator.StartsWith)
                return CompileInTreeQuery((string)right.Value);

            var leftName = CompileLeftValue(left);
            var rightValue = CompileLiteralValue(right.Value, formatterName);
            Term rightTerm = CreateRightTerm(leftName, op, rightValue);
            Term minTerm;
            Term maxTerm;
            switch (op)
            {
                case Operator.StartsWith:                                  // left:right*
                    return new PrefixQuery(rightTerm);
                case Operator.EndsWith:                                    // left:*right
                case Operator.Contains:                                    // left:*right*
                    return new WildcardQuery(rightTerm);
                case Operator.Equal:                                       // left:right
                    return new TermQuery(rightTerm);
                case Operator.NotEqual:                                    // -(left:right)
                    throw new NotSupportedException("##Wrong optimizer");
                case Operator.LessThan:                                    // left:{minValue TO right}
                    minTerm = new Term(leftName, CompileMinValue(left));
                    return new RangeQuery(minTerm, rightTerm, false);
                case Operator.GreaterThan:                                 // left:{right TO maxValue}
                    maxTerm = new Term(leftName, CompileMaxValue(left));
                    return new RangeQuery(rightTerm, maxTerm, false);
                case Operator.LessThanOrEqual:                             // left:[minValue TO right]
                    minTerm = new Term(leftName, CompileMinValue(left));
                    return new RangeQuery(minTerm, rightTerm, true);
                case Operator.GreaterThanOrEqual:                          // left:[right TO maxValue]
                    maxTerm = new Term(leftName, CompileMaxValue(left));
                    return new RangeQuery(rightTerm, maxTerm, true);
                default:
                    throw new NotImplementedException();
            }
        }
Example #2
0
		public BinaryExpression(NodeAttribute property, Operator op, NodeAttribute value)
		{
			_leftValue = new PropertyLiteral(property);
			_operator = op;
			_rightValue = new Literal(value);
		}
Example #3
0
 public BinaryExpression(NodeAttribute property, Operator op, NodeAttribute value)
 {
     _leftValue  = new PropertyLiteral(property);
     _operator   = op;
     _rightValue = new Literal(value);
 }
Example #4
0
		public BinaryExpression(PropertyType property, Operator op, PropertyType value)
		{
			_leftValue = new PropertyLiteral(property);
			_operator = op;
			_rightValue = new Literal(value);
		}
Example #5
0
 public BinaryExpression(PropertyType property, Operator op, PropertyType value)
 {
     _leftValue  = new PropertyLiteral(property);
     _operator   = op;
     _rightValue = new Literal(value);
 }