All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.org.apache.calcite.util.trace.CalciteTrace Maven / Gradle / Ivy

There is a newer version: 5.5.0
Show newest version
/*
 * 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 com.hazelcast.org.apache.calcite.util.trace;

import com.hazelcast.org.apache.calcite.linq4j.function.Function2;
import com.hazelcast.org.apache.calcite.linq4j.function.Functions;
import com.hazelcast.org.apache.calcite.plan.AbstractRelOptPlanner;
import com.hazelcast.org.apache.calcite.plan.RelImplementor;
import com.hazelcast.org.apache.calcite.plan.RelOptPlanner;
import com.hazelcast.org.apache.calcite.prepare.Prepare;

import com.hazelcast.org.checkerframework.checker.nullness.qual.Nullable;
import com.hazelcast.org.slf4j.Logger;
import com.hazelcast.org.slf4j.LoggerFactory;

import java.io.File;

/**
 * Contains all of the {@link com.hazelcast.org.slf4j.Logger tracers} used within
 * com.hazelcast.org.apache.calcite class libraries.
 *
 * 

Note to developers

* *

Please ensure that every tracer used in com.hazelcast.org.apache.calcite is added to * this class as a public static final member called * componentTracer. For example, {@link #getPlannerTracer} is the * tracer used by all classes which take part in the query planning process. * *

The javadoc in this file is the primary source of information on what * tracers are available, so the javadoc against each tracer member must be an * up-to-date description of what that tracer does. * *

In the class where the tracer is used, create a private (or * perhaps protected) static final member called * tracer. */ public abstract class CalciteTrace { //~ Static fields/initializers --------------------------------------------- /** * The "com.hazelcast.org.apache.calcite.sql.parser" tracer reports parser events in * {@link com.hazelcast.org.apache.calcite.sql.parser.SqlParser} and other classes at DEBUG. */ public static final Logger PARSER_LOGGER = getParserTracer(); private static final ThreadLocal<@Nullable Function2> DYNAMIC_HANDLER = ThreadLocal.withInitial(Functions::ignore2); //~ Methods ---------------------------------------------------------------- /** * The "com.hazelcast.org.apache.calcite.plan.RelOptPlanner" tracer prints the query * optimization process. * *

Levels: * *

    *
  • {@link Logger#debug(String)} (formerly FINE) prints rules as they fire; *
  • {@link Logger#trace(String)} (formerly FINER) prints and validates the whole expression * pool and rule queue as each rule fires; *
  • {@link Logger#trace(String)} (formerly FINEST) also prints finer details like rule * importances. *
*/ public static Logger getPlannerTracer() { return LoggerFactory.getLogger(RelOptPlanner.class.getName()); } /** * Reports volcano planner optimization task events. */ public static Logger getPlannerTaskTracer() { return LoggerFactory.getLogger("com.hazelcast.org.apache.calcite.plan.volcano.task"); } /** * The "com.hazelcast.org.apache.calcite.prepare.Prepare" tracer prints the generated * program at DEBUG (formerly, FINE) or higher. */ public static Logger getStatementTracer() { return LoggerFactory.getLogger(Prepare.class.getName()); } /** * The "com.hazelcast.org.apache.calcite.rel.RelImplementorImpl" tracer reports when * expressions are bound to variables (DEBUG, formerly FINE) */ public static Logger getRelImplementorTracer() { return LoggerFactory.getLogger(RelImplementor.class); } /** * The tracer "com.hazelcast.org.apache.calcite.sql.timing" traces timing for * various stages of query processing. * * @see CalciteTimingTracer */ public static Logger getSqlTimingTracer() { return LoggerFactory.getLogger("com.hazelcast.org.apache.calcite.sql.timing"); } /** * The "com.hazelcast.org.apache.calcite.sql.parser" tracer reports parse events. */ public static Logger getParserTracer() { return LoggerFactory.getLogger("com.hazelcast.org.apache.calcite.sql.parser"); } /** * The "com.hazelcast.org.apache.calcite.sql2rel" tracer reports parse events. */ public static Logger getSqlToRelTracer() { return LoggerFactory.getLogger("com.hazelcast.org.apache.calcite.sql2rel"); } public static Logger getRuleAttemptsTracer() { return LoggerFactory.getLogger( AbstractRelOptPlanner.class.getName() + ".rule_execution_summary" ); } /** * The tracers report important/useful information related with the execution * of unit tests. */ public static Logger getTestTracer(Class testClass) { return LoggerFactory.getLogger(testClass.getName()); } /** * Thread-local handler that is called with dynamically generated Java code. * It exists for unit-testing. * The handler is never null; the default handler does nothing. */ public static ThreadLocal<@Nullable Function2> getDynamicHandler() { return DYNAMIC_HANDLER; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy