Skip to content

Commit

Permalink
Merge pull request #58196 from ClickHouse/strange-code
Browse files Browse the repository at this point in the history
Looking at strange code
  • Loading branch information
alexey-milovidov committed Dec 24, 2023
2 parents 069f8bb + 6bb181c commit ef66714
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
1 change: 0 additions & 1 deletion programs/benchmark/Benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <Common/StudentTTest.h>
#include <Common/CurrentMetrics.h>
#include <Common/ErrorCodes.h>
#include <filesystem>


/** A tool for evaluating ClickHouse performance.
Expand Down
11 changes: 2 additions & 9 deletions src/Formats/JSONUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace ErrorCodes

namespace JSONUtils
{

template <const char opening_bracket, const char closing_bracket>
static std::pair<bool, size_t>
fileSegmentationEngineJSONEachRowImpl(ReadBuffer & in, DB::Memory<> & memory, size_t min_bytes, size_t min_rows, size_t max_rows)
Expand Down Expand Up @@ -72,7 +71,7 @@ namespace JSONUtils
}
else
{
pos = find_first_symbols<opening_bracket, closing_bracket, '\\', '"'>(pos, in.buffer().end());
pos = find_first_symbols<opening_bracket, closing_bracket, '"'>(pos, in.buffer().end());

if (pos > in.buffer().end())
throw Exception(ErrorCodes::LOGICAL_ERROR, "Position in buffer is out of bounds. There must be a bug.");
Expand All @@ -89,19 +88,13 @@ namespace JSONUtils
--balance;
++pos;
}
else if (*pos == '\\')
{
++pos;
if (loadAtPosition(in, memory, pos))
++pos;
}
else if (*pos == '"')
{
quotes = true;
++pos;
}

if (balance == 0)
if (!quotes && balance == 0)
{
++number_of_rows;
if ((number_of_rows >= min_rows)
Expand Down

0 comments on commit ef66714

Please sign in to comment.