Skip to content

Commit 5fa4cd8

Browse files
macvincentfacebook-github-bot
authored andcommitted
Write Column Logical Size Into Nimble Files
Differential Revision: D75973860
1 parent cb3e1fc commit 5fa4cd8

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

dwio/nimble/velox/VeloxWriter.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ namespace detail {
4747

4848
class WriterContext : public FieldWriterContext {
4949
public:
50+
struct ColumnStats {
51+
uint64_t logicalSize{0};
52+
};
53+
5054
const VeloxWriterOptions options;
5155
std::unique_ptr<FlushPolicy> flushPolicy;
5256
velox::CpuWallTiming totalFlushTiming;
@@ -63,6 +67,7 @@ class WriterContext : public FieldWriterContext {
6367
uint64_t stripeSize{0};
6468
uint64_t rawSize{0};
6569
std::vector<uint64_t> rowsPerStripe;
70+
std::vector<ColumnStats> columnStats;
6671

6772
WriterContext(
6873
velox::memory::MemoryPool& memoryPool,
@@ -516,10 +521,19 @@ bool VeloxWriter::write(const velox::VectorPtr& vector) {
516521
auto size = vector->size();
517522

518523
// Calculate raw size.
519-
auto rawSize = nimble::getRawSizeFromVector(
520-
vector, velox::common::Ranges::of(0, size));
524+
RawSizeContext context;
525+
auto rawSize = nimble::getRawSizeFromRowVector(
526+
vector, velox::common::Ranges::of(0, size), context, /*topLevel=*/true);
521527
DWIO_ENSURE_GE(rawSize, 0, "Invalid raw size");
522528
context_->rawSize += rawSize;
529+
auto columnCount = context.columnCount();
530+
if (context_->columnStats.empty()) {
531+
context_->columnStats =
532+
std::vector<detail::WriterContext::ColumnStats>(columnCount);
533+
}
534+
for (auto i = 0; i < columnCount; ++i) {
535+
context_->columnStats[i].logicalSize += context.sizeAt(i);
536+
}
523537

524538
if (context_->options.writeExecutor) {
525539
velox::dwio::common::ExecutorBarrier barrier{

0 commit comments

Comments
 (0)