Search in sources :

Example 1 with SequenceFileFormatConfig

use of org.apache.drill.exec.store.easy.sequencefile.SequenceFileFormatConfig in project drill by axbaretto.

the class StoragePluginTestUtils method configureFormatPlugins.

public static void configureFormatPlugins(StoragePluginRegistry pluginRegistry, String storagePlugin) throws ExecutionSetupException {
    FileSystemPlugin fileSystemPlugin = (FileSystemPlugin) pluginRegistry.getPlugin(storagePlugin);
    FileSystemConfig fileSystemConfig = (FileSystemConfig) fileSystemPlugin.getConfig();
    TextFormatPlugin.TextFormatConfig textConfig = new TextFormatPlugin.TextFormatConfig();
    textConfig.extensions = ImmutableList.of("txt");
    textConfig.fieldDelimiter = '\u0000';
    fileSystemConfig.formats.put("txt", textConfig);
    TextFormatPlugin.TextFormatConfig ssvConfig = new TextFormatPlugin.TextFormatConfig();
    ssvConfig.extensions = ImmutableList.of("ssv");
    ssvConfig.fieldDelimiter = ' ';
    fileSystemConfig.formats.put("ssv", ssvConfig);
    TextFormatPlugin.TextFormatConfig psvConfig = new TextFormatPlugin.TextFormatConfig();
    psvConfig.extensions = ImmutableList.of("tbl");
    psvConfig.fieldDelimiter = '|';
    fileSystemConfig.formats.put("psv", psvConfig);
    SequenceFileFormatConfig seqConfig = new SequenceFileFormatConfig();
    seqConfig.extensions = ImmutableList.of("seq");
    fileSystemConfig.formats.put("sequencefile", seqConfig);
    TextFormatPlugin.TextFormatConfig csvhtestConfig = new TextFormatPlugin.TextFormatConfig();
    csvhtestConfig.extensions = ImmutableList.of("csvh-test");
    csvhtestConfig.fieldDelimiter = ',';
    csvhtestConfig.extractHeader = true;
    csvhtestConfig.skipFirstLine = true;
    fileSystemConfig.formats.put("csvh-test", csvhtestConfig);
    pluginRegistry.createOrUpdate(storagePlugin, fileSystemConfig, true);
}
Also used : FileSystemPlugin(org.apache.drill.exec.store.dfs.FileSystemPlugin) SequenceFileFormatConfig(org.apache.drill.exec.store.easy.sequencefile.SequenceFileFormatConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) TextFormatPlugin(org.apache.drill.exec.store.easy.text.TextFormatPlugin)

Example 2 with SequenceFileFormatConfig

use of org.apache.drill.exec.store.easy.sequencefile.SequenceFileFormatConfig in project drill by apache.

the class StoragePluginTestUtils method configureFormatPlugins.

public static void configureFormatPlugins(StoragePluginRegistry pluginRegistry, String storagePlugin) throws PluginException {
    FileSystemConfig fileSystemConfig = (FileSystemConfig) pluginRegistry.getStoredConfig(storagePlugin);
    Map<String, FormatPluginConfig> newFormats = new HashMap<>();
    Optional.ofNullable(fileSystemConfig.getFormats()).ifPresent(newFormats::putAll);
    newFormats.put("txt", new TextFormatConfig(ImmutableList.of("txt"), null, "\u0000", null, null, null, null, null));
    newFormats.put("ssv", new TextFormatConfig(ImmutableList.of("ssv"), null, " ", null, null, null, null, null));
    newFormats.put("psv", new TextFormatConfig(ImmutableList.of("tbl"), null, "|", null, null, null, null, null));
    SequenceFileFormatConfig seqConfig = new SequenceFileFormatConfig(ImmutableList.of("seq"));
    newFormats.put("sequencefile", seqConfig);
    newFormats.put("csvh-test", new TextFormatConfig(ImmutableList.of("csvh-test"), null, ",", null, null, null, true, true));
    FileSystemConfig newFileSystemConfig = new FileSystemConfig(fileSystemConfig.getConnection(), fileSystemConfig.getConfig(), fileSystemConfig.getWorkspaces(), newFormats, PlainCredentialsProvider.EMPTY_CREDENTIALS_PROVIDER);
    newFileSystemConfig.setEnabled(fileSystemConfig.isEnabled());
    pluginRegistry.put(storagePlugin, newFileSystemConfig);
}
Also used : SequenceFileFormatConfig(org.apache.drill.exec.store.easy.sequencefile.SequenceFileFormatConfig) HashMap(java.util.HashMap) FormatPluginConfig(org.apache.drill.common.logical.FormatPluginConfig) TextFormatConfig(org.apache.drill.exec.store.easy.text.TextFormatPlugin.TextFormatConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig)

Aggregations

FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)2 SequenceFileFormatConfig (org.apache.drill.exec.store.easy.sequencefile.SequenceFileFormatConfig)2 HashMap (java.util.HashMap)1 FormatPluginConfig (org.apache.drill.common.logical.FormatPluginConfig)1 FileSystemPlugin (org.apache.drill.exec.store.dfs.FileSystemPlugin)1 TextFormatPlugin (org.apache.drill.exec.store.easy.text.TextFormatPlugin)1 TextFormatConfig (org.apache.drill.exec.store.easy.text.TextFormatPlugin.TextFormatConfig)1