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.
• 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.
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!
Text Formats: CSV • XML • JSON • NDJSON
Human-readable, universally compatible, but computationally heavy. Explore how the 4 primary text formats behave.
Comma-Separated Values
Every row is a line, columns separated by commas. Universal support in Excel and Python.
Extensible Markup Language
Hierarchical nested tags (<customer><name>Alice</name></customer>).
Standard JSON Object
The standard of REST APIs. Supports nested arrays, booleans, and nulls.
Newline Delimited JSON
Each single line is a valid independent JSON record separated by \n.
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.
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.
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 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. |
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!