org.apache.calcite.util.Util.throwIfUnchecked()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.apache.calcite.util.Util.throwIfUnchecked()方法的一些代码示例,展示了Util.throwIfUnchecked()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.throwIfUnchecked()方法的具体详情如下:
包路径:org.apache.calcite.util.Util
类名称:Util
方法名:throwIfUnchecked

Util.throwIfUnchecked介绍

[英]As Throwables .throwIfUnchecked(Throwable), which was introduced in Guava 20, but we don't require Guava version 20 yet.
[中]就像扔掉的一样。throwIfUnchecked(Throwable),它是在番石榴20中引入的,但我们还不需要番石榴20版。

代码示例

代码示例来源:origin: Qihoo360/Quicksql

synchronized <M extends Metadata, H extends MetadataHandler<M>> H create(
  MetadataDef<M> def) {
 try {
  final Key key = new Key((MetadataDef) def, provider,
    ImmutableList.copyOf(ALL_RELS));
  //noinspection unchecked
  return (H) HANDLERS.get(key);
 } catch (UncheckedExecutionException | ExecutionException e) {
  Util.throwIfUnchecked(e.getCause());
  throw new RuntimeException(e.getCause());
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

synchronized <M extends Metadata, H extends MetadataHandler<M>> H create(
  MetadataDef<M> def) {
 try {
  final Key key = new Key((MetadataDef) def, provider,
    ImmutableList.copyOf(ALL_RELS));
  //noinspection unchecked
  return (H) HANDLERS.get(key);
 } catch (UncheckedExecutionException | ExecutionException e) {
  Util.throwIfUnchecked(e.getCause());
  throw new RuntimeException(e.getCause());
 }
}

代码示例来源:origin: Qihoo360/Quicksql

public Object invoke(Object proxy, Method method, Object[] args)
   throws Throwable {
  for (Metadata metadata : metadataList) {
   try {
    final Object o = method.invoke(metadata, args);
    if (o != null) {
     return o;
    }
   } catch (InvocationTargetException e) {
    if (e.getCause() instanceof CyclicMetadataException) {
     continue;
    }
    Util.throwIfUnchecked(e.getCause());
    throw new RuntimeException(e.getCause());
   }
  }
  return null;
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

public Object invoke(Object proxy, Method method, Object[] args)
   throws Throwable {
  for (Metadata metadata : metadataList) {
   try {
    final Object o = method.invoke(metadata, args);
    if (o != null) {
     return o;
    }
   } catch (InvocationTargetException e) {
    if (e.getCause() instanceof CyclicMetadataException) {
     continue;
    }
    Util.throwIfUnchecked(e.getCause());
    throw new RuntimeException(e.getCause());
   }
  }
  return null;
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

public double cardinality(List<Lattice.Column> columns) {
  final List<Double> counts = new ArrayList<>();
  for (Lattice.Column column : columns) {
   try {
    counts.add(cache.get(column));
   } catch (UncheckedExecutionException | ExecutionException e) {
    Util.throwIfUnchecked(e.getCause());
    throw new RuntimeException(e.getCause());
   }
  }
  return (int) Lattice.getRowCount(lattice.getFactRowCount(), counts);
 }
}

代码示例来源:origin: Qihoo360/Quicksql

public void set(String name, String value) {
 final Method method = setterMethods.get(name);
 try {
  method.invoke(o, value);
 } catch (IllegalAccessException | InvocationTargetException e) {
  Util.throwIfUnchecked(e.getCause());
  throw new RuntimeException(e.getCause());
 }
}

代码示例来源:origin: Qihoo360/Quicksql

public double cardinality(List<Lattice.Column> columns) {
  final List<Double> counts = new ArrayList<>();
  for (Lattice.Column column : columns) {
   try {
    counts.add(cache.get(column));
   } catch (UncheckedExecutionException | ExecutionException e) {
    Util.throwIfUnchecked(e.getCause());
    throw new RuntimeException(e.getCause());
   }
  }
  return (int) Lattice.getRowCount(lattice.getFactRowCount(), counts);
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

public void set(String name, String value) {
 final Method method = setterMethods.get(name);
 try {
  method.invoke(o, value);
 } catch (IllegalAccessException | InvocationTargetException e) {
  Util.throwIfUnchecked(e.getCause());
  throw new RuntimeException(e.getCause());
 }
}

代码示例来源:origin: Qihoo360/Quicksql

public Object get(String name) {
 final Method method = getterMethods.get(name);
 try {
  return method.invoke(o);
 } catch (IllegalAccessException | InvocationTargetException e) {
  Util.throwIfUnchecked(e.getCause());
  throw new RuntimeException(e.getCause());
 }
}

代码示例来源:origin: Qihoo360/Quicksql

public <M extends Metadata> M query(RelNode rel, RelMetadataQuery mq,
   Class<M> metadataClazz) {
  try {
   //noinspection unchecked
   final Pair<Class<RelNode>, Class<Metadata>> key =
     (Pair) Pair.of(rel.getClass(), metadataClazz);
   final Metadata apply = cache.get(key).bind(rel, mq);
   return metadataClazz.cast(apply);
  } catch (UncheckedExecutionException | ExecutionException e) {
   Util.throwIfUnchecked(e.getCause());
   throw new RuntimeException(e.getCause());
  }
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

public Object get(String name) {
 final Method method = getterMethods.get(name);
 try {
  return method.invoke(o);
 } catch (IllegalAccessException | InvocationTargetException e) {
  Util.throwIfUnchecked(e.getCause());
  throw new RuntimeException(e.getCause());
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

public <M extends Metadata> M query(RelNode rel, RelMetadataQuery mq,
   Class<M> metadataClazz) {
  try {
   //noinspection unchecked
   final Pair<Class<RelNode>, Class<Metadata>> key =
     (Pair) Pair.of(rel.getClass(), metadataClazz);
   final Metadata apply = cache.get(key).bind(rel, mq);
   return metadataClazz.cast(apply);
  } catch (UncheckedExecutionException | ExecutionException e) {
   Util.throwIfUnchecked(e.getCause());
   throw new RuntimeException(e.getCause());
  }
 }
}

代码示例来源:origin: org.apache.calcite/calcite-druid

public void close() {
  final Throwable e = throwableHolder.get();
  if (e != null) {
   throwableHolder.set(null);
   Util.throwIfUnchecked(e);
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: Qihoo360/Quicksql

public void close() {
    final Throwable e = throwableHolder.get();
    if (e != null) {
      throwableHolder.set(null);
      Util.throwIfUnchecked(e);
      throw new RuntimeException(e);
    }
  }
}

代码示例来源:origin: Qihoo360/Quicksql

/**
 * Performs post-constructor initialization of an operator table. It can't
 * be part of the constructor, because the subclass constructor needs to
 * complete first.
 */
public final void init() {
 // Use reflection to register the expressions stored in public fields.
 for (Field field : getClass().getFields()) {
  try {
   if (SqlFunction.class.isAssignableFrom(field.getType())) {
    SqlFunction op = (SqlFunction) field.get(this);
    if (op != null) {
     register(op);
    }
   } else if (
     SqlOperator.class.isAssignableFrom(field.getType())) {
    SqlOperator op = (SqlOperator) field.get(this);
    register(op);
   }
  } catch (IllegalArgumentException | IllegalAccessException e) {
   Util.throwIfUnchecked(e.getCause());
   throw new RuntimeException(e.getCause());
  }
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

/**
 * Performs post-constructor initialization of an operator table. It can't
 * be part of the constructor, because the subclass constructor needs to
 * complete first.
 */
public final void init() {
 // Use reflection to register the expressions stored in public fields.
 for (Field field : getClass().getFields()) {
  try {
   if (SqlFunction.class.isAssignableFrom(field.getType())) {
    SqlFunction op = (SqlFunction) field.get(this);
    if (op != null) {
     register(op);
    }
   } else if (
     SqlOperator.class.isAssignableFrom(field.getType())) {
    SqlOperator op = (SqlOperator) field.get(this);
    register(op);
   }
  } catch (IllegalArgumentException | IllegalAccessException e) {
   Util.throwIfUnchecked(e.getCause());
   throw new RuntimeException(e.getCause());
  }
 }
}

代码示例来源:origin: Qihoo360/Quicksql

Util.throwIfUnchecked(ex.getTargetException());
throw new RuntimeException(ex.getTargetException());

代码示例来源:origin: org.apache.calcite/calcite-core

Util.throwIfUnchecked(ex.getTargetException());
throw new RuntimeException(ex.getTargetException());

代码示例来源:origin: Qihoo360/Quicksql

} catch (InvocationTargetException
  | UndeclaredThrowableException e) {
 Util.throwIfUnchecked(e.getCause());
 throw new RuntimeException(e.getCause());
} finally {

代码示例来源:origin: org.apache.calcite/calcite-core

} catch (InvocationTargetException
  | UndeclaredThrowableException e) {
 Util.throwIfUnchecked(e.getCause());
 throw new RuntimeException(e.getCause());
} finally {

相关文章