Module 02 • Storage Layouts & File Formats

02. File Formats & Compression Codecs

The way bits and bytes are arranged on a cloud disk determines whether your analytical query takes 2 minutes or 200 milliseconds. Learn how Big Data shifted from human-readable text files to high-performance columnar formats like Apache Parquet and ORC.

Instructor Insight (© Venkata Bhattaram): "Beginners often treat files like simple containers. But in Data Engineering, file formats are active compression and execution engines! When you query a 100-gigabyte CSV file for the average salary, the computer has to read every single employee address, phone number, and birthdate off disk. When you use Parquet, the engine literally skips 95% of the file and reads only the numbers. That single format choice saves enterprise companies millions of dollars in cloud bills."
The Phonebook Analogy: Row-Store vs. Column-Store
Imagine searching a 1,000-page city phonebook containing [Name, Address, Phone Number]:

• Row-Oriented Storage (CSV / JSON): Data is stored line-by-line: [Alice, 123 Elm St, 555-01] • [Bob, 456 Oak St, 555-02]. If you only want to count how many people live in area code 555, your eyes are forced to read all 1,000 addresses! Great for transactional writes (OLTP).

• Columnar Storage (Parquet / ORC): All Names are grouped together on Page 1, all Addresses on Page 2, and all Phone Numbers on Page 3! To calculate area codes, you only flip to Page 3. You never touch Pages 1 and 2! That is the secret to Big Data analytical speed.
Interactive Performance Lab

Row vs. Columnar: 10 Million Row Query Race

Simulate running SELECT avg(salary) FROM employees across 10,000,000 records. Watch how disk I/O and query latency differ between CSV and Parquet!

Row-Store: CSV Must scan all columns
Disk Data Scanned: 0 MB / 4,200 MB
Status: Ready to execute...
Columnar: Apache Parquet Projection pushdown (Salary only)
Disk Data Scanned: 0 MB / 42 MB
Status: Ready to execute...
The Classic Text Files

Text Formats: CSV • XML • JSON • NDJSON

Human-readable, universally compatible, but computationally heavy. Explore how the 4 primary text formats behave.

CSV Flat Grid

Comma-Separated Values

Every row is a line, columns separated by commas. Universal support in Excel and Python.

Downside: No schema types (numbers look like text), escapes comma commas.
XML Markup Tree

Extensible Markup Language

Hierarchical nested tags (<customer><name>Alice</name></customer>).

Downside: Extremely verbose. Up to 70% of file size is closing tags!
JSON Key-Value

Standard JSON Object

The standard of REST APIs. Supports nested arrays, booleans, and nulls.

Downside: Must load entire multi-gigabyte file into memory to parse brackets.
NDJSON Streaming Lines

Newline Delimited JSON

Each single line is a valid independent JSON record separated by \n.

Superpower: Splittable! Big Data engines can process line chunks in parallel.
Enterprise Heavyweights

Big Data Columnar Formats: Apache Parquet & Apache ORC

The dual titans of analytical data engineering. Designed from scratch for petabyte-scale distributed query engines like Spark, Trino, and Hive.

Apache Parquet Spark • Delta • Iceberg Standard

The Universal Cloud Standard

Invented collaboratively by Twitter and Cloudera. Uses Dremel record shredding to preserve nested data structures inside columnar chunks.

  • Metadata Footer: Stores min/max values for every column chunk, allowing queries to skip entire blocks without reading them (Predicate Pushdown).
  • Dictionary Encoding: Replaces repetitive strings (e.g. state codes "CA", "NY") with 1-byte integer IDs.
  • Native Support: First-class format in Snowflake, Databricks, BigQuery, AWS Athena, and DuckDB.
Apache ORC Apache Hive • Presto Native

Optimized Row Columnar

Developed by Hortonworks for the Apache Hive ecosystem. Organizes data into 250MB "stripes" with lightweight indexing streams.

  • Bloom Filters: Built-in probabilistic filters that instantly confirm if a specific ID does NOT exist in a stripe.
  • High Compression Ratio: Extremely aggressive compression on repetitive enterprise transactional tables.
  • Primary Ecosystem: Widely used in on-premises Hadoop clusters and legacy Presto setups.
Compression Trade-Offs

Compression Codecs: Gzip / Zip vs. Snappy & ZSTD

In Big Data, compression is not just about saving hard drive space—it's about CPU decompression speed and whether parallel worker nodes can split the file!

Compression Codec Compression Ratio Decompression Speed Splittability Best Production Use Case
Gzip / Zip (.gz, .zip) Very High (~80%) Slow (CPU Heavy) Non-Splittable (Default) Cold long-term archival where storage cost is the #1 priority.
Snappy (.snappy) Moderate (~50%) Ultra Fast (~500 MB/s) Fully Splittable in Parquet The default standard for Parquet & Kafka streaming. Optimizes CPU time over raw disk bytes.
ZSTD (Zstandard) High (~75%) Fast & Tunable Splittable with framing Modern hybrid standard replacing Gzip in cloud lakehouses.
Hands-On Code Lab

Interactive File Format Inspector & Converter

Toggle between different formats to see the exact payload bytes and disk footprint comparison for the same customer purchase record!

48 Bytes
Storage Size
Moderate
Parsing CPU Cost
Weak (Untyped)
Schema Enforcement