Skip to content

Commit 10fd782

Browse files
committed
Revert "[WIP] Refactor GroupReadSupport to unuse deprecated api (#894)"
Reverting this because it contains backward incompatbile changes. This reverts commit 48f5195.
1 parent 2ce35c7 commit 10fd782

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

parquet-hadoop/src/main/java/org/apache/parquet/hadoop/example/GroupReadSupport.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/*
1+
/*
22
* Licensed to the Apache Software Foundation (ASF) under one
33
* or more contributor license agreements. See the NOTICE file
44
* distributed with this work for additional information
55
* regarding copyright ownership. The ASF licenses this file
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
9+
*
1010
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
11+
*
1212
* Unless required by applicable law or agreed to in writing,
1313
* software distributed under the License is distributed on an
1414
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -24,17 +24,18 @@
2424

2525
import org.apache.parquet.example.data.Group;
2626
import org.apache.parquet.example.data.simple.convert.GroupRecordConverter;
27-
import org.apache.parquet.hadoop.api.InitContext;
2827
import org.apache.parquet.hadoop.api.ReadSupport;
2928
import org.apache.parquet.io.api.RecordMaterializer;
3029
import org.apache.parquet.schema.MessageType;
3130

3231
public class GroupReadSupport extends ReadSupport<Group> {
3332

3433
@Override
35-
public ReadContext init(InitContext context) {
36-
String partialSchemaString = context.getConfiguration().get(ReadSupport.PARQUET_READ_SCHEMA);
37-
MessageType requestedProjection = getSchemaForRead(context.getFileSchema(), partialSchemaString);
34+
public org.apache.parquet.hadoop.api.ReadSupport.ReadContext init(
35+
Configuration configuration, Map<String, String> keyValueMetaData,
36+
MessageType fileSchema) {
37+
String partialSchemaString = configuration.get(ReadSupport.PARQUET_READ_SCHEMA);
38+
MessageType requestedProjection = getSchemaForRead(fileSchema, partialSchemaString);
3839
return new ReadContext(requestedProjection);
3940
}
4041

parquet-hadoop/src/test/java/org/apache/parquet/hadoop/example/GroupReadSupportTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/*
1+
/*
22
* Licensed to the Apache Software Foundation (ASF) under one
33
* or more contributor license agreements. See the NOTICE file
44
* distributed with this work for additional information
55
* regarding copyright ownership. The ASF licenses this file
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
9+
*
1010
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
11+
*
1212
* Unless required by applicable law or agreed to in writing,
1313
* software distributed under the License is distributed on an
1414
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,9 +18,7 @@
1818
*/
1919
package org.apache.parquet.hadoop.example;
2020

21-
import java.util.Set;
2221
import org.apache.hadoop.conf.Configuration;
23-
import org.apache.parquet.hadoop.api.InitContext;
2422
import org.junit.Test;
2523
import org.apache.parquet.hadoop.api.ReadSupport;
2624
import org.apache.parquet.schema.MessageType;
@@ -45,23 +43,23 @@ public class GroupReadSupportTest {
4543
public void testInitWithoutSpecifyingRequestSchema() throws Exception {
4644
GroupReadSupport s = new GroupReadSupport();
4745
Configuration configuration = new Configuration();
48-
Map<String, Set<String>> keyValueMetaData = new HashMap<>();
46+
Map<String, String> keyValueMetaData = new HashMap<String, String>();
4947
MessageType fileSchema = MessageTypeParser.parseMessageType(fullSchemaStr);
5048

51-
ReadSupport.ReadContext context = s.init(new InitContext(configuration, keyValueMetaData, fileSchema));
49+
ReadSupport.ReadContext context = s.init(configuration, keyValueMetaData, fileSchema);
5250
assertEquals(context.getRequestedSchema(), fileSchema);
5351
}
5452

5553
@Test
5654
public void testInitWithPartialSchema() {
5755
GroupReadSupport s = new GroupReadSupport();
5856
Configuration configuration = new Configuration();
59-
Map<String, Set<String>> keyValueMetaData = new HashMap<>();
57+
Map<String, String> keyValueMetaData = new HashMap<String, String>();
6058
MessageType fileSchema = MessageTypeParser.parseMessageType(fullSchemaStr);
6159
MessageType partialSchema = MessageTypeParser.parseMessageType(partialSchemaStr);
6260
configuration.set(ReadSupport.PARQUET_READ_SCHEMA, partialSchemaStr);
6361

64-
ReadSupport.ReadContext context = s.init(new InitContext(configuration, keyValueMetaData, fileSchema));
62+
ReadSupport.ReadContext context = s.init(configuration, keyValueMetaData, fileSchema);
6563
assertEquals(context.getRequestedSchema(), partialSchema);
6664
}
6765
}

parquet-thrift/src/test/java/org/apache/parquet/hadoop/thrift/TestThriftToParquetFileWriter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import org.apache.hadoop.fs.FileStatus;
3030
import org.apache.parquet.column.statistics.*;
31-
import org.apache.parquet.hadoop.api.InitContext;
3231
import org.apache.parquet.hadoop.metadata.BlockMetaData;
3332
import org.apache.parquet.hadoop.metadata.ColumnChunkMetaData;
3433
import org.apache.parquet.hadoop.util.ContextUtil;
@@ -329,7 +328,7 @@ private ParquetReader<Group> createRecordReader(Path parquetFilePath) throws IOE
329328
ParquetMetadata readFooter = ParquetFileReader.readFooter(configuration, parquetFilePath);
330329
MessageType schema = readFooter.getFileMetaData().getSchema();
331330

332-
readSupport.init(new InitContext(configuration, null, schema));
331+
readSupport.init(configuration, null, schema);
333332
return new ParquetReader<Group>(parquetFilePath, readSupport);
334333
}
335334

0 commit comments

Comments
 (0)