Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit f023dd0

Browse files
committed
Fix Murmur3 hash
1 parent 3c7137a commit f023dd0

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

src/codegen/hash.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ llvm::Value *Hash::ComputeCRC32Hash(CodeGen &codegen,
169169
// Now hash the strings
170170
for (auto &varlen : varlens) {
171171
llvm::Value *len = codegen->CreateZExt(varlen.len, codegen.Int64Type());
172-
crc = codegen.Call(RuntimeFunctionsProxy::HashCrc64,
173-
{varlen.val, len, crc});
172+
crc =
173+
codegen.Call(RuntimeFunctionsProxy::HashCrc64, {varlen.val, len, crc});
174174
}
175175

176176
///
@@ -181,7 +181,7 @@ llvm::Value *Hash::ComputeCRC32Hash(CodeGen &codegen,
181181
// single value
182182
llvm::Value *Hash::ComputeMurmur3Hash(
183183
CodeGen &codegen, const std::vector<llvm::Value *> &numerics,
184-
const std::vector<Hash::Varlen> &varlen_buffers) {
184+
const std::vector<Hash::Varlen> &varlens) {
185185
// The magic constants used in Murmur3's final 64-bit avalanche mix
186186
static constexpr uint64_t kMurmur3C1 = 0xff51afd7ed558ccdLLU;
187187
static constexpr uint64_t kMurmur3C2 = 0xc4ceb9fe1a85ec53LLU;
@@ -223,8 +223,16 @@ llvm::Value *Hash::ComputeMurmur3Hash(
223223
}
224224
}
225225

226-
if (!varlen_buffers.empty()) {
227-
throw Exception{"Cannot perform a vectorized Murmur3 hash on strings"};
226+
if (hash == nullptr) {
227+
// No numerics in the hash
228+
hash = codegen.Const64(0);
229+
}
230+
231+
// Now hash the strings
232+
for (auto &varlen : varlens) {
233+
llvm::Value *len = codegen->CreateZExt(varlen.len, codegen.Int64Type());
234+
std::vector<llvm::Value *> args = {varlen.val, len, hash};
235+
hash = codegen.Call(RuntimeFunctionsProxy::HashMurmur3, args);
228236
}
229237

230238
return hash;

src/codegen/operator/table_scan_translator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void TableScanTranslator::ScanConsumer::SetupRowBatch(
221221
for (oid_t col_idx = 0; col_idx < output_col_ids.size(); col_idx++) {
222222
auto *attribute = ais[output_col_ids[col_idx]];
223223
LOG_TRACE("Adding attribute '%s.%s' (%p) into row batch",
224-
scan_plan.GetTable()->GetName().c_str(), attribute->name.c_str(),
224+
plan_.GetTable()->GetName().c_str(), attribute->name.c_str(),
225225
attribute);
226226
batch.AddAttribute(attribute, &access[col_idx]);
227227
}

src/codegen/proxy/runtime_functions_proxy.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ DEFINE_TYPE(ColumnLayoutInfo, "peloton::ColumnLayoutInfo", col_start_ptr,
2626
DEFINE_TYPE(AbstractExpression, "peloton::expression::AbstractExpression",
2727
opaque);
2828

29+
DEFINE_METHOD(peloton::codegen, RuntimeFunctions, HashMurmur3);
2930
DEFINE_METHOD(peloton::codegen, RuntimeFunctions, HashCrc64);
3031
DEFINE_METHOD(peloton::codegen, RuntimeFunctions, GetTileGroup);
3132
DEFINE_METHOD(peloton::codegen, RuntimeFunctions, GetTileGroupLayout);

src/include/codegen/hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Hash {
5454

5555
static llvm::Value *ComputeMurmur3Hash(
5656
CodeGen &codegen, const std::vector<llvm::Value *> &numerics,
57-
const std::vector<Hash::Varlen> &varlen_buffers);
57+
const std::vector<Hash::Varlen> &varlens);
5858
};
5959

6060
} // namespace codegen

src/include/codegen/proxy/runtime_functions_proxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ PROXY(AbstractExpression) {
3434
};
3535

3636
PROXY(RuntimeFunctions) {
37+
DECLARE_METHOD(HashMurmur3);
3738
DECLARE_METHOD(HashCrc64);
3839
DECLARE_METHOD(GetTileGroup);
3940
DECLARE_METHOD(GetTileGroupLayout);

0 commit comments

Comments
 (0)