Abstract: Hashmaps are fundamental to data processing, yet their design has traditionally prioritized performance over social equity. This paper introduces FairHash, a novel hashmap framework that guarantees group fairness by ensuring hash collisions are distributed uniformly across demographic groups. By framing fair hashing as a variant of the "necklace splitting" problem, we prove that perfectly fair partitions always exist. Our evaluation across four large-scale datasets shows that FairHash achieves zero unfairness with logarithmic query times and minimal memory overhead, bridging the gap between efficient data structures and algorithmic fairness.
Introduction
Hashmaps are a foundational building block in computer science, utilized in everything from database joins to security filters. Traditionally, hashmap research focuses on a singular goal: minimizing collisions to maximize lookup speed. Recently, "learned" or data-dependent hashmaps have emerged, leveraging underlying data distributions to create perfectly balanced buckets.
However, these techniques ignore group fairness. In sensitive applications—such as airline security "no-fly" lists—hashmap collisions result in false positives. If these collisions occur more frequently for one demographic group (e.g., based on gender or race), that group faces a disproportionate burden of "extra screening" or invalid results. FairHash addresses this "fairness gap" in data structure design, ensuring that the burden of collisions is shared equally across all groups.
The FairHash Framework
The authors introduce FairHash, a framework comprising three distinct algorithmic families that balance the trade-offs between perfect fairness, memory usage, and computational complexity:
- Ranking-based Algorithms: These identify a "ranking function" (a linear projection of the data) that minimizes unfairness. They are highly memory-efficient, requiring no more storage than a standard data-dependent hashmap.
- Cut-based Algorithms: These guarantee zero unfairness regardless of the data distribution.
- Sweep&Cut: A greedy approach that sweeps through the data to create bins.
- Necklace Splitting: This method makes a clever theoretical connection to the combinatorial "necklace splitting problem." By treating demographic groups as different types of beads on a necklace, the authors use topological results to find the minimum number of "cuts" needed to ensure every hash bucket receives an exactly proportional share of each group.
- Discrepancy-based Algorithms: These utilize dynamic programming or local search heuristics to allow for slight "discrepancies" in bucket sizes, further optimizing for memory or specific fairness constraints.
Theoretical Foundations
A key contribution of this work is the formalization of Pairwise Fairness. This requirement demands that the ratio of different groups is equal across all buckets, ensuring that the probability of two members of the same group colliding is identical to the global collision rate. By reducing fair hashing to the necklace splitting problem, the authors prove that a fair hashmap always exists, regardless of how skewed or "clumped" the input data may be. Furthermore, the algorithms are designed for Pareto-Optimality, ensuring that fairness does not degrade the hashmap's performance for any individual group compared to the global average.
Experimental Evaluation
The researchers evaluated FairHash using four large-scale datasets commonly used in fairness literature:
- Adult: Census data (protected attribute: sex).
- Compas: Criminal defendant records (protected attributes: sex, race).
- Diabetes: Hospitalization records (protected attribute: sex).
- ChicagoPop: A 1-million-entry semi-synthetic dataset simulating the population of Chicago (protected attribute: race).
Results and Discussion
Achieving Zero Unfairness
The experiments demonstrate that FairHash effectively eliminates group bias. While standard CDF-based hashmaps often result in buckets dominated by a single demographic, FairHash maintains consistent group ratios.
Performance and Complexity
Despite the added fairness constraints, FairHash maintains high efficiency. Query times remain logarithmic ($O(\log m)$), matching the performance of state-of-the-art data-dependent hashmaps. While the "Necklace Splitting" approach requires more boundaries (cuts) than a standard hashmap, it typically only requires about twice as many, representing a minimal memory trade-off for guaranteed fairness.
Conclusion and Future Work
FairHash proves that algorithmic bias can be addressed at the data structure level without sacrificing performance. However, challenges remain. The complexity of cut-based methods increases as the number of demographic groups grows, and current ranking functions are limited to linear projections. Future research will explore non-linear functions for high-dimensional data and extend the framework to dynamic settings where data is frequently inserted or deleted.
Summary updated