Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORC-1023: Support writing bloom filters in ConvertTool #933

Merged
merged 2 commits into from
Oct 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions java/tools/src/java/org/apache/orc/tools/convert/ConvertTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class ConvertTool {
private final int csvHeaderLines;
private final String csvNullString;
private final String timestampFormat;
private final String bloomFilterColumns;
private final Writer writer;
private final VectorizedRowBatch batch;

Expand Down Expand Up @@ -194,11 +195,17 @@ public ConvertTool(Configuration conf,
this.csvHeaderLines = getIntOption(opts, 'H', 0);
this.csvNullString = opts.getOptionValue('n', "");
this.timestampFormat = opts.getOptionValue("t", DEFAULT_TIMESTAMP_FORMAT);
this.bloomFilterColumns = opts.getOptionValue('b', null);
String outFilename = opts.hasOption('o')
? opts.getOptionValue('o') : "output.orc";
boolean overwrite = opts.hasOption('O');
writer = OrcFile.createWriter(new Path(outFilename),
OrcFile.writerOptions(conf).setSchema(schema).overwrite(overwrite));
OrcFile.WriterOptions writerOpts = OrcFile.writerOptions(conf)
.setSchema(schema)
.overwrite(overwrite);
if (this.bloomFilterColumns != null) {
writerOpts.bloomFilterColumns(this.bloomFilterColumns);
}
writer = OrcFile.createWriter(new Path(outFilename), writerOpts);
batch = schema.createRowBatch();
}

Expand Down Expand Up @@ -238,6 +245,10 @@ private static CommandLine parseOptions(String[] args) throws ParseException {
options.addOption(
Option.builder("s").longOpt("schema").hasArg()
.desc("The schema to write in to the file").build());
options.addOption(
Option.builder("b").longOpt("bloomFilterColumns").hasArg()
.desc("Comma separated values of column names for which bloom filter is " +
"to be created").build());
options.addOption(
Option.builder("o").longOpt("output").desc("Output filename")
.hasArg().build());
Expand Down