Skip to content

Commit e00d7b5

Browse files
authored
Merge eb93861 into 5c4d7fa
2 parents 5c4d7fa + eb93861 commit e00d7b5

File tree

30 files changed

+586
-313
lines changed

30 files changed

+586
-313
lines changed

.github/config/muted_ya.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ydb/core/tx/schemeshard/ut_move_reboots TSchemeShardMoveRebootsTest.WithDataAndP
4242
ydb/core/tx/schemeshard/ut_pq_reboots TPqGroupTestReboots.AlterWithReboots-PQConfigTransactionsAtSchemeShard-false
4343
ydb/core/tx/schemeshard/ut_restore TImportTests.ShouldSucceedOnManyTables
4444
ydb/core/tx/schemeshard/ut_split_merge TSchemeShardSplitBySizeTest.Merge1KShards
45+
ydb/core/tx/tiering/ut ColumnShardTiers.TTLUsage
4546
ydb/core/tx/tx_proxy/ut_ext_tenant TExtSubDomainTest.CreateTableInsideAndAlterDomainAndTable-AlterDatabaseCreateHiveFirst*
4647
ydb/core/tx/tx_proxy/ut_storage_tenant TStorageTenantTest.RemoveStoragePoolBeforeDroppingTablet
4748
ydb/core/util/ut TCircularOperationQueueTest.ShouldShuffle

ydb/core/formats/arrow/converter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ static bool ConvertData(TCell& cell, const NScheme::TTypeInfo& colType, TMemoryP
3131
}
3232
case NScheme::NTypeIds::JsonDocument: {
3333
const auto binaryJson = NBinaryJson::SerializeToBinaryJson(cell.AsBuf());
34-
if (!binaryJson.Defined()) {
35-
errorMessage = "Invalid JSON for JsonDocument provided";
34+
if (binaryJson.IsFail()) {
35+
errorMessage = "Invalid JSON for JsonDocument provided: " + binaryJson.GetErrorMessage();
3636
return false;
3737
}
3838
const auto saved = memPool.AppendString(TStringBuf(binaryJson->Data(), binaryJson->Size()));
@@ -98,8 +98,9 @@ static arrow::Status ConvertColumn(const NScheme::TTypeInfo colType, std::shared
9898
}
9999
} else {
100100
const auto binaryJson = NBinaryJson::SerializeToBinaryJson(valueBuf);
101-
if (!binaryJson.Defined()) {
102-
return arrow::Status::SerializationError("Cannot serialize json: ", valueBuf);
101+
if (binaryJson.IsFail()) {
102+
return arrow::Status::SerializationError(
103+
"Cannot serialize json (", binaryJson.GetErrorMessage(), "): ", valueBuf.SubStr(0, Min(valueBuf.Size(), 1024ul)));
103104
}
104105
auto appendResult = builder.Append(binaryJson->Data(), binaryJson->Size());
105106
if (!appendResult.ok()) {

ydb/core/formats/arrow/ut/ut_arrow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ struct TDataRow {
223223
std::vector<TCell> cells(value.Cells().data(), value.Cells().data() + value.Cells().size());
224224

225225
auto binaryJson = NBinaryJson::SerializeToBinaryJson(TStringBuf(JsonDocument.data(), JsonDocument.size()));
226-
UNIT_ASSERT(binaryJson.Defined());
226+
UNIT_ASSERT(binaryJson.IsSuccess());
227227

228228
cells[19] = TCell(binaryJson->Data(), binaryJson->Size());
229229
return TOwnedCellVec(cells);

ydb/core/io_formats/cell_maker/cell_maker.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,13 @@ namespace {
8787
return false;
8888
}
8989

90-
result = NBinaryJson::SerializeToBinaryJson(unescaped);
91-
return result.Defined();
90+
auto serializedJson = NBinaryJson::SerializeToBinaryJson(unescaped);
91+
if (serializedJson.IsFail()) {
92+
return false;
93+
}
94+
95+
result = serializedJson.DetachResult();
96+
return true;
9297
}
9398

9499
template <>
@@ -395,8 +400,8 @@ bool MakeCell(TCell& cell, const NJson::TJsonValue& value, const NScheme::TTypeI
395400
case NScheme::NTypeIds::Json:
396401
return TCellMaker<TString, TStringBuf>::MakeDirect(cell, NFormats::WriteJson(value), pool, err);
397402
case NScheme::NTypeIds::JsonDocument:
398-
if (const auto& result = NBinaryJson::SerializeToBinaryJson(NFormats::WriteJson(value))) {
399-
return TCellMaker<TMaybe<NBinaryJson::TBinaryJson>, TStringBuf>::MakeDirect(cell, result, pool, err, &BinaryJsonToStringBuf);
403+
if (auto result = NBinaryJson::SerializeToBinaryJson(NFormats::WriteJson(value)); result.IsSuccess()) {
404+
return TCellMaker<TMaybe<NBinaryJson::TBinaryJson>, TStringBuf>::MakeDirect(cell, result.DetachResult(), pool, err, &BinaryJsonToStringBuf);
400405
} else {
401406
return false;
402407
}

ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8920,7 +8920,7 @@ Y_UNIT_TEST_SUITE(KqpOlapTypes) {
89208920
testHelper.CreateTable(testTable);
89218921
std::string jsonString = R"({"col1": "val1", "obj": {"obj_col2_int": 16}})";
89228922
auto maybeJsonDoc = NBinaryJson::SerializeToBinaryJson(jsonString);
8923-
Y_ABORT_UNLESS(maybeJsonDoc.Defined());
8923+
Y_ABORT_UNLESS(maybeJsonDoc.IsSuccess());
89248924
const std::string jsonBin(maybeJsonDoc->Data(), maybeJsonDoc->Size());
89258925
{
89268926
TTestHelper::TUpdatesBuilder tableInserter(testTable.GetArrowSchema(schema));

ydb/core/tx/data_events/common/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ LIBRARY()
22

33
PEERDIR(
44
ydb/core/protos
5+
ydb/library/conclusion
56
ydb/library/yql/core/issue/protos
67
ydb/public/api/protos
78
)

ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ value {
11961196
const TString string = "test string";
11971197
const TString json = R"({"key": "value"})";
11981198
auto binaryJson = NBinaryJson::SerializeToBinaryJson(json);
1199-
Y_ABORT_UNLESS(binaryJson.Defined());
1199+
Y_ABORT_UNLESS(binaryJson.IsSuccess());
12001200

12011201
const std::pair<ui64, ui64> decimal = NYql::NDecimal::MakePair(NYql::NDecimal::FromString("16.17", NScheme::DECIMAL_PRECISION, NScheme::DECIMAL_SCALE));
12021202
const std::pair<ui64, ui64> decimal35 = NYql::NDecimal::MakePair(NYql::NDecimal::FromString("555555555555555.123456789", 35, 10));

ydb/core/ydb_convert/ydb_convert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ Y_FORCE_INLINE void ConvertData(NUdf::TDataTypeId typeId, const Ydb::Value& valu
512512
case NUdf::TDataType<NUdf::TJsonDocument>::Id: {
513513
CheckTypeId(value.value_case(), Ydb::Value::kTextValue, "JsonDocument");
514514
const auto binaryJson = NBinaryJson::SerializeToBinaryJson(value.text_value());
515-
if (!binaryJson.Defined()) {
515+
if (binaryJson.IsFail()) {
516516
throw yexception() << "Invalid JsonDocument value";
517517
}
518518
res.SetBytes(binaryJson->Data(), binaryJson->Size());
@@ -1238,7 +1238,7 @@ bool CellFromProtoVal(const NScheme::TTypeInfo& type, i32 typmod, const Ydb::Val
12381238
}
12391239
case NScheme::NTypeIds::JsonDocument : {
12401240
const auto binaryJson = NBinaryJson::SerializeToBinaryJson(val.Gettext_value());
1241-
if (!binaryJson.Defined()) {
1241+
if (binaryJson.IsFail()) {
12421242
err = "Invalid JSON for JsonDocument provided";
12431243
return false;
12441244
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <benchmark/benchmark.h>
2+
3+
#include <util/random/random.h>
4+
#include <library/cpp/testing/unittest/registar.h>
5+
#include <library/cpp/json/json_value.h>
6+
#include <library/cpp/json/json_writer.h>
7+
8+
#include <ydb/library/binary_json/write.h>
9+
10+
// ya test -r -D BENCHMARK_MAKE_LARGE_PART
11+
#ifndef BENCHMARK_MAKE_LARGE_PART
12+
#define BENCHMARK_MAKE_LARGE_PART 0
13+
#endif
14+
15+
using namespace NKikimr::NBinaryJson;
16+
17+
namespace {
18+
19+
static ui64 seed = 0;
20+
21+
NJson::TJsonValue GetTestJson(ui64 depth = 10, ui64 nChildren = 2) {
22+
NJson::TJsonValue value;
23+
if (depth == 1) {
24+
value.SetValue(NUnitTest::RandomString(10, seed++));
25+
return value;
26+
}
27+
for (ui64 i = 0; i < nChildren; ++i) {
28+
value.InsertValue(NUnitTest::RandomString(10, seed++), GetTestJson(depth - 1));
29+
}
30+
return value;
31+
}
32+
33+
TString GetTestJsonString() {
34+
seed = 42;
35+
return NJson::WriteJson(GetTestJson(3, 50));
36+
}
37+
38+
static void BenchWriteSimdJson(benchmark::State& state) {
39+
TString value = GetTestJsonString();
40+
TStringBuf buf(value);
41+
for (auto _ : state) {
42+
auto result = SerializeToBinaryJson(buf);
43+
benchmark::DoNotOptimize(result);
44+
benchmark::ClobberMemory();
45+
}
46+
}
47+
48+
}
49+
50+
BENCHMARK(BenchWriteSimdJson)->MinTime(1);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
G_BENCHMARK()
2+
3+
TAG(ya:fat)
4+
SIZE(LARGE)
5+
TIMEOUT(600)
6+
7+
IF (BENCHMARK_MAKE_LARGE_PART)
8+
CFLAGS(
9+
-DBENCHMARK_MAKE_LARGE_PART=1
10+
)
11+
TIMEOUT(1200)
12+
ENDIF()
13+
14+
SRCS(
15+
write.cpp
16+
)
17+
18+
PEERDIR(
19+
library/cpp/testing/unittest
20+
ydb/library/binary_json
21+
ydb/library/yql/minikql/dom
22+
ydb/library/yql/minikql/invoke_builtins/llvm14
23+
ydb/library/yql/public/udf/service/exception_policy
24+
ydb/library/yql/core/issue/protos
25+
ydb/library/yql/sql/pg_dummy
26+
)
27+
28+
YQL_LAST_ABI_VERSION()
29+
30+
END()

0 commit comments

Comments
 (0)