flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-7243) Add ParquetInputFormat
Date Wed, 10 Oct 2018 22:49:04 GMT

    [ https://issues.apache.org/jira/browse/FLINK-7243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16645657#comment-16645657
] 

ASF GitHub Bot commented on FLINK-7243:
---------------------------------------

fhueske commented on a change in pull request #6483: [FLINK-7243][flink-formats] Add parquet
input format
URL: https://github.com/apache/flink/pull/6483#discussion_r224246563
 
 

 ##########
 File path: flink-formats/flink-parquet/src/main/java/org/apache/flink/formats/parquet/utils/ParquetRecordReader.java
 ##########
 @@ -0,0 +1,196 @@
+/*
+ * 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.flink.formats.parquet.utils;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.parquet.column.page.PageReadStore;
+import org.apache.parquet.filter2.compat.FilterCompat;
+import org.apache.parquet.filter2.compat.FilterCompat.Filter;
+import org.apache.parquet.hadoop.ParquetFileReader;
+import org.apache.parquet.hadoop.api.InitContext;
+import org.apache.parquet.hadoop.api.ReadSupport;
+import org.apache.parquet.hadoop.metadata.FileMetaData;
+import org.apache.parquet.io.ColumnIOFactory;
+import org.apache.parquet.io.MessageColumnIO;
+import org.apache.parquet.io.RecordReader;
+import org.apache.parquet.io.api.RecordMaterializer;
+import org.apache.parquet.io.api.RecordMaterializer.RecordMaterializationException;
+import org.apache.parquet.schema.MessageType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.CheckReturnValue;
+import javax.annotation.meta.When;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static org.apache.parquet.Preconditions.checkNotNull;
+
+/**
+ * Customized {@link org.apache.parquet.hadoop.ParquetRecordReader} that support start read
from particular position.
+ */
+public class ParquetRecordReader<T> {
+	private static final Logger LOG = LoggerFactory.getLogger(ParquetRecordReader.class);
+
+	private ColumnIOFactory columnIOFactory;
+	private Filter filter;
+
+	private MessageType readSchema;
+	private MessageType fileSchema;
+	private ReadSupport<T> readSupport;
+
+	private RecordMaterializer<T> recordMaterializer;
+	private T currentValue;
+	private long total;
+	private long current = 0;
+	private int currentBlock = -1;
+	private ParquetFileReader reader;
+	private RecordReader<T> recordReader;
+	private boolean strictTypeChecking = true;
+	private long totalCountLoadedSoFar = 0;
+
+	public ParquetRecordReader(ReadSupport<T> readSupport, MessageType readSchema, Filter
filter) {
+		this.readSupport = readSupport;
+		this.readSchema = readSchema;
+		this.filter = checkNotNull(filter, "filter");
+	}
+
+	public ParquetRecordReader(ReadSupport<T> readSupport, MessageType readSchema) {
+		this(readSupport, readSchema, FilterCompat.NOOP);
+	}
+
+	public void initialize(ParquetFileReader reader, Configuration configuration) {
+		this.reader = reader;
+		FileMetaData parquetFileMetadata = reader.getFooter().getFileMetaData();
+		this.fileSchema = parquetFileMetadata.getSchema();
 
 Review comment:
   I don't quite follow how the different schemas are used and overwritten. Can you please
add some comments?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Add ParquetInputFormat
> ----------------------
>
>                 Key: FLINK-7243
>                 URL: https://issues.apache.org/jira/browse/FLINK-7243
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API &amp; SQL
>            Reporter: godfrey he
>            Assignee: Zhenqiu Huang
>            Priority: Major
>              Labels: pull-request-available
>
> Add a {{ParquetInputFormat}} to read data from a Apache Parquet file. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message