forked from AzureCosmosDB/data-migration-desktop-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParquetDataCol.cs
58 lines (48 loc) · 1.51 KB
/
ParquetDataCol.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using Parquet.Schema;
namespace Cosmos.DataTransfer.ParquetExtension
{
public class ParquetDataCol
{
public string ColumnName { get; set; }
public Type ColumnType { get; set; }
public IEnumerable<object?> ColumnData
{
get
{
var maxRow = SparseColumnData.Keys.Max();
for (long i = 0; i <= maxRow; i++)
{
yield return SparseColumnData.TryGetValue(i, out var value) ? value : null;
}
}
}
public Dictionary<long, object> SparseColumnData { get; } = new Dictionary<long, object>();
public DataField ParquetDataType { get; set; }
public Parquet.Data.DataColumn ParquetDataColumn { get; set; }
public ParquetDataCol()
{
ColumnType = Type.Missing.GetType();
}
public ParquetDataCol(string name, Type coltype)
{
ColumnName = name;
ColumnType = coltype;
if (coltype != System.Type.Missing.GetType())
{
ParquetDataType = MapDataType(name, coltype);
}
}
private static DataField MapDataType(string colname, Type coltype)
{
return new DataField(colname, coltype, true);
}
public void AddColumnValue(long row, object? value)
{
if (value == null)
{
return;
}
SparseColumnData[row] = value;
}
}
}