Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
6a2e051
PARQUET-2471: Add support for geometry logical type
zhangfengcdt Jul 23, 2024
d354012
fix types
zhangfengcdt Jul 23, 2024
969b696
Refactor BoundingBox and GeometryTypes
zhangfengcdt Jul 23, 2024
87ee8ea
revert naming changes
zhangfengcdt Jul 24, 2024
d67e03b
revert TestDecimalUtils
zhangfengcdt Jul 24, 2024
ccf1c4a
revert more
zhangfengcdt Jul 24, 2024
35342c2
refactor statistics
zhangfengcdt Jul 24, 2024
bcfefb7
modify EnvelopeCovering
zhangfengcdt Jul 24, 2024
cf615f6
add more unit tests
zhangfengcdt Jul 25, 2024
c6ae733
update comments
zhangfengcdt Jul 25, 2024
80a629e
add comment for envelope converging expand calculation
zhangfengcdt Jul 26, 2024
e0ec9ef
Fix the boundingbox initial values in constructor
zhangfengcdt Jul 29, 2024
7c728b1
Update the poc implementation for the changes to the spec
zhangfengcdt Aug 7, 2024
fa36d06
remove print
zhangfengcdt Aug 7, 2024
2a1c62a
implement evelop covering for spherical coordinates
zhangfengcdt Aug 8, 2024
d0e7d3d
throw a not-implemented exception for the covering statistics when th…
zhangfengcdt Aug 12, 2024
30d64be
Merge branch 'master' of github.com:apache/parquet-java into feature-…
zhangfengcdt Aug 12, 2024
29a86b5
remove unused comment codes
zhangfengcdt Aug 12, 2024
0c4b8b4
address some review comments
zhangfengcdt Aug 19, 2024
a56e9ad
revert changes that are not desired
zhangfengcdt Aug 20, 2024
1ae3d99
refactor toString and remove test scope of jts-core in parquet-hadoop…
zhangfengcdt Aug 20, 2024
198642d
refactor the converings to be map to avoid ordering issues in stats m…
zhangfengcdt Aug 23, 2024
0cf2de9
address review comments
zhangfengcdt Sep 13, 2024
4f0f7ed
fix formating
zhangfengcdt Sep 13, 2024
a378a9a
address comments to remove string parsing (to be consistent with spec)
zhangfengcdt Sep 23, 2024
698325a
update according to the changes to the upstream pqrquet-format pr
zhangfengcdt Oct 17, 2024
d65ba8e
remove coverings
zhangfengcdt Oct 17, 2024
1b0f5b9
add GeometryStatistics to ColumnMetaData
zhangfengcdt Oct 17, 2024
342e400
more code cleanup for covering
zhangfengcdt Oct 17, 2024
3cc9b68
add toParquetGeometryStatistics
zhangfengcdt Oct 18, 2024
dc05cfd
fix check errors
zhangfengcdt Oct 18, 2024
6f1d586
Merge branch 'master' of github.com:apache/parquet-java into feature-…
zhangfengcdt Nov 13, 2024
e4e3cae
Merge branch 'master' of github.com:apache/parquet-java into feature-…
zhangfengcdt Feb 7, 2025
69d950f
change and remove the encoding and edges from geometry type (spec cha…
zhangfengcdt Feb 7, 2025
d296c6a
fix unit tests
zhangfengcdt Feb 7, 2025
93e28b7
handle the wraparound case for X values
zhangfengcdt Feb 8, 2025
e688d05
support GEOGRAPHY type
zhangfengcdt Feb 8, 2025
01ac560
revert import changes
zhangfengcdt Feb 8, 2025
f9585cd
address pr review comments
zhangfengcdt Feb 19, 2025
b805cf4
fix formatting issue
zhangfengcdt Feb 19, 2025
6aa7028
refactor geography logic type
zhangfengcdt Feb 19, 2025
4536e5f
revert the edge algorithm to use string to avoid loop dependency
zhangfengcdt Feb 19, 2025
f188341
add enum EdgeInterpolationAlgorithm for the geography edge algorithm
zhangfengcdt Feb 21, 2025
214fd39
address pr comments: rename, hash, and equal
zhangfengcdt Feb 21, 2025
907acce
remove column index changes
zhangfengcdt Feb 21, 2025
ef83a2e
revert unnecessary changes
zhangfengcdt Feb 21, 2025
c5d542b
refactor GeospatialStatistics
zhangfengcdt Feb 24, 2025
c1fb37b
refactor writers
zhangfengcdt Feb 24, 2025
dac9ad0
refactor to use colomn value collector instead of binary statistics
zhangfengcdt Feb 24, 2025
e0a319e
revert getLogicalTypeAnnotation
zhangfengcdt Feb 24, 2025
4fd177d
fix TestColumnChunkPageWriteStore
zhangfengcdt Feb 24, 2025
9f0482e
remove DummyBoundingBox
zhangfengcdt Feb 24, 2025
ebd45a9
handle noop builder and null values
zhangfengcdt Feb 25, 2025
0114701
refactor normalizeLongitude
zhangfengcdt Feb 25, 2025
4cd8dfd
add ShowGeospatialStatisticsCommand and tests
zhangfengcdt Feb 25, 2025
5ec6546
add shouldNormalizeLongitude
zhangfengcdt Feb 28, 2025
23af52f
add allowWraparound
zhangfengcdt Mar 3, 2025
d0081be
Merge remote-tracking branch 'apache/master' into feature-apache-parq…
zhangfengcdt Mar 18, 2025
375de55
add allowWraparound in bbox to ParquetProperties
zhangfengcdt Mar 18, 2025
92f45c2
update to use the latest parquet-format release
zhangfengcdt Mar 24, 2025
1ecb5b6
improve handling null, empty, and nan cases in boundingbox
zhangfengcdt Mar 24, 2025
4c10575
remove wrap around logic
zhangfengcdt Mar 28, 2025
8937907
set initial state of bbox to NaN
zhangfengcdt Mar 29, 2025
928109d
add more unit tests to boundingbox
zhangfengcdt Mar 29, 2025
9d08f92
fix comments
zhangfengcdt Mar 29, 2025
f751eb3
make sure no NaN is saved to parquet meta
zhangfengcdt Apr 1, 2025
9916908
upgrade jts version
zhangfengcdt Apr 1, 2025
df461cc
address pr review comments
zhangfengcdt Apr 9, 2025
f3c4979
address pr review comments
zhangfengcdt Apr 11, 2025
7b98a10
refactor BoundingBox
zhangfengcdt Apr 11, 2025
79c80c8
revamp check valid in the geo statistics
zhangfengcdt Apr 11, 2025
f6610e7
update handling of invalid and empty bbox
zhangfengcdt Apr 14, 2025
3fdef44
Merge remote-tracking branch 'apache/master' into feature-apache-parq…
zhangfengcdt Apr 14, 2025
91e9d26
fix unit tests
zhangfengcdt Apr 14, 2025
af23c11
add update + merge test cases with NaN inputs
zhangfengcdt Apr 14, 2025
819b3e3
Merge remote-tracking branch 'apache/master' into feature-apache-parq…
zhangfengcdt Apr 24, 2025
d8ffe0e
address some pr comments
zhangfengcdt Apr 24, 2025
e88268d
add test to TestTypeBuilders
zhangfengcdt Apr 24, 2025
398dd0b
add more tests and fix some comments
zhangfengcdt Apr 24, 2025
efe8875
fix fmt
zhangfengcdt Apr 24, 2025
455d15b
fix the test dependency issue
zhangfengcdt Apr 24, 2025
5e6579f
fix dependency issue
zhangfengcdt Apr 24, 2025
eecd915
clean up the code and add more unit tests
zhangfengcdt Apr 25, 2025
5c63b4e
Merge remote-tracking branch 'apache/master' into feature-apache-parq…
zhangfengcdt Apr 29, 2025
ccd0715
address pr comments
zhangfengcdt May 5, 2025
ef8e343
address pr comment to only check the first coordinate for types update
zhangfengcdt May 12, 2025
81eb57d
change the behavior of merge null or invalid statistics
zhangfengcdt May 12, 2025
e904e3e
change null or invalid only
zhangfengcdt May 12, 2025
882ef38
address review comments - part 1
zhangfengcdt May 14, 2025
e9d2426
address review comments - part 2
zhangfengcdt May 14, 2025
7955496
address review comments
zhangfengcdt May 14, 2025
74e94ab
fix tests
zhangfengcdt May 14, 2025
9f3d31a
update the test to reflect the changes of "Failed to parse WKB geomet…
zhangfengcdt May 14, 2025
136bbf4
fix testInvalidGeometryPresented
zhangfengcdt May 14, 2025
945ecdf
fix spotless errors
zhangfengcdt May 14, 2025
f5dd1d0
address review comments - part 1
zhangfengcdt May 16, 2025
dbc8798
add validity check before checkking any bbox values
zhangfengcdt May 16, 2025
33d3b77
split xy into x and y for valid and empty check
zhangfengcdt May 16, 2025
1957dca
fix scala fmt issue
zhangfengcdt May 16, 2025
aec732e
rename geometry package to geospatial package
zhangfengcdt May 16, 2025
476dfff
clean up code
zhangfengcdt May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions parquet-column/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
<version>${slf4j.version}</version>
</dependency>

<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>${jts.version}</version>
</dependency>

<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>junit-benchmarks</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
*/
package org.apache.parquet.column.statistics;

import org.apache.parquet.column.statistics.geometry.GeometryStatistics;
import org.apache.parquet.io.api.Binary;
import org.apache.parquet.schema.LogicalTypeAnnotation;
import org.apache.parquet.schema.PrimitiveType;
import org.apache.parquet.schema.Types;

Expand All @@ -30,6 +32,7 @@ public class BinaryStatistics extends Statistics<Binary> {

private Binary max;
private Binary min;
private GeometryStatistics geometryStatistics = null;

/**
* @deprecated will be removed in 2.0.0. Use {@link Statistics#createStats(org.apache.parquet.schema.Type)} instead
Expand All @@ -41,6 +44,13 @@ public BinaryStatistics() {

BinaryStatistics(PrimitiveType type) {
super(type);
LogicalTypeAnnotation logicalType = type.getLogicalTypeAnnotation();
if (logicalType instanceof LogicalTypeAnnotation.GeometryLogicalTypeAnnotation) {
LogicalTypeAnnotation.GeometryLogicalTypeAnnotation geometryLogicalType =
(LogicalTypeAnnotation.GeometryLogicalTypeAnnotation) logicalType;
geometryStatistics = new GeometryStatistics(
geometryLogicalType.getEdges(), geometryLogicalType.getCrs(), geometryLogicalType.getMetadata());
}
}

private BinaryStatistics(BinaryStatistics other) {
Expand All @@ -49,6 +59,9 @@ private BinaryStatistics(BinaryStatistics other) {
initializeStats(other.min, other.max);
}
setNumNulls(other.getNumNulls());
if (other.geometryStatistics != null) {
geometryStatistics = other.geometryStatistics.copy();
}
}

@Override
Expand All @@ -62,6 +75,9 @@ public void updateStats(Binary value) {
} else if (comparator().compare(max, value) < 0) {
max = value.copy();
}
if (geometryStatistics != null) {
geometryStatistics.update(value);
}
}

@Override
Expand All @@ -72,6 +88,9 @@ public void mergeStatisticsMinMax(Statistics stats) {
} else {
updateStats(binaryStats.getMin(), binaryStats.getMax());
}
if (geometryStatistics != null) {
geometryStatistics.merge(binaryStats.geometryStatistics);
}
}

/**
Expand Down Expand Up @@ -190,4 +209,12 @@ public void setMinMax(Binary min, Binary max) {
public BinaryStatistics copy() {
return new BinaryStatistics(this);
}

public void setGeometryStatistics(GeometryStatistics geometryStatistics) {
this.geometryStatistics = geometryStatistics;
}

public GeometryStatistics getGeometryStatistics() {
return geometryStatistics;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.Arrays;
import org.apache.parquet.column.UnknownColumnTypeException;
import org.apache.parquet.column.statistics.geometry.GeometryStatistics;
import org.apache.parquet.io.api.Binary;
import org.apache.parquet.schema.Float16;
import org.apache.parquet.schema.LogicalTypeAnnotation;
Expand Down Expand Up @@ -64,6 +65,10 @@ public Builder withNumNulls(long numNulls) {
return this;
}

public Builder withGeometryStatistics(GeometryStatistics geometryStatistics) {
throw new UnsupportedOperationException("Please use the GeometryBuilder");
}

public Statistics<?> build() {
Statistics<?> stats = createStats(type);
if (min != null && max != null) {
Expand Down Expand Up @@ -178,6 +183,30 @@ public Statistics<?> build() {
}
}

// Builder for GEOMETRY type to handle GeometryStatistics
private static class GeometryBuilder extends Builder {

private GeometryStatistics geometryStatistics;

public GeometryBuilder(PrimitiveType type) {
super(type);
assert type.getPrimitiveTypeName() == PrimitiveTypeName.BINARY;
}

@Override
public Builder withGeometryStatistics(GeometryStatistics geometryStatistics) {
this.geometryStatistics = geometryStatistics;
return this;
}

@Override
public Statistics<?> build() {
BinaryStatistics stats = (BinaryStatistics) super.build();
stats.setGeometryStatistics(geometryStatistics);
return stats;
}
}

private final PrimitiveType type;
private final PrimitiveComparator<T> comparator;
private boolean hasNonNullValue;
Expand Down Expand Up @@ -269,6 +298,11 @@ public static Builder getBuilderForReading(PrimitiveType type) {
if (logicalTypeAnnotation instanceof LogicalTypeAnnotation.Float16LogicalTypeAnnotation) {
return new Float16Builder(type);
}
return new Builder(type);
case BINARY:
if (type.getLogicalTypeAnnotation() instanceof LogicalTypeAnnotation.GeometryLogicalTypeAnnotation) {
return new GeometryBuilder(type);
}
default:
return new Builder(type);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/*
* 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.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;

public class BoundingBox {

private double xMin = Double.POSITIVE_INFINITY;
private double xMax = Double.NEGATIVE_INFINITY;
private double yMin = Double.POSITIVE_INFINITY;
private double yMax = Double.NEGATIVE_INFINITY;
private double zMin = Double.POSITIVE_INFINITY;
private double zMax = Double.NEGATIVE_INFINITY;
private double mMin = Double.POSITIVE_INFINITY;
private double mMax = Double.NEGATIVE_INFINITY;

public BoundingBox(
double xMin, double xMax, double yMin, double yMax, double zMin, double zMax, double mMin, double mMax) {
this.xMin = xMin;
this.xMax = xMax;
this.yMin = yMin;
this.yMax = yMax;
this.zMin = zMin;
this.zMax = zMax;
this.mMin = mMin;
this.mMax = mMax;
}

public BoundingBox() {}

public double getXMin() {
return xMin;
}

public double getXMax() {
return xMax;
}

public double getYMin() {
return yMin;
}

public double getYMax() {
return yMax;
}

public double getZMin() {
return zMin;
}

public double getZMax() {
return zMax;
}

public double getMMin() {
return mMin;
}

public double getMMax() {
return mMax;
}

void update(double minX, double maxX, double minY, double maxY, double minZ, double maxZ) {
xMin = Math.min(xMin, minX);
yMin = Math.min(yMin, minY);
xMax = Math.max(xMax, maxX);
yMax = Math.max(yMax, maxY);
zMin = Math.min(zMin, minZ);
zMax = Math.max(zMax, maxZ);
}

void update(Geometry geometry) {
GeometryUtils.normalizeLongitude(geometry);
Envelope envelope = geometry.getEnvelopeInternal();
double minX = envelope.getMinX();
double minY = envelope.getMinY();
double maxX = envelope.getMaxX();
double maxY = envelope.getMaxY();

// JTS (Java Topology Suite) does not handle Z-coordinates directly in the Envelope class
// because it's primarily used for 2D geometries. However, we can iterate through the
// coordinates of the geometry to find the minimum and maximum Z values.
double minZ = Double.POSITIVE_INFINITY;
double maxZ = Double.NEGATIVE_INFINITY;

Coordinate[] coordinates = geometry.getCoordinates();
for (Coordinate coord : coordinates) {
if (!Double.isNaN(coord.getZ())) {
// Update zMin and zMax by iterating through the coordinates.
minZ = Math.min(minZ, coord.getZ());
maxZ = Math.max(maxZ, coord.getZ());
}
}

update(minX, maxX, minY, maxY, minZ, maxZ);
}

// Method to merge a Geometry object into this bounding box
public void merge(Geometry geometry) {
Preconditions.checkArgument(geometry != null, "Cannot merge with null geometry");
GeometryUtils.normalizeLongitude(geometry);
update(geometry);
}

public void merge(BoundingBox other) {
Preconditions.checkArgument(other != null, "Cannot merge with null bounding box");
xMin = Math.min(xMin, other.xMin);
xMax = Math.max(xMax, other.xMax);
yMin = Math.min(yMin, other.yMin);
yMax = Math.max(yMax, other.yMax);
zMin = Math.min(zMin, other.zMin);
zMax = Math.max(zMax, other.zMax);
mMin = Math.min(mMin, other.mMin);
mMax = Math.max(mMax, other.mMax);
}

public void reset() {
xMin = Double.POSITIVE_INFINITY;
xMax = Double.NEGATIVE_INFINITY;
yMin = Double.POSITIVE_INFINITY;
yMax = Double.NEGATIVE_INFINITY;
zMin = Double.POSITIVE_INFINITY;
zMax = Double.NEGATIVE_INFINITY;
mMin = Double.POSITIVE_INFINITY;
mMax = Double.NEGATIVE_INFINITY;
}

public void abort() {
xMin = Double.NaN;
xMax = Double.NaN;
yMin = Double.NaN;
yMax = Double.NaN;
zMin = Double.NaN;
zMax = Double.NaN;
mMin = Double.NaN;
mMax = Double.NaN;
}

public BoundingBox copy() {
return new BoundingBox(xMin, xMax, yMin, yMax, zMin, zMax, mMin, mMax);
}

@Override
public String toString() {
return "BoundingBox{" + "xMin="
+ xMin + ", xMax="
+ xMax + ", yMin="
+ yMin + ", yMax="
+ yMax + ", zMin="
+ zMin + ", zMax="
+ zMax + ", mMin="
+ mMin + ", mMax="
+ mMax + '}';
}
}
Loading