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 OptionValueWrapper next() { final OptionValue value = mergedOptions.next(); final Status status; if (value.getType() == OptionType.BOOT) { status = Status.BOOT; } else { final OptionValue def = fragmentOptions.getValidator(value.getName()).getDefault(); if (value.equalsIgnoreType(def)) { status = Status.DEFAULT; } else { status = Status.CHANGED; } } return new OptionValueWrapper(value.getName(), value.getKind(), value.getType(), value.getNumVal(), value.getStringVal(), value.getBoolVal(), value.getFloatVal(), status); }
@SuppressWarnings("rawtypes") private Setting toSetting(OptionValue option){ // display the value if it is the whitelist or has been set. final boolean showOutsideWhitelist = options.isSet(option.getName()); switch(option.getKind()){ case BOOLEAN: return new Setting.BooleanSetting(option.getName(), option.getBoolVal(), showOutsideWhitelist); case DOUBLE: return new Setting.FloatSetting(option.getName(), option.getFloatVal(), showOutsideWhitelist); case LONG: return new Setting.IntegerSetting(option.getName(), option.getNumVal(), showOutsideWhitelist); case STRING: return new Setting.TextSetting(option.getName(), option.getStringVal(), showOutsideWhitelist); default: throw new IllegalStateException("Unable to handle kind " + option.getKind()); } } }
@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; }
@Override public boolean getOption(BooleanValidator validator) { return getOptionSafe(validator).getBoolVal(); }
public BooleanValidator(String name, boolean def) { super(name, Kind.BOOLEAN, OptionValue.createBoolean(OptionType.SYSTEM, name, def)); } }
@Override public long getOption(LongValidator validator) { return getOptionSafe(validator).getNumVal(); }
@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())); } } }
/** * Constructor for controls option validator. * * @param name the name of the validator * @param def the default JSON, specified as string * @param ttl the number of queries for which this option should be valid */ public ControlsOptionValidator(final String name, final String def, final int ttl) { super(name, OptionValue.Kind.STRING, OptionValue.createString(OptionType.SYSTEM, name, def)); assert ttl > 0; this.ttl = ttl; }
public LongValidator(String name, long def) { super(name, Kind.LONG, OptionValue.createLong(OptionType.SYSTEM, name, def)); } }
public SpillManager(SabotConfig sabotConfig, OptionManager optionManager, String id, Configuration hadoopConf, SpillService spillService, String caller) { final List<String> directories = new ArrayList<>(sabotConfig.getStringList(ExecConstants.SPILL_DIRS)); if (directories.isEmpty()) { throw UserException.dataWriteError().message("No spill locations specified.").build(logger); } this.id = id; this.caller = caller; this.hadoopConf = hadoopConf; this.spillService = spillService; // load options if (optionManager != null) { this.minDiskSpacePercentage = optionManager.getOption(ExecConstants.SPILL_DISK_SPACE_LIMIT_PERCENTAGE); this.minDiskSpace = optionManager.getOption(ExecConstants.SPILL_DISK_SPACE_LIMIT_BYTES); this.healthCheckInterval = optionManager.getOption(ExecConstants.SPILL_DISK_SPACE_CHECK_INTERVAL); } else { this.minDiskSpacePercentage = ExecConstants.SPILL_DISK_SPACE_LIMIT_PERCENTAGE.getDefault().getFloatVal(); this.minDiskSpace = ExecConstants.SPILL_DISK_SPACE_LIMIT_BYTES.getDefault().getNumVal(); this.healthCheckInterval = ExecConstants.SPILL_DISK_SPACE_CHECK_INTERVAL.getDefault().getNumVal(); } try { spillService.makeSpillSubdirs(id); } catch (UserException e) { throw UserException.dataWriteError(e) .addContext("Caller", caller) .build(logger); } }
@Override public String getOption(StringValidator validator) { return getOptionSafe(validator).getStringVal(); } }
@Test public void testTPCHReadWriteNoDictUncompressed() throws Exception { try { test(String.format("alter session set \"%s\" = false", ExecConstants.PARQUET_WRITER_ENABLE_DICTIONARY_ENCODING)); test(String.format("alter session set \"%s\" = 'none'", ExecConstants.PARQUET_WRITER_COMPRESSION_TYPE)); String inputTable = "cp.\"tpch/supplier.parquet\""; runTestAndValidate("*", "*", inputTable, "supplier_parquet_no_dict_uncompressed", false); } finally { test(String.format("alter session set \"%s\" = %b", ExecConstants.PARQUET_WRITER_ENABLE_DICTIONARY_ENCODING, ExecConstants.PARQUET_WRITER_ENABLE_DICTIONARY_ENCODING_VALIDATOR.getDefault().getBoolVal())); test(String.format("alter session set \"%s\" = '%s'", ExecConstants.PARQUET_WRITER_COMPRESSION_TYPE, ExecConstants.PARQUET_WRITER_COMPRESSION_TYPE_VALIDATOR.getDefault().getStringVal())); } }
public DoubleValidator(String name, double def) { super(name, Kind.DOUBLE, OptionValue.createDouble(OptionType.SYSTEM, name, def)); } }
@Override public void setOption(final OptionValue value) { checkArgument(value.getType() == OptionType.SYSTEM, "OptionType must be SYSTEM."); final String name = value.getName().toLowerCase(); final OptionValidator validator = getValidator(name); validator.validate(value); // validate the option if (options.get(name) == null && value.equals(validator.getDefault())) { return; // if the option is not overridden, ignore setting option to default } options.put(name, value); }
@Override public double getOption(DoubleValidator validator) { return getOptionSafe(validator).getFloatVal(); }
@Override public String apply(OptionValue input) { return input.getName(); } };
@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)); } }