-
Notifications
You must be signed in to change notification settings - Fork 484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ORC-1264: [C++] Add a writer option to align compression block with row group #2005
Closed
Closed
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e956f6d
ORC-1264: [C++] Add a writer option to align compression block with r…
luffy-zh ec19f46
fix typo
luffy-zh 3c29347
avoid include pb in public header
luffy-zh af0938c
format changes in TestWriter.cc
luffy-zh 1ffc720
fix typo
luffy-zh f4720f5
add more comments
luffy-zh 6dd0245
fix typo
luffy-zh 18f2f18
fix typo
luffy-zh c9eb0e5
Update c++/src/ColumnWriter.hh
luffy-zh e92cf57
Update c++/include/orc/Reader.hh
luffy-zh 7a31082
format code in ColumnWriter.hh
luffy-zh f1b8e21
add RowGroupPositions
luffy-zh dda9bee
replace rowReader::getPositionEntries() with reader::getRowGroupIndex
luffy-zh 59f2b80
Merge branch 'main' into ORC-1264
luffy-zh de27e0e
add RowGroupIndex size check in TestWriter.cc
luffy-zh d82affc
blockCompressionStream finishStream flush undely stream
luffy-zh 96bae24
format Reader.cc
luffy-zh 23e782f
code format
luffy-zh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1241,23 +1241,6 @@ namespace orc { | |
useTightNumericVector_); | ||
} | ||
|
||
std::vector<RowGroupPositions> RowReaderImpl::getPositionEntries(int columnId) { | ||
loadStripeIndex(); | ||
std::vector<RowGroupPositions> result; | ||
auto rowIndex = rowIndexes_[columnId]; | ||
RowGroupPositions rgPositions; | ||
rgPositions.columnId = columnId; | ||
for (auto rowIndexEntry : rowIndex.entry()) { | ||
auto posVector = rgPositions.positions; | ||
for (auto position : rowIndexEntry.positions()) { | ||
posVector.push_back(position); | ||
} | ||
result.push_back(rgPositions); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
void ensureOrcFooter(InputStream* stream, DataBuffer<char>* buffer, uint64_t postscriptLength) { | ||
const std::string MAGIC("ORC"); | ||
const uint64_t magicLength = MAGIC.length(); | ||
|
@@ -1443,17 +1426,10 @@ namespace orc { | |
uint32_t stripeIndex, const std::set<uint32_t>& included) const { | ||
std::map<uint32_t, BloomFilterIndex> ret; | ||
|
||
// find stripe info | ||
if (stripeIndex >= static_cast<uint32_t>(footer_->stripes_size())) { | ||
throw std::logic_error("Illegal stripe index: " + | ||
to_string(static_cast<int64_t>(stripeIndex))); | ||
} | ||
const proto::StripeInformation currentStripeInfo = | ||
footer_->stripes(static_cast<int>(stripeIndex)); | ||
const proto::StripeFooter currentStripeFooter = getStripeFooter(currentStripeInfo, *contents_); | ||
uint64_t offset; | ||
auto currentStripeFooter = loadCurrentStripeFooter(stripeIndex, offset); | ||
|
||
// iterate stripe footer to get stream of bloom_filter | ||
uint64_t offset = static_cast<uint64_t>(currentStripeInfo.offset()); | ||
for (int i = 0; i < currentStripeFooter.streams_size(); i++) { | ||
const proto::Stream& stream = currentStripeFooter.streams(i); | ||
uint32_t column = static_cast<uint32_t>(stream.column()); | ||
|
@@ -1491,6 +1467,59 @@ namespace orc { | |
return ret; | ||
} | ||
|
||
proto::StripeFooter ReaderImpl::loadCurrentStripeFooter(uint32_t stripeIndex, | ||
uint64_t& offset) const { | ||
// find stripe info | ||
if (stripeIndex >= static_cast<uint32_t>(footer_->stripes_size())) { | ||
throw std::logic_error("Illegal stripe index: " + | ||
to_string(static_cast<int64_t>(stripeIndex))); | ||
} | ||
const proto::StripeInformation currentStripeInfo = | ||
footer_->stripes(static_cast<int>(stripeIndex)); | ||
offset = static_cast<uint64_t>(currentStripeInfo.offset()); | ||
return getStripeFooter(currentStripeInfo, *contents_); | ||
} | ||
|
||
std::map<uint32_t, RowGroupIndex> ReaderImpl::getRowGroupIndex( | ||
uint32_t stripeIndex, const std::set<uint32_t>& included) const { | ||
std::map<uint32_t, RowGroupIndex> ret; | ||
uint64_t offset; | ||
auto currentStripeFooter = loadCurrentStripeFooter(stripeIndex, offset); | ||
|
||
// iterate stripe footer to get stream of row_index | ||
for (int i = 0; i < currentStripeFooter.streams_size(); i++) { | ||
const proto::Stream& stream = currentStripeFooter.streams(i); | ||
uint32_t column = static_cast<uint32_t>(stream.column()); | ||
uint64_t length = static_cast<uint64_t>(stream.length()); | ||
RowGroupIndex rowGroupIndex = ret[column]; | ||
|
||
if (stream.kind() == proto::Stream_Kind_ROW_INDEX && | ||
(included.empty() || included.find(column) != included.end())) { | ||
std::unique_ptr<SeekableInputStream> pbStream = | ||
createDecompressor(contents_->compression, | ||
std::make_unique<SeekableFileInputStream>( | ||
contents_->stream.get(), offset, length, *contents_->pool), | ||
contents_->blockSize, *(contents_->pool), contents_->readerMetrics); | ||
|
||
proto::RowIndex pbRowIndex; | ||
if (!pbRowIndex.ParseFromZeroCopyStream(pbStream.get())) { | ||
throw ParseError("Failed to parse RowIndex"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: provide more debug info, like stripeIndex and columnId? |
||
} | ||
|
||
// add rowGroupIndex to result for one column | ||
for (auto& rowIndexEntry : pbRowIndex.entry()) { | ||
std::vector<uint64_t> posVector; | ||
for (auto& position : rowIndexEntry.positions()) { | ||
posVector.push_back(position); | ||
} | ||
rowGroupIndex.positions.push_back(posVector); | ||
} | ||
} | ||
offset += length; | ||
} | ||
return ret; | ||
} | ||
|
||
RowReader::~RowReader() { | ||
// PASS | ||
} | ||
|
@@ -1499,8 +1528,8 @@ namespace orc { | |
// PASS | ||
} | ||
|
||
InputStream::~InputStream(){ | ||
// PASS | ||
InputStream::~InputStream() { | ||
// PASS | ||
}; | ||
|
||
} // namespace orc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should break the test, or we need to add at least a test case to cover this new API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the RowGroupIndex size check in TestWriter.cc:97.