ClassCompilerSelector(DrillConfig config, OptionManager sessionOptions) { OptionValue value = sessionOptions.getOption(JAVA_COMPILER_OPTION); this.policy = CompilerPolicy.valueOf( (value != null) ? value.string_val.toUpperCase() : config.getString(JAVA_COMPILER_CONFIG).toUpperCase()); value = sessionOptions.getOption(JAVA_COMPILER_JANINO_MAXSIZE_OPTION); this.janinoThreshold = (value != null) ? value.num_val : config.getLong(JAVA_COMPILER_JANINO_MAXSIZE_CONFIG); value = sessionOptions.getOption(JAVA_COMPILER_DEBUG_OPTION); boolean debug = (value != null) ? value.bool_val : config.getBoolean(JAVA_COMPILER_DEBUG_CONFIG); this.janinoClassCompiler = (policy == CompilerPolicy.JANINO || policy == CompilerPolicy.DEFAULT) ? new JaninoClassCompiler(QueryClassLoader.this, debug) : null; this.jdkClassCompiler = (policy == CompilerPolicy.JDK || policy == CompilerPolicy.DEFAULT) ? new JDKClassCompiler(QueryClassLoader.this, debug) : null; }
@Override public OptionValue validate(SqlLiteral value) throws ExpressionParsingException { OptionValue ov = super.validate(value); try { CompilerPolicy.valueOf(ov.string_val.toUpperCase()); } catch (IllegalArgumentException e) { throw new ExpressionParsingException( String.format( "Invalid value '%s' specified for option '%s'. Valid values are %s.", ov.string_val, getOptionName(), Arrays.toString(CompilerPolicy.values()))); } return ov; }
@Override public void validate(OptionValue v) { super.validate(v); try { CompilerPolicy.valueOf(v.string_val.toUpperCase()); } catch (IllegalArgumentException e) { throw UserException.validationError() .message( "Invalid value '%s' specified for option '%s'. Valid values are %s.", v.string_val, getOptionName(), Arrays.toString(CompilerPolicy.values())) .build(logger); } }