Search in sources :

Example 51 with DataSize

use of io.airlift.units.DataSize in project presto by prestodb.

the class TestRcFileReaderManual method readValues.

private static List<Integer> readValues(Slice data, int offset, int length) throws IOException {
    if (offset < 0) {
        // adjust length to new offset
        length += offset;
        offset = 0;
    }
    if (offset + length > data.length()) {
        length = data.length() - offset;
    }
    RcFileReader reader = new RcFileReader(new SliceRcFileDataSource(data), new BinaryRcFileEncoding(), ImmutableMap.of(0, SMALLINT), new BogusRcFileCodecFactory(), offset, length, new DataSize(1, MEGABYTE));
    ImmutableList.Builder<Integer> values = ImmutableList.builder();
    while (reader.advance() >= 0) {
        Block block = reader.readBlock(0);
        for (int position = 0; position < block.getPositionCount(); position++) {
            values.add((int) SMALLINT.getLong(block, position));
        }
    }
    return values.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) DataSize(io.airlift.units.DataSize) Block(com.facebook.presto.spi.block.Block) BinaryRcFileEncoding(com.facebook.presto.rcfile.binary.BinaryRcFileEncoding)

Example 52 with DataSize

use of io.airlift.units.DataSize in project airpal by airbnb.

the class Execution method createNoOpQueryStats.

public static QueryStats createNoOpQueryStats() {
    DateTime now = DateTime.now();
    io.airlift.units.Duration zeroDuration = new io.airlift.units.Duration(0, TimeUnit.SECONDS);
    DataSize zeroData = new DataSize(0, DataSize.Unit.BYTE);
    return new QueryStats(now, null, now, now, zeroDuration, zeroDuration, zeroDuration, zeroDuration, zeroDuration, zeroDuration, 0, 0, 0, 0, 0, 0, 0, 0.0, zeroData, zeroData, zeroDuration, zeroDuration, zeroDuration, zeroDuration, false, ImmutableSet.of(), zeroData, 0, zeroData, 0, zeroData, 0);
}
Also used : QueryStats(com.facebook.presto.execution.QueryStats) DataSize(io.airlift.units.DataSize) Duration(org.joda.time.Duration) DateTime(org.joda.time.DateTime)

Example 53 with DataSize

use of io.airlift.units.DataSize in project presto by prestodb.

the class Top100Benchmark method createOperatorFactories.

@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
    OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice");
    TopNOperatorFactory topNOperator = new TopNOperatorFactory(1, new PlanNodeId("test"), tableScanOperator.getTypes(), 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST), false, new DataSize(16, MEGABYTE));
    return ImmutableList.of(tableScanOperator, topNOperator);
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) OperatorFactory(com.facebook.presto.operator.OperatorFactory) TopNOperatorFactory(com.facebook.presto.operator.TopNOperator.TopNOperatorFactory) TopNOperatorFactory(com.facebook.presto.operator.TopNOperator.TopNOperatorFactory) DataSize(io.airlift.units.DataSize)

Example 54 with DataSize

use of io.airlift.units.DataSize in project presto by prestodb.

the class MemoryLocalQueryRunner method execute.

public void execute(@Language("SQL") String query) {
    Session session = testSessionBuilder().setSystemProperty("optimizer.optimize-hash-generation", "true").build();
    ExecutorService executor = localQueryRunner.getExecutor();
    MemoryPool memoryPool = new MemoryPool(new MemoryPoolId("test"), new DataSize(1, GIGABYTE));
    MemoryPool systemMemoryPool = new MemoryPool(new MemoryPoolId("testSystem"), new DataSize(1, GIGABYTE));
    TaskContext taskContext = new QueryContext(new QueryId("test"), new DataSize(256, MEGABYTE), memoryPool, systemMemoryPool, executor).addTaskContext(new TaskStateMachine(new TaskId("query", 0, 0), executor), session, false, false);
    // Use NullOutputFactory to avoid coping out results to avoid affecting benchmark results
    List<Driver> drivers = localQueryRunner.createDrivers(query, new NullOutputOperator.NullOutputFactory(), taskContext);
    boolean done = false;
    while (!done) {
        boolean processed = false;
        for (Driver driver : drivers) {
            if (!driver.isFinished()) {
                driver.process();
                processed = true;
            }
        }
        done = !processed;
    }
}
Also used : TaskContext(com.facebook.presto.operator.TaskContext) TaskId(com.facebook.presto.execution.TaskId) QueryId(com.facebook.presto.spi.QueryId) Driver(com.facebook.presto.operator.Driver) QueryContext(com.facebook.presto.memory.QueryContext) NullOutputOperator(com.facebook.presto.testing.NullOutputOperator) TaskStateMachine(com.facebook.presto.execution.TaskStateMachine) DataSize(io.airlift.units.DataSize) ExecutorService(java.util.concurrent.ExecutorService) MemoryPoolId(com.facebook.presto.spi.memory.MemoryPoolId) Session(com.facebook.presto.Session) MemoryPool(com.facebook.presto.memory.MemoryPool)

Example 55 with DataSize

use of io.airlift.units.DataSize in project presto by prestodb.

the class FormatUtils method formatDataRate.

public static String formatDataRate(DataSize dataSize, Duration duration, boolean longForm) {
    double rate = dataSize.toBytes() / duration.getValue(SECONDS);
    if (Double.isNaN(rate) || Double.isInfinite(rate)) {
        rate = 0;
    }
    String rateString = formatDataSize(new DataSize(rate, BYTE), false);
    if (longForm) {
        if (!rateString.endsWith("B")) {
            rateString += "B";
        }
        rateString += "/s";
    }
    return rateString;
}
Also used : DataSize(io.airlift.units.DataSize)

Aggregations

DataSize (io.airlift.units.DataSize)114 Test (org.testng.annotations.Test)71 Duration (io.airlift.units.Duration)36 Page (com.facebook.presto.spi.Page)23 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)19 RowPagesBuilder (com.facebook.presto.RowPagesBuilder)11 HashAggregationOperatorFactory (com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory)11 URI (java.net.URI)11 MockQueryExecution (com.facebook.presto.execution.MockQueryExecution)10 RootInternalResourceGroup (com.facebook.presto.execution.resourceGroups.InternalResourceGroup.RootInternalResourceGroup)10 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)10 Type (com.facebook.presto.spi.type.Type)9 MaterializedResult (com.facebook.presto.testing.MaterializedResult)9 MemoryPoolId (com.facebook.presto.spi.memory.MemoryPoolId)7 QueryId (com.facebook.presto.spi.QueryId)6 BufferResult (com.facebook.presto.execution.buffer.BufferResult)5 MetadataManager (com.facebook.presto.metadata.MetadataManager)5 TopNOperatorFactory (com.facebook.presto.operator.TopNOperator.TopNOperatorFactory)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 ArrayList (java.util.ArrayList)5