Skip to content

Commit 784f7d9

Browse files
committed
Fix -Wshorten-64-to-32 in examples
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
1 parent b8ab686 commit 784f7d9

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

src/Common/examples/arena_with_free_lists.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ struct Dictionary
176176
{
177177
case AttributeUnderlyingTypeTest::UInt8: std::get<ContainerPtrType<UInt8>>(attribute.arrays)[idx] = value.get<UInt64>(); break;
178178
case AttributeUnderlyingTypeTest::UInt16: std::get<ContainerPtrType<UInt16>>(attribute.arrays)[idx] = value.get<UInt64>(); break;
179-
case AttributeUnderlyingTypeTest::UInt32: std::get<ContainerPtrType<UInt32>>(attribute.arrays)[idx] = value.get<UInt64>(); break;
179+
case AttributeUnderlyingTypeTest::UInt32: std::get<ContainerPtrType<UInt32>>(attribute.arrays)[idx] = static_cast<UInt32>(value.get<UInt64>()); break;
180180
case AttributeUnderlyingTypeTest::UInt64: std::get<ContainerPtrType<UInt64>>(attribute.arrays)[idx] = value.get<UInt64>(); break;
181181
case AttributeUnderlyingTypeTest::Int8: std::get<ContainerPtrType<Int8>>(attribute.arrays)[idx] = value.get<Int64>(); break;
182182
case AttributeUnderlyingTypeTest::Int16: std::get<ContainerPtrType<Int16>>(attribute.arrays)[idx] = value.get<Int64>(); break;
183-
case AttributeUnderlyingTypeTest::Int32: std::get<ContainerPtrType<Int32>>(attribute.arrays)[idx] = value.get<Int64>(); break;
183+
case AttributeUnderlyingTypeTest::Int32: std::get<ContainerPtrType<Int32>>(attribute.arrays)[idx] = static_cast<Int32>(value.get<Int64>()); break;
184184
case AttributeUnderlyingTypeTest::Int64: std::get<ContainerPtrType<Int64>>(attribute.arrays)[idx] = value.get<Int64>(); break;
185185
case AttributeUnderlyingTypeTest::Float32: std::get<ContainerPtrType<Float32>>(attribute.arrays)[idx] = static_cast<Float32>(value.get<Float64>()); break;
186186
case AttributeUnderlyingTypeTest::Float64: std::get<ContainerPtrType<Float64>>(attribute.arrays)[idx] = value.get<Float64>(); break;

src/Common/examples/array_cache.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ int main(int argc, char ** argv)
4646

4747
size_t cache_size = DB::parse<size_t>(argv[1]);
4848
size_t num_threads = DB::parse<size_t>(argv[2]);
49-
size_t num_iterations = DB::parse<size_t>(argv[3]);
49+
int num_iterations = DB::parse<int>(argv[3]);
5050
size_t region_max_size = DB::parse<size_t>(argv[4]);
51-
size_t max_key = DB::parse<size_t>(argv[5]);
51+
int max_key = DB::parse<int>(argv[5]);
5252

5353
using Cache = ArrayCache<int, int>;
5454
Cache cache(cache_size);
@@ -60,7 +60,7 @@ int main(int argc, char ** argv)
6060
{
6161
pcg64 generator(randomSeed());
6262

63-
for (size_t j = 0; j < num_iterations; ++j)
63+
for (int j = 0; j < num_iterations; ++j)
6464
{
6565
size_t size = std::uniform_int_distribution<size_t>(1, region_max_size)(generator);
6666
int key = std::uniform_int_distribution<int>(1, max_key)(generator);

src/Common/examples/average.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ Float NO_INLINE microsort(const PODArray<UInt8> & keys, const PODArray<Float> &
425425
for (size_t i = 1; i < HISTOGRAM_SIZE; ++i)
426426
positions[i] = positions[i - 1] + count[i - 1];
427427

428-
for (size_t i = 0; i < size; ++i)
428+
for (UInt32 i = 0; i < size; ++i)
429429
*positions[keys[i]]++ = i;
430430

431431
/// Update states.

src/IO/examples/valid_utf8_perf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ int main(int argc, char ** argv)
1010
{
1111
int repeats = 1;
1212
if (argc >= 2)
13-
repeats = std::stol(argv[1]);
13+
repeats = static_cast<int>(std::stol(argv[1]));
1414

1515
std::string text((std::istreambuf_iterator<char>(std::cin)),
1616
std::istreambuf_iterator<char>());

src/IO/examples/zlib_ng_bug.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ int main(int, char **)
2323
throw std::runtime_error("Cannot deflateInit2");
2424

2525
zstr.next_in = in.data();
26-
zstr.avail_in = in.size();
26+
zstr.avail_in = static_cast<int>(in.size());
2727
zstr.next_out = out.data();
28-
zstr.avail_out = out.size();
28+
zstr.avail_out = static_cast<int>(out.size());
2929

3030
while (zstr.avail_in > 0)
3131
if (Z_OK != deflate(&zstr, Z_NO_FLUSH))

src/Interpreters/examples/hash_map_string_small.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
struct SmallStringRef
2525
{
26-
UInt32 size = 0;
26+
size_t size = 0;
2727

2828
union
2929
{

src/Storages/examples/merge_selector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int main(int, char **)
6666

6767
size_t sum_merged_size = 0;
6868
size_t start_index = 0;
69-
size_t max_level = 0;
69+
unsigned max_level = 0;
7070
bool in_range = false;
7171

7272
for (size_t i = 0, size = parts.size(); i < size; ++i)

src/Storages/examples/merge_selector2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int main(int, char **)
7272

7373
size_t sum_merged_size = 0;
7474
size_t start_index = 0;
75-
size_t max_level = 0;
75+
unsigned max_level = 0;
7676
bool in_range = false;
7777

7878
for (size_t i = 0, size = parts.size(); i < size; ++i)

0 commit comments

Comments
 (0)