15 using System.Collections.Generic;
22 public static void Run()
24 Console.WriteLine(
"=== Schema Builder Demo ===\n");
27 Console.WriteLine(
"1. KineticaType with Column Builders:");
28 Console.WriteLine(
" ---------------------------------");
32 new List<KineticaType.Column>
40 Console.WriteLine($
" Schema: {simpleType.getSchemaString()}");
44 Console.WriteLine(
"2. Complex Record with Nullable Fields:");
45 Console.WriteLine(
" ------------------------------------");
49 new List<KineticaType.Column>
61 Console.WriteLine($
" Schema: {sensorType.getSchemaString()}");
65 Console.WriteLine(
"3. Record with Shard Key:");
66 Console.WriteLine(
" -----------------------");
70 new List<KineticaType.Column>
78 Console.WriteLine($
" Schema: {shardedType.getSchemaString()}");
82 Console.WriteLine(
"4. SQL CREATE TABLE Approach (Recommended):");
83 Console.WriteLine(
" -----------------------------------------");
84 Console.WriteLine(
" Instead of manually building schemas, use SQL:");
86 Console.WriteLine(
@" CREATE TABLE sensors.readings ( 87 sensor_id VARCHAR(64) NOT NULL, 88 location VARCHAR(128), 89 timestamp_ms TIMESTAMP NOT NULL, 93 is_valid TINYINT DEFAULT 1, 94 PRIMARY KEY (sensor_id, timestamp_ms), 100 Console.WriteLine(
"5. Column Type Reference:");
101 Console.WriteLine(
" ----------------------");
103 Console.WriteLine($
" {new string('-', 65)}");
104 Console.WriteLine($
" {"int",-20} {"INT
",-20} {"INT8, INT16
for smaller
",-25}");
105 Console.WriteLine($
" {"long",-20} {"LONG
",-20} {"TIMESTAMP
for time
",-25}");
106 Console.WriteLine($
" {"float",-20} {"FLOAT
",-20} {"",-25}");
107 Console.WriteLine($
" {"double",-20} {"DOUBLE
",-20} {"",-25}");
108 Console.WriteLine($
" {"string",-20} {"STRING
",-20} {"CHAR1-256, IPV4, etc.
",-25}");
109 Console.WriteLine($
" {"byte[]
",-20} {"BYTES
",-20} {"WKT, WKB
for geospatial
",-25}");
113 Console.WriteLine(
"6. Column Properties Reference:");
114 Console.WriteLine(
" ----------------------------");
115 Console.WriteLine($
" {"Property
",-25} {"Description
",-50}");
116 Console.WriteLine($
" {new string('-', 75)}");
117 Console.WriteLine($
" {"PRIMARY_KEY
",-25} {"Column is part of the primary key
",-50}");
118 Console.WriteLine($
" {"SHARD_KEY
",-25} {"Column is used
for data sharding
",-50}");
119 Console.WriteLine($
" {"NULLABLE
",-25} {"Column can contain
null values
",-50}");
120 Console.WriteLine($
" {"TIMESTAMP
",-25} {"Long column stores timestamp (ms)
",-50}");
121 Console.WriteLine($
" {"CHAR1-CHAR256
",-25} {"String with fixed max length
",-50}");
122 Console.WriteLine($
" {"INT8, INT16
",-25} {"Smaller integer storage
",-50}");
123 Console.WriteLine($
" {"IPV4
",-25} {"String stores IPv4 address
",-50}");
124 Console.WriteLine($
" {"DECIMAL
",-25} {"String stores decimal number
",-50}");
125 Console.WriteLine($
" {"DATE
",-25} {"String stores date (YYYY-MM-DD)
",-50}");
126 Console.WriteLine($
" {"TIME
",-25} {"String stores time (HH:MM:SS)
",-50}");
127 Console.WriteLine($
" {"DATETIME
",-25} {"String stores datetime
",-50}");
128 Console.WriteLine($
" {"WKT
",-25} {"String stores geospatial WKT
",-50}");
132 Console.WriteLine(
"7. Best Practices:");
133 Console.WriteLine(
" ----------------");
134 Console.WriteLine(
" * Use SQL CREATE TABLE for production - it's clearer and more maintainable");
135 Console.WriteLine(
" * Always define a PRIMARY KEY for uniqueness constraints");
136 Console.WriteLine(
" * Use SHARD KEY on high-cardinality columns for even distribution");
137 Console.WriteLine(
" * Use NULLABLE only when needed - non-nullable is more efficient");
138 Console.WriteLine(
" * Use CHAR(N) instead of STRING when max length is known");
139 Console.WriteLine(
" * Use TIMESTAMP for time columns to enable time-based queries");
142 Console.WriteLine(
"=== Demo Complete ===");
const string PRIMARY_KEY
This property indicates that this column will be part of (or the entire) primary key.
Column properties used for Kinetica types.
const string CHAR64
This property provides optimized memory, disk and query performance for string columns.
Immutable metadata about a column in a Kinetica type.
const string SHARD_KEY
This property indicates that this column will be part of (or the entire) shard key.
const string INT8
This property provides optimized memory and query performance for int columns.
Immutable collection of metadata about a Kinetica type.
const string NULLABLE
This property indicates that this column is nullable.