mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 19:42:00 +00:00
dbms: Server: Synced with master. [#METR-17276]
This commit is contained in:
commit
d6c89fc9f8
@ -203,8 +203,6 @@ private:
|
|||||||
if (container_type != details::ContainerType::SMALL)
|
if (container_type != details::ContainerType::SMALL)
|
||||||
throw Poco::Exception("Internal error", ErrorCodes::LOGICAL_ERROR);
|
throw Poco::Exception("Internal error", ErrorCodes::LOGICAL_ERROR);
|
||||||
|
|
||||||
container_type = details::ContainerType::MEDIUM;
|
|
||||||
|
|
||||||
if (current_memory_tracker)
|
if (current_memory_tracker)
|
||||||
current_memory_tracker->alloc(sizeof(medium));
|
current_memory_tracker->alloc(sizeof(medium));
|
||||||
|
|
||||||
@ -214,6 +212,8 @@ private:
|
|||||||
tmp_medium->insert(x);
|
tmp_medium->insert(x);
|
||||||
|
|
||||||
medium = tmp_medium;
|
medium = tmp_medium;
|
||||||
|
|
||||||
|
container_type = details::ContainerType::MEDIUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void toLarge()
|
void toLarge()
|
||||||
@ -221,18 +221,26 @@ private:
|
|||||||
if ((container_type != details::ContainerType::SMALL) && (container_type != details::ContainerType::MEDIUM))
|
if ((container_type != details::ContainerType::SMALL) && (container_type != details::ContainerType::MEDIUM))
|
||||||
throw Poco::Exception("Internal error", ErrorCodes::LOGICAL_ERROR);
|
throw Poco::Exception("Internal error", ErrorCodes::LOGICAL_ERROR);
|
||||||
|
|
||||||
container_type = details::ContainerType::LARGE;
|
|
||||||
|
|
||||||
if (current_memory_tracker)
|
if (current_memory_tracker)
|
||||||
current_memory_tracker->alloc(sizeof(large));
|
current_memory_tracker->alloc(sizeof(large));
|
||||||
|
|
||||||
Large * tmp_large = new Large;
|
Large * tmp_large = new Large;
|
||||||
|
|
||||||
|
if (container_type == details::ContainerType::SMALL)
|
||||||
|
{
|
||||||
|
for (const auto & x : small)
|
||||||
|
tmp_large->insert(x);
|
||||||
|
}
|
||||||
|
else if (container_type == details::ContainerType::MEDIUM)
|
||||||
|
{
|
||||||
for (const auto & x : *medium)
|
for (const auto & x : *medium)
|
||||||
tmp_large->insert(x);
|
tmp_large->insert(x);
|
||||||
|
}
|
||||||
|
|
||||||
large = tmp_large;
|
large = tmp_large;
|
||||||
|
|
||||||
|
if (container_type == details::ContainerType::MEDIUM)
|
||||||
|
{
|
||||||
delete medium;
|
delete medium;
|
||||||
medium = nullptr;
|
medium = nullptr;
|
||||||
|
|
||||||
@ -240,6 +248,9 @@ private:
|
|||||||
current_memory_tracker->free(sizeof(medium));
|
current_memory_tracker->free(sizeof(medium));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container_type = details::ContainerType::LARGE;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Small small;
|
Small small;
|
||||||
Medium * medium = nullptr;
|
Medium * medium = nullptr;
|
||||||
|
@ -132,7 +132,8 @@ public:
|
|||||||
const ColumnConstString * col = typeid_cast<const ColumnConstString *>(&*block.getByPosition(arguments[0]).column);
|
const ColumnConstString * col = typeid_cast<const ColumnConstString *>(&*block.getByPosition(arguments[0]).column);
|
||||||
|
|
||||||
if (!col)
|
if (!col)
|
||||||
throw Exception("Illegal column " + col->getName() + " of first argument of function " + getName() + ". Must be constant string.",
|
throw Exception("Illegal column " + block.getByPosition(arguments[0]).column->getName()
|
||||||
|
+ " of first argument of function " + getName() + ". Must be constant string.",
|
||||||
ErrorCodes::ILLEGAL_COLUMN);
|
ErrorCodes::ILLEGAL_COLUMN);
|
||||||
|
|
||||||
const String & sep_str = col->getData();
|
const String & sep_str = col->getData();
|
||||||
@ -198,7 +199,8 @@ public:
|
|||||||
const ColumnConstString * col = typeid_cast<const ColumnConstString *>(&*block.getByPosition(arguments[0]).column);
|
const ColumnConstString * col = typeid_cast<const ColumnConstString *>(&*block.getByPosition(arguments[0]).column);
|
||||||
|
|
||||||
if (!col)
|
if (!col)
|
||||||
throw Exception("Illegal column " + col->getName() + " of first argument of function " + getName() + ". Must be constant string.",
|
throw Exception("Illegal column " + block.getByPosition(arguments[0]).column->getName()
|
||||||
|
+ " of first argument of function " + getName() + ". Must be constant string.",
|
||||||
ErrorCodes::ILLEGAL_COLUMN);
|
ErrorCodes::ILLEGAL_COLUMN);
|
||||||
|
|
||||||
sep = col->getData();
|
sep = col->getData();
|
||||||
@ -264,7 +266,8 @@ public:
|
|||||||
const ColumnConstString * col = typeid_cast<const ColumnConstString *>(&*block.getByPosition(arguments[1]).column);
|
const ColumnConstString * col = typeid_cast<const ColumnConstString *>(&*block.getByPosition(arguments[1]).column);
|
||||||
|
|
||||||
if (!col)
|
if (!col)
|
||||||
throw Exception("Illegal column " + col->getName() + " of first argument of function " + getName() + ". Must be constant string.",
|
throw Exception("Illegal column " + block.getByPosition(arguments[1]).column->getName()
|
||||||
|
+ " of first argument of function " + getName() + ". Must be constant string.",
|
||||||
ErrorCodes::ILLEGAL_COLUMN);
|
ErrorCodes::ILLEGAL_COLUMN);
|
||||||
|
|
||||||
re = Regexps::get<false, false>(col->getData());
|
re = Regexps::get<false, false>(col->getData());
|
||||||
|
@ -522,6 +522,9 @@ void InterpreterSelectQuery::executeSingleQuery()
|
|||||||
if (has_order_by)
|
if (has_order_by)
|
||||||
executeOrder(streams);
|
executeOrder(streams);
|
||||||
|
|
||||||
|
if (has_order_by && query.limit_length)
|
||||||
|
executeDistinct(streams, false, selected_columns);
|
||||||
|
|
||||||
if (query.limit_length)
|
if (query.limit_length)
|
||||||
executePreLimit(streams);
|
executePreLimit(streams);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
#include <statdaemons/Stopwatch.h>
|
#include <statdaemons/Stopwatch.h>
|
||||||
|
|
||||||
|
#include <farmhash.h>
|
||||||
|
#include <metrohash.h>
|
||||||
|
|
||||||
#define DBMS_HASH_MAP_COUNT_COLLISIONS
|
#define DBMS_HASH_MAP_COUNT_COLLISIONS
|
||||||
#define DBMS_HASH_MAP_DEBUG_RESIZES
|
#define DBMS_HASH_MAP_DEBUG_RESIZES
|
||||||
|
|
||||||
@ -32,8 +35,8 @@ for file in MobilePhoneModel PageCharset Params URLDomain UTMSource Referer URL
|
|||||||
if [[ $TOTAL_ELEMS -gt 25000000 ]]; then break; fi
|
if [[ $TOTAL_ELEMS -gt 25000000 ]]; then break; fi
|
||||||
./hash_map_string_3 $size $method < ${file}.bin 2>&1 |
|
./hash_map_string_3 $size $method < ${file}.bin 2>&1 |
|
||||||
grep HashMap | grep -oE '[0-9\.]+ elem';
|
grep HashMap | grep -oE '[0-9\.]+ elem';
|
||||||
done | awk -W interactive '{ if ($1 > x) { x = $1 }; printf(".") } END { print x }' | tee /tmp/hash_map_string_2_res;
|
done | awk -W interactive '{ if ($1 > x) { x = $1 }; printf(".") } END { print x }' | tee /tmp/hash_map_string_3_res;
|
||||||
CUR_RESULT=$(cat /tmp/hash_map_string_2_res | tr -d '.')
|
CUR_RESULT=$(cat /tmp/hash_map_string_3_res | tr -d '.')
|
||||||
if [[ $CUR_RESULT -gt $BEST_RESULT ]]; then
|
if [[ $CUR_RESULT -gt $BEST_RESULT ]]; then
|
||||||
BEST_METHOD=$method
|
BEST_METHOD=$method
|
||||||
BEST_RESULT=$CUR_RESULT
|
BEST_RESULT=$CUR_RESULT
|
||||||
@ -277,6 +280,32 @@ struct VerySimpleHash
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct FarmHash64
|
||||||
|
{
|
||||||
|
size_t operator() (StringRef x) const
|
||||||
|
{
|
||||||
|
return farmhash::Hash64(x.data, x.size);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <void metrohash64(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * out)>
|
||||||
|
struct MetroHash64
|
||||||
|
{
|
||||||
|
size_t operator() (StringRef x) const
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
std::uint64_t u64;
|
||||||
|
std::uint8_t u8[sizeof(u64)];
|
||||||
|
};
|
||||||
|
|
||||||
|
metrohash64(reinterpret_cast<const std::uint8_t *>(x.data), x.size, 0, u8);
|
||||||
|
|
||||||
|
return u64;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*struct CRC32Hash
|
/*struct CRC32Hash
|
||||||
{
|
{
|
||||||
size_t operator() (StringRef x) const
|
size_t operator() (StringRef x) const
|
||||||
@ -426,6 +455,9 @@ int main(int argc, char ** argv)
|
|||||||
if (!m || m == 5) bench<StringRef_CompareMemcmp, CRC32Hash> (data, "StringRef_CRC32Hash");
|
if (!m || m == 5) bench<StringRef_CompareMemcmp, CRC32Hash> (data, "StringRef_CRC32Hash");
|
||||||
if (!m || m == 6) bench<StringRef_CompareMemcmp, CRC32ILPHash> (data, "StringRef_CRC32ILPHash");
|
if (!m || m == 6) bench<StringRef_CompareMemcmp, CRC32ILPHash> (data, "StringRef_CRC32ILPHash");
|
||||||
if (!m || m == 7) bench<StringRef_CompareMemcmp, VerySimpleHash>(data, "StringRef_VerySimpleHash");
|
if (!m || m == 7) bench<StringRef_CompareMemcmp, VerySimpleHash>(data, "StringRef_VerySimpleHash");
|
||||||
|
if (!m || m == 8) bench<StringRef_CompareMemcmp, FarmHash64>(data, "StringRef_FarmHash64");
|
||||||
|
if (!m || m == 9) bench<StringRef_CompareMemcmp, MetroHash64<metrohash64_1>>(data, "StringRef_MetroHash64_1");
|
||||||
|
if (!m || m == 10) bench<StringRef_CompareMemcmp, MetroHash64<metrohash64_2>>(data, "StringRef_MetroHash64_2");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
@ -0,0 +1,5 @@
|
|||||||
|
DROP TABLE IF EXISTS numbers_memory;
|
||||||
|
CREATE TABLE numbers_memory AS system.numbers ENGINE = Memory;
|
||||||
|
INSERT INTO numbers_memory SELECT number FROM system.numbers LIMIT 100;
|
||||||
|
SELECT DISTINCT number FROM remote('127.0.0.{2,3}', default.numbers_memory) ORDER BY number LIMIT 10;
|
||||||
|
DROP TABLE numbers_memory;
|
Loading…
Reference in New Issue
Block a user