Appendix A: Serialization and Compression
1 min readRow-Based vs Columnar
| Format | จุดเด่น | จุดอ่อน |
|---|---|---|
| CSV | ง่าย, universal | error-prone, ไม่มี schema จริง — ควรหลีกเลี่ยงใน pipelines |
| JSON/JSONL | มาตรฐาน API, native support ใน DB สมัยใหม่ | performance ต่ำกว่า columnar มาก |
| Avro | Row-oriented, binary, schema ใน JSON | ไม่เหมาะกับ analytical workloads |
| Parquet | Columnar, schema, nested data, portable | update records ยาก |
| ORC | คล้าย Parquet, นิยมใน Hive | support น้อยกว่า Parquet |
| Apache Arrow | In-memory columnar, ข้ามภาษา | ไม่ใช่ storage format — ใช้ใน processing |
วิธีเลือก Format
| Use Case | แนะนำ |
|---|---|
| Data exchange ผ่าน API | JSON |
| Bulk storage ใน data lake | Parquet |
| RPC / Kafka messages | Avro |
| In-memory processing ข้ามภาษา | Arrow |
| CDC + analytics table | Hudi / Iceberg |
Compression
- Snappy: speed-optimized, นิยมกับ Parquet
- Columnar + compression = maximize disk/network bandwidth
- Compression ratio 10:1 → effective scan speed 200 MB/s → 2 GB/s