Search in sources :

Example 1 with OnHeapMemoryManager

use of io.crate.memory.OnHeapMemoryManager 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 });
}
Also used : Input(io.crate.data.Input) InputCollectExpression(io.crate.execution.engine.collect.InputCollectExpression) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) SumAggregation(io.crate.execution.engine.aggregation.impl.SumAggregation) Functions(io.crate.metadata.Functions) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) AggregationImplModule(io.crate.execution.engine.aggregation.impl.AggregationImplModule) Setup(org.openjdk.jmh.annotations.Setup)

Example 2 with OnHeapMemoryManager

use of io.crate.memory.OnHeapMemoryManager in project crate by crate.

the class GroupingStringCollectorBenchmark method createGroupingCollector.

@Setup
public void createGroupingCollector() {
    Functions functions = new ModulesBuilder().add(new AggregationImplModule()).createInjector().getInstance(Functions.class);
    groupByMinCollector = createGroupByMinBytesRefCollector(functions);
    memoryManager = new OnHeapMemoryManager(bytes -> {
    });
    List<String> keys = new ArrayList<>(Locale.getISOCountries().length);
    keys.addAll(Arrays.asList(Locale.getISOCountries()));
    rows = new ArrayList<>(20_000_000);
    for (int i = 0; i < 20_000_000; i++) {
        rows.add(new Row1(keys.get(i % keys.size())));
    }
}
Also used : Input(io.crate.data.Input) MinimumAggregation(io.crate.execution.engine.aggregation.impl.MinimumAggregation) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Arrays(java.util.Arrays) AggregationImplModule(io.crate.execution.engine.aggregation.impl.AggregationImplModule) Blackhole(org.openjdk.jmh.infra.Blackhole) SENTINEL(io.crate.data.SentinelRow.SENTINEL) CollectExpression(io.crate.execution.engine.collect.CollectExpression) BatchIterator(io.crate.data.BatchIterator) Scope(org.openjdk.jmh.annotations.Scope) ArrayList(java.util.ArrayList) Functions(io.crate.metadata.Functions) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) Locale(java.util.Locale) Setup(org.openjdk.jmh.annotations.Setup) Mode(org.openjdk.jmh.annotations.Mode) InMemoryBatchIterator(io.crate.data.InMemoryBatchIterator) Signature(io.crate.metadata.functions.Signature) State(org.openjdk.jmh.annotations.State) RamAccounting(io.crate.breaker.RamAccounting) InputCollectExpression(io.crate.execution.engine.collect.InputCollectExpression) Benchmark(org.openjdk.jmh.annotations.Benchmark) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) BatchIterators(io.crate.data.BatchIterators) Version(org.elasticsearch.Version) Row(io.crate.data.Row) Literal(io.crate.expression.symbol.Literal) AggregateMode(io.crate.expression.symbol.AggregateMode) DataTypes(io.crate.types.DataTypes) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) Collections(java.util.Collections) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) ArrayList(java.util.ArrayList) Functions(io.crate.metadata.Functions) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) AggregationImplModule(io.crate.execution.engine.aggregation.impl.AggregationImplModule) Setup(org.openjdk.jmh.annotations.Setup)

Example 3 with OnHeapMemoryManager

use of io.crate.memory.OnHeapMemoryManager in project crate by crate.

the class HyperLogLogDistinctAggregationBenchmark method setUp.

@Setup
public void setUp() throws Exception {
    hash = new MurmurHash3.Hash128();
    final InputCollectExpression inExpr0 = new InputCollectExpression(0);
    Functions functions = new ModulesBuilder().add(new ExtraFunctionsModule()).createInjector().getInstance(Functions.class);
    final HyperLogLogDistinctAggregation hllAggregation = (HyperLogLogDistinctAggregation) functions.getQualified(Signature.aggregate(HyperLogLogDistinctAggregation.NAME, DataTypes.STRING.getTypeSignature(), DataTypes.LONG.getTypeSignature()), List.of(DataTypes.STRING), DataTypes.STRING);
    onHeapMemoryManager = new OnHeapMemoryManager(bytes -> {
    });
    offHeapMemoryManager = new OffHeapMemoryManager();
    hyperLogLogPlusPlus = new HyperLogLogPlusPlus(HyperLogLogPlusPlus.DEFAULT_PRECISION, onHeapMemoryManager::allocate);
    onHeapCollector = new AggregateCollector(Collections.singletonList(inExpr0), RamAccounting.NO_ACCOUNTING, onHeapMemoryManager, Version.CURRENT, AggregateMode.ITER_FINAL, new AggregationFunction[] { hllAggregation }, Version.CURRENT, new Input[][] { { inExpr0 } }, new Input[] { Literal.BOOLEAN_TRUE });
    offHeapCollector = new AggregateCollector(Collections.singletonList(inExpr0), RamAccounting.NO_ACCOUNTING, offHeapMemoryManager, Version.CURRENT, AggregateMode.ITER_FINAL, new AggregationFunction[] { hllAggregation }, Version.CURRENT, new Input[][] { { inExpr0 } }, new Input[] { Literal.BOOLEAN_TRUE });
}
Also used : IntStream(java.util.stream.IntStream) Input(io.crate.data.Input) OffHeapMemoryManager(io.crate.memory.OffHeapMemoryManager) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Scope(org.openjdk.jmh.annotations.Scope) Warmup(org.openjdk.jmh.annotations.Warmup) Function(java.util.function.Function) ExtraFunctionsModule(io.crate.module.ExtraFunctionsModule) Functions(io.crate.metadata.Functions) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) BiConsumer(java.util.function.BiConsumer) TearDown(org.openjdk.jmh.annotations.TearDown) Setup(org.openjdk.jmh.annotations.Setup) Mode(org.openjdk.jmh.annotations.Mode) AggregationFunction(io.crate.execution.engine.aggregation.AggregationFunction) HyperLogLogPlusPlus(io.crate.execution.engine.aggregation.impl.HyperLogLogPlusPlus) Signature(io.crate.metadata.functions.Signature) MurmurHash3(org.elasticsearch.common.hash.MurmurHash3) State(org.openjdk.jmh.annotations.State) RamAccounting(io.crate.breaker.RamAccounting) Collectors(java.util.stream.Collectors) InputCollectExpression(io.crate.execution.engine.collect.InputCollectExpression) Benchmark(org.openjdk.jmh.annotations.Benchmark) StandardCharsets(java.nio.charset.StandardCharsets) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Version(org.elasticsearch.Version) Row(io.crate.data.Row) Literal(io.crate.expression.symbol.Literal) AggregateMode(io.crate.expression.symbol.AggregateMode) DataTypes(io.crate.types.DataTypes) AggregateCollector(io.crate.execution.engine.aggregation.AggregateCollector) Fork(org.openjdk.jmh.annotations.Fork) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) Collections(java.util.Collections) Row1(io.crate.data.Row1) OffHeapMemoryManager(io.crate.memory.OffHeapMemoryManager) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) Functions(io.crate.metadata.Functions) AggregateCollector(io.crate.execution.engine.aggregation.AggregateCollector) ExtraFunctionsModule(io.crate.module.ExtraFunctionsModule) AggregationFunction(io.crate.execution.engine.aggregation.AggregationFunction) Input(io.crate.data.Input) InputCollectExpression(io.crate.execution.engine.collect.InputCollectExpression) HyperLogLogPlusPlus(io.crate.execution.engine.aggregation.impl.HyperLogLogPlusPlus) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) MurmurHash3(org.elasticsearch.common.hash.MurmurHash3) Setup(org.openjdk.jmh.annotations.Setup)

Example 4 with OnHeapMemoryManager

use of io.crate.memory.OnHeapMemoryManager in project crate by crate.

the class ProjectionToProjectorVisitorTest method prepare.

@Before
public void prepare() {
    nodeCtx = createNodeContext();
    MockitoAnnotations.initMocks(this);
    visitor = new ProjectionToProjectorVisitor(clusterService, new NodeLimits(new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), new NoneCircuitBreakerService(), nodeCtx, THREAD_POOL, Settings.EMPTY, mock(TransportActionProvider.class, Answers.RETURNS_DEEP_STUBS), new InputFactory(nodeCtx), EvaluatingNormalizer.functionOnlyNormalizer(nodeCtx), t -> null, t -> null);
    memoryManager = new OnHeapMemoryManager(usedBytes -> {
    });
    avgSignature = Signature.aggregate("avg", DataTypes.INTEGER.getTypeSignature(), DataTypes.DOUBLE.getTypeSignature());
}
Also used : TransactionContext(io.crate.metadata.TransactionContext) Arrays(java.util.Arrays) EvaluatingNormalizer(io.crate.expression.eval.EvaluatingNormalizer) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) NodeLimits(io.crate.execution.jobs.NodeLimits) Projector(io.crate.data.Projector) MockitoAnnotations(org.mockito.MockitoAnnotations) Settings(org.elasticsearch.common.settings.Settings) Is.is(org.hamcrest.core.Is.is) TestingHelpers.createNodeContext(io.crate.testing.TestingHelpers.createNodeContext) Bucket(io.crate.data.Bucket) NodeContext(io.crate.metadata.NodeContext) Aggregation(io.crate.expression.symbol.Aggregation) InMemoryBatchIterator(io.crate.data.InMemoryBatchIterator) AggregationProjection(io.crate.execution.dsl.projection.AggregationProjection) SortingProjector(io.crate.execution.engine.sort.SortingProjector) UUID(java.util.UUID) EqOperator(io.crate.expression.operator.EqOperator) Signature(io.crate.metadata.functions.Signature) RandomizedTest.$(com.carrotsearch.randomizedtesting.RandomizedTest.$) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) List(java.util.List) Row(io.crate.data.Row) Matchers.contains(org.hamcrest.Matchers.contains) Symbol(io.crate.expression.symbol.Symbol) AggregateMode(io.crate.expression.symbol.AggregateMode) DataTypes(io.crate.types.DataTypes) TopNProjection(io.crate.execution.dsl.projection.TopNProjection) CountAggregation(io.crate.execution.engine.aggregation.impl.CountAggregation) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Mockito.mock(org.mockito.Mockito.mock) CoordinatorTxnCtx(io.crate.metadata.CoordinatorTxnCtx) OrderedTopNProjection(io.crate.execution.dsl.projection.OrderedTopNProjection) InputColumn(io.crate.expression.symbol.InputColumn) SENTINEL(io.crate.data.SentinelRow.SENTINEL) BatchIterator(io.crate.data.BatchIterator) SearchPath(io.crate.metadata.SearchPath) ArrayList(java.util.ArrayList) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) SortingTopNProjector(io.crate.execution.engine.sort.SortingTopNProjector) Before(org.junit.Before) Answers(org.mockito.Answers) GroupProjection(io.crate.execution.dsl.projection.GroupProjection) FilterProjection(io.crate.execution.dsl.projection.FilterProjection) Test(org.junit.Test) GroupingProjector(io.crate.execution.engine.aggregation.GroupingProjector) Function(io.crate.expression.symbol.Function) TestingHelpers.isRow(io.crate.testing.TestingHelpers.isRow) RamAccounting(io.crate.breaker.RamAccounting) TransportActionProvider(io.crate.execution.TransportActionProvider) TestingBatchIterators(io.crate.testing.TestingBatchIterators) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) CollectionBucket(io.crate.data.CollectionBucket) RowGranularity(io.crate.metadata.RowGranularity) Literal(io.crate.expression.symbol.Literal) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) AggregationPipe(io.crate.execution.engine.aggregation.AggregationPipe) InputFactory(io.crate.expression.InputFactory) Collections(java.util.Collections) InputFactory(io.crate.expression.InputFactory) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) NodeLimits(io.crate.execution.jobs.NodeLimits) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) Before(org.junit.Before)

Example 5 with OnHeapMemoryManager

use of io.crate.memory.OnHeapMemoryManager in project crate by crate.

the class ProjectorsTest method prepare.

@Before
public void prepare() throws Exception {
    nodeCtx = createNodeContext();
    memoryManager = new OnHeapMemoryManager(bytes -> {
    });
    projectorFactory = new ProjectionToProjectorVisitor(clusterService, new NodeLimits(new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), new NoneCircuitBreakerService(), nodeCtx, THREAD_POOL, Settings.EMPTY, mock(TransportActionProvider.class, Answers.RETURNS_DEEP_STUBS), new InputFactory(nodeCtx), new EvaluatingNormalizer(nodeCtx, RowGranularity.SHARD, r -> Literal.ofUnchecked(r.valueType(), r.valueType().sanitizeValue("1")), null), t -> null, t -> null, Version.CURRENT, new ShardId("dummy", UUID.randomUUID().toString(), 0), null);
}
Also used : ShardId(org.elasticsearch.index.shard.ShardId) InputColumn(io.crate.expression.symbol.InputColumn) Arrays(java.util.Arrays) EvaluatingNormalizer(io.crate.expression.eval.EvaluatingNormalizer) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) NodeLimits(io.crate.execution.jobs.NodeLimits) ArrayList(java.util.ArrayList) Settings(org.elasticsearch.common.settings.Settings) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) TestingHelpers.createNodeContext(io.crate.testing.TestingHelpers.createNodeContext) Before(org.junit.Before) NodeContext(io.crate.metadata.NodeContext) Answers(org.mockito.Answers) GroupProjection(io.crate.execution.dsl.projection.GroupProjection) FilterProjection(io.crate.execution.dsl.projection.FilterProjection) GroupingProjector(io.crate.execution.engine.aggregation.GroupingProjector) Test(org.junit.Test) UUID(java.util.UUID) RamAccounting(io.crate.breaker.RamAccounting) TransportActionProvider(io.crate.execution.TransportActionProvider) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) RowGranularity(io.crate.metadata.RowGranularity) Version(org.elasticsearch.Version) Literal(io.crate.expression.symbol.Literal) AggregateMode(io.crate.expression.symbol.AggregateMode) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) Matchers.is(org.hamcrest.Matchers.is) InputFactory(io.crate.expression.InputFactory) Collections(java.util.Collections) CoordinatorTxnCtx(io.crate.metadata.CoordinatorTxnCtx) Mockito.mock(org.mockito.Mockito.mock) ShardId(org.elasticsearch.index.shard.ShardId) InputFactory(io.crate.expression.InputFactory) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) EvaluatingNormalizer(io.crate.expression.eval.EvaluatingNormalizer) NodeLimits(io.crate.execution.jobs.NodeLimits) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) Before(org.junit.Before)

Aggregations

OnHeapMemoryManager (io.crate.memory.OnHeapMemoryManager)10 RamAccounting (io.crate.breaker.RamAccounting)7 Row (io.crate.data.Row)6 Literal (io.crate.expression.symbol.Literal)6 BatchIterator (io.crate.data.BatchIterator)5 InMemoryBatchIterator (io.crate.data.InMemoryBatchIterator)5 AggregateMode (io.crate.expression.symbol.AggregateMode)5 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)5 Version (org.elasticsearch.Version)5 Input (io.crate.data.Input)4 SENTINEL (io.crate.data.SentinelRow.SENTINEL)4 InputCollectExpression (io.crate.execution.engine.collect.InputCollectExpression)4 InputFactory (io.crate.expression.InputFactory)4 Functions (io.crate.metadata.Functions)4 RowGranularity (io.crate.metadata.RowGranularity)4 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)4 TestingRowConsumer (io.crate.testing.TestingRowConsumer)4 DataTypes (io.crate.types.DataTypes)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4