[
https://issues.apache.org/jira/browse/PARQUET-1942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17786166#comment-17786166
]
ASF GitHub Bot commented on PARQUET-1942:
-----------------------------------------
wgtmac commented on code in PR #1193:
URL: https://github.com/apache/parquet-mr/pull/1193#discussion_r1393636511
##########
parquet-arrow/src/main/java/org/apache/parquet/arrow/schema/Map3Levels.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.parquet.arrow.schema;
+
+import org.apache.parquet.schema.GroupType;
+import org.apache.parquet.schema.LogicalTypeAnnotation;
+import org.apache.parquet.schema.OriginalType;
+import org.apache.parquet.schema.Type;
+
+import static org.apache.parquet.schema.Type.Repetition.REPEATED;
+
+/**
+ * Represents a standard 3 levels Parquet map
+ */
+class Map3Levels {
+ private final GroupType map;
+ private final GroupType repeated;
+ private final Type key;
+ private final Type value;
+
+ /**
+ * Will validate the structure of the map
+ * @param map the Parquet map
+ */
+ public Map3Levels(GroupType map) {
+ if (map.getLogicalTypeAnnotation() != LogicalTypeAnnotation.mapType() ||
map.getFields().size() != 1) {
+ throw new IllegalArgumentException("invalid map type: " + map);
+ }
+ this.map = map;
+ Type repeatedField = map.getFields().get(0);
+ if (repeatedField.isPrimitive() || !repeatedField.isRepetition(REPEATED)
|| repeatedField.asGroupType().getFields().size() != 2) {
+ throw new IllegalArgumentException("invalid map key: " + map);
+ }
+ this.repeated = repeatedField.asGroupType();
+ this.key = repeated.getFields().get(0);
+ this.value = repeated.getFields().get(1);
+ }
+
+ /**
+ * @return the root list element (an optional group with one child)
Review Comment:
```suggestion
* @return the root map element (an optional group with two children)
```
##########
parquet-arrow/src/main/java/org/apache/parquet/arrow/schema/Map3Levels.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.parquet.arrow.schema;
+
+import org.apache.parquet.schema.GroupType;
+import org.apache.parquet.schema.LogicalTypeAnnotation;
+import org.apache.parquet.schema.OriginalType;
+import org.apache.parquet.schema.Type;
+
+import static org.apache.parquet.schema.Type.Repetition.REPEATED;
+
+/**
+ * Represents a standard 3 levels Parquet map
+ */
Review Comment:
```suggestion
/**
* Represents a standard 3 levels Parquet map
* - optional map
* - repeated key_value
* - required key, optional value
*/
```
##########
parquet-arrow/src/main/java/org/apache/parquet/arrow/schema/Map3Levels.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.parquet.arrow.schema;
+
+import org.apache.parquet.schema.GroupType;
+import org.apache.parquet.schema.LogicalTypeAnnotation;
+import org.apache.parquet.schema.OriginalType;
+import org.apache.parquet.schema.Type;
+
+import static org.apache.parquet.schema.Type.Repetition.REPEATED;
+
+/**
+ * Represents a standard 3 levels Parquet map
+ */
+class Map3Levels {
+ private final GroupType map;
+ private final GroupType repeated;
+ private final Type key;
+ private final Type value;
+
+ /**
+ * Will validate the structure of the map
+ * @param map the Parquet map
+ */
+ public Map3Levels(GroupType map) {
+ if (map.getLogicalTypeAnnotation() != LogicalTypeAnnotation.mapType() ||
map.getFields().size() != 1) {
+ throw new IllegalArgumentException("invalid map type: " + map);
+ }
+ this.map = map;
+ Type repeatedField = map.getFields().get(0);
+ if (repeatedField.isPrimitive() || !repeatedField.isRepetition(REPEATED)
|| repeatedField.asGroupType().getFields().size() != 2) {
+ throw new IllegalArgumentException("invalid map key: " + map);
+ }
+ this.repeated = repeatedField.asGroupType();
+ this.key = repeated.getFields().get(0);
+ this.value = repeated.getFields().get(1);
+ }
+
+ /**
+ * @return the root list element (an optional group with one child)
+ */
+ public GroupType getMap() {
+ return map;
+ }
+
+ /**
+ * @return repeated level, single child of list
Review Comment:
```suggestion
* @return repeated level, single child of map
```
> Bump Apache Arrow 2.0.0
> -----------------------
>
> Key: PARQUET-1942
> URL: https://issues.apache.org/jira/browse/PARQUET-1942
> Project: Parquet
> Issue Type: Improvement
> Components: parquet-mr
> Affects Versions: 1.11.0
> Reporter: Fokko Driesprong
> Assignee: Fokko Driesprong
> Priority: Major
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)