Search in sources :

Example 81 with DataSize

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

the class TestOrcStorageManager method testMaxFileSize.

@Test
public void testMaxFileSize() throws Exception {
    List<Long> columnIds = ImmutableList.of(3L, 7L);
    List<Type> columnTypes = ImmutableList.of(BIGINT, createVarcharType(5));
    List<Page> pages = rowPagesBuilder(columnTypes).row(123L, "hello").row(456L, "bye").build();
    // Set maxFileSize to 1 byte, so adding any page makes the StoragePageSink full
    OrcStorageManager manager = createOrcStorageManager(20, new DataSize(1, BYTE));
    StoragePageSink sink = createStoragePageSink(manager, columnIds, columnTypes);
    sink.appendPages(pages);
    assertTrue(sink.isFull());
}
Also used : VarcharType.createVarcharType(com.facebook.presto.spi.type.VarcharType.createVarcharType) Type(com.facebook.presto.spi.type.Type) DataSize(io.airlift.units.DataSize) OptionalLong(java.util.OptionalLong) Page(com.facebook.presto.spi.Page) Test(org.testng.annotations.Test)

Example 82 with DataSize

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

the class TestOrcStorageManager method testMaxShardRows.

@Test
public void testMaxShardRows() throws Exception {
    OrcStorageManager manager = createOrcStorageManager(2, new DataSize(2, MEGABYTE));
    List<Long> columnIds = ImmutableList.of(3L, 7L);
    List<Type> columnTypes = ImmutableList.of(BIGINT, createVarcharType(10));
    StoragePageSink sink = createStoragePageSink(manager, columnIds, columnTypes);
    List<Page> pages = rowPagesBuilder(columnTypes).row(123L, "hello").row(456L, "bye").build();
    sink.appendPages(pages);
    assertTrue(sink.isFull());
}
Also used : VarcharType.createVarcharType(com.facebook.presto.spi.type.VarcharType.createVarcharType) Type(com.facebook.presto.spi.type.Type) DataSize(io.airlift.units.DataSize) OptionalLong(java.util.OptionalLong) Page(com.facebook.presto.spi.Page) Test(org.testng.annotations.Test)

Example 83 with DataSize

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

the class OrcTestingUtil method createReaderNoRows.

public static OrcRecordReader createReaderNoRows(OrcDataSource dataSource) throws IOException {
    OrcReader orcReader = new OrcReader(dataSource, new OrcMetadataReader(), new DataSize(1, Unit.MEGABYTE), new DataSize(1, Unit.MEGABYTE));
    assertEquals(orcReader.getColumnNames().size(), 0);
    return createRecordReader(orcReader, ImmutableMap.of());
}
Also used : OrcReader(com.facebook.presto.orc.OrcReader) OrcMetadataReader(com.facebook.presto.orc.metadata.OrcMetadataReader) DataSize(io.airlift.units.DataSize)

Example 84 with DataSize

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

the class TestFileResourceGroupConfigurationManager method testConfiguration.

@Test
public void testConfiguration() {
    ResourceGroupConfigurationManager manager = parse("resource_groups_config.json");
    ResourceGroup global = new TestingResourceGroup(new ResourceGroupId("global"));
    manager.configure(global, new SelectionContext(true, "user", Optional.empty(), 1));
    assertEquals(global.getSoftMemoryLimit(), new DataSize(1, MEGABYTE));
    assertEquals(global.getSoftCpuLimit(), new Duration(1, HOURS));
    assertEquals(global.getHardCpuLimit(), new Duration(1, DAYS));
    assertEquals(global.getCpuQuotaGenerationMillisPerSecond(), 1000 * 24);
    assertEquals(global.getMaxQueuedQueries(), 1000);
    assertEquals(global.getMaxRunningQueries(), 100);
    assertEquals(global.getSchedulingPolicy(), WEIGHTED);
    assertEquals(global.getSchedulingWeight(), 0);
    assertEquals(global.getJmxExport(), true);
    ResourceGroup sub = new TestingResourceGroup(new ResourceGroupId(new ResourceGroupId("global"), "sub"));
    manager.configure(sub, new SelectionContext(true, "user", Optional.empty(), 1));
    assertEquals(sub.getSoftMemoryLimit(), new DataSize(2, MEGABYTE));
    assertEquals(sub.getMaxRunningQueries(), 3);
    assertEquals(sub.getMaxQueuedQueries(), 4);
    assertEquals(sub.getSchedulingPolicy(), null);
    assertEquals(sub.getSchedulingWeight(), 5);
    assertEquals(sub.getJmxExport(), false);
}
Also used : ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) ResourceGroupConfigurationManager(com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager) DataSize(io.airlift.units.DataSize) Duration(io.airlift.units.Duration) SelectionContext(com.facebook.presto.spi.resourceGroups.SelectionContext) ResourceGroup(com.facebook.presto.spi.resourceGroups.ResourceGroup) Test(org.testng.annotations.Test)

Example 85 with DataSize

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

the class RcFileTester method writeRcFileColumnNew.

private static DataSize writeRcFileColumnNew(File outputFile, Format format, Compression compression, Type type, Iterator<?> values, Map<String, String> metadata) throws Exception {
    OutputStreamSliceOutput output = new OutputStreamSliceOutput(new FileOutputStream(outputFile));
    AircompressorCodecFactory codecFactory = new AircompressorCodecFactory(new HadoopCodecFactory(RcFileTester.class.getClassLoader()));
    RcFileWriter writer = new RcFileWriter(output, ImmutableList.of(type), format.getVectorEncoding(), compression.getCodecName(), codecFactory, metadata, // use a smaller size to create more row groups
    new DataSize(100, KILOBYTE), new DataSize(200, KILOBYTE), true);
    BlockBuilder blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), 1024);
    while (values.hasNext()) {
        Object value = values.next();
        writeValue(type, blockBuilder, value);
    }
    writer.write(new Page(blockBuilder.build()));
    writer.close();
    writer.validate(new FileRcFileDataSource(outputFile));
    return new DataSize(output.size(), BYTE);
}
Also used : FileOutputStream(java.io.FileOutputStream) DataSize(io.airlift.units.DataSize) StructObject(org.apache.hadoop.hive.serde2.StructObject) Page(com.facebook.presto.spi.Page) OutputStreamSliceOutput(io.airlift.slice.OutputStreamSliceOutput) BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

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