congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Hook
Code IndexAdd Tabnine to your IDE (free)

How to use
Hook
in
org.apache.calcite.runtime

Best Java code snippets using org.apache.calcite.runtime.Hook (Showing top 20 results out of 315)

origin: apache/storm

/**
 * StormDataContext Constructor.
 */
public StormDataContext() {
  // Store the time at which the query started executing. The SQL
  // standard says that functions such as CURRENT_TIMESTAMP return the
  // same value throughout the query.
  final Holder<Long> timeHolder = Holder.of(System.currentTimeMillis());
  // Give a hook chance to alter the clock.
  Hook.CURRENT_TIME.run(timeHolder);
  final long time = timeHolder.get();
  final TimeZone timeZone = Calendar.getInstance().getTimeZone();
  final long localOffset = timeZone.getOffset(time);
  final long currentOffset = localOffset;
  ImmutableMap.Builder<Object, Object> builder = ImmutableMap.builder();
  builder.put(Variable.UTC_TIMESTAMP.camelName, time)
      .put(Variable.CURRENT_TIMESTAMP.camelName, time + currentOffset)
      .put(Variable.LOCAL_TIMESTAMP.camelName, time + localOffset)
      .put(Variable.TIME_ZONE.camelName, timeZone);
  map = builder.build();
}
origin: apache/incubator-druid

 @Override
 public void evaluate() throws Throwable
 {
  clearRecordedQueries();
  final Consumer<Object> function = query -> {
   try {
    recordedQueries.add((Query) query);
    log.info(
      "Issued query: %s",
      objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(query)
    );
   }
   catch (Exception e) {
    log.warn(e, "Failed to serialize query: %s", query);
   }
  };
  try (final Hook.Closeable unhook = Hook.QUERY_PLAN.add(function)) {
   base.evaluate();
  }
 }
};
origin: Qihoo360/Quicksql

/** @deprecated Use {@link #addThread(Consumer)}. */
@SuppressWarnings("Guava")
@Deprecated // to be removed in 2.0
public <T, R> Closeable addThread(
  final com.google.common.base.Function<T, R> handler) {
 return addThread((Consumer<T>) handler::apply);
}
origin: org.apache.calcite/calcite-core

@Test public <T> void testReduceCaseNullabilityChange() throws Exception {
 HepProgram program = new HepProgramBuilder()
   .addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
   .addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
   .build();
 try (Hook.Closeable a = Hook.REL_BUILDER_SIMPLIFY.add(Hook.propertyJ(false))) {
  checkPlanning(program,
    "select case when empno = 1 then 1 when 1 IS NOT NULL then 2 else null end as qx "
      + "from emp");
 }
}
origin: Qihoo360/Quicksql

final boolean b = value instanceof Boolean
  && (Boolean) value;
closer.add(Hook.ENABLE_BINDABLE.addThread(Hook.propertyJ(b)));
origin: Qihoo360/Quicksql

/** Adds a property hook. */
public <V> AssertQuery withProperty(Hook hook, V value) {
 return withHook(hook, Hook.propertyJ(value));
}
origin: Qihoo360/Quicksql

if (Hook.ENABLE_BINDABLE.get(false)) {
 return LogicalTableScan.create(cluster, this);
origin: org.apache.calcite/calcite-core

/** Adds a handler for this thread. */
public <T> Closeable addThread(final Consumer<T> handler) {
 //noinspection unchecked
 threadHandlers.get().add((Consumer<Object>) handler);
 return () -> removeThread(handler);
}
origin: Qihoo360/Quicksql

/** Adds a handler for this Hook.
 *
 * <p>Returns a {@link Hook.Closeable} so that you can use the following
 * try-finally pattern to prevent leaks:</p>
 *
 * <blockquote><pre>
 *     final Hook.Closeable closeable = Hook.FOO.add(HANDLER);
 *     try {
 *         ...
 *     } finally {
 *         closeable.close();
 *     }</pre>
 * </blockquote>
 */
public <T> Closeable add(final Consumer<T> handler) {
 //noinspection unchecked
 handlers.add((Consumer<Object>) handler);
 return () -> remove(handler);
}
origin: org.apache.calcite/calcite-core

/** @deprecated Use {@link #addThread(Consumer)}. */
@SuppressWarnings("Guava")
@Deprecated // to be removed in 2.0
public <T, R> Closeable addThread(
  final com.google.common.base.Function<T, R> handler) {
 return addThread((Consumer<T>) handler::apply);
}
origin: org.apache.drill.exec/drill-java-exec

public RelRoot toRel(final SqlNode validatedNode) {
 if (planner == null) {
  planner = new VolcanoPlanner(costFactory, settings);
  planner.setExecutor(new DrillConstExecutor(functions, util, settings));
  planner.clearRelTraitDefs();
  planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
  planner.addRelTraitDef(DrillDistributionTraitDef.INSTANCE);
  planner.addRelTraitDef(RelCollationTraitDef.INSTANCE);
 }
 if (cluster == null) {
  initCluster();
 }
 final SqlToRelConverter sqlToRelConverter =
   new SqlToRelConverter(new Expander(), validator, catalog, cluster, DrillConvertletTable.INSTANCE,
     sqlToRelConverterConfig);
 /*
  * Sets value to false to avoid simplifying project expressions
  * during creating new projects since it may cause changing data mode
  * which causes to assertion errors during type validation
  */
 Hook.REL_BUILDER_SIMPLIFY.add(Hook.propertyJ(false));
 //To avoid unexpected column errors set a value of top to false
 final RelRoot rel = sqlToRelConverter.convertQuery(validatedNode, false, false);
 return rel.withRel(sqlToRelConverter.flattenTypes(rel.rel, true));
}
origin: org.apache.calcite/calcite-core

final boolean b = value instanceof Boolean
  && (Boolean) value;
closer.add(Hook.ENABLE_BINDABLE.addThread(Hook.propertyJ(b)));
origin: org.apache.calcite/calcite-core

/** Adds a property hook. */
public <V> AssertQuery withProperty(Hook hook, V value) {
 return withHook(hook, Hook.propertyJ(value));
}
origin: org.apache.calcite/calcite-core

if (Hook.ENABLE_BINDABLE.get(false)) {
 return LogicalTableScan.create(cluster, this);
origin: Qihoo360/Quicksql

/** Adds a handler for this thread. */
public <T> Closeable addThread(final Consumer<T> handler) {
 //noinspection unchecked
 threadHandlers.get().add((Consumer<Object>) handler);
 return () -> removeThread(handler);
}
origin: org.apache.calcite/calcite-core

/** Adds a handler for this Hook.
 *
 * <p>Returns a {@link Hook.Closeable} so that you can use the following
 * try-finally pattern to prevent leaks:</p>
 *
 * <blockquote><pre>
 *     final Hook.Closeable closeable = Hook.FOO.add(HANDLER);
 *     try {
 *         ...
 *     } finally {
 *         closeable.close();
 *     }</pre>
 * </blockquote>
 */
public <T> Closeable add(final Consumer<T> handler) {
 //noinspection unchecked
 handlers.add((Consumer<Object>) handler);
 return () -> remove(handler);
}
origin: apache/incubator-druid

@SuppressWarnings("unchecked")
private <T> Sequence<T> runQuery(Query<T> query)
{
 Hook.QUERY_PLAN.run(query);
 final String queryId = UUID.randomUUID().toString();
 plannerContext.addNativeQueryId(queryId);
 query = query.withId(queryId)
        .withSqlQueryId(plannerContext.getSqlQueryId());
 final AuthenticationResult authenticationResult = plannerContext.getAuthenticationResult();
 return queryLifecycleFactory.factorize().runSimple(query, authenticationResult, null);
}
origin: Qihoo360/Quicksql

@Before public void before() {
 this.closeable =
   Hook.CONVERTED.addThread(SqlToRelConverterExtendedTest::foo);
}
origin: org.apache.calcite/calcite-core

/** @deprecated Use {@link #add(Consumer)}. */
@SuppressWarnings("Guava")
@Deprecated // to be removed in 2.0
public <T, R> Closeable add(final Function<T, R> handler) {
 return add((Consumer<T>) handler::apply);
}
origin: org.apache.calcite/calcite-core

public <V> Sql withProperty(Hook hook, V value) {
 return withHook(hook, Hook.propertyJ(value));
}
org.apache.calcite.runtimeHook

Javadoc

Collection of hooks that can be set by observers and are executed at various parts of the query preparation process.

For testing and debugging rather than for end-users.

Most used methods

  • run
    Runs all handlers registered for this Hook, with the given argument.
  • add
  • addThread
    Adds a handler for this thread.
  • propertyJ
    Returns a function that, when a hook is called, will "return" a given value. (Because of the way hoo
  • get
    Returns the value of a property hook. (Property hooks take a Holder as an argument.)
  • remove
    Removes a handler from this Hook.
  • removeThread
    Removes a thread handler from this Hook.

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • onRequestPermissionsResult (Fragment)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Menu (java.awt)
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Collectors (java.util.stream)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now