java 生成parquet文件格式_java或者scala如何生成parquet文件

很多的:

java代码实例parquet.hadoop.parquetwriter

例子1:

[mw_shl_code=java,true]private boolean closeFile() {

boolean retval = false;

if( data.parquetWriters != null ) {

Iterator openFiles = data.parquetWriters.iterator();

while ( openFiles.hasNext() ) {

ParquetWriter writer = openFiles.next();

if ( writer != null ) {

try {

writer.close();

} catch ( Exception e ) {

logBasic( "Error trying to close file.  This may not be a problem.");

logDetailed( "Stack trace from error trying to close file:", e );

}

writer = null;

}

}

if ( log.isDebug() ) {

logDebug( "Closed all open parquet writers." );

}

}

return retval;

}

[/mw_shl_code]

例子2:

[mw_shl_code=java,true]public ParquetOutputData() {

super();

daf = new SimpleDateFormat();

dafs = new DateFormatSymbols();

defaultDateFormat = new SimpleDateFormat();

defaultDateFormatSymbols = new DateFormatSymbols();

openFiles = new ArrayList();

parquetWriters = new ArrayList();

}

[/mw_shl_code]

例子3:

[mw_shl_code=java,true]@Override

public void open() {

Preconditions.checkState(state.equals(ReaderWriterState.NEW),

"Unable to open a writer from state:%s", state);

logger.debug(

"Opening data file with pathTmp:{} (final path will be path:{})",

pathTmp, path);

try {

CompressionCodecName codecName = CompressionCodecName.UNCOMPRESSED;

if (enableCompression) {

if (SnappyCodec.isNativeCodeLoaded()) {

codecName = CompressionCodecName.SNAPPY;

} else {

logger.warn("Compression enabled, but Snappy native code not loaded. " +

"Parquet file will not be compressed.");

}

}

avroParquetWriter = new AvroParquetWriter(fileSystem.makeQualified(pathTmp),

schema, codecName, DEFAULT_BLOCK_SIZE,

ParquetWriter.DEFAULT_PAGE_SIZE);

} catch (IOException e) {

throw new DatasetWriterException("Unable to create writer to path:" + pathTmp, e);

}

state = ReaderWriterState.OPEN;

}[/mw_shl_code]

更多

http://www.aboutyun.com/home.php ... do=blog&id=3078

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值