use of com.hazelcast.sql.impl.optimizer.SqlOptimizer in project hazelcast by hazelcast.
the class SqlServiceImpl method createOptimizer.
/**
* Create either normal or not-implemented optimizer instance.
*
* @param nodeEngine Node engine.
* @return Optimizer.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private SqlOptimizer createOptimizer(NodeEngine nodeEngine, QueryResultRegistry resultRegistry) {
// 1. Resolve class name.
String className = System.getProperty(OPTIMIZER_CLASS_PROPERTY_NAME, SQL_MODULE_OPTIMIZER_CLASS);
// 2. Get the class.
Class clazz;
try {
clazz = Class.forName(className);
} catch (ClassNotFoundException e) {
logger.log(SQL_MODULE_OPTIMIZER_CLASS.equals(className) ? Level.FINE : Level.WARNING, "Optimizer class \"" + className + "\" not found, falling back to " + DisabledSqlOptimizer.class.getName());
return new DisabledSqlOptimizer();
} catch (Exception e) {
throw new HazelcastException("Failed to resolve optimizer class " + className + ": " + e.getMessage(), e);
}
// 3. Get required constructor.
Constructor<SqlOptimizer> constructor;
try {
constructor = clazz.getConstructor(NodeEngine.class, QueryResultRegistry.class);
} catch (ReflectiveOperationException e) {
throw new HazelcastException("Failed to get the constructor for the optimizer class " + className + ": " + e.getMessage(), e);
}
// 4. Finally, get the instance.
try {
return constructor.newInstance(nodeEngine, resultRegistry);
} catch (ReflectiveOperationException e) {
throw new HazelcastException("Failed to instantiate the optimizer class " + className + ": " + e.getMessage(), e);
}
}
use of com.hazelcast.sql.impl.optimizer.SqlOptimizer in project hazelcast by hazelcast.
the class OptimizerInstantiationTest method testCreate.
@Test
public void testCreate() {
SqlServiceImpl service = ((HazelcastInstanceProxy) instance()).getOriginal().node.getNodeEngine().getSqlService();
SqlOptimizer optimizer = service.getOptimizer();
assertNotNull(optimizer);
assertEquals(CalciteSqlOptimizer.class, optimizer.getClass());
}
Aggregations