use of io.crate.expression.symbol.ParameterSymbol in project crate by crate.
the class UpdateSettingsPlanTest method testUpdateMultipleSettingsWithParameters.
@Test
public void testUpdateMultipleSettingsWithParameters() throws Exception {
List<Assignment<Symbol>> settings = List.of(new Assignment<>(Literal.of("stats.operations_log_size"), List.of(new ParameterSymbol(0, DataTypes.LONG))), new Assignment<>(Literal.of("stats.jobs_log_size"), List.of(new ParameterSymbol(1, DataTypes.LONG))));
Settings expected = Settings.builder().put("stats.operations_log_size", 10).put("stats.jobs_log_size", 25).build();
assertThat(buildSettingsFrom(settings, symbolEvaluator(new RowN(new Object[] { 10, 25 }))), is(expected));
}
use of io.crate.expression.symbol.ParameterSymbol in project crate by crate.
the class UpdateSettingsPlanTest method testUpdateObjectWithParameter.
@Test
public void testUpdateObjectWithParameter() throws Exception {
List<Assignment<Symbol>> settings = List.of(new Assignment<>(Literal.of("stats"), List.of(new ParameterSymbol(0, ObjectType.UNTYPED))));
Map<String, Object> param = MapBuilder.<String, Object>newMapBuilder().put("enabled", true).put("breaker", MapBuilder.newMapBuilder().put("log", MapBuilder.newMapBuilder().put("jobs", MapBuilder.newMapBuilder().put("overhead", 1.05d).map()).map()).map()).map();
Settings expected = Settings.builder().put("stats.enabled", true).put("stats.breaker.log.jobs.overhead", 1.05d).build();
assertThat(buildSettingsFrom(settings, symbolEvaluator(new RowN(new Object[] { param }))), is(expected));
}
use of io.crate.expression.symbol.ParameterSymbol in project crate by crate.
the class SelectivityFunctions method eqSelectivity.
private static double eqSelectivity(Symbol leftArg, Symbol rightArg, Stats stats, @Nullable Row params) {
ColumnIdent column = getColumn(leftArg);
if (column == null) {
return DEFAULT_EQ_SEL;
}
var columnStats = stats.statsByColumn().get(column);
if (columnStats == null) {
return DEFAULT_EQ_SEL;
}
if (rightArg instanceof ParameterSymbol && params != null) {
var value = params.get(((ParameterSymbol) rightArg).index());
return eqSelectivityFromValueAndStats(value, columnStats);
}
if (rightArg instanceof Literal) {
return eqSelectivityFromValueAndStats(((Literal) rightArg).value(), columnStats);
}
return 1.0 / columnStats.approxDistinct();
}
Aggregations