Kinetica   C#   API  Version 7.2.3.1
TypePropertiesBuilder.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 
4 namespace kinetica.SchemaBuilder;
5 
20  public sealed class TypePropertiesBuilder
21  {
22  private readonly Dictionary<string, IList<string>> _properties;
23 
28  {
29  _properties = new Dictionary<string, IList<string>>(StringComparer.OrdinalIgnoreCase);
30  }
31 
38  {
39  _properties[name] = props.Build();
40  return this;
41  }
42 
48  public TypePropertiesBuilder ColumnProperty(string name, string property)
49  {
50  if (!_properties.TryGetValue(name, out var propList))
51  {
52  propList = new List<string>();
53  _properties[name] = propList;
54  }
55 
56  if (!propList.Contains(property))
57  propList.Add(property);
58 
59  return this;
60  }
61 
65  public TypePropertiesBuilder PrimaryKey(string name)
66  {
67  return ColumnProperty(name, "primary_key");
68  }
69 
73  public TypePropertiesBuilder ShardKey(string name)
74  {
75  return ColumnProperty(name, "shard_key");
76  }
77 
81  public TypePropertiesBuilder Nullable(string name)
82  {
83  return ColumnProperty(name, "nullable");
84  }
85 
89  public TypePropertiesBuilder Timestamp(string name)
90  {
91  return ColumnProperty(name, "timestamp");
92  }
93 
97  public TypePropertiesBuilder Data(string name)
98  {
99  return ColumnProperty(name, "data");
100  }
101 
105  public TypePropertiesBuilder Ipv4(string name)
106  {
107  return ColumnProperty(name, "ipv4");
108  }
109 
113  public TypePropertiesBuilder Date(string name)
114  {
115  return ColumnProperty(name, "date");
116  }
117 
121  public TypePropertiesBuilder DateTime(string name)
122  {
123  return ColumnProperty(name, "datetime");
124  }
125 
129  public TypePropertiesBuilder Time(string name)
130  {
131  return ColumnProperty(name, "time");
132  }
133 
137  public TypePropertiesBuilder Decimal(string name)
138  {
139  return ColumnProperty(name, "decimal");
140  }
141 
145  public TypePropertiesBuilder Uuid(string name)
146  {
147  return ColumnProperty(name, "uuid");
148  }
149 
153  public TypePropertiesBuilder Boolean(string name)
154  {
155  return ColumnProperty(name, "boolean");
156  }
157 
161  public TypePropertiesBuilder Int8(string name)
162  {
163  return ColumnProperty(name, "int8");
164  }
165 
169  public TypePropertiesBuilder Int16(string name)
170  {
171  return ColumnProperty(name, "int16");
172  }
173 
177  public TypePropertiesBuilder Wkt(string name)
178  {
179  return ColumnProperty(name, "wkt");
180  }
181 
185  public TypePropertiesBuilder CharN(string name, int n)
186  {
187  var prop = n switch
188  {
189  1 => "char1",
190  2 => "char2",
191  4 => "char4",
192  8 => "char8",
193  16 => "char16",
194  32 => "char32",
195  64 => "char64",
196  128 => "char128",
197  256 => "char256",
198  _ => throw new ArgumentException($"Invalid char length: {n}", nameof(n))
199  };
200  return ColumnProperty(name, prop);
201  }
202 
206  public IReadOnlyDictionary<string, IList<string>> Build()
207  {
208  return new Dictionary<string, IList<string>>(_properties, StringComparer.OrdinalIgnoreCase);
209  }
210  }
TypePropertiesBuilder CharN(string name, int n)
Marks a column as char(N) type.
TypePropertiesBuilder()
Creates a new TypePropertiesBuilder.
TypePropertiesBuilder Ipv4(string name)
Marks a column as IPv4 type.
IReadOnlyDictionary< string, IList< string > > Build()
Builds the properties dictionary.
TypePropertiesBuilder Boolean(string name)
Marks a column as boolean type.
TypePropertiesBuilder DateTime(string name)
Marks a column as datetime type.
TypePropertiesBuilder Timestamp(string name)
Marks a column as timestamp type.
TypePropertiesBuilder Wkt(string name)
Marks a column as WKT (geometry) type.
TypePropertiesBuilder Column(string name, KineticaColumnProperties props)
Adds properties for a column.
Builder for Kinetica column properties.
TypePropertiesBuilder Nullable(string name)
Marks a column as nullable.
TypePropertiesBuilder PrimaryKey(string name)
Marks a column as primary key.
TypePropertiesBuilder Decimal(string name)
Marks a column as decimal type.
TypePropertiesBuilder ColumnProperty(string name, string property)
Adds a single property to a column.
TypePropertiesBuilder Uuid(string name)
Marks a column as UUID type.
TypePropertiesBuilder Data(string name)
Marks a column as data column (text search enabled).
Builder for constructing type properties dictionaries.
TypePropertiesBuilder Int8(string name)
Marks a column as int8 type.
TypePropertiesBuilder Date(string name)
Marks a column as date type.
TypePropertiesBuilder ShardKey(string name)
Marks a column as shard key.
IList< string > Build()
Builds the list of properties.
TypePropertiesBuilder Int16(string name)
Marks a column as int16 type.
TypePropertiesBuilder Time(string name)
Marks a column as time type.