Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public Optional<Converter> visit(LogicalTypeAnnotation.ListLogicalTypeAnnotation
public Optional<Converter> visit(LogicalTypeAnnotation.MapLogicalTypeAnnotation mapLogicalType) {
return of(new MapConverter(parentBuilder, fieldDescriptor, parquetType));
}
}).orElse(newScalarConverter(parent, parentBuilder, fieldDescriptor, parquetType));
}).orElseGet(() -> newScalarConverter(parent, parentBuilder, fieldDescriptor, parquetType));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, the root cause is we use orElse here, instead of orElseGet.
orElseGet is the lazy way to get the fallback value, while orElse is not. In the case of repeated fields (list and map), it was still trying to call newScalarConverter while using orELse, which is irrelevant (and thus the bug).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @qinghui-xu , looks like the fix you suggested works well!

In this case, the good news: this is a bug, which is not yet released, because that orElse was added by me in PARQUET-1410 (my bad). Bad news: it is a regression, would be nice to get this committed before next release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the prompt fix.


private Converter newScalarConverter(ParentValueContainer pvc, Message.Builder parentBuilder, Descriptors.FieldDescriptor fieldDescriptor, Type parquetType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public void testMapIntMessageClassSchemaCompliant() throws Exception {
ProtoWriteSupport.setWriteSpecsCompliant(conf, true);

Path outputPath = new WriteUsingMR(conf).write(msgEmpty, msgNonEmpty);
ReadUsingMR readUsingMR = new ReadUsingMR();
ReadUsingMR readUsingMR = new ReadUsingMR(conf);
String customClass = TestProtobuf.MapIntMessage.class.getName();
ProtoReadSupport.setProtobufClass(readUsingMR.getConfiguration(), customClass);
List<Message> result = readUsingMR.read(outputPath);
Expand Down Expand Up @@ -303,7 +303,7 @@ public void testRepeatedInnerMessageClassSchemaCompliant() throws Exception {
ProtoWriteSupport.setWriteSpecsCompliant(conf, true);

Path outputPath = new WriteUsingMR(conf).write(msgEmpty, msgNonEmpty);
ReadUsingMR readUsingMR = new ReadUsingMR();
ReadUsingMR readUsingMR = new ReadUsingMR(conf);
String customClass = TestProtobuf.RepeatedInnerMessage.class.getName();
ProtoReadSupport.setProtobufClass(readUsingMR.getConfiguration(), customClass);
List<Message> result = readUsingMR.read(outputPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
/*
* 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
Expand All @@ -28,7 +28,6 @@
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
import org.apache.parquet.proto.ProtoParquetInputFormat;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -41,19 +40,27 @@ public class ReadUsingMR {

private static List<Message> outputMessages;

Configuration conf = new Configuration();
Configuration conf;
private String projection;

public void setRequestedProjection(String projection) {
this.projection = projection;
}

public ReadUsingMR() {
this(new Configuration());
}

public ReadUsingMR(Configuration conf) {
this.conf = conf;
}

public Configuration getConfiguration() {
return conf;
}

public static class ReadingMapper extends Mapper<Void, MessageOrBuilder, LongWritable, Message> {
protected void map(Void key, MessageOrBuilder value, Context context) throws IOException, InterruptedException {
protected void map(Void key, MessageOrBuilder value, Context context) {
Message clone = ((Message.Builder) value).build();
outputMessages.add(clone);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
/*
* 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
Expand All @@ -33,7 +33,6 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand All @@ -55,7 +54,7 @@ public WriteUsingMR() {
}

public WriteUsingMR(Configuration conf) {
this.conf = new Configuration();
this.conf = conf;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

}

public Configuration getConfiguration() {
Expand Down