Skip to content

Commit 105f95c

Browse files
macvincentfacebook-github-bot
authored andcommitted
Clean Up Nimble Flush Policy Code (facebookincubator#235)
Summary: Pull Request resolved: facebookincubator#235 Differential Revision: D81514657
1 parent 47b3ab6 commit 105f95c

File tree

3 files changed

+6
-27
lines changed

3 files changed

+6
-27
lines changed

dwio/nimble/velox/FlushPolicy.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@ namespace facebook::nimble {
1919

2020
FlushDecision RawStripeSizeFlushPolicy::shouldFlush(
2121
const StripeProgress& stripeProgress) {
22-
return stripeProgress.rawStripeSize >= rawStripeSize_ ? FlushDecision::Stripe
22+
return stripeProgress.stripeRawSize >= rawStripeSize_ ? FlushDecision::Stripe
2323
: FlushDecision::None;
2424
}
2525

26-
void RawStripeSizeFlushPolicy::onClose() {
27-
// No-op
28-
}
29-
3026
} // namespace facebook::nimble

dwio/nimble/velox/FlushPolicy.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ namespace facebook::nimble {
2222

2323
struct StripeProgress {
2424
// Size of the stripe data when it's fully decompressed and decoded
25-
const uint64_t rawStripeSize;
25+
const uint64_t stripeRawSize;
2626
// Size of the stripe after buffered data is encoded and optionally compressed
27-
const uint64_t stripeSize;
28-
// Size of the allocated buffer in the writer
29-
const uint64_t bufferSize;
27+
const uint64_t stripeEncodedSize;
3028
};
3129

3230
enum class FlushDecision : uint8_t {
@@ -39,9 +37,6 @@ class FlushPolicy {
3937
public:
4038
virtual ~FlushPolicy() = default;
4139
virtual FlushDecision shouldFlush(const StripeProgress& stripeProgress) = 0;
42-
// Required for memory pressure coordination for now. Will remove in the
43-
// future.
44-
virtual void onClose() = 0;
4540
};
4641

4742
class RawStripeSizeFlushPolicy final : public FlushPolicy {
@@ -51,8 +46,6 @@ class RawStripeSizeFlushPolicy final : public FlushPolicy {
5146

5247
FlushDecision shouldFlush(const StripeProgress& stripeProgress) override;
5348

54-
void onClose() override;
55-
5649
private:
5750
const uint64_t rawStripeSize_;
5851
};
@@ -61,16 +54,12 @@ class LambdaFlushPolicy : public FlushPolicy {
6154
public:
6255
explicit LambdaFlushPolicy(
6356
std::function<FlushDecision(const StripeProgress&)> lambda)
64-
: lambda_{lambda} {}
57+
: lambda_{std::move(lambda)} {}
6558

6659
FlushDecision shouldFlush(const StripeProgress& stripeProgress) override {
6760
return lambda_(stripeProgress);
6861
}
6962

70-
void onClose() override {
71-
// No-op
72-
}
73-
7463
private:
7564
std::function<FlushDecision(const StripeProgress&)> lambda_;
7665
};

dwio/nimble/velox/VeloxWriter.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "dwio/nimble/velox/SchemaSerialization.h"
3434
#include "dwio/nimble/velox/SchemaTypes.h"
3535
#include "dwio/nimble/velox/StatsGenerated.h"
36-
#include "folly/ScopeGuard.h"
3736
#include "velox/common/time/CpuWallTimer.h"
3837
#include "velox/dwio/common/ExecutorBarrier.h"
3938
#include "velox/type/Type.h"
@@ -551,8 +550,6 @@ void VeloxWriter::close() {
551550

552551
if (file_) {
553552
try {
554-
auto exitGuard =
555-
folly::makeGuard([this]() { context_->flushPolicy->onClose(); });
556553
flush();
557554
root_->close();
558555

@@ -845,11 +842,8 @@ bool VeloxWriter::tryWriteStripe(bool force) {
845842

846843
auto shouldFlush = [&]() {
847844
return context_->flushPolicy->shouldFlush(StripeProgress{
848-
.rawStripeSize = context_->memoryUsed,
849-
.stripeSize = context_->stripeSize,
850-
.bufferSize =
851-
static_cast<uint64_t>(context_->bufferMemoryPool->usedBytes()),
852-
});
845+
.stripeRawSize = context_->memoryUsed,
846+
.stripeEncodedSize = context_->stripeSize});
853847
};
854848

855849
auto decision = force ? FlushDecision::Stripe : shouldFlush();

0 commit comments

Comments
 (0)