use of org.apache.commons.dbutils.handlers.ScalarHandler in project metacat by Netflix.
the class HiveConnectorFastTableService method exists.
/**
* {@inheritDoc}.
*/
@Override
public boolean exists(@Nonnull final ConnectorContext requestContext, @Nonnull final QualifiedName name) {
final long start = registry.clock().monotonicTime();
final Map<String, String> tags = new HashMap<String, String>();
tags.put("request", HiveMetrics.exists.name());
boolean result = false;
// Get data source
final DataSource dataSource = DataSourceManager.get().get(catalogName);
try (Connection conn = dataSource.getConnection()) {
final Object qResult = new QueryRunner().query(conn, SQL_EXIST_TABLE_BY_NAME, new ScalarHandler(1), name.getDatabaseName(), name.getTableName());
if (qResult != null) {
result = true;
}
} catch (SQLException e) {
throw Throwables.propagate(e);
} finally {
final long duration = registry.clock().monotonicTime() - start;
log.debug("### Time taken to complete exists is {} ms", duration);
this.registry.timer(requestTimerId.withTags(tags)).record(duration, TimeUnit.MILLISECONDS);
}
return result;
}
Aggregations