[ https://issues.apache.org/jira/browse/DRILL-6153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16364904#comment-16364904 ]
ASF GitHub Bot commented on DRILL-6153: --------------------------------------- Github user ppadma commented on a diff in the pull request: https://github.com/apache/drill/pull/1121#discussion_r168325765 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/protocol/OperatorRecordBatch.java --- @@ -0,0 +1,167 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.physical.impl.protocol; + +import java.util.Iterator; + +import org.apache.drill.common.exceptions.UserException; +import org.apache.drill.common.expression.SchemaPath; +import org.apache.drill.exec.ops.FragmentContext; +import org.apache.drill.exec.ops.FragmentContextInterface; +import org.apache.drill.exec.ops.OperatorContext; +import org.apache.drill.exec.physical.base.PhysicalOperator; +import org.apache.drill.exec.record.BatchSchema; +import org.apache.drill.exec.record.CloseableRecordBatch; +import org.apache.drill.exec.record.TypedFieldId; +import org.apache.drill.exec.record.VectorContainer; +import org.apache.drill.exec.record.VectorWrapper; +import org.apache.drill.exec.record.WritableBatch; +import org.apache.drill.exec.record.selection.SelectionVector2; +import org.apache.drill.exec.record.selection.SelectionVector4; + +/** + * Modular implementation of the standard Drill record batch iterator + * protocol. The protocol has two parts: control of the operator and + * access to the record batch. Each is encapsulated in separate + * implementation classes to allow easier customization for each + * situation. The operator internals are, themselves, abstracted to + * yet another class with the steps represented as method calls rather + * than as internal states as in the record batch iterator protocol. + * <p> + * Note that downstream operators make an assumption that the + * same vectors will appear from one batch to the next. That is, + * not only must the schema be the same, but if column "a" appears + * in two batches, the same value vector must back "a" in both + * batches. The <tt>TransferPair</tt> abstraction fails if different + * vectors appear across batches. + */ + +public class OperatorRecordBatch implements CloseableRecordBatch { + static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(OperatorRecordBatch.class); + + private final OperatorDriver driver; + private final BatchAccessor batchAccessor; + + public OperatorRecordBatch(FragmentContext context, PhysicalOperator config, OperatorExec opExec) { + OperatorContext opContext = context.newOperatorContext(config); + opContext.getStats().startProcessing(); + + // Chicken-and-egg binding: the two objects must know about each other. Pass the + // context to the operator exec via a bind method. + + try { + opExec.bind(opContext); + driver = new OperatorDriver(opContext, opExec); + batchAccessor = opExec.batchAccessor(); + } catch (UserException e) { + opContext.close(); + throw e; + } catch (Throwable t) { + opContext.close(); + throw UserException.executionError(t) + .addContext("Exception thrown from", opExec.getClass().getSimpleName() + ".bind()") + .build(logger); + } + finally { + opContext.getStats().stopProcessing(); + } + } + + @Override + public FragmentContext getContext() { + + // Backward compatibility with the full server context. Awkward for testing + + FragmentContext fragmentContext = fragmentContext(); + if (fragmentContext instanceof FragmentContext) { --- End diff -- not clear what we are doing here. why can't we just return fragmentContext ? > Revised operator framework > -------------------------- > > Key: DRILL-6153 > URL: https://issues.apache.org/jira/browse/DRILL-6153 > Project: Apache Drill > Issue Type: Improvement > Reporter: Paul Rogers > Assignee: Paul Rogers > Priority: Major > Fix For: 1.13.0 > > > Adds the core operator framework which is the foundation for the revised scan > operators. This is another incremental part of the batch sizing project. -- This message was sent by Atlassian JIRA (v7.6.3#76005)