mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 05:22:17 +00:00
73 lines
3.5 KiB
C++
73 lines
3.5 KiB
C++
#include <Interpreters/BlobStorageLog.h>
|
|
#include <base/getFQDNOrHostName.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
#include <DataTypes/DataTypeString.h>
|
|
#include <DataTypes/DataTypeEnum.h>
|
|
#include <DataTypes/DataTypeDateTime.h>
|
|
#include <DataTypes/DataTypeDateTime64.h>
|
|
#include <DataTypes/DataTypeLowCardinality.h>
|
|
#include <DataTypes/DataTypeDate.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
ColumnsDescription BlobStorageLogElement::getColumnsDescription()
|
|
{
|
|
auto event_enum_type = std::make_shared<DataTypeEnum8>(
|
|
DataTypeEnum8::Values{
|
|
{"Upload", static_cast<Int8>(EventType::Upload)},
|
|
{"Delete", static_cast<Int8>(EventType::Delete)},
|
|
{"MultiPartUploadCreate", static_cast<Int8>(EventType::MultiPartUploadCreate)},
|
|
{"MultiPartUploadWrite", static_cast<Int8>(EventType::MultiPartUploadWrite)},
|
|
{"MultiPartUploadComplete", static_cast<Int8>(EventType::MultiPartUploadComplete)},
|
|
{"MultiPartUploadAbort", static_cast<Int8>(EventType::MultiPartUploadAbort)},
|
|
});
|
|
|
|
return ColumnsDescription
|
|
{
|
|
{"hostname", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "Hostname of the server executing the query."},
|
|
{"event_date", std::make_shared<DataTypeDate>(), "Date of the event."},
|
|
{"event_time", std::make_shared<DataTypeDateTime>(), "Time of the event."},
|
|
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6), "Time of the event with microseconds precision."},
|
|
|
|
{"event_type", event_enum_type, "Type of the event. Possible values: 'Upload', 'Delete', 'MultiPartUploadCreate', 'MultiPartUploadWrite', 'MultiPartUploadComplete', 'MultiPartUploadAbort'"},
|
|
|
|
{"query_id", std::make_shared<DataTypeString>(), "Identifier of the query associated with the event, if any."},
|
|
{"thread_id", std::make_shared<DataTypeUInt64>(), "Identifier of the thread performing the operation."},
|
|
{"thread_name", std::make_shared<DataTypeString>(), "Name of the thread performing the operation."},
|
|
|
|
{"disk_name", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "Name of the associated disk."},
|
|
{"bucket", std::make_shared<DataTypeString>(), "Name of the bucket."},
|
|
{"remote_path", std::make_shared<DataTypeString>(), "Path to the remote resource."},
|
|
{"local_path", std::make_shared<DataTypeString>(), "Path to the metadata file on the local system, which references the remote resource."},
|
|
{"data_size", std::make_shared<DataTypeUInt64>(), "Size of the data involved in the upload event."},
|
|
|
|
{"error", std::make_shared<DataTypeString>(), "Error message associated with the event, if any."},
|
|
};
|
|
}
|
|
|
|
void BlobStorageLogElement::appendToBlock(MutableColumns & columns) const
|
|
{
|
|
size_t i = 0;
|
|
|
|
auto event_time_seconds = timeInSeconds(event_time);
|
|
columns[i++]->insert(getFQDNOrHostName());
|
|
columns[i++]->insert(DateLUT::instance().toDayNum(event_time_seconds).toUnderType());
|
|
columns[i++]->insert(event_time_seconds);
|
|
columns[i++]->insert(Decimal64(timeInMicroseconds(event_time)));
|
|
columns[i++]->insert(static_cast<Int8>(event_type));
|
|
columns[i++]->insert(query_id);
|
|
columns[i++]->insert(thread_id);
|
|
columns[i++]->insert(thread_name);
|
|
columns[i++]->insert(disk_name);
|
|
columns[i++]->insert(bucket);
|
|
columns[i++]->insert(remote_path);
|
|
columns[i++]->insert(local_path);
|
|
columns[i++]->insert(data_size);
|
|
columns[i++]->insert(error_message);
|
|
}
|
|
|
|
}
|