Github user sudheeshkatkam commented on a diff in the pull request: https://github.com/apache/drill/pull/521#discussion_r68133092 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/ClassGenerator.java --- @@ -215,22 +218,47 @@ public JVar declareVectorValueSetupAndMember(DirectExpression batchName, TypedFi return vv; } + public enum BlkCreateMode { + TRUE, // Create new block + FALSE, // Do not create block; put into existing block. + TRUE_IF_BOUND // Create new block only if # of expressions added hit upper-bound (ExecConstants.CODE_GEN_EXP_IN_METHOD_SIZE) + } + public HoldingContainer addExpr(LogicalExpression ex) { - return addExpr(ex, true); + // default behavior is always to put expression into new block. + return addExpr(ex, BlkCreateMode.TRUE); } - public HoldingContainer addExpr(LogicalExpression ex, boolean rotate) { -// logger.debug("Adding next write {}", ex); - if (rotate) { - rotateBlock(); + public HoldingContainer addExpr(LogicalExpression ex, BlkCreateMode mode) { + if (mode == BlkCreateMode.TRUE || mode == BlkCreateMode.TRUE_IF_BOUND) { + rotateBlock(mode); } + + for (LinkedList<SizedJBlock> b : blocks) { + b.getLast().incCounter(); + } + return evaluationVisitor.addExpr(ex, this); } public void rotateBlock() { - evaluationVisitor.previousExpressions.clear(); - for (LinkedList<JBlock> b : blocks) { - b.add(new JBlock(true, true)); + // default behavior is always to create new block. + rotateBlock(BlkCreateMode.TRUE); + } + + private void rotateBlock(BlkCreateMode mode) { + boolean blockRotated = false; + for (LinkedList<SizedJBlock> b : blocks) { + if (mode == BlkCreateMode.TRUE || + (mode == BlkCreateMode.TRUE_IF_BOUND && + optionManager != null && + b.getLast().getCount() > optionManager.getOption(ExecConstants.CODE_GEN_EXP_IN_METHOD_SIZE).num_val)) { --- End diff -- Drop `.num_val`. The OptionValidator is typed (LongValidator).
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---