Search in sources :

Example 26 with HumanReadableBytes

use of org.apache.druid.java.util.common.HumanReadableBytes in project druid by druid-io.

the class DruidProcessingConfig method intermediateComputeSizeBytes.

public int intermediateComputeSizeBytes() {
    HumanReadableBytes sizeBytesConfigured = intermediateComputeSizeBytesConfigured();
    if (!DEFAULT_PROCESSING_BUFFER_SIZE_BYTES.equals(sizeBytesConfigured)) {
        if (sizeBytesConfigured.getBytes() > Integer.MAX_VALUE) {
            throw new IAE("druid.processing.buffer.sizeBytes must be less than 2GiB");
        }
        return sizeBytesConfigured.getBytesInInt();
    } else if (computedBufferSizeBytes.get() != null) {
        return computedBufferSizeBytes.get();
    }
    long directSizeBytes;
    try {
        directSizeBytes = JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
        log.info("Detected max direct memory size of [%,d] bytes", directSizeBytes);
    } catch (UnsupportedOperationException e) {
        // max direct memory defaults to max heap size on recent JDK version, unless set explicitly
        directSizeBytes = computeMaxMemoryFromMaxHeapSize();
        log.info("Defaulting to at most [%,d] bytes (25%% of max heap size) of direct memory for computation buffers", directSizeBytes);
    }
    int numProcessingThreads = getNumThreads();
    int numMergeBuffers = getNumMergeBuffers();
    int totalNumBuffers = numMergeBuffers + numProcessingThreads;
    int sizePerBuffer = (int) ((double) directSizeBytes / (double) (totalNumBuffers + 1));
    final int computedSizePerBuffer = Math.min(sizePerBuffer, MAX_DEFAULT_PROCESSING_BUFFER_SIZE_BYTES);
    if (computedBufferSizeBytes.compareAndSet(null, computedSizePerBuffer)) {
        log.info("Auto sizing buffers to [%,d] bytes each for [%,d] processing and [%,d] merge buffers", computedSizePerBuffer, numProcessingThreads, numMergeBuffers);
    }
    return computedSizePerBuffer;
}
Also used : HumanReadableBytes(org.apache.druid.java.util.common.HumanReadableBytes) IAE(org.apache.druid.java.util.common.IAE)

Example 27 with HumanReadableBytes

use of org.apache.druid.java.util.common.HumanReadableBytes in project druid by druid-io.

the class ExpressionLambdaAggregatorFactoryTest method testDoubleArrayTypeFinalized.

@Test
public void testDoubleArrayTypeFinalized() {
    ExpressionLambdaAggregatorFactory agg = new ExpressionLambdaAggregatorFactory("expr_agg_name", ImmutableSet.of("some_column", "some_other_column"), null, "0.0", "ARRAY<DOUBLE>[]", null, false, false, "__acc + some_column + some_other_column", "array_set_add(__acc, expr_agg_name)", null, "array_to_string(o, ';')", new HumanReadableBytes(2048), TestExprMacroTable.INSTANCE);
    Assert.assertEquals(ColumnType.DOUBLE, agg.getIntermediateType());
    Assert.assertEquals(ColumnType.DOUBLE_ARRAY, agg.getCombiningFactory().getIntermediateType());
    Assert.assertEquals(ColumnType.STRING, agg.getResultType());
}
Also used : HumanReadableBytes(org.apache.druid.java.util.common.HumanReadableBytes) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 28 with HumanReadableBytes

use of org.apache.druid.java.util.common.HumanReadableBytes in project druid by druid-io.

the class ExpressionLambdaAggregatorFactoryTest method testStringArrayTypeFinalized.

@Test
public void testStringArrayTypeFinalized() {
    ExpressionLambdaAggregatorFactory agg = new ExpressionLambdaAggregatorFactory("expr_agg_name", ImmutableSet.of("some_column", "some_other_column"), null, "''", "ARRAY<STRING>[]", null, false, false, "concat(__acc, some_column, some_other_column)", "array_set_add(__acc, expr_agg_name)", null, "array_to_string(o, ';')", new HumanReadableBytes(2048), TestExprMacroTable.INSTANCE);
    Assert.assertEquals(ColumnType.STRING, agg.getIntermediateType());
    Assert.assertEquals(ColumnType.STRING_ARRAY, agg.getCombiningFactory().getIntermediateType());
    Assert.assertEquals(ColumnType.STRING, agg.getResultType());
}
Also used : HumanReadableBytes(org.apache.druid.java.util.common.HumanReadableBytes) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 29 with HumanReadableBytes

use of org.apache.druid.java.util.common.HumanReadableBytes in project druid by druid-io.

the class ExpressionLambdaAggregatorFactoryTest method testInitialCombineValueMustBeConstant.

@Test
public void testInitialCombineValueMustBeConstant() {
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("initial combining value must be constant");
    ExpressionLambdaAggregatorFactory agg = new ExpressionLambdaAggregatorFactory("expr_agg_name", ImmutableSet.of("some_column", "some_other_column"), null, "0.0", "x + y", true, false, false, "__acc + some_column + some_other_column", "__acc + expr_agg_name", null, null, new HumanReadableBytes(2048), TestExprMacroTable.INSTANCE);
    agg.getResultType();
}
Also used : HumanReadableBytes(org.apache.druid.java.util.common.HumanReadableBytes) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 30 with HumanReadableBytes

use of org.apache.druid.java.util.common.HumanReadableBytes in project druid by druid-io.

the class ExpressionLambdaAggregatorFactoryTest method testStringArrayType.

@Test
public void testStringArrayType() {
    ExpressionLambdaAggregatorFactory agg = new ExpressionLambdaAggregatorFactory("expr_agg_name", ImmutableSet.of("some_column", "some_other_column"), null, "''", "ARRAY<STRING>[]", null, false, false, "concat(__acc, some_column, some_other_column)", "array_set_add(__acc, expr_agg_name)", null, null, new HumanReadableBytes(2048), TestExprMacroTable.INSTANCE);
    Assert.assertEquals(ColumnType.STRING, agg.getIntermediateType());
    Assert.assertEquals(ColumnType.STRING_ARRAY, agg.getCombiningFactory().getIntermediateType());
    Assert.assertEquals(ColumnType.STRING_ARRAY, agg.getResultType());
}
Also used : HumanReadableBytes(org.apache.druid.java.util.common.HumanReadableBytes) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

HumanReadableBytes (org.apache.druid.java.util.common.HumanReadableBytes)39 Test (org.junit.Test)35 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)19 List (java.util.List)7 MaxSizeSplitHintSpec (org.apache.druid.data.input.MaxSizeSplitHintSpec)6 ExpressionLambdaAggregatorFactory (org.apache.druid.query.aggregation.ExpressionLambdaAggregatorFactory)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 InputSplit (org.apache.druid.data.input.InputSplit)4 SegmentsSplitHintSpec (org.apache.druid.data.input.SegmentsSplitHintSpec)4 DynamicPartitionsSpec (org.apache.druid.indexer.partitions.DynamicPartitionsSpec)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 File (java.io.File)3 Collectors (java.util.stream.Collectors)3 Nullable (javax.annotation.Nullable)3 AggregateCall (org.apache.calcite.rel.core.AggregateCall)3 Project (org.apache.calcite.rel.core.Project)3 RexBuilder (org.apache.calcite.rex.RexBuilder)3 RexLiteral (org.apache.calcite.rex.RexLiteral)3 RexNode (org.apache.calcite.rex.RexNode)3 SqlAggFunction (org.apache.calcite.sql.SqlAggFunction)3