sachouche commented on a change in pull request #1330: DRILL-6147: Adding Columnar Parquet Batch Sizing functionality URL: https://github.com/apache/drill/pull/1330#discussion_r199036942
########## File path: exec/java-exec/src/main/java/org/apache/drill/exec/util/record/RecordBatchStats.java ########## @@ -0,0 +1,225 @@ +/* + * 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.util.record; + +import org.apache.drill.common.types.TypeProtos.MajorType; +import org.apache.drill.exec.ExecConstants; +import org.apache.drill.exec.memory.BufferAllocator; +import org.apache.drill.exec.ops.FragmentContext; +import org.apache.drill.exec.ops.FragmentContextImpl; +import org.apache.drill.exec.ops.OperatorContext; +import org.apache.drill.exec.proto.ExecProtos.FragmentHandle; +import org.apache.drill.exec.proto.helper.QueryIdHelper; +import org.apache.drill.exec.record.MaterializedField; +import org.apache.drill.exec.record.RecordBatch; +import org.apache.drill.exec.record.RecordBatchSizer; +import org.apache.drill.exec.record.RecordBatchSizer.ColumnSize; + +/** + * Utility class to capture key record batch statistics. + */ +public final class RecordBatchStats { + /** A prefix for all batch stats to simplify search */ + public static final String BATCH_STATS_PREFIX = "BATCH_STATS"; + + /** Helper class which loads contextual record batch logging options */ + public static final class RecordBatchStatsContext { + private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(RecordBatchStatsContext.class); + + /** batch size logging for all readers */ + private final boolean enableBatchSzLogging; + /** Fine grained batch size logging */ + private final boolean enableFgBatchSzLogging; + /** Unique Operator Identifier */ + private final String contextOperatorId; + + /** + * @param options options manager + */ + public RecordBatchStatsContext(FragmentContext context, OperatorContext oContext) { + enableBatchSzLogging = context.getOptions().getBoolean(ExecConstants.STATS_LOGGING_BATCH_SIZE_OPTION); + enableFgBatchSzLogging = context.getOptions().getBoolean(ExecConstants.STATS_LOGGING_FG_BATCH_SIZE_OPTION); + contextOperatorId = new StringBuilder() + .append(getQueryId(context)) + .append(":") + .append(oContext.getStats().getId()) + .toString(); + } + + /** + * @return the enableBatchSzLogging + */ + public boolean isEnableBatchSzLogging() { + return enableBatchSzLogging || enableFgBatchSzLogging || logger.isDebugEnabled(); + } + + /** + * @return the enableFgBatchSzLogging + */ + public boolean isEnableFgBatchSzLogging() { + return enableFgBatchSzLogging || logger.isDebugEnabled(); + } + + /** + * @return indicates whether stats messages should be logged in info or debug level + */ + public boolean useInfoLevelLogging() { + return isEnableBatchSzLogging() && !logger.isDebugEnabled(); Review comment: please see response above. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
