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

Gabor Szadovszky commented on PARQUET-1808:
-------------------------------------------

[~tiddman],

I agree that the current project structure of parquet-mr is not optimal. It is 
not always clear which classes are for the public and which are only for 
internal use. Unfortunately, we cannot restructure the whole project without 
braking changes so this effort is left for the next major release.

I guess, you not only use classes from the {{parquet-column}}  jar but from 
{{parquet-hadoop}} as well. As you are using the {{Group}} as the data 
structure you should use {{ExampleInputFormat}}, {{ExampleOutputFormat}}. Both 
in the names and the class comments are stated that these classes are example 
implementations. {{ExampleParquetWriter}} even states that "_THIS IS AN EXAMPLE 
ONLY AND NOT INTENDED FOR USE._"

parquet-mr does not have its own fully supported data structure to use. 
Instead, it has bindings for different serialization engines (e.g. thrift, 
protobuf) or data structures (e.g. avro). Many of our clients use the Avro 
binding so they are able to use the data structures avro provides. You may find 
some examples for using {{parquet-avro}} in the [unit 
tests|https://github.com/apache/parquet-mr/tree/master/parquet-avro/src/test/java/org/apache/parquet/avro].
 You may also check the the sub-modules for the other bindings. I would suggest 
checking the related unit tests if the you cannot find proper documentation.
Another option would be to implement your own data structure (if you don't have 
it already) and implement the binding to it. You may check the implementation 
of the binding for the {{Group}} data structure in 
[parquet-hadoop|https://github.com/apache/parquet-mr/tree/master/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/example].

> SimpleGroup.toString() uses String += and so has poor performance
> -----------------------------------------------------------------
>
>                 Key: PARQUET-1808
>                 URL: https://issues.apache.org/jira/browse/PARQUET-1808
>             Project: Parquet
>          Issue Type: Bug
>          Components: parquet-mr
>    Affects Versions: 1.11.0
>            Reporter: Randy Tidd
>            Priority: Minor
>              Labels: pull-request-available
>
> This method in SimpleGroup uses `+=` for String concatenation which is a 
> known performance problem in Java, the performance degrades exponentially the 
> more strings that are added.
> [https://github.com/apache/parquet-mr/blob/d69192809d0d5ec36c0d8c126c8bed09ee3cee35/parquet-column/src/main/java/org/apache/parquet/example/data/simple/SimpleGroup.java#L50]
> We ran into a performance problem whereby a single column in a Parquet file 
> was defined as a group:
> {code:java}
>     optional group customer_ids (LIST) {
>         repeated group list { 
>         optional binary element (STRING); 
>       }
>     }{code}
>  
> and had over 31,000 values. Reading this single column took over 8 minutes 
> due to time spent in the `toString()` method.  Using a different 
> implementation that uses `StringBuffer` like this:
> {code:java}
>  StringBuffer result = new StringBuffer();
>  int i = 0;
>  for (Type field : schema.getFields()) {
>    String name = field.getName();
>    List<Object> values = data[i];
>    ++i;
>    if (values != null) {
>      if (values.size() > 0) {
>        for (Object value : values) {
>          result.append(indent);
>          result.append(name);
>          if (value == null) { 
>            result.append(": NULL\n");
>          } else if (value instanceof Group){ 
>            result.append("\n"); 
>            result.append(betterToString((SimpleGroup)value, indent+" "));
>          } else { 
>            result.append(": "); 
>            result.append(value.toString()); 
>            result.append("\n"); 
>          }
>        }
>      }
>    }
>  }
>  return result.toString();{code}
> reduced that time to less than 500 milliseconds. 
> The existing implementation is really poor and exhibits an infamous Java 
> string performance issue and should be fixed.
> This was a significant problem for us but we were able to work around it so I 
> am marking this issue as "Minor".



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to