Skip to content

Commit

Permalink
Merge branch 'ydb-platform:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
alexv-smirnov authored Jun 4, 2024
2 parents 3ca7a53 + 106fc30 commit 1a13778
Show file tree
Hide file tree
Showing 42 changed files with 783 additions and 427 deletions.
1 change: 1 addition & 0 deletions ydb/apps/ydb/ut/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ SRCS(
run_ydb.cpp
supported_codecs.cpp
supported_codecs_fixture.cpp
ydb-dump.cpp
)

PEERDIR(
Expand Down
72 changes: 72 additions & 0 deletions ydb/apps/ydb/ut/ydb-dump.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "run_ydb.h"

#include <util/string/split.h>

#include <library/cpp/testing/common/env.h>
#include <library/cpp/testing/unittest/registar.h>

#include <ydb/public/sdk/cpp/client/ydb_table/table.h>

#include <ydb/public/api/protos/ydb_table.pb.h>

Y_UNIT_TEST_SUITE(YdbDump) {

Y_UNIT_TEST(NotNullTypeDump) {
RunYdb({"-v", "yql", "-s",
R"(CREATE TABLE TableWithNotNullTypeForDump (
k Uint32 NOT NULL,
v String NOT NULL,
ov String,
PRIMARY KEY(k));
)"},
TList<TString>());

const TString output = RunYdb({"-v", "tools", "dump", "--scheme-only"}, TList<TString>());

struct TFlags {
const bool HasNullFlag;
const bool IsOptionalType;
};

TVector<TFlags> column_flags;
auto fillFlag = [&column_flags](const TString& str) {
Ydb::Table::ColumnMeta meta;
google::protobuf::TextFormat::ParseFromString(str, &meta);
column_flags.emplace_back(TFlags{meta.has_not_null(), meta.type().has_optional_type()});
};

const TString token = "columns {";
size_t start = 0;
while (true) {
start = output.find(token, start);
if (start != TString::npos) {
int scope = 1;
start += token.size();
size_t pos = start;
while (pos < output.size() && scope != 0) {
if (output[pos] == '{') {
scope++;
} else if (output[pos] == '}') {
scope--;
}
pos++;
}
Y_ABORT_UNLESS(pos > start);
fillFlag(output.substr(start, pos - start - 1));
start = pos;
} else {
break;
}
}

// For compatibility reason we do not show not null flag
UNIT_ASSERT_VALUES_EQUAL(column_flags.size(), 3);
UNIT_ASSERT_VALUES_EQUAL(column_flags[0].HasNullFlag, false);
UNIT_ASSERT_VALUES_EQUAL(column_flags[0].IsOptionalType, false);
UNIT_ASSERT_VALUES_EQUAL(column_flags[1].HasNullFlag, false);
UNIT_ASSERT_VALUES_EQUAL(column_flags[1].IsOptionalType, false);
UNIT_ASSERT_VALUES_EQUAL(column_flags[2].HasNullFlag, false);
UNIT_ASSERT_VALUES_EQUAL(column_flags[2].IsOptionalType, true);
}

}
64 changes: 36 additions & 28 deletions ydb/ci/build_bloat/html/bloat.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,55 @@
body {
font-family: sans-serif;
font-size: 0.8em;
margin: 2ex 4ex;
height: calc(100vh - 20px);
}

h1 {
font-weight: normal;
.content {
height: 100%;
display: flex;
flex-direction: column;
gap: 1ex;
}

#map {
.header {
width: 100%;
height: 600px;

position: relative;
cursor: pointer;
-webkit-user-select: none;
display: flex;
flex-direction: row;
flex-wrap: wrap;
vertical-align: middle;
}

legend {
float: right;
padding: 0;
.header div {
padding: 1ex 1em;
}

legend div {
display: inline-block;
vertical-align: middle;
position: static !important;
.header legend {
display: flex;
flex-direction: row;
gap: 1em;
padding: 0;
}

legend > div {
width: 62px;
height: 27px;
.header .note {
width: 100%;
flex-basis: content;
flex-grow: 1;
}

legend > div > div {
width: 50px;
height: 15px;
margin: 5px;
text-align: center;
.header .webtreemap-node {
flex-basis: max-content;
flex-grow: 0;
position: relative;
text-align: center;
}

legend h2 {
display: inline-block;
font-weight: initial;
vertical-align: middle;
#map {
flex-basis: 100%;

min-width: 300px;
min-height: 300px;

position: relative;
cursor: pointer;
user-select: none;
}
53 changes: 23 additions & 30 deletions ydb/ci/build_bloat/html/index.html
Original file line number Diff line number Diff line change
@@ -1,41 +1,34 @@
<!DOCTYPE html>
<!-- Based on https://github.com/martine/webtreemap -->
<head>
<title>binary size</title>
<link rel="stylesheet" href="webtreemap.css">
<link rel="stylesheet" href="bloat.css">
<script src='webtreemap.js'></script>
<title>Build bloat</title>
<link rel="stylesheet" href="webtreemap.css">
<link rel="stylesheet" href="bloat.css">
</head>

<body>
<legend>
<h2>Legend:</h2>
<div class="webtreemap-node webtreemap-symbol-dir webtreemap-aggregate">
<div class="webtreemap-node webtreemap-symbol-dir">
Dir
<div class="content">
<div class="header">
<div class="note">Click on a box to zoom in. Click on the outermost box to zoom out.</div>
<legend>
<div>Legend:</div>
<div class="webtreemap-node webtreemap-type-dir">Dir</div>
<div class="webtreemap-node webtreemap-type-cpp">Cpp</div>
<div class="webtreemap-node webtreemap-type-h">Header</div>
</legend>
</div>
<div id='map'></div>
</div>
<div class="webtreemap-node webtreemap-symbol-cpp webtreemap-aggregate">
<div class="webtreemap-node webtreemap-symbol-cpp">
Cpp
</div>
</div>
<div class="webtreemap-node webtreemap-symbol-h webtreemap-aggregate">
<div class="webtreemap-node webtreemap-symbol-h">
Header
</div>
</div>
</legend>

<h1>build time bloat</h1>
<p>Click on a box to zoom in. Click on the outermost box to zoom out.</p>

<div id='map'></div>

<script src="bloat.json"></script>
<script>
var map = document.getElementById('map');
appendTreemap(map, kTree);
</script>
<script src="bloat.json"></script>
<script type="text/javascript" src='webtreemap.js'></script>
<script type="text/javascript">
var map = document.getElementById('map');
var bloat = null;

renderTreemap(map, kTree);
window.addEventListener("resize", (event) => {
renderTreemap(map, kTree);
});
</script>
</body>
33 changes: 12 additions & 21 deletions ydb/ci/build_bloat/html/webtreemap.css
Original file line number Diff line number Diff line change
@@ -1,49 +1,39 @@
/* Based on https://github.com/martine/webtreemap */

.webtreemap-node {
/* Required attributes. */
position: absolute;
overflow: hidden; /* To hide overlong captions. */
background: white; /* Nodes must be opaque for zIndex layering. */
border: solid 1px black; /* Calculations assume 1px border. */
border: solid 1px #555; /* Calculations assume 1px border. */

/* Optional: CSS animation. */
-webkit-transition: top 0.3s,
left 0.3s,
width 0.3s,
height 0.3s;
transition: top 0.3s,
left 0.3s,
width 0.3s,
height 0.3s;
}

/* Optional: highlight nodes on mouseover. */
.webtreemap-node:hover {
background: #eee;
background: #FFFFFF;
}

/* Optional: Different background colors depending on symbol. */
.webtreemap-symbol-h {
/* Optional: Different background colors depending on type. */
.webtreemap-type-h {
background: #66C2A5;
}
.webtreemap-symbol-cpp {
.webtreemap-type-cpp {
background: #FC8D62;
}
.webtreemap-symbol-dir {
.webtreemap-type-dir {
background: #8DA0CB;
}
.webtreemap-symbol-dir.webtreemap-aggregate {
background: #CBD5E8;
}
.webtreemap-symbol-cpp.webtreemap-aggregate {
background: #FDCDAC;
}
.webtreemap-symbol-h.webtreemap-aggregate {
background: #E6F5C9;
}

#legend > * {
border: solid 1px #444;
}

/* Optional: Different borders depending on level. */
/*
.webtreemap-level0 {
border: solid 1px #444;
}
Expand All @@ -59,6 +49,7 @@
.webtreemap-level4 {
border: solid 1px #ccc;
}
*/

/* Optional: styling on node captions. */
.webtreemap-caption {
Expand Down
Loading

0 comments on commit 1a13778

Please sign in to comment.