fix style

This commit is contained in:
zhanglistar 2024-11-20 16:40:09 +08:00
parent 151c881e43
commit 2b39f6c019
11 changed files with 18 additions and 22 deletions

View File

@ -614,6 +614,7 @@
M(734, CANNOT_WRITE_AFTER_BUFFER_CANCELED) \
M(735, QUERY_WAS_CANCELLED_BY_CLIENT) \
M(736, JSON_PARSE_ERROR) \
\
M(900, DISTRIBUTED_CACHE_ERROR) \
M(901, CANNOT_USE_DISTRIBUTED_CACHE) \
M(902, PROTOCOL_VERSION_MISMATCH) \

View File

@ -1,10 +1,8 @@
#pragma once
#include "Common/StackTrace.h"
#include "config.h"
#if USE_SIMDJSON
# include <Common/logger_useful.h>
# include <base/types.h>
# include <Common/Exception.h>
# include <base/defines.h>
@ -294,7 +292,7 @@ public:
simdjson::ondemand::number_type nt{};
auto res = value.get_number_type().get(nt);
chassert(res == simdjson::SUCCESS);
switch(nt)
switch (nt)
{
case simdjson::ondemand::number_type::signed_integer:
format.number(value.get_int64().value_unsafe());
@ -663,7 +661,6 @@ struct OnDemandSimdJSONParser
ALWAYS_INLINE KeyValuePair operator*() const
{
//SIMDJSON_ASSIGN_OR_THROW(auto field_wrapper, *it);
auto field_wrapper = *it;
if (field_wrapper.error())
{
@ -716,8 +713,6 @@ struct OnDemandSimdJSONParser
/// Optional: Provides access to an object's element by index.
KeyValuePair operator[](size_t index) const
{
///SIMDJSON_ASSIGN_OR_THROW(auto b, object.reset());
///(void)b;
SIMDJSON_ASSIGN_OR_THROW(auto it, object.begin());
while (index--)
{

View File

@ -1324,7 +1324,7 @@ public:
size_t old_size = tuple_col.size();
auto object = element.getObject();
auto it = object.begin();
size_t object_size{};
size_t object_size = 0;
for (; it != object.end(); ++it)
{
++object_size;

View File

@ -368,7 +368,6 @@ public:
/// Here it is possible to handle errors with ON ERROR (as described in ISO/IEC TR 19075-6),
/// however this functionality is not implemented yet
}
//current_element = root;
}
if (status == VisitorStatus::Exhausted)
@ -420,10 +419,8 @@ public:
bool success = false;
const char * array_begin = "[";
const char * array_end = "]";
//const char * comma = ", ";
JSONStringSerializer json_serializer(col_str);
json_serializer.addRawData(array_begin, 1);
//std::vector<Element> result{};
std::function<void(const Element&)> result_func= [&json_serializer](const Element & element) { json_serializer.addElement(element); };
while ((status = generator_json_path.getNextItemBatch(current_element, result_func)) != VisitorStatus::Exhausted)
{
@ -437,8 +434,6 @@ public:
/// Here it is possible to handle errors with ON ERROR (as described in ISO/IEC TR 19075-6),
/// however this functionality is not implemented yet
}
//current_element = root;
//result.clear();
}
if (!success)
{

View File

@ -623,7 +623,7 @@ public:
static bool insertResultToColumn(IColumn & dest, const Element & element, std::string_view, const FormatSettings &, String &)
{
size_t size{};
size_t size;
if (element.isArray())
size = element.getArray().size();
else if (element.isObject())

View File

@ -24,7 +24,7 @@ public:
*/
virtual VisitorStatus getNextItem(TElement & element) = 0;
virtual VisitorStatus getNextItemBatch(TElement & element, std::function<void(const TElement &)> & ) = 0;
virtual VisitorStatus getNextItemBatch(TElement & element, std::function<void(const TElement &)> & res_func) = 0;
virtual ~IGenerator() = default;
};

View File

@ -15,14 +15,19 @@ public:
* Applies this visitor to document and mutates its state
* @param element simdjson element
*/
virtual VisitorStatus visit(typename JSONParser::Element & element) = 0;
virtual VisitorStatus visitBatch(TElement & element, std::function<void(const TElement &)> & , bool ) = 0;
virtual VisitorStatus visit(TElement & element) = 0;
/**
* Applies this visitor to document and mutates its state, returning a batch of results
* @param element simdjson element
*/
virtual VisitorStatus visitBatch(TElement &element, std::function<void(const TElement &)> & res_func, bool can_reduce) = 0;
/**
* Applies this visitor to document, but does not mutate state
* @param element simdjson element
*/
virtual VisitorStatus apply(typename JSONParser::Element & element) = 0;
virtual VisitorStatus apply(typename JSONParser::Element & element) const = 0;
/**
* Restores visitor's initial state for later use

View File

@ -17,7 +17,7 @@ public:
const char * getName() const override { return "VisitorJSONPathMemberAccess"; }
VisitorStatus apply(typename JSONParser::Element & element) override
VisitorStatus apply(typename JSONParser::Element & element) const override
{
typename JSONParser::Element result;
auto obj = element.getObject();

View File

@ -19,7 +19,7 @@ public:
const char * getName() const override { return "VisitorJSONPathRange"; }
VisitorStatus apply(typename JSONParser::Element & element) override
VisitorStatus apply(typename JSONParser::Element & element) const override
{
element = (*array)[current_index];
return VisitorStatus::Ok;

View File

@ -15,7 +15,7 @@ public:
const char * getName() const override { return "VisitorJSONPathRoot"; }
VisitorStatus apply(typename JSONParser::Element & /*element*/) override
VisitorStatus apply(typename JSONParser::Element & /*element*/) const override
{
/// No-op on document, since we are already passed document's root
return VisitorStatus::Ok;

View File

@ -18,7 +18,7 @@ public:
const char * getName() const override { return "VisitorJSONPathStar"; }
VisitorStatus apply(typename JSONParser::Element & element) override
VisitorStatus apply(typename JSONParser::Element & element) const override
{
element = array.value()[current_index];
return VisitorStatus::Ok;