-
Notifications
You must be signed in to change notification settings - Fork 507
ORC-1130:[C++] Suppress the present stream when the data stream has no null value #1067
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
Changes from all commits
25f5c77
ea6b73a
d71fae7
0cc30e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,7 +100,8 @@ namespace orc { | |
| enableBloomFilter(false), | ||
| memPool(*options.getMemoryPool()), | ||
| indexStream(), | ||
| bloomFilterStream() { | ||
| bloomFilterStream(), | ||
| hasNullValue(false) { | ||
|
|
||
| std::unique_ptr<BufferedOutputStream> presentStream = | ||
| factory.createStream(proto::Stream_Kind_PRESENT); | ||
|
|
@@ -139,10 +140,22 @@ namespace orc { | |
| uint64_t offset, | ||
| uint64_t numValues, | ||
| const char* incomingMask) { | ||
| notNullEncoder->add(batch.notNull.data() + offset, numValues, incomingMask); | ||
| const char* notNull = batch.notNull.data() + offset; | ||
| notNullEncoder->add(notNull, numValues, incomingMask); | ||
| hasNullValue |= batch.hasNulls; | ||
| for (uint64_t i = 0; !hasNullValue && i < numValues; ++i) { | ||
| if (!notNull[i]) { | ||
| hasNullValue = true; | ||
|
Member
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. I'd suggest checking hasNullValue in line 145 or 146 because hasNullValue may already be set by previous nulls.
Member
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. In addition, we should check batch.hasNulls as a shortcut.
Contributor
Author
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. This logic has been changed to take the or operation with batch.hasNulls. |
||
| } | ||
| } | ||
| } | ||
|
|
||
| void ColumnWriter::flush(std::vector<proto::Stream>& streams) { | ||
| if (!hasNullValue) { | ||
| // supress the present stream | ||
| notNullEncoder->suppress(); | ||
| return; | ||
| } | ||
| proto::Stream stream; | ||
| stream.set_kind(proto::Stream_Kind_PRESENT); | ||
| stream.set_column(static_cast<uint32_t>(columnId)); | ||
|
|
@@ -199,6 +212,21 @@ namespace orc { | |
| } | ||
|
|
||
| void ColumnWriter::writeIndex(std::vector<proto::Stream> &streams) const { | ||
| if (!hasNullValue) { | ||
| // remove positions of present stream | ||
| int presentCount = indexStream->isCompressed() ? 4 : 3; | ||
| for (int i = 0; i != rowIndex->entry_size(); ++i) { | ||
| proto::RowIndexEntry* entry = rowIndex->mutable_entry(i); | ||
| std::vector<uint64_t> positions; | ||
| for (int j = presentCount; j < entry->positions_size(); ++j) { | ||
| positions.push_back(entry->positions(j)); | ||
| } | ||
| entry->clear_positions(); | ||
| for (size_t j = 0; j != positions.size(); ++j) { | ||
| entry->add_positions(positions[j]); | ||
| } | ||
| } | ||
| } | ||
| // write row index to output stream | ||
| rowIndex->SerializeToZeroCopyStream(indexStream.get()); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,6 +97,10 @@ namespace orc { | |
| return dataSize; | ||
| } | ||
|
|
||
| void BufferedOutputStream::suppress() { | ||
|
Member
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. Could you add an empty line before this?
Contributor
Author
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. done. |
||
| dataBuffer->resize(0); | ||
| } | ||
|
|
||
| void AppendOnlyBufferedStream::write(const char * data, size_t size) { | ||
| size_t dataOffset = 0; | ||
| while (size > 0) { | ||
|
|
||
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.
Why not nullify buffer? I'd add a reset() function to clear the state and use it here and in the ByteRleEncoderImpl constructor.
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 don't find the reset function, so I add this function by the way.