Search in sources :

Example 1 with RecordWriter

use of org.apache.drill.exec.store.RecordWriter in project drill by apache.

the class JSONFormatPlugin method getRecordWriter.

@Override
public RecordWriter getRecordWriter(FragmentContext context, EasyWriter writer) throws IOException {
    Map<String, String> options = Maps.newHashMap();
    options.put("location", writer.getLocation());
    FragmentHandle handle = context.getHandle();
    String fragmentId = String.format("%d_%d", handle.getMajorFragmentId(), handle.getMinorFragmentId());
    options.put("prefix", fragmentId);
    options.put("separator", " ");
    options.put(FileSystem.FS_DEFAULT_NAME_KEY, ((FileSystemConfig) writer.getStorageConfig()).connection);
    options.put("extension", "json");
    options.put("extended", Boolean.toString(context.getOptions().getOption(ExecConstants.JSON_EXTENDED_TYPES)));
    options.put("uglify", Boolean.toString(context.getOptions().getOption(ExecConstants.JSON_WRITER_UGLIFY)));
    options.put("skipnulls", Boolean.toString(context.getOptions().getOption(ExecConstants.JSON_WRITER_SKIPNULLFIELDS)));
    RecordWriter recordWriter = new JsonRecordWriter(writer.getStorageStrategy());
    recordWriter.init(options);
    return recordWriter;
}
Also used : RecordWriter(org.apache.drill.exec.store.RecordWriter) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle)

Example 2 with RecordWriter

use of org.apache.drill.exec.store.RecordWriter in project drill by apache.

the class TextFormatPlugin method getRecordWriter.

@Override
public RecordWriter getRecordWriter(final FragmentContext context, final EasyWriter writer) throws IOException {
    final Map<String, String> options = Maps.newHashMap();
    options.put("location", writer.getLocation());
    FragmentHandle handle = context.getHandle();
    String fragmentId = String.format("%d_%d", handle.getMajorFragmentId(), handle.getMinorFragmentId());
    options.put("prefix", fragmentId);
    options.put("separator", ((TextFormatConfig) getConfig()).getFieldDelimiterAsString());
    options.put(FileSystem.FS_DEFAULT_NAME_KEY, ((FileSystemConfig) writer.getStorageConfig()).connection);
    options.put("extension", ((TextFormatConfig) getConfig()).getExtensions().get(0));
    RecordWriter recordWriter = new DrillTextRecordWriter(context.getAllocator(), writer.getStorageStrategy());
    recordWriter.init(options);
    return recordWriter;
}
Also used : RecordWriter(org.apache.drill.exec.store.RecordWriter) DrillTextRecordWriter(org.apache.drill.exec.store.text.DrillTextRecordWriter) DrillTextRecordWriter(org.apache.drill.exec.store.text.DrillTextRecordWriter) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle)

Example 3 with RecordWriter

use of org.apache.drill.exec.store.RecordWriter in project drill by apache.

the class ParquetFormatPlugin method getRecordWriter.

public RecordWriter getRecordWriter(FragmentContext context, ParquetWriter writer) throws IOException, OutOfMemoryException {
    Map<String, String> options = Maps.newHashMap();
    options.put("location", writer.getLocation());
    FragmentHandle handle = context.getHandle();
    String fragmentId = String.format("%d_%d", handle.getMajorFragmentId(), handle.getMinorFragmentId());
    options.put("prefix", fragmentId);
    options.put(FileSystem.FS_DEFAULT_NAME_KEY, ((FileSystemConfig) writer.getStorageConfig()).connection);
    options.put(ExecConstants.PARQUET_BLOCK_SIZE, context.getOptions().getOption(ExecConstants.PARQUET_BLOCK_SIZE).num_val.toString());
    options.put(ExecConstants.PARQUET_WRITER_USE_SINGLE_FS_BLOCK, context.getOptions().getOption(ExecConstants.PARQUET_WRITER_USE_SINGLE_FS_BLOCK).bool_val.toString());
    options.put(ExecConstants.PARQUET_PAGE_SIZE, context.getOptions().getOption(ExecConstants.PARQUET_PAGE_SIZE).num_val.toString());
    options.put(ExecConstants.PARQUET_DICT_PAGE_SIZE, context.getOptions().getOption(ExecConstants.PARQUET_DICT_PAGE_SIZE).num_val.toString());
    options.put(ExecConstants.PARQUET_WRITER_COMPRESSION_TYPE, context.getOptions().getOption(ExecConstants.PARQUET_WRITER_COMPRESSION_TYPE).string_val);
    options.put(ExecConstants.PARQUET_WRITER_ENABLE_DICTIONARY_ENCODING, context.getOptions().getOption(ExecConstants.PARQUET_WRITER_ENABLE_DICTIONARY_ENCODING).bool_val.toString());
    RecordWriter recordWriter = new ParquetRecordWriter(context, writer);
    recordWriter.init(options);
    return recordWriter;
}
Also used : RecordWriter(org.apache.drill.exec.store.RecordWriter) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle) MagicString(org.apache.drill.exec.store.dfs.MagicString)

Aggregations

FragmentHandle (org.apache.drill.exec.proto.ExecProtos.FragmentHandle)3 RecordWriter (org.apache.drill.exec.store.RecordWriter)3 MagicString (org.apache.drill.exec.store.dfs.MagicString)1 DrillTextRecordWriter (org.apache.drill.exec.store.text.DrillTextRecordWriter)1