You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/03/15 10:45:30 UTC

[GitHub] [beam] iemejia opened a new pull request #14229: [BEAM-11972] Close all opened channels/readers on ParquetIO

iemejia opened a new pull request #14229:
URL: https://github.com/apache/beam/pull/14229


   R: @aromanenko-dev 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [beam] iemejia commented on pull request #14229: [BEAM-11972] Close all opened channels/readers on ParquetIO

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14229:
URL: https://github.com/apache/beam/pull/14229#issuecomment-799592890


   Logging fixed, PTAL again @aromanenko-dev 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [beam] iemejia removed a comment on pull request #14229: [BEAM-11972] Close all opened channels/readers on ParquetIO

Posted by GitBox <gi...@apache.org>.
iemejia removed a comment on pull request #14229:
URL: https://github.com/apache/beam/pull/14229#issuecomment-799367563


   Run Java PreCommit


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [beam] iemejia commented on a change in pull request #14229: [BEAM-11972] Close all opened channels/readers on ParquetIO

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #14229:
URL: https://github.com/apache/beam/pull/14229#discussion_r594343385



##########
File path: sdks/java/io/parquet/src/main/java/org/apache/beam/sdk/io/parquet/ParquetIO.java
##########
@@ -762,83 +762,86 @@ public void processElement(
               conf, new Schema.Parser().parse(requestSchemaString));
         }
         ParquetReadOptions options = HadoopReadOptions.builder(conf).build();
-        ParquetFileReader reader =
-            ParquetFileReader.open(new BeamParquetInputFile(file.openSeekable()), options);
-        Filter filter = checkNotNull(options.getRecordFilter(), "filter");
-        Configuration hadoopConf = ((HadoopReadOptions) options).getConf();
-        FileMetaData parquetFileMetadata = reader.getFooter().getFileMetaData();
-        MessageType fileSchema = parquetFileMetadata.getSchema();
-        Map<String, String> fileMetadata = parquetFileMetadata.getKeyValueMetaData();
-        ReadSupport.ReadContext readContext =
-            readSupport.init(
-                new InitContext(
-                    hadoopConf, Maps.transformValues(fileMetadata, ImmutableSet::of), fileSchema));
-        ColumnIOFactory columnIOFactory = new ColumnIOFactory(parquetFileMetadata.getCreatedBy());
-
-        RecordMaterializer<GenericRecord> recordConverter =
-            readSupport.prepareForRead(hadoopConf, fileMetadata, fileSchema, readContext);
-        reader.setRequestedSchema(readContext.getRequestedSchema());
-        MessageColumnIO columnIO =
-            columnIOFactory.getColumnIO(readContext.getRequestedSchema(), fileSchema, true);
-        long currentBlock = tracker.currentRestriction().getFrom();
-        for (int i = 0; i < currentBlock; i++) {
-          reader.skipNextRowGroup();
-        }
-        while (tracker.tryClaim(currentBlock)) {
-          PageReadStore pages = reader.readNextRowGroup();
-          LOG.debug("block {} read in memory. row count = {}", currentBlock, pages.getRowCount());
-          currentBlock += 1;
-          RecordReader<GenericRecord> recordReader =
-              columnIO.getRecordReader(
-                  pages, recordConverter, options.useRecordFilter() ? filter : FilterCompat.NOOP);
-          long currentRow = 0;
-          long totalRows = pages.getRowCount();
-          while (currentRow < totalRows) {
-            try {
-              GenericRecord record;
-              currentRow += 1;
+        try (ParquetFileReader reader =

Review comment:
       Yes it is only that.

##########
File path: sdks/java/io/parquet/src/main/java/org/apache/beam/sdk/io/parquet/ParquetIO.java
##########
@@ -1012,14 +1016,15 @@ public void processElement(ProcessContext processContext) throws Exception {
         try (ParquetReader<GenericRecord> reader = builder.build()) {
           GenericRecord read;
           while ((read = reader.read()) != null) {
-            processContext.output(parseFn.apply(read));
+            receiver.output(parseFn.apply(read));

Review comment:
       Shorter code (one line less) + Using nicer Beam style.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [beam] aromanenko-dev commented on a change in pull request #14229: [BEAM-11972] Close all opened channels/readers on ParquetIO

Posted by GitBox <gi...@apache.org>.
aromanenko-dev commented on a change in pull request #14229:
URL: https://github.com/apache/beam/pull/14229#discussion_r594269053



##########
File path: sdks/java/io/parquet/src/test/resources/log4j-test.properties
##########
@@ -0,0 +1,39 @@
+################################################################################
+#  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.
+################################################################################
+
+# Set root logger level to ERROR.
+# set manually to INFO for debugging purposes.
+log4j.rootLogger=ERROR, testlogger
+
+# ConsoleAppender.
+log4j.appender.testlogger=org.apache.log4j.ConsoleAppender
+log4j.appender.testlogger.target = System.err
+log4j.appender.testlogger.layout=org.apache.log4j.PatternLayout
+log4j.appender.testlogger.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
+
+# Beam SDK logging
+log4j.logger.org.apache.beam=INFO
+#log4j.logger.org.apache.beam.sdk.options.PipelineOptionsFactory=INFO
+#log4j.logger.org.apache.beam.sdk.runners.TransformHierarchy=INFO
+#log4j.logger.org.apache.beam.sdk.util.WindowTracing=INFO
+log4j.logger.org.apache.beam.sdk.io.LocalFileSystem=DEBUG

Review comment:
       I guess that log level was temporary changed and it should be back to INFO?

##########
File path: sdks/java/io/parquet/src/main/java/org/apache/beam/sdk/io/parquet/ParquetIO.java
##########
@@ -1012,14 +1016,15 @@ public void processElement(ProcessContext processContext) throws Exception {
         try (ParquetReader<GenericRecord> reader = builder.build()) {
           GenericRecord read;
           while ((read = reader.read()) != null) {
-            processContext.output(parseFn.apply(read));
+            receiver.output(parseFn.apply(read));

Review comment:
       What is a reason of using this instead of `ProcessContext`?

##########
File path: sdks/java/io/parquet/src/main/java/org/apache/beam/sdk/io/parquet/ParquetIO.java
##########
@@ -762,83 +762,86 @@ public void processElement(
               conf, new Schema.Parser().parse(requestSchemaString));
         }
         ParquetReadOptions options = HadoopReadOptions.builder(conf).build();
-        ParquetFileReader reader =
-            ParquetFileReader.open(new BeamParquetInputFile(file.openSeekable()), options);
-        Filter filter = checkNotNull(options.getRecordFilter(), "filter");
-        Configuration hadoopConf = ((HadoopReadOptions) options).getConf();
-        FileMetaData parquetFileMetadata = reader.getFooter().getFileMetaData();
-        MessageType fileSchema = parquetFileMetadata.getSchema();
-        Map<String, String> fileMetadata = parquetFileMetadata.getKeyValueMetaData();
-        ReadSupport.ReadContext readContext =
-            readSupport.init(
-                new InitContext(
-                    hadoopConf, Maps.transformValues(fileMetadata, ImmutableSet::of), fileSchema));
-        ColumnIOFactory columnIOFactory = new ColumnIOFactory(parquetFileMetadata.getCreatedBy());
-
-        RecordMaterializer<GenericRecord> recordConverter =
-            readSupport.prepareForRead(hadoopConf, fileMetadata, fileSchema, readContext);
-        reader.setRequestedSchema(readContext.getRequestedSchema());
-        MessageColumnIO columnIO =
-            columnIOFactory.getColumnIO(readContext.getRequestedSchema(), fileSchema, true);
-        long currentBlock = tracker.currentRestriction().getFrom();
-        for (int i = 0; i < currentBlock; i++) {
-          reader.skipNextRowGroup();
-        }
-        while (tracker.tryClaim(currentBlock)) {
-          PageReadStore pages = reader.readNextRowGroup();
-          LOG.debug("block {} read in memory. row count = {}", currentBlock, pages.getRowCount());
-          currentBlock += 1;
-          RecordReader<GenericRecord> recordReader =
-              columnIO.getRecordReader(
-                  pages, recordConverter, options.useRecordFilter() ? filter : FilterCompat.NOOP);
-          long currentRow = 0;
-          long totalRows = pages.getRowCount();
-          while (currentRow < totalRows) {
-            try {
-              GenericRecord record;
-              currentRow += 1;
+        try (ParquetFileReader reader =

Review comment:
       Is it only `try-with-resources` change or something else?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [beam] aromanenko-dev commented on pull request #14229: [BEAM-11972] Close all opened channels/readers on ParquetIO

Posted by GitBox <gi...@apache.org>.
aromanenko-dev commented on pull request #14229:
URL: https://github.com/apache/beam/pull/14229#issuecomment-799337403


   Run Java PreCommit


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [beam] aromanenko-dev merged pull request #14229: [BEAM-11972] Close all opened channels/readers on ParquetIO

Posted by GitBox <gi...@apache.org>.
aromanenko-dev merged pull request #14229:
URL: https://github.com/apache/beam/pull/14229


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [beam] iemejia commented on a change in pull request #14229: [BEAM-11972] Close all opened channels/readers on ParquetIO

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #14229:
URL: https://github.com/apache/beam/pull/14229#discussion_r594527928



##########
File path: sdks/java/io/parquet/src/test/resources/log4j-test.properties
##########
@@ -0,0 +1,39 @@
+################################################################################
+#  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.
+################################################################################
+
+# Set root logger level to ERROR.
+# set manually to INFO for debugging purposes.
+log4j.rootLogger=ERROR, testlogger
+
+# ConsoleAppender.
+log4j.appender.testlogger=org.apache.log4j.ConsoleAppender
+log4j.appender.testlogger.target = System.err
+log4j.appender.testlogger.layout=org.apache.log4j.PatternLayout
+log4j.appender.testlogger.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
+
+# Beam SDK logging
+log4j.logger.org.apache.beam=INFO
+#log4j.logger.org.apache.beam.sdk.options.PipelineOptionsFactory=INFO
+#log4j.logger.org.apache.beam.sdk.runners.TransformHierarchy=INFO
+#log4j.logger.org.apache.beam.sdk.util.WindowTracing=INFO
+log4j.logger.org.apache.beam.sdk.io.LocalFileSystem=DEBUG

Review comment:
       Ok I removed all DEBUG logging save for ParquetIO since it is the goal of the PR.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [beam] iemejia commented on pull request #14229: [BEAM-11972] Close all opened channels/readers on ParquetIO

Posted by GitBox <gi...@apache.org>.
iemejia commented on pull request #14229:
URL: https://github.com/apache/beam/pull/14229#issuecomment-799367563


   Run Java PreCommit


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [beam] iemejia commented on a change in pull request #14229: [BEAM-11972] Close all opened channels/readers on ParquetIO

Posted by GitBox <gi...@apache.org>.
iemejia commented on a change in pull request #14229:
URL: https://github.com/apache/beam/pull/14229#discussion_r594344799



##########
File path: sdks/java/io/parquet/src/test/resources/log4j-test.properties
##########
@@ -0,0 +1,39 @@
+################################################################################
+#  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.
+################################################################################
+
+# Set root logger level to ERROR.
+# set manually to INFO for debugging purposes.
+log4j.rootLogger=ERROR, testlogger
+
+# ConsoleAppender.
+log4j.appender.testlogger=org.apache.log4j.ConsoleAppender
+log4j.appender.testlogger.target = System.err
+log4j.appender.testlogger.layout=org.apache.log4j.PatternLayout
+log4j.appender.testlogger.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
+
+# Beam SDK logging
+log4j.logger.org.apache.beam=INFO
+#log4j.logger.org.apache.beam.sdk.options.PipelineOptionsFactory=INFO
+#log4j.logger.org.apache.beam.sdk.runners.TransformHierarchy=INFO
+#log4j.logger.org.apache.beam.sdk.util.WindowTracing=INFO
+log4j.logger.org.apache.beam.sdk.io.LocalFileSystem=DEBUG

Review comment:
       This file is mostly to be able to see what is happening behind the scenes, in FileIO + internal Parquet implementation.
   `LocalFileSystem` is indeed less important, I can comment it if you prefer.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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