Examples of ConstantExpression


Examples of com.facebook.presto.sql.relational.ConstantExpression

        for (RowExpression testValue : values) {
            ByteCodeNode testByteCode = generatorContext.generate(testValue);

            if (testValue instanceof ConstantExpression && ((ConstantExpression) testValue).getValue() != null) {
                ConstantExpression constant = (ConstantExpression) testValue;
                Object object = constant.getValue();
                constantValuesBuilder.add(object);

                try {
                    int hashCode = (int) hashCodeFunction.getCallSite().dynamicInvoker().invoke(object);
                    hashBucketsBuilder.put(hashCode, testByteCode);
                }
                catch (Throwable throwable) {
                    throw new IllegalArgumentException("Error processing IN statement: error calculating hash code for " + object, throwable);
                }
            }
            else {
                defaultBucket.add(testByteCode);
            }
        }
        ImmutableListMultimap<Integer, ByteCodeNode> hashBuckets = hashBucketsBuilder.build();
        ImmutableSet<Object> constantValues = constantValuesBuilder.build();

        LabelNode end = new LabelNode("end");
        LabelNode match = new LabelNode("match");
        LabelNode noMatch = new LabelNode("noMatch");

        LabelNode defaultLabel = new LabelNode("default");

        CompilerContext context = generatorContext.getContext();

        ByteCodeNode switchBlock;
        if (constantValues.size() < 1000) {
            Block switchCaseBlocks = new Block(context);
            LookupSwitch.LookupSwitchBuilder switchBuilder = lookupSwitchBuilder();
            for (Map.Entry<Integer, Collection<ByteCodeNode>> bucket : hashBuckets.asMap().entrySet()) {
                LabelNode label = new LabelNode("inHash" + bucket.getKey());
                switchBuilder.addCase(bucket.getKey(), label);
                Collection<ByteCodeNode> testValues = bucket.getValue();

                Block caseBlock = buildInCase(generatorContext, context, type, label, match, defaultLabel, testValues, false);
                switchCaseBlocks
                        .append(caseBlock.setDescription("case " + bucket.getKey()));
            }
            switchBuilder.defaultCase(defaultLabel);

            switchBlock = new Block(context)
                    .comment("lookupSwitch(hashCode(<stackValue>))")
                    .dup(javaType)
                    .invokeDynamic(hashCodeFunction.getName(), hashCodeFunction.getCallSite().type(), hashCodeFunction.getBindingId())
                    .append(switchBuilder.build())
                    .append(switchCaseBlocks);
        }
        else {
            // TODO: replace Set with fastutils (or similar) primitive sets if types are primitive
            // for huge IN lists, use a Set
            FunctionBinding constant = generatorContext.getBootstrapBinder().bindConstant(constantValues, Set.class);

            switchBlock = new Block(context)
                    .comment("inListSet.contains(<stackValue>)")
                    .append(new IfStatement(context,
                            new Block(context)
                                    .comment("value (+boxing if necessary)")
                                    .dup(javaType)
                                    .append(ByteCodeUtils.boxPrimitive(context, javaType))
                                    .comment("set")
                                    .invokeDynamic(
                                            constant.getName(),
                                            constant.getCallSite().type(),
                                            constant.getBindingId())
                                    // TODO: use invokeVirtual on the set instead. This requires swapping the two elements in the stack
                                    .invokeStatic(CompilerOperations.class, "in", boolean.class, Object.class, Set.class),
                            jump(match),
                            NOP));
        }
View Full Code Here

Examples of com.foundationdb.sql.optimizer.plan.ConstantExpression

        Object resultValue = comparison.get(one.getValue(), two.getValue());
        if (resultValue == RangeEndpoint.RangePointComparison.INVALID_COMPARISON)
            return null;
        boolean resultInclusive = one.isInclusive() || two.isInclusive();
        ConstantExpression resultExpression;
        if (resultValue == one.getValue())
            resultExpression = one.getValueExpression();
        else if (resultValue == two.getValue())
            resultExpression = two.getValueExpression();
        else
View Full Code Here

Examples of com.ocpsoft.pretty.faces.el.ConstantExpression

      if (matcher.matches())
      {
         String name = matcher.group(1);
         String el = matcher.group(2);

         result.setExpression(new ConstantExpression("#{" + el + "}"));
         result.setName(name);
         result.setExpressionIsPlainText(false);
      }
      return result;
   }
View Full Code Here

Examples of com.ocpsoft.pretty.faces.el.ConstantExpression

      Matcher matcher = pattern.matcher(param.getExpression().getELExpression());
      if (matcher.matches())
      {
         String el = matcher.group(1);
         result.setExpression(new ConstantExpression("#{" + el + "}"));
         result.setExpressionIsPlainText(false);
      }
      return result;
   }
View Full Code Here

Examples of com.ocpsoft.pretty.faces.el.ConstantExpression

    }

    @Test
    public void testQueryParameterStringStringString()
    {
        QueryParameter param1 = new QueryParameter("name", "value", new ConstantExpression("expression"));
        assertEquals("name", param1.getName());
        assertEquals("value", param1.getValue());
        assertEquals("expression", param1.getExpression().getELExpression());
    }
View Full Code Here

Examples of com.ocpsoft.pretty.faces.el.ConstantExpression

     * Extra setter method creating a {@link ConstantExpression}.
     * Used only for Digester only.
     */
    public void setValidator(final String validator)
    {
       this.validatorExpression = new ConstantExpression(validator);
    }
View Full Code Here

Examples of com.ocpsoft.pretty.faces.el.ConstantExpression

     * Extra setter method creating a {@link ConstantExpression} for the
     * validatorExpression. Used only for Digester only.
     */
    public void setValidator(String validator)
    {
       this.validatorExpression = new ConstantExpression(validator);
    }
View Full Code Here

Examples of com.ocpsoft.pretty.faces.el.ConstantExpression

     * Extra setter method creating a {@link ConstantExpression}.
     * Used only for Digester only.
     */
    public void setExpression(final String expression)
    {
        this.expression = new ConstantExpression(expression);
    }
View Full Code Here

Examples of com.ocpsoft.pretty.faces.el.ConstantExpression

         pathValidator.setValidatorIds(join(validationAnnotation.validatorIds(), " "));

         // optional validator method
         if (!isBlank(validationAnnotation.validator()))
         {
            pathValidator.setValidatorExpression(new ConstantExpression(validationAnnotation.validator()));
         }

         // add PathValidator to the mapping
         mapping.getPathValidators().add(pathValidator);
View Full Code Here

Examples of com.ocpsoft.pretty.faces.el.ConstantExpression

            queryParam.setOnPostback(queryParamSpec.isOnPostback());

            // optional validator method
            if (!isBlank(queryParamSpec.getValidator()))
            {
               queryParam.setValidatorExpression(new ConstantExpression(queryParamSpec.getValidator()));
            }

            // try to get bean name
            Class<?> clazz = queryParamSpec.getOwnerClass();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.