com.marklogic.flux.impl.export.ExportParquetFilesCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flux-api Show documentation
Show all versions of flux-api Show documentation
Flux API for data movement with MarkLogic
/*
* Copyright © 2024 MarkLogic Corporation. All Rights Reserved.
*/
package com.marklogic.flux.impl.export;
import com.marklogic.flux.api.ParquetFilesExporter;
import com.marklogic.flux.api.ReadRowsOptions;
import com.marklogic.flux.api.WriteSparkFilesOptions;
import picocli.CommandLine;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
@CommandLine.Command(
name = "export-parquet-files",
description = "Read rows via Optic from MarkLogic and write them to Parquet files on a local filesystem, HDFS, or S3 " +
"using Spark's support defined at %nhttps://spark.apache.org/docs/latest/sql-data-sources-parquet.html ."
)
public class ExportParquetFilesCommand extends AbstractExportRowsToFilesCommand implements ParquetFilesExporter {
@CommandLine.Mixin
private WriteParquetFilesParams writeParams = new WriteParquetFilesParams();
@Override
protected String getWriteFormat() {
return "parquet";
}
@Override
protected WriteStructuredFilesParams getWriteFilesParams() {
return writeParams;
}
public static class WriteParquetFilesParams extends WriteStructuredFilesParams implements WriteSparkFilesOptions {
@CommandLine.Option(
names = "-P",
description = "Specify any Spark Parquet option defined at " +
"%nhttps://spark.apache.org/docs/latest/sql-data-sources-parquet.html; e.g. -Pcompression=gzip."
)
private Map additionalOptions = new HashMap<>();
@Override
public Map get() {
return additionalOptions;
}
@Override
public WriteSparkFilesOptions additionalOptions(Map options) {
this.additionalOptions = options;
return this;
}
}
@Override
public ParquetFilesExporter from(Consumer consumer) {
consumer.accept(readParams);
return this;
}
@Override
public ParquetFilesExporter from(String opticQuery) {
readParams.opticQuery(opticQuery);
return this;
}
@Override
public ParquetFilesExporter to(Consumer consumer) {
consumer.accept(writeParams);
return this;
}
@Override
public ParquetFilesExporter to(String path) {
writeParams.path(path);
return this;
}
}