Skip to content

Commit cb3e1fc

Browse files
macvincentfacebook-github-bot
authored andcommitted
Extract Column Logical Size from Raw Size Utils (#176)
Summary: Rollback Plan: Differential Revision: D75927903
1 parent bf44e45 commit cb3e1fc

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

dwio/nimble/velox/RawSizeContext.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#pragma once
1818

19+
#include "dwio/nimble/common/Exceptions.h"
1920
#include "dwio/nimble/velox/DecodedVectorManager.h"
2021

2122
namespace facebook::nimble {
@@ -28,8 +29,27 @@ class RawSizeContext {
2829
return decodedVectorManager_;
2930
}
3031

32+
void appendSize(uint64_t size) {
33+
columnSizes_.push_back(size);
34+
}
35+
36+
uint64_t sizeAt(uint64_t columnIndex) const {
37+
NIMBLE_ASSERT(
38+
columnIndex < columnSizes_.size(),
39+
fmt::format(
40+
"Column index {} is out of range. Total number of columns is {}",
41+
columnIndex,
42+
columnSizes_.size()));
43+
return columnSizes_.at(columnIndex);
44+
}
45+
46+
uint64_t columnCount() const {
47+
return columnSizes_.size();
48+
}
49+
3150
private:
3251
DecodedVectorManager decodedVectorManager_;
52+
std::vector<uint64_t> columnSizes_;
3353
};
3454

3555
} // namespace facebook::nimble

dwio/nimble/velox/RawSizeUtils.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ uint64_t getRawSizeFromMapVector(
442442
uint64_t getRawSizeFromRowVector(
443443
const velox::VectorPtr& vector,
444444
const velox::common::Ranges& ranges,
445-
RawSizeContext& context) {
445+
RawSizeContext& context,
446+
const bool topLevel) {
446447
VELOX_CHECK_NOT_NULL(vector);
447448
const auto& encoding = vector->encoding();
448449
const velox::RowVector* rowVector;
@@ -528,8 +529,12 @@ uint64_t getRawSizeFromRowVector(
528529
if ((*childRangesPtr).size()) {
529530
const auto childrenSize = rowVector->childrenSize();
530531
for (size_t i = 0; i < childrenSize; ++i) {
531-
rawSize +=
532+
auto childRawSize =
532533
getRawSizeFromVector(rowVector->childAt(i), *childRangesPtr, context);
534+
rawSize += childRawSize;
535+
if (topLevel) {
536+
context.appendSize(childRawSize);
537+
}
533538
}
534539
}
535540

dwio/nimble/velox/RawSizeUtils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ uint64_t getRawSizeFromVector(
3232
const velox::VectorPtr& vector,
3333
const velox::common::Ranges& ranges);
3434

35+
uint64_t getRawSizeFromRowVector(
36+
const velox::VectorPtr& vector,
37+
const velox::common::Ranges& ranges,
38+
RawSizeContext& context,
39+
const bool topLevel = false);
3540
} // namespace facebook::nimble

0 commit comments

Comments
 (0)