aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yt/yt/client/table_client/logical_type.cpp60
-rw-r--r--yt/yt/client/table_client/logical_type.h18
-rw-r--r--yt/yt/client/table_client/schema.cpp26
-rw-r--r--yt/yt/client/table_client/schema.h11
4 files changed, 57 insertions, 58 deletions
diff --git a/yt/yt/client/table_client/logical_type.cpp b/yt/yt/client/table_client/logical_type.cpp
index 5c31d97df6..821b726e59 100644
--- a/yt/yt/client/table_client/logical_type.cpp
+++ b/yt/yt/client/table_client/logical_type.cpp
@@ -325,9 +325,9 @@ i64 TDecimalLogicalType::GetMemoryUsage() const
return sizeof(*this);
}
-i64 TDecimalLogicalType::GetMemoryUsage(i64 limit) const
+i64 TDecimalLogicalType::GetMemoryUsage(i64 threshold) const
{
- YT_ASSERT(limit > 0);
+ YT_ASSERT(threshold > 0);
return sizeof(*this);
}
@@ -389,17 +389,17 @@ i64 TOptionalLogicalType::GetMemoryUsage() const
}
}
-i64 TOptionalLogicalType::GetMemoryUsage(i64 limit) const
+i64 TOptionalLogicalType::GetMemoryUsage(i64 threshold) const
{
- YT_ASSERT(limit > 0);
+ YT_ASSERT(threshold > 0);
if (Element_->GetMetatype() == ELogicalMetatype::Simple) {
// NB: See TOptionalLogicalType::GetMemoryUsage().
return 0;
- } else if (auto sizeOfThis = static_cast<i64>(sizeof(*this)); sizeOfThis >= limit) {
+ } else if (auto sizeOfThis = static_cast<i64>(sizeof(*this)); sizeOfThis >= threshold) {
return sizeof(*this);
} else {
- return sizeOfThis + Element_->GetMemoryUsage(limit - sizeOfThis);
+ return sizeOfThis + Element_->GetMemoryUsage(threshold - sizeOfThis);
}
}
@@ -433,9 +433,9 @@ i64 TSimpleLogicalType::GetMemoryUsage() const
return 0;
}
-i64 TSimpleLogicalType::GetMemoryUsage(i64 limit) const
+i64 TSimpleLogicalType::GetMemoryUsage(i64 threshold) const
{
- YT_ASSERT(limit > 0);
+ YT_ASSERT(threshold > 0);
return 0;
}
@@ -472,14 +472,14 @@ i64 TListLogicalType::GetMemoryUsage() const
return sizeof(*this) + Element_->GetMemoryUsage();
}
-i64 TListLogicalType::GetMemoryUsage(i64 limit) const
+i64 TListLogicalType::GetMemoryUsage(i64 threshold) const
{
- YT_ASSERT(limit > 0);
+ YT_ASSERT(threshold > 0);
- if (auto sizeOfThis = static_cast<i64>(sizeof(*this)); sizeOfThis >= limit) {
+ if (auto sizeOfThis = static_cast<i64>(sizeof(*this)); sizeOfThis >= threshold) {
return sizeOfThis;
} else {
- return sizeOfThis + Element_->GetMemoryUsage(limit - sizeOfThis);
+ return sizeOfThis + Element_->GetMemoryUsage(threshold - sizeOfThis);
}
}
@@ -727,16 +727,16 @@ i64 TStructLogicalTypeBase::GetMemoryUsage() const
return usage;
}
-i64 TStructLogicalTypeBase::GetMemoryUsage(i64 limit) const
+i64 TStructLogicalTypeBase::GetMemoryUsage(i64 threshold) const
{
- YT_ASSERT(limit > 0);
+ YT_ASSERT(threshold > 0);
auto usage = static_cast<i64>(sizeof(*this) + sizeof(TStructField) * Fields_.size());
for (const auto& field : Fields_) {
- if (usage >= limit) {
+ if (usage >= threshold) {
return usage;
}
- usage += field.Type->GetMemoryUsage(limit - usage);
+ usage += field.Type->GetMemoryUsage(threshold - usage);
}
return usage;
}
@@ -799,16 +799,16 @@ i64 TTupleLogicalTypeBase::GetMemoryUsage() const
return usage;
}
-i64 TTupleLogicalTypeBase::GetMemoryUsage(i64 limit) const
+i64 TTupleLogicalTypeBase::GetMemoryUsage(i64 threshold) const
{
- YT_ASSERT(limit > 0);
+ YT_ASSERT(threshold > 0);
auto usage = static_cast<i64>(sizeof(*this) + sizeof(TLogicalTypePtr) * Elements_.size());
for (const auto& element : Elements_) {
- if (usage >= limit) {
+ if (usage >= threshold) {
return usage;
}
- usage += element->GetMemoryUsage(limit - usage);
+ usage += element->GetMemoryUsage(threshold - usage);
}
return usage;
}
@@ -867,19 +867,19 @@ i64 TDictLogicalType::GetMemoryUsage() const
return sizeof(*this) + Key_->GetMemoryUsage() + Value_->GetMemoryUsage();
}
-i64 TDictLogicalType::GetMemoryUsage(i64 limit) const
+i64 TDictLogicalType::GetMemoryUsage(i64 threshold) const
{
- YT_ASSERT(limit > 0);
+ YT_ASSERT(threshold > 0);
auto usage = static_cast<i64>(sizeof(*this));
- if (usage >= limit) {
+ if (usage >= threshold) {
return usage;
}
- usage += Key_->GetMemoryUsage(limit - usage);
- if (usage >= limit) {
+ usage += Key_->GetMemoryUsage(threshold - usage);
+ if (usage >= threshold) {
return usage;
}
- usage += Value_->GetMemoryUsage(limit - usage);
+ usage += Value_->GetMemoryUsage(threshold - usage);
return usage;
}
@@ -965,15 +965,15 @@ i64 TTaggedLogicalType::GetMemoryUsage() const
return sizeof(*this) + GetElement()->GetMemoryUsage();
}
-i64 TTaggedLogicalType::GetMemoryUsage(i64 limit) const
+i64 TTaggedLogicalType::GetMemoryUsage(i64 threshold) const
{
- YT_ASSERT(limit > 0);
+ YT_ASSERT(threshold > 0);
auto usage = static_cast<i64>(sizeof(*this));
- if (usage >= limit) {
+ if (usage >= threshold) {
return usage;
}
- usage += GetElement()->GetMemoryUsage(limit - usage);
+ usage += GetElement()->GetMemoryUsage(threshold - usage);
return usage;
}
diff --git a/yt/yt/client/table_client/logical_type.h b/yt/yt/client/table_client/logical_type.h
index 2c9a6afbfa..9385889632 100644
--- a/yt/yt/client/table_client/logical_type.h
+++ b/yt/yt/client/table_client/logical_type.h
@@ -72,7 +72,7 @@ public:
Y_FORCE_INLINE const TTaggedLogicalType& UncheckedAsTaggedTypeRef() const;
virtual i64 GetMemoryUsage() const = 0;
- virtual i64 GetMemoryUsage(i64 limit) const = 0;
+ virtual i64 GetMemoryUsage(i64 threshold) const = 0;
virtual int GetTypeComplexity() const = 0;
// This function doesn't validate children of current node.
@@ -177,7 +177,7 @@ public:
TDecimalLogicalType(int precision, int scale);
i64 GetMemoryUsage() const override;
- i64 GetMemoryUsage(i64 limit) const override;
+ i64 GetMemoryUsage(i64 threshold) const override;
int GetTypeComplexity() const override;
void ValidateNode(const TWalkContext& context) const override;
bool IsNullable() const override;
@@ -206,7 +206,7 @@ public:
Y_FORCE_INLINE bool IsElementNullable() const;
i64 GetMemoryUsage() const override;
- i64 GetMemoryUsage(i64 limit) const override;
+ i64 GetMemoryUsage(i64 threshold) const override;
int GetTypeComplexity() const override;
void ValidateNode(const TWalkContext& context) const override;
bool IsNullable() const override;
@@ -227,7 +227,7 @@ public:
Y_FORCE_INLINE ESimpleLogicalValueType GetElement() const;
i64 GetMemoryUsage() const override;
- i64 GetMemoryUsage(i64 limit) const override;
+ i64 GetMemoryUsage(i64 threshold) const override;
int GetTypeComplexity() const override;
void ValidateNode(const TWalkContext& context) const override;
bool IsNullable() const override;
@@ -247,7 +247,7 @@ public:
Y_FORCE_INLINE const TLogicalTypePtr& GetElement() const;
i64 GetMemoryUsage() const override;
- i64 GetMemoryUsage(i64 limit) const override;
+ i64 GetMemoryUsage(i64 threshold) const override;
int GetTypeComplexity() const override;
void ValidateNode(const TWalkContext& context) const override;
bool IsNullable() const override;
@@ -308,7 +308,7 @@ public:
Y_FORCE_INLINE const std::vector<TStructField>& GetFields() const;
i64 GetMemoryUsage() const override;
- i64 GetMemoryUsage(i64 limit) const override;
+ i64 GetMemoryUsage(i64 threshold) const override;
int GetTypeComplexity() const override;
void ValidateNode(const TWalkContext& context) const override;
bool IsNullable() const override;
@@ -328,7 +328,7 @@ public:
Y_FORCE_INLINE const std::vector<TLogicalTypePtr>& GetElements() const;
i64 GetMemoryUsage() const override;
- i64 GetMemoryUsage(i64 limit) const override;
+ i64 GetMemoryUsage(i64 threshold) const override;
int GetTypeComplexity() const override;
void ValidateNode(const TWalkContext& context) const override;
bool IsNullable() const override;
@@ -385,7 +385,7 @@ public:
Y_FORCE_INLINE const TLogicalTypePtr& GetValue() const;
i64 GetMemoryUsage() const override;
- i64 GetMemoryUsage(i64 limit) const override;
+ i64 GetMemoryUsage(i64 threshold) const override;
int GetTypeComplexity() const override;
void ValidateNode(const TWalkContext& context) const override;
bool IsNullable() const override;
@@ -407,7 +407,7 @@ public:
Y_FORCE_INLINE const TLogicalTypePtr& GetElement() const;
i64 GetMemoryUsage() const override;
- i64 GetMemoryUsage(i64 limit) const override;
+ i64 GetMemoryUsage(i64 threshold) const override;
int GetTypeComplexity() const override;
void ValidateNode(const TWalkContext& context) const override;
bool IsNullable() const override;
diff --git a/yt/yt/client/table_client/schema.cpp b/yt/yt/client/table_client/schema.cpp
index 46cfbee1b2..4b826077e0 100644
--- a/yt/yt/client/table_client/schema.cpp
+++ b/yt/yt/client/table_client/schema.cpp
@@ -282,9 +282,9 @@ i64 TColumnSchema::GetMemoryUsage() const
(Group_ ? Group_->size() : 0);
}
-i64 TColumnSchema::GetMemoryUsage(i64 limit) const
+i64 TColumnSchema::GetMemoryUsage(i64 threshold) const
{
- YT_ASSERT(limit > 0);
+ YT_ASSERT(threshold > 0);
auto usage = static_cast<i64>(
sizeof(TColumnSchema) +
@@ -295,11 +295,11 @@ i64 TColumnSchema::GetMemoryUsage(i64 limit) const
(Aggregate_ ? Aggregate_->size() : 0) +
(Group_ ? Group_->size() : 0));
- if (usage >= limit) {
+ if (usage >= threshold) {
return usage;
}
- return usage + LogicalType_->GetMemoryUsage(limit - usage);
+ return usage + LogicalType_->GetMemoryUsage(threshold - usage);
}
bool TColumnSchema::IsOfV1Type() const
@@ -1459,17 +1459,17 @@ i64 TTableSchema::GetMemoryUsage() const
return usage;
}
-i64 TTableSchema::GetMemoryUsage(i64 limit) const
+i64 TTableSchema::GetMemoryUsage(i64 threshold) const
{
- YT_ASSERT(limit > 0);
+ YT_ASSERT(threshold > 0);
auto usage = static_cast<i64>(sizeof(TTableSchema));
for (const auto& column : Columns()) {
- if (usage >= limit) {
+ if (usage >= threshold) {
return usage;
}
- usage += column.GetMemoryUsage(limit - usage);
+ usage += column.GetMemoryUsage(threshold - usage);
}
return usage;
}
@@ -1613,19 +1613,19 @@ void PrintTo(const TTableSchema& tableSchema, std::ostream* os)
TTableSchemaTruncatedFormatter::TTableSchemaTruncatedFormatter(
const TTableSchemaPtr& schema,
- i64 memoryLimit)
+ i64 memoryThreshold)
: Schema_(schema.Get())
- , Limit_(memoryLimit)
+ , Threshold_(memoryThreshold)
{
- YT_ASSERT(Limit_ >= 0);
+ YT_ASSERT(Threshold_ >= 0);
}
void TTableSchemaTruncatedFormatter::operator()(TStringBuilderBase* builder) const
{
if (!Schema_) {
builder->AppendString(ToString(nullptr));
- } else if (Limit_ > 0 && Schema_->GetMemoryUsage(Limit_) <= Limit_) {
- builder->AppendFormat("%v", *Schema_);
+ } else if (Threshold_ > 0 && Schema_->GetMemoryUsage(Threshold_) < Threshold_) {
+ FormatValue(builder, *Schema_, "%v");
} else {
builder->AppendString("<schema memory usage is over the logging threshold>");
}
diff --git a/yt/yt/client/table_client/schema.h b/yt/yt/client/table_client/schema.h
index a74ed5f5d7..5feae632bf 100644
--- a/yt/yt/client/table_client/schema.h
+++ b/yt/yt/client/table_client/schema.h
@@ -166,7 +166,7 @@ public:
EValueType GetWireType() const;
i64 GetMemoryUsage() const;
- i64 GetMemoryUsage(i64 limit) const;
+ i64 GetMemoryUsage(i64 threshold) const;
// Check if column has plain old v1 type.
bool IsOfV1Type() const;
@@ -398,8 +398,7 @@ public:
void Load(TStreamLoadContext& context);
i64 GetMemoryUsage() const;
-
- i64 GetMemoryUsage(i64 limit) const;
+ i64 GetMemoryUsage(i64 threshold) const;
private:
struct TColumnInfo
@@ -469,18 +468,18 @@ class TTableSchemaTruncatedFormatter
{
public:
// NB: #schema is allowed to be |nullptr|.
- TTableSchemaTruncatedFormatter(const TTableSchemaPtr& schema, i64 memoryLimit);
+ TTableSchemaTruncatedFormatter(const TTableSchemaPtr& schema, i64 memoryThreshold);
void operator()(TStringBuilderBase* builder) const;
private:
const TTableSchema* const Schema_ = nullptr;
- const i64 Limit_ = 0;
+ const i64 Threshold_ = 0;
};
TFormatterWrapper<TTableSchemaTruncatedFormatter> MakeTableSchemaTruncatedFormatter(
const TTableSchemaPtr& schema,
- i64 memoryLimit);
+ i64 memoryThreshold);
////////////////////////////////////////////////////////////////////////////////