Urgent.News

What's breaking now, across thousands of outlets.

Tech

Bloom Filters Explained: How a Tiny Bit Array Can Handle Millions of Lookups

Imagine you are running a website with 100 million registered users. Every time someone enters a username, your application needs to answer: «“Has this username already been used?”» The obvious solution is to query the database. But what if you receive 100,000 username checks per second, and most of those usernames don't even exist? A Bloom filter can act as a tiny, extremely fast pre-check…

A Bloom filter is an efficient data structure that tests if an item belongs to a set with probabilistic outcomes. It returns two possible answers: definitely not present or possibly present. The filter does not store the actual items but rather a bit array manipulated by hash functions. Hash functions convert input items into positions within the bit array.

When an item is added, the corresponding bits are set to 1. Searching involves hashing the input, checking the bit array positions, and determining if all positions are set to 1. If so, the item possibly exists in the set. However, a zero in any position instantly proves the item's absence. False positives can occur when different items cause the same set of bit positions to be set.

Despite this, Bloom filters are valuable in real-world applications like username registration, where they help reduce unnecessary database queries for non-existent usernames.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Light Pollution Map: A Free Tool to Find Dark Skies Near You

If you've ever tried to plan a stargazing trip, you know the biggest obstacle usually isn't the weather — it's finding a spot dark enough to actually see the stars.

  • Light Pollution Map is free tool for finding dark skies.
  • Overlay light pollution data on regular map to locate darkest areas.
  • Useful for stargazers, astrophotographers, and weekend stargazing trips.

More from Monday 24 August →