Kontinuation commented on code in PR #2971:
URL: https://github.com/apache/parquet-java/pull/2971#discussion_r1969869883


##########
parquet-column/src/main/java/org/apache/parquet/column/statistics/geometry/GeospatialStatistics.java:
##########
@@ -0,0 +1,265 @@
+/*
+ * 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.column.statistics.geometry;
+
+import org.apache.parquet.Preconditions;
+import org.apache.parquet.io.api.Binary;
+import org.apache.parquet.schema.LogicalTypeAnnotation;
+import org.apache.parquet.schema.PrimitiveType;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKBReader;
+
+/**
+ * A structure for capturing metadata for estimating the unencoded,
+ * uncompressed size of geospatial data written.
+ */
+public class GeospatialStatistics {
+
+  public static final String DEFAULT_GEOSPATIAL_STAT_CRS = "OGC:CRS84";
+
+  // Metadata that may impact the statistics calculation
+  private final String crs;
+  private final BoundingBox boundingBox;
+  private final EdgeInterpolationAlgorithm edgeAlgorithm;
+  private final GeospatialTypes geospatialTypes;
+  //   private final WKBReader reader = new WKBReader();
+
+  /**
+   * Whether the statistics has valid value.
+   *
+   * It is true by default. Only set to false while it fails to merge 
statistics.
+   */
+  private boolean valid = true;
+
+  public void mergeStatistics(GeospatialStatistics other) {
+    if (other == null) {
+      return;
+    }
+    this.boundingBox.merge(other.boundingBox);
+    this.geospatialTypes.merge(other.geospatialTypes);
+  }
+
+  /**
+   * Builder to create a GeospatialStatistics.
+   */
+  public static class Builder {
+    private final String crs;
+    private BoundingBox boundingBox;
+    private GeospatialTypes geospatialTypes;
+    private EdgeInterpolationAlgorithm edgeAlgorithm;
+    private final WKBReader reader = new WKBReader();
+
+    /**
+     * Create a builder to create a GeospatialStatistics.
+     * For Geometry type, edgeAlgorithm is not required.
+     *
+     * @param crs the coordinate reference system
+     */
+    public Builder(String crs) {
+      this.crs = crs;
+      this.boundingBox = new BoundingBox();
+      this.geospatialTypes = new GeospatialTypes();
+      this.edgeAlgorithm = null;
+    }
+
+    /**
+     * Create a builder to create a GeospatialStatistics.
+     * For Geography type, optional edgeAlgorithm can be set.
+     *
+     * @param crs the coordinate reference system
+     */
+    public Builder(String crs, EdgeInterpolationAlgorithm edgeAlgorithm) {
+      this.crs = crs;
+      this.boundingBox = new BoundingBox();
+      this.geospatialTypes = new GeospatialTypes();
+      this.edgeAlgorithm = edgeAlgorithm;
+    }
+
+    public void update(Binary value) {
+      if (value == null) {
+        return;
+      }
+      try {
+        Geometry geom = reader.read(value.getBytes());
+        update(geom);
+      } catch (ParseException e) {
+        abort();
+      }

Review Comment:
   Adding an empty `update` implementation to `NoopBuilder` may resolve this 
issue.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to