Skip to content

ORC-1858: [C++] Add support to get StripeStatistics without row index - #2144

Closed
wushap wants to merge 7 commits into
apache:mainfrom
wushap:main
Closed

ORC-1858: [C++] Add support to get StripeStatistics without row index#2144
wushap wants to merge 7 commits into
apache:mainfrom
wushap:main

Conversation

@wushap

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

add a C++ API in reader to get stripe level statistics without reading row group index.

Why are the changes needed?

To #2137

How was this patch tested?

UT PASS

Was this patch authored or co-authored using generative AI tooling?

NO

@dongjoon-hyun

Copy link
Copy Markdown
Member

Thank you for making a PR, @wushap .

cc @wgtmac

@dongjoon-hyundongjoon-hyun added this to the 2.2.0 milestone Feb 24, 2025
@ffacs

Copy link
Copy Markdown
Contributor

@wushap Gently ping, could you make the CI happy?

Comment threadc++/src/Reader.cc Outdated
throw std::logic_error("No stripe statistics in file");
}
StatContext statContext(hasCorrectStatistics());
return std::unique_ptr<Statistics>(new StatisticsImpl(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::make_unique would be better

@wgtmac

Copy link
Copy Markdown
Member

Thanks for adding this! Could you please create a JIRA issue for this? If you don't have one, please request one from https://selfserve.apache.org/jira-account.html.

@wushapwushap changed the title add StripeStatistic api and testORC-1858:add StripeStatistic api and testFeb 27, 2025
@wushapwushap changed the title ORC-1858:add StripeStatistic api and testORC-1858: [C++]add StripeStatistic api and testFeb 27, 2025
@wushap

Copy link
Copy Markdown
ContributorAuthor

Thanks for adding this! Could you please create a JIRA issue for this? If you don't have one, please request one from https://selfserve.apache.org/jira-account.html.

https://issues.apache.org/jira/browse/ORC-1858
here

Comment threadc++/include/orc/Reader.hh Outdated
* @param stripeIndex the index of the stripe (0 to N-1) to get statistics about
* @return the statistics about that stripe without reading row group index statistics
*/
virtual std::unique_ptr<Statistics> getStripeStatisticsOnly(uint64_t stripeIndex) const = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not to introduce a new API, especially when the name of getStripeStatisticsOnly is a little bit misleading. This is not your fault, getStripeStatistics does not clearly state it carries row index statistics as well :(

What about changing the existing API like below:

virtual std::unique_ptr<StripeStatistics> getStripeStatistics(uint64_t stripeIndex, bool includeRowIndex = true) const = 0;

Then return different StripeStatistics subclasses depending on the value of includeRowIndex.

 class StripeStatisticsImpl : public StripeStatistics {
private:
std::unique_ptr<StatisticsImpl> columnStats_;
// DELIBERATELY NOT IMPLEMENTED
StripeStatisticsImpl(const StripeStatisticsImpl&);
StripeStatisticsImpl& operator=(const StripeStatisticsImpl&);
public:
StripeStatisticsImpl(const proto::StripeStatistics& stripeStats,
const StatContext& statContext);
virtual const ColumnStatistics* getColumnStatistics(uint32_t columnId) const override {
return columnStats_->getColumnStatistics(columnId);
}
uint32_t getNumberOfColumns() const override {
return columnStats_->getNumberOfColumns();
}
virtual const ColumnStatistics* getRowIndexStatistics(uint32_t columnId,
uint32_t rowIndex) const override {
throw NotImplementedYet("getRowIndexStatistics");
}
virtual ~StripeStatisticsImpl() override;
uint32_t getNumberOfRowIndexStats(uint32_t columnId) const override {
throw NotImplementedYet("getNumberOfRowIndexStats");
}
};
class StripeStatisticsWithRowIndexImpl : public StripeStatisticsImpl {
private:
std::vector<std::vector<std::shared_ptr<const ColumnStatistics> > > rowIndexStats_;
public:
StripeStatisticsWithRowIndexImpl(const proto::StripeStatistics& stripeStats,
std::vector<std::vector<proto::ColumnStatistics> >& indexStats,
const StatContext& statContext);
virtual const ColumnStatistics* getRowIndexStatistics(uint32_t columnId,
uint32_t rowIndex) const override {
// check id indices are valid
return rowIndexStats_[columnId][rowIndex].get();
}
virtual ~StripeStatisticsWithRowIndexImpl() override;
uint32_t getNumberOfRowIndexStats(uint32_t columnId) const override {
return static_cast<uint32_t>(rowIndexStats_[columnId].size());
}
};

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks better

@wgtmacwgtmac changed the title ORC-1858: [C++]add StripeStatistic api and testORC-1858: [C++] Add support to get StripeStatistics without row indexMar 1, 2025

@wgtmacwgtmac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Thanks @wushap!

@dongjoon-hyundongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM. Thank you, @wushap and @wgtmac .
Merged to main for Apache ORC 2.2.0.

@dongjoon-hyun

Copy link
Copy Markdown
Member

Welcome to the Apache ORC community and congratulation for your first commit, @wushap .

I added you to the Apache ORC contributor group and assigned ORC-1858 to you.

dongjoon-hyun pushed a commit to apache/spark that referenced this pull request Jul 30, 2025
### What changes were proposed in this pull request?
This PR aims to upgrade ORC to 2.2.0. 2.2.0 RC1 is currently under voting.
### Why are the changes needed?
Apache ORC 2.2.0 is a new feature release.
- https://github.com/apache/orc/releases/tag/v2.2.0
- apache/orc#2032
- apache/orc#2338
- apache/orc#2269
- apache/orc#2249
- apache/orc#2144
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Pass the CIs.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes#51676 from williamhyun/ORC-2.2.0.
Authored-by: William Hyun <william@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@wushap@dongjoon-hyun@ffacs@wgtmac