Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Latest commit

 

History

History
43 lines (36 loc) · 1.01 KB

complex-map.md

File metadata and controls

43 lines (36 loc) · 1.01 KB

Maps

Map in parquet format are similar to C# dictionaries i.e. they can map a key to a value. The perfect use case for them is when you cannot define a schema beforehand, or really just want a map of values in a column.

For instance, let's declare a schema with two columns:

  • Row ID
  • A map of integer to it's human representation
var ds = new DataSet(
   new DataField<int>("id")
   new MapField("names",
      new DataField("key", DataType.Int32),
      new DataField("value", DataType.String)),
   );

ds.Add(1, new Dictionary<int, string>
{
   [1] = "one",
   [2] = "two",
   [3] = "three"
});

Map value can also be a complex type like a structure, for example:

var ds = new DataSet(
   new DataField<int>("id"),
   new StructField("structure",
      new DataField<int>("id"),
      new MapField("map",
         new DataField<int>("key"),
         new DataField<string>("value")
   )));
ds.Add(1, new Row(1, new Dictionary<int, string>
{
   [1] = "one",
   [2] = "two",
   [3] = "three"
}));