Arrow JS API · encoded type
Store repeated values through a shared dictionary.
Dictionary describes a column whose physical values are integer indices into a logical dictionary. It can reduce repeated text or categorical values while retaining the original value type for readers.
The Dictionary model
Separate the repeated value from its index.
A dictionary type names both the logical value type and the integer index type. The encoding is most useful for repeated values, while the schema carries the dictionary identity needed for serialization.
Logical value
The type stored in the dictionary
Index
An integer type pointing into dictionary values
Identity
Dictionary id carried in message metadata
Ordering
Optional flag for order-preserving indices
Detailed guide
Dictionary type reference
The sections below document constructor arguments, members, dictionary ids, index types, and string representation.
This page is aligned to Apache Arrow JS v21.x (apache-arrow).
A Dictionary DataType that describes dictionary-encoded values (index + dictionary lookup table).
Usage
import {Dictionary, Utf8, Int32} from 'apache-arrow';
const type = new Dictionary(new Utf8(), new Int32());
console.log(type.isOrdered, type.id);
import {Dictionary, Utf8, Int32} from 'apache-arrow';
const type = new Dictionary(new Utf8(), new Int32());
console.log(type.toString());
Members
id: bigint | number | null— Dictionary type identifier used in message metadata.indices: TKey— Integer index key type (Int8,Int16,Int32,Uint8,Uint16,Uint32).dictionary: T— Logical value type of the dictionary payload.isOrdered: boolean— Whether dictionary index values are order-preserving.children: Field[]— Nested field descriptors (inherited fromDataType).valueType: T— Alias fordictionary.ArrayType: T['ArrayType']— Value array constructor for dictionary index type.typeId: Type.Dictionary— Data type enum value for this type.
Constructor
constructor(dictionary: T, indices: TKey, id?: bigint | number | null, isOrdered?: boolean | null)
Construct a dictionary type with explicit dictionary values and index type.
Methods
toString(): string— Returns canonical"Dictionary<...>"representation.