prasannarajaperumal commented on code in PR #6268:
URL: https://github.com/apache/hudi/pull/6268#discussion_r942153785


##########
website/src/pages/tech-specs.md:
##########
@@ -0,0 +1,371 @@
+# Apache Hudi Storage Format Specification [DRAFT]
+
+
+
+This document is a specification for the Hudi Storage Format which transforms 
immutable cloud/file storage systems into transactional data lakes. 
+
+## Overview
+
+Hudi Storage Format enables the following features over very large collection 
of files/objects
+
+- streaming primitives like incremental merges, change stream etc
+- database primitives like tables, transactions, mutability, indexes and query 
performance optimizations 
+
+Apache Hudi is an open source data lake platform that is built on top of the 
Hudi Storage Format and it unlocks the following features 
+
+- **Unified Computation model** - an unified way to combine large batch style 
operations and frequent near real time streaming operations over a single 
unified dataset
+- **Self-Optimized Storage** - Automatically handle all the table storage 
maintenance such as compaction, clustering, vacuuming asynchronously and 
non-blocking to actual data changes
+- **Cloud Native Database** - abstracts Table/Schema from actual storage and 
ensures up-to-date metadata and indexes unlocking multi-fold read and write 
performance optimizations
+- **Engine neutrality** - designed to be neutral and not having a preferred 
computation engine. Apache Hudi will manage metadata, provide common 
abstractions and pluggable interfaces to most/all common computational engines.
+
+
+
+## Storage Format
+
+### Layout Hierarchy
+
+At a high level, Hudi organizes data into a high level directory structure 
under the base path (root directory for the Hudi table). The directory 
structure is based on coarse-grained partitioning values set for the dataset. 
Non-partitioned data sets store all the data files under the base path. Hudi 
storage format has a special reserved *.hoodie* directory under the base path 
that is used to store transaction logs and metadata.
+
+```
+/data/hudi_trips/                                      <== BASE PATH
+├── .hoodie/                                           <== META BASE PATH
+│   └── metadata/ 
+├── americas/
+│   ├── brazil/
+│   │   └── sao_paulo/      <== PARTITIONED DIRECTORY 
+│   │       ├── <data_files>
+│   └── united_states/
+│       └── san_francisco/
+│           ├── <data_files>
+└── asia/
+    └── india/
+        └── chennai/
+            ├── <data_files>
+```
+
+Hudi storage format offers two table types offering different trade-offs 
between ingest and query performance and the data files are stored differently 
based on the chosen table type. 
+
+| Table Type    | Trade-off                                                    
|
+| ------------- | ------------------------------------------------------------ 
|
+| Copy on Write | Optimized for read performance and ideal for slow changing 
datasets |
+| Merge-on-read | Optimized to balance the write and read performance and 
ideal for frequently changing datasets |
+
+
+
+### Data Model
+
+Within each partition, data is organized into key-value model. Every row is 
uniquely identified with a row key. To write a row into Hudi dataset, each row 
must specify the following user fields 
+
+| User fields                 | Description                                    
              |
+| --------------------------- | 
------------------------------------------------------------ |
+| Partitioning key [Optional] | Value of this field defines the directory 
hierarchy within the table base path. This essentially provides an hierarchy 
isolation for managing data and related metadata |
+| Row key(s)                     | Record keys uniquely identify a record/row 
within each partition if partitioning is enabled |
+| Ordering field(s)           | Hudi guarantees the uniqueness constraint of 
row key and the conflict resolution configuration manages strategies on how to 
disambiguate when multiple records with the same keys are to be merged into the 
dataset. The resolution logic can be based on an ordering field or can be 
custom, specific to the dataset. To ensure consistent behaviour dealing with 
duplicate records, the resolution logic should be commutative and idempotent |
+
+**Hudi metadata fields**
+
+Hudi format stores the user fields along with the row merged along with 
transactional metadata fields. These fields are encoded in the data-file format 
and available in the table schema. 
+
+| Hudi meta-fields             | Description                                   
               |
+| ---------------------------- | 
------------------------------------------------------------ |
+| _hoodie_commit_time [string] | Every modification to a Hudi dataset creates 
an entry into the Transaction timeline. This entry is identified with the 
commit time. This field matches to the commit time of the instant in the 
timeline that created this record. More on how to populate this in Hudi 
transactions section below. |
+| _hoodie_record_key           | Unique record key identifying the row within 
the partition   |
+| _hoodie_partition_path       | Partition path under which the data is 
organized into        |
+| _hoodie_file_name            | The data file name this record belongs to     
               |
+| _hoodie_is_deleted           | Tombstone field to denote the record key is 
deleted          |
+
+
+
+## Transaction Log (Timeline)
+
+Data consistency in Hudi is provided using Multi-version Concurrency Control 
(MVCC). Every transactional action on the Hudi table creates a new entry 
(instant) in the timeline. All transactional actions follows the state 
transition below
+
+* **requested** - Action is requested to start on the timeline. 
+* **inflight** - Action has started running and is currently in-flight
+* **completed** - Action has completed running
+
+All actions and the state transitions are registered with the timeline using 
an atomic put of special meta-file inside the  *.hoodie* directory. The 
requirement from the underlying storage system is to support an atomic-put and 
read-after-write consistency. The meta file structure is as follows
+
+```
+[Action timestamp].[Action type].[Action state] 
+```
+
+* **Action timestamp** - Monotonically increasing value to denote strict 
ordering of actions in the timeline. This could be provided by an external 
token provider or rely on the system epoch time at millisecond granularity. 

Review Comment:
   Yeah I think the format can leave the specifics on how to generate this 
monotonically increasing value to the implementation. But the caveat on retry 
may be worth calling out - not sure where. This is more like things to watch 
out for in the implementation, but there are tons of things we can mention 
here. I am inclined to leave it as-is for now. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to