use of io.crate.metadata.Functions in project crate by crate.
the class GroupingBytesRefCollectorBenchmark method createGroupingCollector.
@Setup
public void createGroupingCollector() {
Functions functions = new ModulesBuilder().add(new AggregationImplModule()).createInjector().getInstance(Functions.class);
groupByMinCollector = createGroupByMinBytesRefCollector(functions);
List<BytesRef> keys = new ArrayList<>(Locale.getISOCountries().length);
for (String s : Locale.getISOCountries()) {
keys.add(new BytesRef(s));
}
rows = new ArrayList<>(20_000_000);
for (int i = 0; i < 20_000_000; i++) {
rows.add(new Row1(keys.get(i % keys.size())));
}
}
use of io.crate.metadata.Functions in project crate by crate.
the class CurrentSchemaFunctionTest method testNormalizeCurrentSchemaCustomSchema.
@Test
public void testNormalizeCurrentSchemaCustomSchema() throws Exception {
sqlExpressions = new SqlExpressions(tableSources, new SessionContext(0, Option.NONE, "custom_schema"));
functions = sqlExpressions.getInstance(Functions.class);
assertNormalize("current_schema()", isLiteral("custom_schema"), false);
}
use of io.crate.metadata.Functions in project crate by crate.
the class UnnestFunctionTest method prepareFunctions.
@Before
public void prepareFunctions() throws Exception {
sqlExpressions = new SqlExpressions(ImmutableMap.of(QualifiedName.of("t"), mock(DocTableRelation.class)));
functions = sqlExpressions.getInstance(Functions.class);
}
use of io.crate.metadata.Functions in project crate by crate.
the class SystemCollectSource method getCollector.
@Override
public CrateCollector getCollector(CollectPhase phase, BatchConsumer consumer, JobCollectContext jobCollectContext) {
RoutedCollectPhase collectPhase = (RoutedCollectPhase) phase;
// sys.operations can contain a _node column - these refs need to be normalized into literals
EvaluatingNormalizer normalizer = new EvaluatingNormalizer(functions, RowGranularity.DOC, ReplaceMode.COPY, new NodeSysReferenceResolver(nodeSysExpression), null);
final RoutedCollectPhase routedCollectPhase = collectPhase.normalize(normalizer, null);
Map<String, Map<String, List<Integer>>> locations = collectPhase.routing().locations();
String table = Iterables.getOnlyElement(locations.get(clusterService.localNode().getId()).keySet());
Supplier<CompletableFuture<? extends Iterable<?>>> iterableGetter = iterableGetters.get(table);
assert iterableGetter != null : "iterableGetter for " + table + " must exist";
boolean requiresScroll = consumer.requiresScroll();
return BatchIteratorCollectorBridge.newInstance(() -> iterableGetter.get().thenApply(dataIterable -> RowsBatchIterator.newInstance(dataIterableToRowsIterable(routedCollectPhase, requiresScroll, dataIterable), collectPhase.toCollect().size())), consumer);
}
use of io.crate.metadata.Functions in project crate by crate.
the class AggregateCollectorBenchmark method setup.
@Setup
public void setup() {
InputCollectExpression inExpr0 = new InputCollectExpression(0);
Functions functions = new ModulesBuilder().add(new AggregationImplModule()).createInjector().getInstance(Functions.class);
SumAggregation<?> sumAggregation = (SumAggregation<?>) functions.getQualified(Signature.aggregate(SumAggregation.NAME, DataTypes.INTEGER.getTypeSignature(), DataTypes.LONG.getTypeSignature()), List.of(DataTypes.INTEGER), DataTypes.INTEGER);
var memoryManager = new OnHeapMemoryManager(bytes -> {
});
collector = new AggregateCollector(Collections.singletonList(inExpr0), RamAccounting.NO_ACCOUNTING, memoryManager, Version.CURRENT, AggregateMode.ITER_FINAL, new AggregationFunction[] { sumAggregation }, Version.CURRENT, new Input[][] { { inExpr0 } }, new Input[] { Literal.BOOLEAN_TRUE });
}
Aggregations