aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-03-05 19:43:26 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-03-05 19:54:12 +0300
commitad2a5a5eb7f9abb107a1ce3ec81d8038e7e06d1a (patch)
tree271eb7e73731ef5489f29820ee8400f37757607e
parentaa891ba4c064f61a12f10f884a6af149d733b64d (diff)
downloadydb-ad2a5a5eb7f9abb107a1ce3ec81d8038e7e06d1a.tar.gz
Intermediate changes
-rw-r--r--yt/yt/client/arrow/arrow_row_stream_encoder.cpp39
-rw-r--r--yt/yt/core/actions/unittests/future_ut.cpp28
-rw-r--r--yt/yt/library/program/program_config_mixin.h34
3 files changed, 101 insertions, 0 deletions
diff --git a/yt/yt/client/arrow/arrow_row_stream_encoder.cpp b/yt/yt/client/arrow/arrow_row_stream_encoder.cpp
index aaa81b7ef8..c36c6724a1 100644
--- a/yt/yt/client/arrow/arrow_row_stream_encoder.cpp
+++ b/yt/yt/client/arrow/arrow_row_stream_encoder.cpp
@@ -80,6 +80,14 @@ std::tuple<org::apache::arrow::flatbuf::Type, flatbuffers::Offset<void>> Seriali
org::apache::arrow::flatbuf::Precision_DOUBLE)
.Union());
+ case ESimpleLogicalValueType::Float:
+ return std::tuple(
+ org::apache::arrow::flatbuf::Type_FloatingPoint,
+ org::apache::arrow::flatbuf::CreateFloatingPoint(
+ *flatbufBuilder,
+ org::apache::arrow::flatbuf::Precision_SINGLE)
+ .Union());
+
case ESimpleLogicalValueType::Boolean:
return std::tuple(
org::apache::arrow::flatbuf::Type_Bool,
@@ -468,6 +476,35 @@ void SerializeDoubleColumn(
});
}
+void SerializeFloatColumn(
+ const TTypedBatchColumn& typedColumn,
+ TRecordBatchSerializationContext* context)
+{
+ const auto* column = typedColumn.Column;
+ YT_VERIFY(column->Values);
+ YT_VERIFY(column->Values->BitWidth == 32);
+ YT_VERIFY(column->Values->BaseValue == 0);
+ YT_VERIFY(!column->Values->ZigZagEncoded);
+
+ YT_LOG_DEBUG("Adding float column (ColumnId: %v, StartIndex: %v, ValueCount: %v)",
+ column->Id,
+ column->StartIndex,
+ column->ValueCount,
+ column->Rle.has_value());
+
+ SerializeColumnPrologue(typedColumn, context);
+
+ context->AddBuffer(
+ column->ValueCount * sizeof(float),
+ [=] (TMutableRef dstRef) {
+ auto relevantValues = column->GetRelevantTypedValues<float>();
+ ::memcpy(
+ dstRef.Begin(),
+ relevantValues.Begin(),
+ column->ValueCount * sizeof(float));
+ });
+}
+
void SerializeStringLikeColumn(
const TTypedBatchColumn& typedColumn,
TRecordBatchSerializationContext* context)
@@ -583,6 +620,8 @@ void SerializeColumn(
SerializeIntegerColumn(typedColumn, simpleType, context);
} else if (simpleType == ESimpleLogicalValueType::Double) {
SerializeDoubleColumn(typedColumn, context);
+ } else if (simpleType == ESimpleLogicalValueType::Float) {
+ SerializeFloatColumn(typedColumn, context);
} else if (IsStringLikeType(simpleType)) {
SerializeStringLikeColumn(typedColumn, context);
} else if (simpleType == ESimpleLogicalValueType::Boolean) {
diff --git a/yt/yt/core/actions/unittests/future_ut.cpp b/yt/yt/core/actions/unittests/future_ut.cpp
index 9b564e7481..5185d0cd8d 100644
--- a/yt/yt/core/actions/unittests/future_ut.cpp
+++ b/yt/yt/core/actions/unittests/future_ut.cpp
@@ -1689,6 +1689,34 @@ TEST_F(TFutureTest, AbandonDuringGet)
thread.join();
}
+TEST_F(TFutureTest, CancelAppliedToUncancellable)
+{
+ auto promise = NewPromise<void>();
+ auto future = promise.ToFuture();
+
+ auto uncancelable = future.ToUncancelable();
+ auto future1 = uncancelable.Apply(BIND([&] () -> void {}));
+ future1.Cancel(TError("Cancel"));
+ EXPECT_FALSE(promise.IsSet());
+ EXPECT_FALSE(promise.IsCanceled());
+ EXPECT_FALSE(uncancelable.IsSet());
+ EXPECT_FALSE(future1.IsSet());
+
+ auto immediatelyCancelable = uncancelable.ToImmediatelyCancelable();
+ auto future2 = immediatelyCancelable.Apply(BIND([&] () -> void {}));
+ future2.Cancel(TError("Cancel"));
+ EXPECT_FALSE(promise.IsSet());
+ EXPECT_FALSE(promise.IsCanceled());
+ EXPECT_TRUE(immediatelyCancelable.IsSet());
+ EXPECT_TRUE(future2.IsSet());
+ EXPECT_EQ(NYT::EErrorCode::Canceled, future2.Get().GetCode());
+
+ promise.Set();
+ EXPECT_TRUE(uncancelable.IsSet());
+ EXPECT_TRUE(future1.IsSet());
+ EXPECT_TRUE(future1.Get().IsOK());
+}
+
///////////////////////////////////////////////////////////////////////////////
} // namespace
diff --git a/yt/yt/library/program/program_config_mixin.h b/yt/yt/library/program/program_config_mixin.h
index 784c422477..4f47196e5d 100644
--- a/yt/yt/library/program/program_config_mixin.h
+++ b/yt/yt/library/program/program_config_mixin.h
@@ -36,6 +36,12 @@ protected:
}
opts
.AddLongOption(
+ Format("%v-schema", argumentName),
+ Format("print %v schema and exit", argumentName))
+ .OptionalValue(YsonSchemaFormat_, "FORMAT")
+ .StoreResult(&ConfigSchema_);
+ opts
+ .AddLongOption(
Format("%v-template", argumentName),
Format("print %v template and exit", argumentName))
.SetFlag(&ConfigTemplate_);
@@ -58,6 +64,12 @@ protected:
opts
.AddLongOption(
+ Format("dynamic-%v-schema", argumentName),
+ Format("print %v schema and exit", argumentName))
+ .OptionalValue(YsonSchemaFormat_, "FORMAT")
+ .StoreResult(&DynamicConfigSchema_);
+ opts
+ .AddLongOption(
Format("dynamic-%v-template", argumentName),
Format("print dynamic %v template and exit", argumentName))
.SetFlag(&DynamicConfigTemplate_);
@@ -95,6 +107,20 @@ protected:
config->Save(&writer);
Cout << Flush;
};
+ auto printSchema = [] (const auto& config, TString format) {
+ if (format == YsonSchemaFormat_) {
+ using namespace NYson;
+ TYsonWriter writer(&Cout, EYsonFormat::Pretty);
+ config->WriteSchema(&writer);
+ Cout << Endl;
+ } else {
+ THROW_ERROR_EXCEPTION("Unknown schema format %v", format);
+ }
+ };
+ if (!ConfigSchema_.empty()) {
+ printSchema(New<TConfig>(), ConfigSchema_);
+ return true;
+ }
if (ConfigTemplate_) {
print(New<TConfig>());
return true;
@@ -105,6 +131,10 @@ protected:
}
if constexpr (!std::is_same_v<TDynamicConfig, void>) {
+ if (!DynamicConfigSchema_.empty()) {
+ printSchema(New<TDynamicConfig>(), DynamicConfigSchema_);
+ return true;
+ }
if (DynamicConfigTemplate_) {
print(New<TDynamicConfig>());
return true;
@@ -154,11 +184,15 @@ private:
const TString ArgumentName_;
TString ConfigPath_;
+ TString ConfigSchema_;
bool ConfigTemplate_;
bool ConfigActual_;
+ TString DynamicConfigSchema_;
bool DynamicConfigTemplate_ = false;
NYTree::EUnrecognizedStrategy UnrecognizedStrategy_ = NYTree::EUnrecognizedStrategy::KeepRecursive;
+ static constexpr auto YsonSchemaFormat_ = "yson-schema";
+
TIntrusivePtr<TConfig> Config_;
NYTree::INodePtr ConfigNode_;
};