Search in sources :

Example 1 with FormatPlugin

use of org.apache.drill.exec.store.dfs.FormatPlugin in project drill by apache.

the class DrillStatsTable method readStatistics.

private TableStatistics readStatistics(DrillTable drillTable, Path path) throws IOException {
    final Object selection = drillTable.getSelection();
    if (selection instanceof FormatSelection) {
        StoragePlugin storagePlugin = drillTable.getPlugin();
        FormatSelection formatSelection = (FormatSelection) selection;
        FormatPluginConfig formatConfig = formatSelection.getFormat();
        if (storagePlugin instanceof FileSystemPlugin && (formatConfig instanceof ParquetFormatConfig)) {
            FormatPlugin fmtPlugin = storagePlugin.getFormatPlugin(formatConfig);
            if (fmtPlugin.supportsStatistics()) {
                return fmtPlugin.readStatistics(fs, path);
            }
        }
    }
    return null;
}
Also used : FileSystemPlugin(org.apache.drill.exec.store.dfs.FileSystemPlugin) FormatPluginConfig(org.apache.drill.common.logical.FormatPluginConfig) FormatSelection(org.apache.drill.exec.store.dfs.FormatSelection) ParquetFormatConfig(org.apache.drill.exec.store.parquet.ParquetFormatConfig) StoragePlugin(org.apache.drill.exec.store.StoragePlugin) FormatPlugin(org.apache.drill.exec.store.dfs.FormatPlugin)

Example 2 with FormatPlugin

use of org.apache.drill.exec.store.dfs.FormatPlugin in project drill by apache.

the class HiveStoragePlugin method getFormatPlugin.

@Override
public FormatPlugin getFormatPlugin(FormatPluginConfig formatConfig) {
    // TODO: implement formatCreator similar to FileSystemPlugin formatCreator. DRILL-6621
    try {
        Class<?> mapRDBFormatPluginConfigClass = Class.forName("org.apache.drill.exec.store.mapr.db.MapRDBFormatPluginConfig");
        Class<?> mapRDBFormatPluginClass = Class.forName("org.apache.drill.exec.store.mapr.db.MapRDBFormatPlugin");
        if (mapRDBFormatPluginConfigClass.isInstance(formatConfig)) {
            return (FormatPlugin) mapRDBFormatPluginClass.getConstructor(new Class[] { String.class, DrillbitContext.class, Configuration.class, StoragePluginConfig.class, mapRDBFormatPluginConfigClass }).newInstance(new Object[] { HIVE_MAPRDB_FORMAT_PLUGIN_NAME, context, hiveConf, config, formatConfig });
        }
    } catch (ReflectiveOperationException e) {
        throw new DrillRuntimeException("The error is occurred while connecting to MapR-DB or instantiating mapRDBFormatPlugin", e);
    }
    throw new DrillRuntimeException(String.format("Hive storage plugin doesn't support usage of %s format plugin", formatConfig.getClass().getName()));
}
Also used : DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) FormatPlugin(org.apache.drill.exec.store.dfs.FormatPlugin)

Aggregations

FormatPlugin (org.apache.drill.exec.store.dfs.FormatPlugin)2 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)1 FormatPluginConfig (org.apache.drill.common.logical.FormatPluginConfig)1 StoragePlugin (org.apache.drill.exec.store.StoragePlugin)1 FileSystemPlugin (org.apache.drill.exec.store.dfs.FileSystemPlugin)1 FormatSelection (org.apache.drill.exec.store.dfs.FormatSelection)1 ParquetFormatConfig (org.apache.drill.exec.store.parquet.ParquetFormatConfig)1