Apache DataFusion SQL Query Engine
ARROW-255: Finalize Dictionary representation
Julien Le Dem3927d28a64c3
diff --git a/format/Layout.md b/format/Layout.mdindex 5eaefeebf2..a953930e17 100644--- a/format/Layout.md+++ b/format/Layout.md@@ -583,6 +583,43 @@ even if the null bitmap of the parent union array indicates the slot isnull. Additionally, a child array may have a non-null slot even ifthe the types array indicates that a slot contains a different type at the index.+## Dictionary encoding++When a field is dictionary encoded, the values are represented by an array of Int32 representing the index of the value in the dictionary.+The Dictionary is received as a DictionaryBacth whose id is referenced by a dictionary attribute defined in the metadata (Message.fbs) in the Field table.+The dictionary has the same layout as the type of the field would dictate. Each entry in the dictionary can be accessed by its index in the DictionaryBatch.+When a Schema references a Dictionary id, it must send a DictionaryBatch for this id before any RecordBatch.++As an example, you could have the following data:+```+type: List<String>++[+ ['a', 'b'],+ ['a', 'b'],+ ['a', 'b'],+ ['c', 'd', 'e'],+ ['c', 'd', 'e'],+ ['c', 'd', 'e'],+ ['c', 'd', 'e'],+ ['a', 'b']+]+```+In dictionary-encoded form, this could appear as:+```+data List<String> (dictionary-encoded, dictionary id i)+indices: [0, 0, 0, 1, 1, 1, 0]++dictionary i++type: List<String>++[+ ['a', 'b'],+ ['c', 'd', 'e'],+]+```+## ReferencesApache Drill Documentation - [Value Vectors][6]diff --git a/format/Message.fbs b/format/Message.fbsindex 2928207db8..a78009b6e5 100644--- a/format/Message.fbs+++ b/format/Message.fbs@@ -104,6 +104,10 @@ table Field {name: string;nullable: bool;type: Type;+ // present only if the field is dictionary encoded+ // will point to a dictionary provided by a DictionaryBatch message+ dictionary: long;+ // children apply only to Nested data types like Struct, List and Unionchildren: [Field];}@@ -185,8 +189,8 @@ table RecordBatch {/// For sending dictionary encoding information. Any Field can be/// dictionary-encoded, but in this case none of its children may be/// dictionary-encoded.+/// There is one dictionary batch per dictionary///-/// TODO(wesm): To be documented in more detailtable DictionaryBatch {id: long;