Search in sources :

Example 6 with ColumnInfo

use of com.facebook.presto.raptor.metadata.ColumnInfo in project presto by prestodb.

the class TestShardEjector method testEjector.

@Test(invocationCount = 20)
public void testEjector() throws Exception {
    NodeManager nodeManager = createNodeManager("node1", "node2", "node3", "node4", "node5");
    ShardEjector ejector = new ShardEjector(nodeManager.getCurrentNode().getNodeIdentifier(), nodeManager::getWorkerNodes, shardManager, storageService, new Duration(1, HOURS), Optional.of(new TestingBackupStore()), "test");
    List<ShardInfo> shards = ImmutableList.<ShardInfo>builder().add(shardInfo("node1", 14)).add(shardInfo("node1", 13)).add(shardInfo("node1", 12)).add(shardInfo("node1", 11)).add(shardInfo("node1", 10)).add(shardInfo("node1", 10)).add(shardInfo("node1", 10)).add(shardInfo("node1", 10)).add(shardInfo("node2", 5)).add(shardInfo("node2", 5)).add(shardInfo("node3", 10)).add(shardInfo("node4", 10)).add(shardInfo("node5", 10)).add(shardInfo("node6", 200)).build();
    long tableId = createTable("test");
    List<ColumnInfo> columns = ImmutableList.of(new ColumnInfo(1, BIGINT));
    shardManager.createTable(tableId, columns, false, OptionalLong.empty());
    long transactionId = shardManager.beginTransaction();
    shardManager.commitShards(transactionId, tableId, columns, shards, Optional.empty(), 0);
    for (ShardInfo shard : shards.subList(0, 8)) {
        File file = storageService.getStorageFile(shard.getShardUuid());
        storageService.createParents(file);
        assertTrue(file.createNewFile());
    }
    ejector.process();
    shardManager.getShardNodes(tableId, TupleDomain.all());
    Set<UUID> ejectedShards = shards.subList(0, 4).stream().map(ShardInfo::getShardUuid).collect(toSet());
    Set<UUID> keptShards = shards.subList(4, 8).stream().map(ShardInfo::getShardUuid).collect(toSet());
    Set<UUID> remaining = uuids(shardManager.getNodeShards("node1"));
    for (UUID uuid : ejectedShards) {
        assertFalse(remaining.contains(uuid));
        assertFalse(storageService.getStorageFile(uuid).exists());
    }
    assertEquals(remaining, keptShards);
    for (UUID uuid : keptShards) {
        assertTrue(storageService.getStorageFile(uuid).exists());
    }
    Set<UUID> others = ImmutableSet.<UUID>builder().addAll(uuids(shardManager.getNodeShards("node2"))).addAll(uuids(shardManager.getNodeShards("node3"))).addAll(uuids(shardManager.getNodeShards("node4"))).addAll(uuids(shardManager.getNodeShards("node5"))).build();
    assertTrue(others.containsAll(ejectedShards));
}
Also used : ColumnInfo(com.facebook.presto.raptor.metadata.ColumnInfo) Duration(io.airlift.units.Duration) NodeManager(com.facebook.presto.spi.NodeManager) TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) File(java.io.File) ShardInfo(com.facebook.presto.raptor.metadata.ShardInfo) Test(org.testng.annotations.Test)

Example 7 with ColumnInfo

use of com.facebook.presto.raptor.metadata.ColumnInfo in project presto by prestodb.

the class OrcStorageManager method computeShardStats.

private List<ColumnStats> computeShardStats(File file) {
    try (OrcDataSource dataSource = fileOrcDataSource(defaultReaderAttributes, file)) {
        OrcReader reader = new OrcReader(dataSource, new OrcMetadataReader(), defaultReaderAttributes.getMaxMergeDistance(), defaultReaderAttributes.getMaxReadSize());
        ImmutableList.Builder<ColumnStats> list = ImmutableList.builder();
        for (ColumnInfo info : getColumnInfo(reader)) {
            computeColumnStats(reader, info.getColumnId(), info.getType()).ifPresent(list::add);
        }
        return list.build();
    } catch (IOException e) {
        throw new PrestoException(RAPTOR_ERROR, "Failed to read file: " + file, e);
    }
}
Also used : FileOrcDataSource(com.facebook.presto.orc.FileOrcDataSource) OrcDataSource(com.facebook.presto.orc.OrcDataSource) OrcReader(com.facebook.presto.orc.OrcReader) ImmutableList(com.google.common.collect.ImmutableList) ColumnStats(com.facebook.presto.raptor.metadata.ColumnStats) ShardStats.computeColumnStats(com.facebook.presto.raptor.storage.ShardStats.computeColumnStats) OrcMetadataReader(com.facebook.presto.orc.metadata.OrcMetadataReader) ColumnInfo(com.facebook.presto.raptor.metadata.ColumnInfo) PrestoException(com.facebook.presto.spi.PrestoException) IOException(java.io.IOException)

Example 8 with ColumnInfo

use of com.facebook.presto.raptor.metadata.ColumnInfo in project presto by prestodb.

the class TestBucketBalancer method createBucketedTable.

private long createBucketedTable(String tableName, long distributionId, DataSize compressedSize) {
    MetadataDao dao = dbi.onDemand(MetadataDao.class);
    long tableId = dao.insertTable("test", tableName, false, false, distributionId, 0);
    List<ColumnInfo> columnsA = ImmutableList.of(new ColumnInfo(1, BIGINT));
    shardManager.createTable(tableId, columnsA, false, OptionalLong.empty());
    metadataDao.updateTableStats(tableId, 1024, 1024 * 1024 * 1024, compressedSize.toBytes(), compressedSize.toBytes() * 2);
    return tableId;
}
Also used : ColumnInfo(com.facebook.presto.raptor.metadata.ColumnInfo) MetadataDao(com.facebook.presto.raptor.metadata.MetadataDao)

Aggregations

ColumnInfo (com.facebook.presto.raptor.metadata.ColumnInfo)8 MetadataDao (com.facebook.presto.raptor.metadata.MetadataDao)3 ShardInfo (com.facebook.presto.raptor.metadata.ShardInfo)3 Constraint (com.facebook.presto.spi.Constraint)3 PrestoException (com.facebook.presto.spi.PrestoException)3 ImmutableList (com.google.common.collect.ImmutableList)3 UUID (java.util.UUID)3 ShardManager (com.facebook.presto.raptor.metadata.ShardManager)2 TableColumn (com.facebook.presto.raptor.metadata.TableColumn)2 FileOrcDataSource (com.facebook.presto.orc.FileOrcDataSource)1 OrcDataSource (com.facebook.presto.orc.OrcDataSource)1 OrcReader (com.facebook.presto.orc.OrcReader)1 OrcMetadataReader (com.facebook.presto.orc.metadata.OrcMetadataReader)1 OrcType (com.facebook.presto.orc.metadata.OrcType)1 RaptorBucketFunction.validateBucketType (com.facebook.presto.raptor.RaptorBucketFunction.validateBucketType)1 BUCKET_NUMBER_COLUMN_NAME (com.facebook.presto.raptor.RaptorColumnHandle.BUCKET_NUMBER_COLUMN_NAME)1 SHARD_UUID_COLUMN_NAME (com.facebook.presto.raptor.RaptorColumnHandle.SHARD_UUID_COLUMN_NAME)1 SHARD_UUID_COLUMN_TYPE (com.facebook.presto.raptor.RaptorColumnHandle.SHARD_UUID_COLUMN_TYPE)1 RaptorColumnHandle.bucketNumberColumnHandle (com.facebook.presto.raptor.RaptorColumnHandle.bucketNumberColumnHandle)1 RaptorColumnHandle.isHiddenColumn (com.facebook.presto.raptor.RaptorColumnHandle.isHiddenColumn)1