提交 6df5d556 编写于 作者: A Alexey Milovidov

Changed namespace [#DEVTOOLS-3381].

上级 a99f25f2
......@@ -55,7 +55,7 @@
* - this version of CityHash is exposed in cityHash64 function in ClickHouse SQL language;
* - and already used by many users for data ordering, sampling and sharding.
*/
namespace CityHash64_v1_0_2
namespace CityHash_v1_0_2
{
typedef uint8_t uint8;
......
......@@ -30,7 +30,7 @@
#include <city.h>
namespace CityHash64_v1_0_2
namespace CityHash_v1_0_2
{
// Hash function for a byte array.
......
......@@ -71,7 +71,7 @@ using namespace std;
#endif
#endif
namespace CityHash64_v1_0_2
namespace CityHash_v1_0_2
{
static uint64 UNALIGNED_LOAD64(const char *p) {
......@@ -363,7 +363,7 @@ uint128 CityHash128(const char *s, size_t len) {
#include <citycrc.h>
#include <nmmintrin.h>
namespace CityHash64_v1_0_2
namespace CityHash_v1_0_2
{
// Requires len >= 240.
......
......@@ -266,7 +266,7 @@ struct OneAdder<T, Data, typename std::enable_if<
typename std::enable_if<std::is_same<T2, String>::value>::type * = nullptr)
{
StringRef value = column.getDataAt(row_num);
data.set.insert(CityHash64_v1_0_2::CityHash64(value.data, value.size));
data.set.insert(CityHash_v1_0_2::CityHash64(value.data, value.size));
}
};
......@@ -290,7 +290,7 @@ struct OneAdder<T, Data, typename std::enable_if<
typename std::enable_if<std::is_same<T2, String>::value>::type * = nullptr)
{
StringRef value = column.getDataAt(row_num);
data.set.insert(CityHash64_v1_0_2::CityHash64(value.data, value.size));
data.set.insert(CityHash_v1_0_2::CityHash64(value.data, value.size));
}
};
......
......@@ -107,7 +107,7 @@ struct AggregateFunctionUniqUpToData<String> : AggregateFunctionUniqUpToData<UIn
{
/// Keep in mind that calculations are approximate.
StringRef value = column.getDataAt(row_num);
insert(CityHash64_v1_0_2::CityHash64(value.data, value.size), threshold);
insert(CityHash_v1_0_2::CityHash64(value.data, value.size), threshold);
}
};
......
......@@ -39,14 +39,14 @@ struct UniqVariadicHash<false, false>
{
StringRef value = (*column)->getDataAt(row_num);
hash = CityHash64_v1_0_2::CityHash64(value.data, value.size);
hash = CityHash_v1_0_2::CityHash64(value.data, value.size);
++column;
}
while (column < columns_end)
{
StringRef value = (*column)->getDataAt(row_num);
hash = CityHash64_v1_0_2::Hash128to64(CityHash64_v1_0_2::uint128(CityHash64_v1_0_2::CityHash64(value.data, value.size), hash));
hash = CityHash_v1_0_2::Hash128to64(CityHash_v1_0_2::uint128(CityHash_v1_0_2::CityHash64(value.data, value.size), hash));
++column;
}
......@@ -68,14 +68,14 @@ struct UniqVariadicHash<false, true>
{
StringRef value = column->get()->getDataAt(row_num);
hash = CityHash64_v1_0_2::CityHash64(value.data, value.size);
hash = CityHash_v1_0_2::CityHash64(value.data, value.size);
++column;
}
while (column < columns_end)
{
StringRef value = column->get()->getDataAt(row_num);
hash = CityHash64_v1_0_2::Hash128to64(CityHash64_v1_0_2::uint128(CityHash64_v1_0_2::CityHash64(value.data, value.size), hash));
hash = CityHash_v1_0_2::Hash128to64(CityHash_v1_0_2::uint128(CityHash_v1_0_2::CityHash64(value.data, value.size), hash));
++column;
}
......
......@@ -42,7 +42,7 @@ struct UInt128Hash
{
size_t operator()(UInt128 x) const
{
return CityHash64_v1_0_2::Hash128to64({x.first, x.second});
return CityHash_v1_0_2::Hash128to64({x.first, x.second});
}
};
......@@ -122,7 +122,7 @@ struct UInt256Hash
size_t operator()(UInt256 x) const
{
/// NOTE suboptimal
return CityHash64_v1_0_2::Hash128to64({CityHash64_v1_0_2::Hash128to64({x.a, x.b}), CityHash64_v1_0_2::Hash128to64({x.c, x.d})});
return CityHash_v1_0_2::Hash128to64({CityHash_v1_0_2::Hash128to64({x.a, x.b}), CityHash_v1_0_2::Hash128to64({x.c, x.d})});
}
};
......
......@@ -48,12 +48,12 @@ int main(int argc, char ** argv)
for (size_t i = 0; i < rows; ++i)
{
*reinterpret_cast<UInt64*>(&hashes[i * 16]) = CityHash64_v1_0_2::CityHash64(strings[i].data(), strings[i].size());
*reinterpret_cast<UInt64*>(&hashes[i * 16]) = CityHash_v1_0_2::CityHash64(strings[i].data(), strings[i].size());
}
watch.stop();
UInt64 check = CityHash64_v1_0_2::CityHash64(&hashes[0], hashes.size());
UInt64 check = CityHash_v1_0_2::CityHash64(&hashes[0], hashes.size());
std::cerr << std::fixed << std::setprecision(2)
<< "CityHash64 (check = " << check << ")"
......@@ -78,7 +78,7 @@ int main(int argc, char ** argv)
watch.stop();
UInt64 check = CityHash64_v1_0_2::CityHash64(&hashes[0], hashes.size());
UInt64 check = CityHash_v1_0_2::CityHash64(&hashes[0], hashes.size());
std::cerr << std::fixed << std::setprecision(2)
<< "SipHash (check = " << check << ")"
......@@ -99,7 +99,7 @@ int main(int argc, char ** argv)
watch.stop();
UInt64 check = CityHash64_v1_0_2::CityHash64(&hashes[0], hashes.size());
UInt64 check = CityHash_v1_0_2::CityHash64(&hashes[0], hashes.size());
std::cerr << std::fixed << std::setprecision(2)
<< "SipHash, stream (check = " << check << ")"
......@@ -121,7 +121,7 @@ int main(int argc, char ** argv)
watch.stop();
UInt64 check = CityHash64_v1_0_2::CityHash64(&hashes[0], hashes.size());
UInt64 check = CityHash_v1_0_2::CityHash64(&hashes[0], hashes.size());
std::cerr << std::fixed << std::setprecision(2)
<< "MD5 (check = " << check << ")"
......
......@@ -165,7 +165,7 @@ struct StringRefHash64
{
size_t operator() (StringRef x) const
{
return CityHash64_v1_0_2::CityHash64(x.data, x.size);
return CityHash_v1_0_2::CityHash64(x.data, x.size);
}
};
......@@ -177,7 +177,7 @@ struct StringRefHash64
inline UInt64 hashLen16(UInt64 u, UInt64 v)
{
return CityHash64_v1_0_2::Hash128to64(CityHash64_v1_0_2::uint128(u, v));
return CityHash_v1_0_2::Hash128to64(CityHash_v1_0_2::uint128(u, v));
}
inline UInt64 shiftMix(UInt64 val)
......
......@@ -638,9 +638,9 @@ struct URLHashImpl
{
/// do not take last slash, '?' or '#' character into account
if (size > 0 && (data[size - 1] == '/' || data[size - 1] == '?' || data[size - 1] == '#'))
return CityHash64_v1_0_2::CityHash64(data, size - 1);
return CityHash_v1_0_2::CityHash64(data, size - 1);
return CityHash64_v1_0_2::CityHash64(data, size);
return CityHash_v1_0_2::CityHash64(data, size);
}
};
......@@ -844,10 +844,10 @@ struct NameIntHash64 { static constexpr auto name = "intHash64"; };
struct ImplCityHash64
{
static constexpr auto name = "cityHash64";
using uint128_t = CityHash64_v1_0_2::uint128;
using uint128_t = CityHash_v1_0_2::uint128;
static auto Hash128to64(const uint128_t & x) { return CityHash64_v1_0_2::Hash128to64(x); }
static auto Hash64(const char * const s, const std::size_t len) { return CityHash64_v1_0_2::CityHash64(s, len); }
static auto Hash128to64(const uint128_t & x) { return CityHash_v1_0_2::Hash128to64(x); }
static auto Hash64(const char * const s, const std::size_t len) { return CityHash_v1_0_2::CityHash64(s, len); }
};
struct ImplFarmHash64
......@@ -862,9 +862,9 @@ struct ImplFarmHash64
struct ImplMetroHash64
{
static constexpr auto name = "metroHash64";
using uint128_t = CityHash64_v1_0_2::uint128;
using uint128_t = CityHash_v1_0_2::uint128;
static auto Hash128to64(const uint128_t & x) { return CityHash64_v1_0_2::Hash128to64(x); }
static auto Hash128to64(const uint128_t & x) { return CityHash_v1_0_2::Hash128to64(x); }
static auto Hash64(const char * const s, const std::size_t len)
{
union {
......
......@@ -42,7 +42,7 @@ size_t CompressedReadBufferBase::readCompressedData(size_t & size_decompressed,
if (compressed_in->eof())
return 0;
CityHash64_v1_0_2::uint128 checksum;
CityHash_v1_0_2::uint128 checksum;
compressed_in->readStrict(reinterpret_cast<char *>(&checksum), sizeof(checksum));
own_compressed_buffer.resize(COMPRESSED_BLOCK_HEADER_SIZE);
......@@ -80,7 +80,7 @@ size_t CompressedReadBufferBase::readCompressedData(size_t & size_decompressed,
compressed_in->readStrict(&compressed_buffer[COMPRESSED_BLOCK_HEADER_SIZE], size_compressed - COMPRESSED_BLOCK_HEADER_SIZE);
}
if (!disable_checksum && checksum != CityHash64_v1_0_2::CityHash128(&compressed_buffer[0], size_compressed))
if (!disable_checksum && checksum != CityHash_v1_0_2::CityHash128(&compressed_buffer[0], size_compressed))
throw Exception("Checksum doesn't match: corrupted data.", ErrorCodes::CHECKSUM_DOESNT_MATCH);
return size_compressed + sizeof(checksum);
......
......@@ -102,7 +102,7 @@ void CompressedWriteBuffer::nextImpl()
throw Exception("Unknown compression method", ErrorCodes::UNKNOWN_COMPRESSION_METHOD);
}
CityHash64_v1_0_2::uint128 checksum = CityHash64_v1_0_2::CityHash128(compressed_buffer_ptr, compressed_size);
CityHash_v1_0_2::uint128 checksum = CityHash_v1_0_2::CityHash128(compressed_buffer_ptr, compressed_size);
out.write(reinterpret_cast<const char *>(&checksum), sizeof(checksum));
out.write(compressed_buffer_ptr, compressed_size);
......
......@@ -15,7 +15,7 @@ template <class Buffer>
class IHashingBuffer : public BufferWithOwnMemory<Buffer>
{
public:
using uint128 = CityHash64_v1_0_2::uint128;
using uint128 = CityHash_v1_0_2::uint128;
IHashingBuffer<Buffer>(size_t block_size_ = DBMS_DEFAULT_HASHING_BLOCK_SIZE)
: BufferWithOwnMemory<Buffer>(block_size_), block_pos(0), block_size(block_size_), state(0, 0)
......@@ -25,14 +25,14 @@ public:
uint128 getHash()
{
if (block_pos)
return CityHash64_v1_0_2::CityHash128WithSeed(&BufferWithOwnMemory<Buffer>::memory[0], block_pos, state);
return CityHash_v1_0_2::CityHash128WithSeed(&BufferWithOwnMemory<Buffer>::memory[0], block_pos, state);
else
return state;
}
void append(DB::BufferBase::Position data)
{
state = CityHash64_v1_0_2::CityHash128WithSeed(data, block_size, state);
state = CityHash_v1_0_2::CityHash128WithSeed(data, block_size, state);
}
/// computation of the hash depends on the partitioning of blocks
......
......@@ -4,19 +4,19 @@
#define FAIL(msg) { std::cout << msg; exit(1); }
CityHash64_v1_0_2::uint128 referenceHash(const char * data, size_t len)
CityHash_v1_0_2::uint128 referenceHash(const char * data, size_t len)
{
const size_t block_size = DBMS_DEFAULT_HASHING_BLOCK_SIZE;
CityHash64_v1_0_2::uint128 state(0, 0);
CityHash_v1_0_2::uint128 state(0, 0);
size_t pos;
for (pos = 0; pos + block_size <= len; pos += block_size)
{
state = CityHash64_v1_0_2::CityHash128WithSeed(data + pos, block_size, state);
state = CityHash_v1_0_2::CityHash128WithSeed(data + pos, block_size, state);
}
if (pos < len)
state = CityHash64_v1_0_2::CityHash128WithSeed(data + pos, len - pos, state);
state = CityHash_v1_0_2::CityHash128WithSeed(data + pos, len - pos, state);
return state;
}
......@@ -12,7 +12,7 @@ void test(size_t data_size)
for (size_t i = 0; i < data_size; ++i)
data[i] = rand() & 255;
CityHash64_v1_0_2::uint128 reference = referenceHash(data, data_size);
CityHash_v1_0_2::uint128 reference = referenceHash(data, data_size);
std::vector<size_t> block_sizes = {56, 128, 513, 2048, 3055, 4097, 4096};
for (size_t read_buffer_block_size : block_sizes)
......
......@@ -11,7 +11,7 @@ void test(size_t data_size)
for (size_t i = 0; i < data_size; ++i)
data[i] = rand() & 255;
CityHash64_v1_0_2::uint128 reference = referenceHash(data, data_size);
CityHash_v1_0_2::uint128 reference = referenceHash(data, data_size);
DB::WriteBufferFromFile sink("/dev/null", 1 << 16);
......
......@@ -76,7 +76,7 @@ struct DefaultHash<CompactStringRef>
{
size_t operator() (CompactStringRef x) const
{
return CityHash64_v1_0_2::CityHash64(x.data(), x.size);
return CityHash_v1_0_2::CityHash64(x.data(), x.size);
}
};
......
......@@ -65,7 +65,7 @@ struct DefaultHash<STRUCT> \
{ \
size_t operator() (STRUCT x) const \
{ \
return CityHash64_v1_0_2::CityHash64(x.data, x.size); \
return CityHash_v1_0_2::CityHash64(x.data, x.size); \
} \
};
......
......@@ -68,7 +68,7 @@ struct DefaultHash<STRUCT> \
{ \
size_t operator() (STRUCT x) const \
{ \
return CityHash64_v1_0_2::CityHash64(x.data, x.size); \
return CityHash_v1_0_2::CityHash64(x.data, x.size); \
} \
};
......
......@@ -16,7 +16,7 @@ namespace DB
/// Checksum of one file.
struct MergeTreeDataPartChecksum
{
using uint128 = CityHash64_v1_0_2::uint128;
using uint128 = CityHash_v1_0_2::uint128;
size_t file_size {};
uint128 file_hash {};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册