Reference library

Big data & Spark

PySpark jobs, partitioning, batch processing, and large-dataset transform patterns.

3 matches
Big data & Spark medium

Bloom Filter Join Mock in Python

A mock hash join that uses a Bloom filter to pre-filter one table before performing an exact match, reducing the number of comparisons in large dataset joins.

bloom filter join hashing
Python
import hashlib
import random
import string


class BloomFilter:
    def __init__(self, size: int = 200, num_hashes: int = 3):
        self.bits = [False] * size
        self.size = size
        self.num_hashes = num_hashes

    def _hashes(self, item: str):
        result = []
        for seed in range(self.num_hashes…
12 0 Open
Big data & Spark medium

Mock Predicate Pushdown in Python for Big Data Queries

Simulate predicate pushdown by applying filters at the storage layer before materializing rows, showing how big data engines optimize queries.

big-data query-optimization predicate-pushdown
Python
class Query:
    def __init__(self, table, rows):
        self.table = table
        self.rows = rows

    def filter(self, predicate):
        return Query(
            self.table,
            [row for row in self.rows if all(predicate(row) for predicate in predicate)]
        )

    def filter_pushdown(self, predica…
15 0 Open
Big data & Spark medium

Mock RDD in Python: Simulate Spark RDD Lazy Transformations

Simulate Apache Spark RDD behavior in Python with lazy maps, filters, partitions, and a collect action.

spark rdd big-data
Python
import random

def mock_rdd(data, num_slices=2):
    """
    A simple simulation of Spark RDD behavior with lazy evaluation,
    transformations, and an action.
    """
    class SimpleRDD:
        def __init__(self, data, num_slices=2):
            self.data = data
            self.num_slices = num_slices
           …
13 0 Open

Browse by section

Each section groups closely related Python snippets.

Big data & Spark — Python code examples

What you will find here

This page collects big data & spark snippets — short, copy-ready Python you can paste into our free online IDE and run without installing anything. Each sample includes a plain-English explanation and the full source code.

Samples vs tutorials and challenges

Samples are quick reference — one concept per page. For step-by-step teaching, use our Python tutorials. To test yourself, try quizzes or coding challenges. Clean up style with the Python formatter.