Skip to content

Commit

Permalink
Merge pull request #33 from timeplus-io/bugfix/issue-31-full-build-fa…
Browse files Browse the repository at this point in the history
…iled

Bugfix/issue 31 full build failed
  • Loading branch information
qijun-niu-timeplus authored Sep 5, 2023
2 parents eb2e41a + a7d6bde commit 41b3c83
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 67 deletions.
19 changes: 0 additions & 19 deletions src/AggregateFunctions/tests/gtest_uda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,24 +511,6 @@ TEST_F(UDATestCase, returnNumberForBoolArray)
checkV8ReturnResult("bool", true, create_fn, check_fn);
}

void dumpArray(ColumnArray & col)
{
std::cout << "structure: " << col.dumpStructure() << std::endl;
std::cout << "data: ";
for (int i = 0; i < col.getData().size(); i++)
{
std::cout << col.getData()[i] << ",";
}
std::cout << std::endl;

std::cout << "offsets: ";
for (uint64_t i : col.getOffsets())
{
std::cout << i << ",";
}
std::cout << std::endl;
}

using CREATE_DATA_FUNC = std::function<void(MutableColumnPtr &)>;
using CHECK_V8_DATA_FUNC = std::function<void(v8::Isolate *, v8::Local<v8::Context> &, v8::Local<v8::Array> &)>;

Expand Down Expand Up @@ -661,7 +643,6 @@ TEST_F(UDATestCase, prepareArgumentsNestedArray)
column_array.insert(nested1);
Array nested2 = Array{Array{6}, Array{7}};
column_array.insert(nested2);
/// dumpArray(column_array);
};

auto check_nested_arr = [](v8::Isolate *, v8::Local<v8::Context> & local_ctx, v8::Local<v8::Array> & v8_arr)
Expand Down
3 changes: 1 addition & 2 deletions src/Common/CurrentThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <Interpreters/Context_fwd.h>
#include <Common/ThreadStatus.h>
#include <base/StringRef.h>

#include <memory>
#include <string>
Expand Down Expand Up @@ -87,7 +86,7 @@ class CurrentThread
static void finalizePerformanceCounters();

/// Returns a non-empty string if the thread is attached to a query
static StringRef getQueryId()
static std::string_view getQueryId()
{
if (unlikely(!current_thread))
return {};
Expand Down
2 changes: 1 addition & 1 deletion src/Common/ThreadStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class ThreadStatus : public boost::noncopyable
return thread_state.load(std::memory_order_relaxed);
}

StringRef getQueryId() const
std::string_view getQueryId() const
{
return query_id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/TraceSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void TraceSender::send(TraceType trace_type, const StackTrace & stack_trace, Int

if (CurrentThread::isInitialized())
{
query_id = CurrentThread::getQueryId();
query_id = StringRef(CurrentThread::getQueryId());
query_id.size = std::min(query_id.size, QUERY_ID_MAX_LEN);

thread_id = CurrentThread::get().thread_id;
Expand Down
2 changes: 1 addition & 1 deletion src/Dictionaries/IPAddressDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void IPAddressDictionary::loadData()
setAttributeValue(attribute, attribute_column[row]);
}

const auto [addr, prefix] = parseIPFromString(std::string_view(key_column_ptr->getDataAt(row)));
const auto [addr, prefix] = parseIPFromString(key_column_ptr->getDataAt(row).toView());
has_ipv6 = has_ipv6 || (addr.family() == Poco::Net::IPAddress::IPv6);

size_t row_number = ip_records.size();
Expand Down
1 change: 1 addition & 0 deletions src/Functions/s2CapContains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <Columns/ColumnTuple.h>
#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/DataTypeTuple.h>
#include <DataTypes/DataTypeFactory.h>
#include <Functions/FunctionFactory.h>
#include <Common/typeid_cast.h>
#include <Common/NaNUtils.h>
Expand Down
1 change: 1 addition & 0 deletions src/Functions/s2CellsIntersect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <Columns/ColumnTuple.h>
#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/DataTypeTuple.h>
#include <DataTypes/DataTypeFactory.h>
#include <Functions/FunctionFactory.h>
#include <Common/typeid_cast.h>
#include <base/range.h>
Expand Down
8 changes: 4 additions & 4 deletions src/Interpreters/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,30 +1262,30 @@ void Context::setSettings(const Settings & settings_)
}


void Context::setSetting(StringRef name, const String & value)
void Context::setSetting(std::string_view name, const String & value)
{
auto lock = getLock();
if (name == "profile")
{
setCurrentProfile(value);
return;
}
settings.set(std::string_view{name}, value);
settings.set(name, value);

if (name == "readonly" || name == "allow_ddl" || name == "allow_introspection_functions")
calculateAccessRights();
}


void Context::setSetting(StringRef name, const Field & value)
void Context::setSetting(std::string_view name, const Field & value)
{
auto lock = getLock();
if (name == "profile")
{
setCurrentProfile(value.safeGet<String>());
return;
}
settings.set(std::string_view{name}, value);
settings.set(name, value);

if (name == "readonly" || name == "allow_ddl" || name == "allow_introspection_functions")
calculateAccessRights();
Expand Down
4 changes: 2 additions & 2 deletions src/Interpreters/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ class Context: public std::enable_shared_from_this<Context>
void setSettings(const Settings & settings_);

/// Set settings by name.
void setSetting(StringRef name, const String & value);
void setSetting(StringRef name, const Field & value);
void setSetting(std::string_view name, const String & value);
void setSetting(std::string_view name, const Field & value);
void applySettingChange(const SettingChange & change);
void applySettingsChanges(const SettingsChanges & changes);

Expand Down
4 changes: 2 additions & 2 deletions src/Interpreters/PartLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ bool PartLog::addNewParts(
{
PartLogElement elem;

if (query_id.data && query_id.size)
elem.query_id.insert(0, query_id.data, query_id.size);
if (!query_id.empty())
elem.query_id.insert(0, query_id.data(), query_id.size());

elem.event_type = PartLogElement::NEW_PART; //-V1048

Expand Down
4 changes: 4 additions & 0 deletions src/Interpreters/Streaming/TableFunctionDescription_fwd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

#include <memory>
#include <vector>


namespace DB
{
namespace Streaming
Expand Down
4 changes: 4 additions & 0 deletions src/Interpreters/Streaming/TimestampFunctionDescription_fwd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

#include <memory>
#include <vector>


namespace DB
{
namespace Streaming
Expand Down
1 change: 1 addition & 0 deletions src/Interpreters/Streaming/WindowCommon.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <Core/ColumnWithTypeAndName.h>
#include <Columns/ColumnsDateTime.h>
#include <Interpreters/Streaming/SessionInfo.h>
#include <Interpreters/Streaming/TableFunctionDescription_fwd.h>
Expand Down
2 changes: 1 addition & 1 deletion src/Interpreters/TransactionsInfoLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void TransactionsInfoLogElement::fillCommonFields(const TransactionInfoContext *
event_time = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
thread_id = getThreadId();

query_id = CurrentThread::getQueryId().toString();
query_id = std::string(CurrentThread::getQueryId());

if (!context)
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Loggers/ExtendedLogChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ ExtendedLogMessage ExtendedLogMessage::getFrom(const Poco::Message & base)
if (current_thread)
{
auto query_id_ref = CurrentThread::getQueryId();
if (query_id_ref.size)
msg_ext.query_id.assign(query_id_ref.data, query_id_ref.size);
if (!query_id_ref.empty())
msg_ext.query_id.assign(query_id_ref.data(), query_id_ref.size());
}

msg_ext.thread_id = getThreadId();
Expand Down
1 change: 0 additions & 1 deletion src/Parsers/ASTPartition.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <Parsers/IAST.h>
#include <base/StringRef.h>


namespace DB
Expand Down
12 changes: 6 additions & 6 deletions src/Processors/Formats/Impl/AvroRowOutputFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ AvroSerializer::SchemaWithSerializeFn AvroSerializer::createSchemaWithSerializeF
if (traits->isStringAsString(column_name))
return {avro::StringSchema(), [](const IColumn & column, size_t row_num, avro::Encoder & encoder)
{
StringRef s = assert_cast<const ColumnString &>(column).getDataAt(row_num);
encoder.encodeString(s.toString());
const std::string_view & s = assert_cast<const ColumnString &>(column).getDataAt(row_num).toView();
encoder.encodeString(std::string(s));
}
};
else
return {avro::BytesSchema(), [](const IColumn & column, size_t row_num, avro::Encoder & encoder)
{
StringRef s = assert_cast<const ColumnString &>(column).getDataAt(row_num);
encoder.encodeBytes(reinterpret_cast<const uint8_t *>(s.data), s.size);
const std::string_view & s = assert_cast<const ColumnString &>(column).getDataAt(row_num).toView();
encoder.encodeBytes(reinterpret_cast<const uint8_t *>(s.data()), s.size());
}
};
case TypeIndex::FixedString:
Expand All @@ -206,8 +206,8 @@ AvroSerializer::SchemaWithSerializeFn AvroSerializer::createSchemaWithSerializeF
auto schema = avro::FixedSchema(static_cast<int>(size), "fixed_" + toString(type_name_increment));
return {schema, [](const IColumn & column, size_t row_num, avro::Encoder & encoder)
{
StringRef s = assert_cast<const ColumnFixedString &>(column).getDataAt(row_num);
encoder.encodeFixed(reinterpret_cast<const uint8_t *>(s.data), s.size);
const std::string_view & s = assert_cast<const ColumnFixedString &>(column).getDataAt(row_num).toView();
encoder.encodeFixed(reinterpret_cast<const uint8_t *>(s.data()), s.size());
}};
}
case TypeIndex::Enum8:
Expand Down
4 changes: 2 additions & 2 deletions src/Processors/Formats/Impl/CHColumnToArrowColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ namespace DB
}
else
{
StringRef string_ref = internal_column.getDataAt(string_i);
status = builder.Append(string_ref.data, static_cast<int>(string_ref.size));
std::string_view string_ref = internal_column.getDataAt(string_i).toView();
status = builder.Append(string_ref.data(), static_cast<int>(string_ref.size()));
}
checkStatus(status, write_column->getName(), format_name);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Processors/Formats/Impl/MsgPackRowOutputFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ void MsgPackRowOutputFormat::serializeField(const IColumn & column, DataTypePtr
}
case TypeIndex::String:
{
StringRef string = assert_cast<const ColumnString &>(column).getDataAt(row_num);
const std::string_view & string = assert_cast<const ColumnString &>(column).getDataAt(row_num).toView();
packer.pack_bin(static_cast<unsigned>(string.size()));
packer.pack_bin_body(string.data(), static_cast<unsigned>(string.size()));
return;
}
case TypeIndex::FixedString:
{
StringRef string = assert_cast<const ColumnFixedString &>(column).getDataAt(row_num);
const std::string_view & string = assert_cast<const ColumnFixedString &>(column).getDataAt(row_num).toView();
packer.pack_bin(static_cast<unsigned>(string.size()));
packer.pack_bin_body(string.data(), static_cast<unsigned>(string.size()));
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Processors/Formats/Impl/RawBLOBRowOutputFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ RawBLOBRowOutputFormat::RawBLOBRowOutputFormat(

void RawBLOBRowOutputFormat::writeField(const IColumn & column, const ISerialization &, size_t row_num)
{
StringRef value = column.getDataAt(row_num);
out.write(value.data, value.size);
std::string_view value = column.getDataAt(row_num).toView();
out.write(value.data(), value.size());
}


Expand Down
12 changes: 6 additions & 6 deletions src/Server/GRPCServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,14 +1517,14 @@ namespace
auto & log_entry = *result.add_logs();
log_entry.set_time(column_time.getElement(row));
log_entry.set_time_microseconds(column_time_microseconds.getElement(row));
StringRef query_id = column_query_id.getDataAt(row);
log_entry.set_query_id(query_id.data, query_id.size);
std::string_view query_id = column_query_id.getDataAt(row).toView();
log_entry.set_query_id(query_id.data(), query_id.size());
log_entry.set_thread_id(column_thread_id.getElement(row));
log_entry.set_level(static_cast<::proton::grpc::LogsLevel>(column_level.getElement(row)));
StringRef source = column_source.getDataAt(row);
log_entry.set_source(source.data, source.size);
StringRef text = column_text.getDataAt(row);
log_entry.set_text(text.data, text.size);
std::string_view source = column_source.getDataAt(row).toView();
log_entry.set_source(source.data(), source.size());
std::string_view text = column_text.getDataAt(row).toView();
log_entry.set_text(text.data(), text.size());
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions src/Server/HTTPHandlerRequestFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <Server/HTTP/HTTPServerRequest.h>
#include <Common/Exception.h>
#include <Common/StringUtils/StringUtils.h>
#include <base/StringRef.h>
#include <base/find_symbols.h>

#include <re2/re2.h>
Expand All @@ -23,16 +22,16 @@ namespace ErrorCodes

using CompiledRegexPtr = std::shared_ptr<const re2::RE2>;

static inline bool checkRegexExpression(StringRef match_str, const CompiledRegexPtr & compiled_regex)
static inline bool checkRegexExpression(std::string_view match_str, const CompiledRegexPtr & compiled_regex)
{
int num_captures = compiled_regex->NumberOfCapturingGroups() + 1;

re2::StringPiece matches[num_captures];
re2::StringPiece match_input(match_str.data, match_str.size);
return compiled_regex->Match(match_input, 0, match_str.size, re2::RE2::Anchor::ANCHOR_BOTH, matches, num_captures);
re2::StringPiece match_input(match_str.data(), match_str.size());
return compiled_regex->Match(match_input, 0, match_str.size(), re2::RE2::Anchor::ANCHOR_BOTH, matches, num_captures);
}

static inline bool checkExpression(StringRef match_str, const std::pair<String, CompiledRegexPtr> & expression)
static inline bool checkExpression(std::string_view match_str, const std::pair<String, CompiledRegexPtr> & expression)
{
if (expression.second)
return checkRegexExpression(match_str, expression.second);
Expand Down Expand Up @@ -71,7 +70,7 @@ static inline auto urlFilter(Poco::Util::AbstractConfiguration & config, const s
const auto & uri = request.getURI();
const auto & end = find_first_symbols<'?'>(uri.data(), uri.data() + uri.size());

return checkExpression(StringRef(uri.data(), end - uri.data()), expression);
return checkExpression(std::string_view(uri.data(), end - uri.data()), expression);
};
}

Expand All @@ -93,7 +92,7 @@ static inline auto headersFilter(Poco::Util::AbstractConfiguration & config, con
for (const auto & [header_name, header_expression] : headers_expression)
{
const auto & header_value = request.get(header_name, "");
if (!checkExpression(StringRef(header_value.data(), header_value.size()), header_expression))
if (!checkExpression(std::string_view(header_value.data(), header_value.size()), header_expression))
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Storages/MergeTree/MergeList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ MemoryTrackerThreadSwitcher::MemoryTrackerThreadSwitcher(MergeListEntry & merge_
prev_untracked_memory = current_thread->untracked_memory;
current_thread->untracked_memory = merge_list_entry->untracked_memory;

prev_query_id = current_thread->getQueryId().toString();
prev_query_id = std::string(current_thread->getQueryId());
current_thread->setQueryId(merge_list_entry->query_id);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Storages/System/StorageSystemStackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ namespace
const ucontext_t signal_context = *reinterpret_cast<ucontext_t *>(context);
stack_trace = StackTrace(signal_context);

StringRef query_id = CurrentThread::getQueryId();
query_id_size = std::min(query_id.size, max_query_id_size);
if (query_id.data && query_id.size)
memcpy(query_id_data, query_id.data, query_id_size);
std::string_view query_id = CurrentThread::getQueryId();
query_id_size = std::min(query_id.size(), max_query_id_size);
if (!query_id.empty())
memcpy(query_id_data, query_id.data(), query_id_size);

/// This is unneeded (because we synchronize through pipe) but makes TSan happy.
data_ready_num.store(notification_num, std::memory_order_release);
Expand Down
2 changes: 1 addition & 1 deletion src/TableFunctions/TableFunctionProxyBase.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include <TableFunctions/ITableFunction.h>

#include <Interpreters/ExpressionActions.h>
#include <Interpreters/StorageID.h>
#include <Interpreters/Streaming/TableFunctionDescription_fwd.h>
#include <Interpreters/Streaming/TimestampFunctionDescription_fwd.h>
#include <Interpreters/TreeRewriter.h>
#include <Storages/StorageInMemoryMetadata.h>
#include <Storages/StorageSnapshot.h>
#include <Core/Streaming/DataStreamSemantic.h>
Expand Down

0 comments on commit 41b3c83

Please sign in to comment.