public BooleanValidator(String name, boolean def) { super(name, Kind.BOOLEAN, OptionValue.createBoolean(OptionType.SYSTEM, name, def)); } }
public static OptionValue createOption(Kind kind, OptionType type, String name, String val) { switch (kind) { case BOOLEAN: return createBoolean(type, name, Boolean.valueOf(val)); case LONG: return createLong(type, name, Long.valueOf(val)); case STRING: return createString(type, name, val); case DOUBLE: return createDouble(type, name, Double.valueOf(val)); default: return null; } }
@Override public void applyOptions(OptionManager manager) { if (optionProvider != null) { optionProvider.applyOptions(manager); } // TODO(DX-5912): disable hash join after merge join is implemented // manager.setOption(OptionValue.createBoolean(OptionValue.OptionType.QUERY, // PlannerSettings.HASHJOIN.getOptionName(), false)); manager.setOption(OptionValue.createBoolean(OptionValue.OptionType.QUERY, PlannerSettings.HASHAGG.getOptionName(), false)); } }
@Override public void setSubstitutionEnabled(boolean enable) { getOptionManager().setOption(OptionValue.createBoolean(SYSTEM, REFLECTION_ENABLE_SUBSTITUTION.getOptionName(), enable)); }
@Override public OptionValue next() { final Entry<String, ConfigValue> e = entries.next(); final ConfigValue cv = e.getValue(); final String name = e.getKey(); OptionValue optionValue = null; switch(cv.valueType()) { case BOOLEAN: optionValue = OptionValue.createBoolean(OptionType.BOOT, name, (Boolean) cv.unwrapped()); break; case LIST: case OBJECT: case STRING: optionValue = OptionValue.createString(OptionType.BOOT, name, cv.render()); break; case NUMBER: optionValue = OptionValue.createLong(OptionType.BOOT, name, ((Number) cv.unwrapped()).longValue()); break; case NULL: throw new IllegalStateException("Config value \"" + name + "\" has NULL type"); } return optionValue; }
switch(validator.getDefault().getKind()){ case BOOLEAN: this.setOption(OptionValue.createBoolean(OptionType.SYSTEM, validator.getOptionName(), Boolean.parseBoolean(value))); break; case DOUBLE:
@PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/acceleration/settings") public void saveSystemSettings(final SystemSettingsApiDescriptor descriptor) { Preconditions.checkArgument(descriptor.getLimit() != null, "limit is required"); Preconditions.checkArgument(descriptor.getLimit() > 0, "limit must be positive"); Preconditions.checkArgument(descriptor.getAccelerateAggregation() != null, "accelerateAggregation is required"); Preconditions.checkArgument(descriptor.getAccelerateRaw() != null, "accelerateRaw is required"); SystemOptionManager optionManager = context.getOptionManager(); optionManager.setOption(OptionValue.createLong(OptionValue.OptionType.SYSTEM, ReflectionOptions.MAX_AUTOMATIC_REFLECTIONS.getOptionName(), descriptor.getLimit())); optionManager.setOption(OptionValue.createBoolean(OptionValue.OptionType.SYSTEM, ReflectionOptions.ENABLE_AUTOMATIC_AGG_REFLECTIONS.getOptionName(), descriptor.getAccelerateAggregation())); optionManager.setOption(OptionValue.createBoolean(OptionValue.OptionType.SYSTEM, ReflectionOptions.ENABLE_AUTOMATIC_RAW_REFLECTIONS.getOptionName(), descriptor.getAccelerateRaw())); if (descriptor.getLayoutRefreshMaxAttempts() != null) { optionManager.setOption(OptionValue.createLong(OptionValue.OptionType.SYSTEM, ExecConstants.LAYOUT_REFRESH_MAX_ATTEMPTS.getOptionName(), descriptor.getLayoutRefreshMaxAttempts())); } } }
@Override public void applyOptions(OptionManager manager) { if (enableLeafLimits) { manager.setOption(createBoolean(QUERY, PlannerSettings.ENABLE_LEAF_LIMITS.getOptionName(), true)); manager.setOption(createLong(QUERY, ExecConstants.MAX_WIDTH_GLOBAL_KEY, manager.getOption(PlannerSettings.LEAF_LIMIT_MAX_WIDTH))); manager.setOption(createLong(QUERY, ExecConstants.SLICE_TARGET, 1)); } if (enableOutputLimits) { manager.setOption(createBoolean(QUERY, PlannerSettings.ENABLE_OUTPUT_LIMITS.getOptionName(), true)); } // always store results manager.setOption(createString(QUERY, PlannerSettings.STORE_QUERY_RESULTS.getOptionName(), StoreQueryResultsPolicy.PATH_AND_ATTEMPT_ID.name())); manager.setOption(createString(QUERY, PlannerSettings.QUERY_RESULTS_STORE_TABLE.getOptionName(), queryResultsStorePath)); if (!allowPartitionPruning) { manager.setOption(createBoolean(QUERY, PlannerSettings.ENABLE_PARTITION_PRUNING.getOptionName(), false)); } if (internalSingleThreaded) { manager.setOption(createBoolean(QUERY, ExecConstants.SORT_FILE_BLOCKS.getOptionName(), true)); manager.setOption(createBoolean(QUERY, PlannerSettings.EXCHANGE.getOptionName(), true)); } }
return OptionValue.createBoolean(type, name, (Boolean) object);
@Override public void close() throws Exception { testContext.getOptions().setOption(OptionValue.createBoolean(OptionType.SYSTEM, validator.getOptionName(), oldValue)); }}; }
private OptionValue toOptionValue(Setting setting){ if (setting instanceof Setting.BooleanSetting) { return OptionValue.createBoolean(OptionType.SYSTEM, setting.getId(), ((Setting.BooleanSetting)setting).getValue()); } else if(setting instanceof Setting.FloatSetting) { return OptionValue.createDouble(OptionType.SYSTEM, setting.getId(), ((Setting.FloatSetting)setting).getValue()); } else if(setting instanceof Setting.IntegerSetting) { return OptionValue.createLong(OptionType.SYSTEM, setting.getId(), ((Setting.IntegerSetting)setting).getValue()); } else if(setting instanceof Setting.TextSetting) { return OptionValue.createString(OptionType.SYSTEM, setting.getId(), ((Setting.TextSetting)setting).getValue()); } else { throw new IllegalStateException("Unable to handle setting " + setting ); } }
protected void onlyAllowPeriodicWakeup(boolean periodicOnly) { getSabotContext().getOptionManager() .setOption( OptionValue.createBoolean(SYSTEM, REFLECTION_PERIODIC_WAKEUP_ONLY.getOptionName(), periodicOnly)); }
public AutoCloseable with(final BooleanValidator validator, final boolean value){ final boolean oldValue = testContext.getOptions().getOption(validator); testContext.getOptions().setOption(OptionValue.createBoolean(OptionType.SYSTEM, validator.getOptionName(), value)); return new AutoCloseable(){ @Override public void close() throws Exception { testContext.getOptions().setOption(OptionValue.createBoolean(OptionType.SYSTEM, validator.getOptionName(), oldValue)); }}; }
@Test public void testUploadDisabled() throws Exception { try { // disable uploads getSabotContext().getOptionManager().setOption(OptionValue.createBoolean(OptionValue.OptionType.SYSTEM, UIOptions.ALLOW_FILE_UPLOADS.getOptionName(), false)); FormDataMultiPart form = new FormDataMultiPart(); FormDataBodyPart fileBody = new FormDataBodyPart("file", FileUtils.getResourceAsFile("/datasets/csv/pipe.csv"), MediaType.MULTIPART_FORM_DATA_TYPE); form.bodyPart(fileBody); form.bodyPart(new FormDataBodyPart("fileName", "pipe")); expectStatus(Response.Status.FORBIDDEN, getBuilder(getAPIv2().path("home/" + HOME_NAME + "/upload_start/").queryParam("extension", "csv")).buildPost(Entity.entity(form, form.getMediaType()))); } finally { // re-enable uploads getSabotContext().getOptionManager().setOption(OptionValue.createBoolean(OptionValue.OptionType.SYSTEM, UIOptions.ALLOW_FILE_UPLOADS.getOptionName(), true)); } }
SystemOptionManager.STORE_NAME, SystemOptionManager.OptionStoreCreator.class, new JacksonSerializer<>(context.getLpPersistence().getMapper(), OptionValue.class)); options.put(ReflectionOptions.ENABLE_SUBHOUR_POLICIES.getOptionName(), OptionValue.createBoolean( OptionValue.OptionType.SYSTEM, ReflectionOptions.ENABLE_SUBHOUR_POLICIES.getOptionName(), true)); options.close();
testContext.getOptions().setOption(OptionValue.createBoolean(OptionType.SYSTEM, ExecConstants.FAST_OR_ENABLE.getOptionName(), false)); testFunction(expr, ObjectArrays.concat(objects, result)); } catch(Throwable t) {
@Test public void simpleSelectWithLimitWithSoftScanWithLeafLimitsEnabled() { when(optionManager.getOption(eq(PlannerSettings.ENABLE_LEAF_LIMITS.getOptionName()))) .thenReturn(OptionValue.createBoolean(OptionType.QUERY, PlannerSettings.ENABLE_LEAF_LIMITS.getOptionName(), true)); try { Prel input = newScreen( newLimit(0, 10, newProject(exprs(), rowType(), newUnionExchange( newLimit(0, 10, newProject(exprs(), rowType(), newSoftScan(rowType()) ) ) ) ) ) ); Prel output = SimpleLimitExchangeRemover.apply(plannerSettings, input); verifyOutput(output, "Screen", "Limit", "Project", "UnionExchange", "Limit", "Project", "SystemScan"); } finally { when(optionManager.getOption(eq(PlannerSettings.ENABLE_LEAF_LIMITS.getOptionName()))) .thenReturn(PlannerSettings.ENABLE_LEAF_LIMITS.getDefault()); } }
protected static void setMaterializationCacheSettings(boolean enabled, long refreshDelayInSeconds) { l(ContextService.class).get().getOptionManager().setOption( OptionValue.createBoolean(SYSTEM, MATERIALIZATION_CACHE_ENABLED.getOptionName(), enabled)); l(ContextService.class).get().getOptionManager().setOption( OptionValue.createLong(SYSTEM, ReflectionOptions.MATERIALIZATION_CACHE_REFRESH_DELAY_MILLIS.getOptionName(), refreshDelayInSeconds*1000)); }
@Before public void setup() throws Exception { if (created) { return; } created = true; // We don’t care about the reflection manager taking too long to respond in these tests so we disable wakeup events to avoid timing issues. l(ContextService.class).get().getOptionManager().setOption( OptionValue.createBoolean(SYSTEM, REFLECTION_PERIODIC_WAKEUP_ONLY.getOptionName(), true)); addCPSource(); addEmployeesJson(); uploadHomeFile(); Dataset dataset = createDataset(); datasetId = dataset.getId(); }
@Test public void testCompilationNoDebug() throws CompileException, ClassNotFoundException, ClassTransformationException, IOException { CodeGenerator<ExampleInner> cg = newCodeGenerator(ExampleInner.class, ExampleTemplateWithInner.class); ClassSet classSet = new ClassSet(null, cg.getDefinition().getTemplateClassName(), cg.getMaterializedClassName()); String sourceCode = cg.generateAndGet(); sessionOptions.setOption(OptionValue.createString(OptionType.SESSION, ClassCompilerSelector.JAVA_COMPILER_OPTION, ClassCompilerSelector.CompilerPolicy.JDK.name())); sessionOptions.setOption(OptionValue.createBoolean(OptionType.SESSION, ClassCompilerSelector.JAVA_COMPILER_DEBUG_OPTION, false)); ClassCompilerSelector classCompilerSelector = new ClassCompilerSelector(DEFAULT_SABOT_CONFIG, sessionOptions); QueryClassLoader loader = new QueryClassLoader(classCompilerSelector); final ClassBytes[] codeWithoutDebug = loader.getClassByteCode(classSet.generated, sourceCode); loader.close(); int sizeWithoutDebug = 0; for (ClassBytes bs : codeWithoutDebug) { sizeWithoutDebug += bs.getBytes().length; } sessionOptions.setOption(OptionValue.createBoolean(OptionType.SESSION, ClassCompilerSelector.JAVA_COMPILER_DEBUG_OPTION, true)); classCompilerSelector = new ClassCompilerSelector(DEFAULT_SABOT_CONFIG, sessionOptions); loader = new QueryClassLoader(classCompilerSelector); final ClassBytes[] codeWithDebug = loader.getClassByteCode(classSet.generated, sourceCode); loader.close(); int sizeWithDebug = 0; for(ClassBytes bs : codeWithDebug) { sizeWithDebug += bs.getBytes().length; } Assert.assertTrue("Debug code is smaller than optimized code!!!", sizeWithDebug > sizeWithoutDebug); logger.debug("Optimized code is {}% smaller than debug code.", (int)((sizeWithDebug - sizeWithoutDebug)/(double)sizeWithDebug*100)); }