Skip to main content

Apache ORC

At a glance
  • Problem solved: speed up Hive and reduce the size of data stored in Hadoop, with a columnar format that knows the types.
  • Era: created in January 2013, shipped in Hive 0.11. Standalone Apache project since 2015.
  • Category: columnar file format.

Historical context​

Before ORC, Hive's standard columnar format is RCFile. Its limitation: it treats each column as a binary blob, with no type semantics. It can therefore neither pick a suitable encoding nor index the values. ORC was created in January 2013 as part of the initiative to massively speed up Hive, the same year as Parquet.

Key idea​

A self-describing, type-aware format: the writer knows the type of each column, picks the most suitable encoding and builds lightweight indexes while writing. The reader only reads, decompresses and processes the columns and row blocks the query needs.

How it works​

  • Stripes of about 64 MB, independent of each other: the natural unit of distributed work. Within each stripe, columns are stored separately.
  • File tail (metadata, footer, postscript) written at the end, because HDFS does not allow changing a file once written. The reader starts there.
  • Type-specific encodings: dictionary, bit packing, delta, run length, then optional generic compression (zlib, Snappy).
  • Indexes and statistics: per-column min/max for every group of 10,000 rows, per stripe and for the whole file. Predicate pushdown skips useless stripes and row groups. Bloom filters are available.
  • Full set of Hive types, including struct, list, map and union.
  • Hive ACID: base and delta files, merged by minor and major compactions.

By the numbers​

FigureContextSource
64 MBDefault stripe sizeORC documentation
10,000 rowsGranularity of the lightweight indexes inside a stripeORC documentation
300 PBHive data in Facebook's warehouse, with about 600 TB coming in daily (2014)Facebook Engineering 2014
5x then 8xAverage compression ratio of RCFile, then of Facebook's tuned ORC (2014)Facebook Engineering 2014
80%Share of string columns in Facebook's warehouse (2014)Facebook Engineering 2014
3xFacebook's ORC writer versus the open source ORC writer, on average (2014)Facebook Engineering 2014

Milestones​

  • 9 January 2013: Owen O'Malley opens ticket HIVE-3874, "Create a new Optimized Row Columnar file format for Hive".
  • 15 May 2013: Hive 0.11.0, the first release shipping ORC.
  • 10 April 2014: Facebook describes its move from RCFile to ORC on a 300 PB warehouse.
  • 22 April 2015: ORC leaves Hive and becomes an Apache top-level project.
  • 26 June 2015: the current logo is adopted.
  • 25 January 2016: ORC 1.0.0, with a native C++ reader.
  • 8 March 2024: ORC 2.0.0.

Did you know?​

  • "stored as ORC". ORC started as a Hive feature so that writing STORED AS ORC in a table definition would be enough. Vectorization, ACID, predicate pushdown and LLAP were then added to Hive for ORC first.
  • Leaving Hive to slim down. In 2015, ORC became a separate project because depending on the large Hive jar pulled in many other projects, a hurdle for Pig, MapReduce, Cascading or Spark.
  • A disappointing first test. At Facebook, the original ORC bloated some tables: dictionary encoding applied to every string was costly on high-entropy columns. Facebook made it adaptive.
  • The logo that lost. The 2015 logo announcement mentions another option: "a big white hand on a black shield".

Strengths and limitations​

StrengthsLimitations
Much smaller files than RCFileBorn for Hive, closely tied to its ecosystem
Data skipping via indexes and statisticsWrite-once files: edits go through deltas
ACID transactions in HiveACID not designed for OLTP (not millions of transactions per hour)

What came next​

  • Parquet, the competing columnar format of the same era.
  • Iceberg and table formats bring ACID at the table level, on top of the files.
  • TODO: source ORC's current position versus Parquet (Trino, Iceberg, Spark).

Sources​

To do
  • ORC's current position versus Parquet (Trino, Iceberg, Spark): to be sourced.
  • Facebook uses 256 MB stripes while the ORC documentation states about 64 MB by default: check whether the default changed.