/* 
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.parquet.proto;

import com.google.protobuf.Message;
import com.google.protobuf.MessageOrBuilder;
import org.apache.hadoop.fs.Path;
import org.apache.parquet.hadoop.ParquetWriter;
import org.apache.parquet.hadoop.api.WriteSupport;
import org.apache.parquet.hadoop.metadata.CompressionCodecName;

import java.io.IOException;

/**
 * Write Protobuf records to a Parquet file.
 */
public class ProtoParquetWriter<T extends MessageOrBuilder> extends ParquetWriter<T> {

  /**
   * Create a new {@link ProtoParquetWriter}.
   *
   * @param file                 The file name to write to.
   * @param protoMessage         Protobuf message class
   * @param compressionCodecName Compression code to use, or CompressionCodecName.UNCOMPRESSED
   * @param blockSize            HDFS block size
   * @param pageSize             See parquet write up. Blocks are subdivided into pages for alignment and other purposes.
   * @throws IOException if there is an error while writing
   */
  public ProtoParquetWriter(Path file, Class<? extends Message> protoMessage,
                            CompressionCodecName compressionCodecName, int blockSize,
                            int pageSize) throws IOException {
    super(file, new ProtoWriteSupport(protoMessage),
            compressionCodecName, blockSize, pageSize);
  }

  /**
   * Create a new {@link ProtoParquetWriter}.
   *
   * @param file                 The file name to write to.
   * @param protoMessage         Protobuf message class
   * @param compressionCodecName Compression code to use, or CompressionCodecName.UNCOMPRESSED
   * @param blockSize            HDFS block size
   * @param pageSize             See parquet write up. Blocks are subdivided into pages for alignment and other purposes.
   * @param enableDictionary     Whether to use a dictionary to compress columns.
   * @param validating           to turn on validation using the schema
   * @throws IOException if there is an error while writing
   */
  public ProtoParquetWriter(Path file, Class<? extends Message> protoMessage,
                            CompressionCodecName compressionCodecName, int blockSize,
                            int pageSize, boolean enableDictionary, boolean validating) throws IOException {
    super(file, new ProtoWriteSupport(protoMessage),
            compressionCodecName, blockSize, pageSize, enableDictionary, validating);
  }

  /**
   * Create a new {@link ProtoParquetWriter}. The default block size is 50 MB.The default
   * page size is 1 MB.  Default compression is no compression. (Inherited from {@link ParquetWriter})
   *
   * @param file The file name to write to.
   * @param protoMessage         Protobuf message class
   * @throws IOException if there is an error while writing
   */
  public ProtoParquetWriter(Path file, Class<? extends Message> protoMessage) throws IOException {
    this(file, protoMessage, CompressionCodecName.UNCOMPRESSED,
            DEFAULT_BLOCK_SIZE, DEFAULT_PAGE_SIZE);
  }

}

@@ -1116,16 +1116,102 @@
 decName;
+%0Aimport org.apache.parquet.io.OutputFile;%0Aimport org.apache.hadoop.conf.Configuration;
 %0A%0Aimport
@@ -3885,11 +3885,959 @@
 E);%0A  %7D%0A
+  %0A  public static %3CT%3E Builder%3CT%3E builder(Path file) %7B%0A%09    return new Builder%3CT%3E(file);%0A%09%7D%0A%0A%09public static %3CT%3E Builder%3CT%3E builder(OutputFile file) %7B%0A%09    return new Builder%3CT%3E(file);%0A%09%7D%0A%09%0A%09private static %3CT extends MessageOrBuilder%3E WriteSupport%3CT%3E writeSupport(Class%3C? extends Message%3E protoMessage) %7B%0A%09%09return new ProtoWriteSupport%3CT%3E(protoMessage);%0A%09%7D%0A%09  %0A%09public static class Builder%3CT%3E extends ParquetWriter.Builder%3CT, Builder%3CT%3E%3E %7B%0A%09%09  %0A%09%09Class%3C? extends Message%3E protoMessage = null;%0A%0A%09%09private Builder(Path file) %7B%0A%09%09%09super(file);%0A%09%09%7D%0A%0A%09%09private Builder(OutputFile file) %7B%0A%09%09    super(file);%0A%09%09%7D%0A%0A%09%09protected Builder%3CT%3E self() %7B%0A%09%09    return this;%0A%09%09%7D%0A%09%09%0A%09%09public Builder%3CT%3E withMessage(Class%3C? extends Message%3E protoMessage)%7B%0A%09%09%09this.protoMessage = protoMessage;%0A%09%09%09return this;%0A%09%09%7D%0A%0A%09%09protected WriteSupport%3CT%3E getWriteSupport(Configuration conf) %7B%0A%09%09    return (WriteSupport%3CT%3E) ProtoParquetWriter.writeSupport(protoMessage);%0A%09%09%7D    %0A%09%7D
 %0A%7D%0A

Add missing Builder Class to ProtoParquetWriter Class (#791)