Search in sources :

Example 1 with HiveBatchPageSourceFactory

use of com.facebook.presto.hive.HiveBatchPageSourceFactory in project presto by prestodb.

the class ParquetTester method testSingleRead.

public static void testSingleRead(Iterable<?>[] readValues, List<String> columnNames, List<Type> columnTypes, ParquetMetadataSource parquetMetadataSource, File dataFile) {
    HiveClientConfig config = new HiveClientConfig().setHiveStorageFormat(HiveStorageFormat.PARQUET).setUseParquetColumnNames(false).setParquetMaxReadBlockSize(new DataSize(1_000, DataSize.Unit.BYTE));
    ConnectorSession session = new TestingConnectorSession(new HiveSessionProperties(config, new OrcFileWriterConfig(), new ParquetFileWriterConfig(), new CacheConfig()).getSessionProperties());
    HiveBatchPageSourceFactory pageSourceFactory = new ParquetPageSourceFactory(FUNCTION_AND_TYPE_MANAGER, FUNCTION_RESOLUTION, HDFS_ENVIRONMENT, new FileFormatDataSourceStats(), parquetMetadataSource);
    ConnectorPageSource connectorPageSource = createPageSource(pageSourceFactory, session, dataFile, columnNames, columnTypes, HiveStorageFormat.PARQUET);
    Iterator<?>[] expectedValues = stream(readValues).map(Iterable::iterator).toArray(size -> new Iterator<?>[size]);
    if (connectorPageSource instanceof RecordPageSource) {
        assertRecordCursor(columnTypes, expectedValues, ((RecordPageSource) connectorPageSource).getCursor());
    } else {
        assertPageSource(columnTypes, expectedValues, connectorPageSource);
    }
    assertFalse(stream(expectedValues).allMatch(Iterator::hasNext));
}
Also used : HiveBatchPageSourceFactory(com.facebook.presto.hive.HiveBatchPageSourceFactory) TestingConnectorSession(com.facebook.presto.testing.TestingConnectorSession) OrcFileWriterConfig(com.facebook.presto.hive.OrcFileWriterConfig) FileFormatDataSourceStats(com.facebook.presto.hive.FileFormatDataSourceStats) ConnectorPageSource(com.facebook.presto.spi.ConnectorPageSource) HiveSessionProperties(com.facebook.presto.hive.HiveSessionProperties) RecordPageSource(com.facebook.presto.spi.RecordPageSource) DataSize(io.airlift.units.DataSize) AbstractIterator(com.google.common.collect.AbstractIterator) Iterator(java.util.Iterator) ConnectorSession(com.facebook.presto.spi.ConnectorSession) TestingConnectorSession(com.facebook.presto.testing.TestingConnectorSession) CacheConfig(com.facebook.presto.cache.CacheConfig) ParquetFileWriterConfig(com.facebook.presto.hive.ParquetFileWriterConfig) HiveClientConfig(com.facebook.presto.hive.HiveClientConfig)

Aggregations

CacheConfig (com.facebook.presto.cache.CacheConfig)1 FileFormatDataSourceStats (com.facebook.presto.hive.FileFormatDataSourceStats)1 HiveBatchPageSourceFactory (com.facebook.presto.hive.HiveBatchPageSourceFactory)1 HiveClientConfig (com.facebook.presto.hive.HiveClientConfig)1 HiveSessionProperties (com.facebook.presto.hive.HiveSessionProperties)1 OrcFileWriterConfig (com.facebook.presto.hive.OrcFileWriterConfig)1 ParquetFileWriterConfig (com.facebook.presto.hive.ParquetFileWriterConfig)1 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)1 ConnectorSession (com.facebook.presto.spi.ConnectorSession)1 RecordPageSource (com.facebook.presto.spi.RecordPageSource)1 TestingConnectorSession (com.facebook.presto.testing.TestingConnectorSession)1 AbstractIterator (com.google.common.collect.AbstractIterator)1 DataSize (io.airlift.units.DataSize)1 Iterator (java.util.Iterator)1