mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge branch 'master' into yandex-to-clickhouse-in-configs
This commit is contained in:
commit
8660f6740f
@ -156,7 +156,7 @@ Poco::AutoPtr<Poco::XML::Document> YAMLParser::parse(const String& path)
|
||||
throw Exception(ErrorCodes::CANNOT_OPEN_FILE, "Unable to open YAML configuration file {}", path);
|
||||
}
|
||||
Poco::AutoPtr<Poco::XML::Document> xml = new Document;
|
||||
Poco::AutoPtr<Poco::XML::Element> root_node = xml->createElement("yandex");
|
||||
Poco::AutoPtr<Poco::XML::Element> root_node = xml->createElement("clickhouse");
|
||||
xml->appendChild(root_node);
|
||||
try
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ void FileChecker::save() const
|
||||
std::unique_ptr<WriteBuffer> out = disk->writeFile(tmp_files_info_path);
|
||||
|
||||
/// So complex JSON structure - for compatibility with the old format.
|
||||
writeCString("{\"yandex\":{", *out);
|
||||
writeCString("{\"clickhouse\":{", *out);
|
||||
|
||||
auto settings = FormatSettings();
|
||||
for (auto it = map.begin(); it != map.end(); ++it)
|
||||
@ -153,7 +153,7 @@ void FileChecker::load()
|
||||
}
|
||||
JSON json(out.str());
|
||||
|
||||
JSON files = json["yandex"];
|
||||
JSON files = json.has("clickhouse") ? json["clickhouse"] : json["yandex"];
|
||||
for (const JSON file : files) // NOLINT
|
||||
map[unescapeForFileName(file.getName())] = file.getValue()["size"].toUInt();
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include <Interpreters/BloomFilter.h>
|
||||
#include <city.h>
|
||||
#include <Columns/ColumnArray.h>
|
||||
#include <Columns/ColumnMap.h>
|
||||
#include <Columns/ColumnNullable.h>
|
||||
#include <Columns/ColumnLowCardinality.h>
|
||||
#include <DataTypes/DataTypeArray.h>
|
||||
#include <DataTypes/DataTypeMap.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <DataTypes/DataTypeLowCardinality.h>
|
||||
|
||||
@ -124,6 +126,14 @@ DataTypePtr BloomFilter::getPrimitiveType(const DataTypePtr & data_type)
|
||||
throw Exception("Unexpected type " + data_type->getName() + " of bloom filter index.", ErrorCodes::BAD_ARGUMENTS);
|
||||
}
|
||||
|
||||
if (const auto * map_type = typeid_cast<const DataTypeMap *>(data_type.get()))
|
||||
{
|
||||
if (!typeid_cast<const DataTypeMap *>(map_type->getKeyType().get()))
|
||||
return getPrimitiveType(map_type->getKeyType());
|
||||
else
|
||||
throw Exception("Unexpected key type " + data_type->getName() + " of bloom filter index for map.", ErrorCodes::BAD_ARGUMENTS);
|
||||
}
|
||||
|
||||
if (const auto * nullable_type = typeid_cast<const DataTypeNullable *>(data_type.get()))
|
||||
return getPrimitiveType(nullable_type->getNestedType());
|
||||
|
||||
@ -138,6 +148,9 @@ ColumnPtr BloomFilter::getPrimitiveColumn(const ColumnPtr & column)
|
||||
if (const auto * array_col = typeid_cast<const ColumnArray *>(column.get()))
|
||||
return getPrimitiveColumn(array_col->getDataPtr());
|
||||
|
||||
if (const auto * map_col = typeid_cast<const ColumnMap *>(column.get()))
|
||||
return getPrimitiveColumn(map_col->getNestedData().getColumnPtr(0));
|
||||
|
||||
if (const auto * nullable_col = typeid_cast<const ColumnNullable *>(column.get()))
|
||||
return getPrimitiveColumn(nullable_col->getNestedColumnPtr());
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <Columns/IColumn.h>
|
||||
#include <Columns/ColumnArray.h>
|
||||
#include <Columns/ColumnConst.h>
|
||||
#include <Columns/ColumnMap.h>
|
||||
#include <Columns/ColumnNullable.h>
|
||||
#include <Columns/ColumnsNumber.h>
|
||||
#include <Columns/ColumnString.h>
|
||||
@ -123,6 +124,26 @@ struct BloomFilterHash
|
||||
}
|
||||
}
|
||||
|
||||
if (which.isMap())
|
||||
{
|
||||
const auto * map_col = typeid_cast<const ColumnMap *>(column.get());
|
||||
const auto & keys_data = map_col->getNestedData().getColumn(0);
|
||||
if (checkAndGetColumn<ColumnNullable>(keys_data))
|
||||
throw Exception("Unexpected key type " + data_type->getName() + " of bloom filter index.", ErrorCodes::BAD_ARGUMENTS);
|
||||
|
||||
const auto & offsets = map_col->getNestedColumn().getOffsets();
|
||||
limit = offsets[pos + limit - 1] - offsets[pos - 1]; /// PaddedPODArray allows access on index -1.
|
||||
pos = offsets[pos - 1];
|
||||
|
||||
if (limit == 0)
|
||||
{
|
||||
auto index_column = ColumnUInt64::create(1);
|
||||
ColumnUInt64::Container & index_column_vec = index_column->getData();
|
||||
index_column_vec[0] = 0;
|
||||
return index_column;
|
||||
}
|
||||
}
|
||||
|
||||
const ColumnPtr actual_col = BloomFilter::getPrimitiveColumn(column);
|
||||
const DataTypePtr actual_type = BloomFilter::getPrimitiveType(data_type);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <Common/HashTable/ClearableHashMap.h>
|
||||
#include <Common/FieldVisitorsAccurateComparison.h>
|
||||
#include <DataTypes/DataTypeArray.h>
|
||||
#include <DataTypes/DataTypeMap.h>
|
||||
#include <DataTypes/DataTypeTuple.h>
|
||||
#include <Columns/ColumnConst.h>
|
||||
#include <Columns/ColumnTuple.h>
|
||||
@ -188,7 +189,6 @@ bool MergeTreeIndexConditionBloomFilter::mayBeTrueOnGranule(const MergeTreeIndex
|
||||
const auto & filter = filters[query_index_hash.first];
|
||||
const ColumnPtr & hash_column = query_index_hash.second;
|
||||
|
||||
|
||||
match_rows = maybeTrueOnBloomFilter(&*hash_column,
|
||||
filter,
|
||||
hash_functions,
|
||||
@ -509,6 +509,37 @@ bool MergeTreeIndexConditionBloomFilter::traverseASTEquals(
|
||||
|
||||
return match_with_subtype;
|
||||
}
|
||||
|
||||
if (function->name == "arrayElement")
|
||||
{
|
||||
const auto & col_name = assert_cast<ASTIdentifier *>(function->arguments.get()->children[0].get())->name();
|
||||
|
||||
if (header.has(col_name))
|
||||
{
|
||||
size_t position = header.getPositionByName(col_name);
|
||||
const DataTypePtr & index_type = header.getByPosition(position).type;
|
||||
const auto * map_type = typeid_cast<const DataTypeMap *>(index_type.get());
|
||||
if (map_type)
|
||||
{
|
||||
out.function = function_name == "equals" ? RPNElement::FUNCTION_EQUALS : RPNElement::FUNCTION_NOT_EQUALS;
|
||||
|
||||
auto & argument = function->arguments.get()->children[1];
|
||||
|
||||
if (const auto * literal = argument->as<ASTLiteral>())
|
||||
{
|
||||
auto element_key = literal->value;
|
||||
const DataTypePtr actual_type = BloomFilter::getPrimitiveType(index_type);
|
||||
out.predicate.emplace_back(std::make_pair(position, BloomFilterHash::hashWithField(actual_type.get(), element_key)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user