dongjoon-hyun commented on code in PR #2269:
URL: https://github.com/apache/orc/pull/2269#discussion_r2152534104
##########
c++/src/Statistics.hh:
##########
@@ -1683,6 +1683,127 @@ namespace orc {
}
};
+ class GeospatialColumnStatisticsImpl : public GeospatialColumnStatistics,
+ public MutableColumnStatistics {
+ private:
+ geospatial::WKBGeometryBounder bounder_;
+ InternalCharStatistics stats_;
+
+ public:
+ GeospatialColumnStatisticsImpl() {
+ reset();
+ }
+ explicit GeospatialColumnStatisticsImpl(const proto::ColumnStatistics&
stats);
+ virtual ~GeospatialColumnStatisticsImpl();
+
+ uint64_t getNumberOfValues() const override {
+ return stats_.getNumberOfValues();
+ }
+
+ void setNumberOfValues(uint64_t value) override {
+ stats_.setNumberOfValues(value);
+ }
+
+ void increase(uint64_t count) override {
+ stats_.setNumberOfValues(stats_.getNumberOfValues() + count);
+ }
+
+ bool hasNull() const override {
+ return stats_.hasNull();
+ }
+
+ void setHasNull(bool hasNull) override {
+ stats_.setHasNull(hasNull);
+ }
+
+ void merge(const MutableColumnStatistics& other) override {
+ const GeospatialColumnStatisticsImpl& geoStats =
+ dynamic_cast<const GeospatialColumnStatisticsImpl&>(other);
+ stats_.merge(geoStats.stats_);
+ bounder_.Merge(geoStats.bounder_);
+ }
+
+ void reset() override {
+ stats_.reset();
+ bounder_.Reset();
+ }
+
+ void update(const char* value, size_t length) override {
+ bounder_.MergeGeometry(std::string_view(value, length));
+ }
+
+ void toProtoBuf(proto::ColumnStatistics& pbStats) const override {
+ pbStats.set_has_null(stats_.hasNull());
+ pbStats.set_number_of_values(stats_.getNumberOfValues());
+
+ proto::GeospatialStatistics* geoStats =
pbStats.mutable_geospatial_statistics();
+ const auto& bbox = bounder_.Bounds();
+ if (bbox.BoundValid(0) && bbox.BoundValid(1) && !bbox.BoundEmpty(0) &&
!bbox.BoundEmpty(1)) {
+ geoStats->mutable_bbox()->set_xmin(bbox.min[0]);
+ geoStats->mutable_bbox()->set_xmax(bbox.max[0]);
+ geoStats->mutable_bbox()->set_ymin(bbox.min[1]);
+ geoStats->mutable_bbox()->set_ymax(bbox.max[1]);
+ if (bbox.BoundValid(2) && !bbox.BoundEmpty(2)) {
+ geoStats->mutable_bbox()->set_zmin(bbox.min[2]);
+ geoStats->mutable_bbox()->set_zmax(bbox.max[2]);
+ }
+ if (bbox.BoundValid(3) && !bbox.BoundEmpty(3)) {
+ geoStats->mutable_bbox()->set_mmin(bbox.min[3]);
+ geoStats->mutable_bbox()->set_mmax(bbox.max[3]);
+ }
+ }
+ for (auto type : bounder_.GeometryTypes()) {
+ geoStats->add_geospatial_types(type);
+ }
+ }
+
+ std::string toString() const override {
+ if (!bounder_.IsValid()) {
+ return "<GeoStatistics> invalid";
+ }
+
+ std::stringstream ss;
+ ss << "<GeoStatistics>";
Review Comment:
ditto. Why do we have this only in C++ implementation? If this is required,
can we have this in Java first?
--
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]