Skip to content

Commit f52284a

Browse files
committed
Fix wrong hash function in Unordered2MapRecord
1 parent 3ce17dd commit f52284a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/src/main/java/io/questdb/cairo/map/Unordered2MapRecord.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.questdb.cairo.sql.RecordCursor;
3131
import io.questdb.std.Decimal128;
3232
import io.questdb.std.Decimal256;
33+
import io.questdb.std.Hash;
3334
import io.questdb.std.IntList;
3435
import io.questdb.std.Long256;
3536
import io.questdb.std.Long256Impl;
@@ -327,7 +328,10 @@ public MapValue getValue() {
327328

328329
@Override
329330
public long keyHashCode() {
330-
return 0; // no-op
331+
// Although this map does not use hash codes, this method is implemented
332+
// for the purpose of map sharding, i.e. to spread keys among multiple Unordered2Maps
333+
// in case when group by functions, such as count_distinct(), have high cardinality.
334+
return Hash.hashShort64(Unsafe.getUnsafe().getShort(startAddress));
331335
}
332336

333337
public void of(long address) {

0 commit comments

Comments
 (0)