Kinetica   C#   API  Version 7.2.3.0
Test.cs
Go to the documentation of this file.
1 
7 using System.Text.RegularExpressions;
8 using kinetica;
9 using Newtonsoft.Json;
10 using JDBC.NET.Data;
11 using NetTopologySuite.Geometries;
12 
13 
14 namespace Test
15 {
19  public static class StringExt
20  {
21  public static string Truncate( this string value, int maxLength )
22  {
23  if ( string.IsNullOrEmpty( value ) )
24  return value;
25 
26  return ( value.Length <= maxLength ) ? value : value[..maxLength];
27  }
28  }
29 
30 
36  class Test
37  {
38  static void Main( string[] args )
39  {
40  Console.WriteLine("=============================");
41  Console.WriteLine("= Test C# Project - Running =");
42  Console.WriteLine("=============================");
43  Console.WriteLine();
44 
45  if ( args.Length < 1 )
46  {
47  Console.WriteLine( "Missing URL as command-line parameter." );
48  Console.WriteLine( "E.g., http://kinetica:9191" );
49  return;
50  }
51 
52  try
53  {
54  string server_url = args[0];
55  Console.WriteLine( "URL: {0}", server_url );
56  Console.WriteLine();
57 
58  ProcessArgs(args, out Kinetica.Options? _ServerOptions, out string? _JdbcDriverPath);
59 
60  if (_ServerOptions == null) {
61  Console.WriteLine("Command line parameters can be either [<oauth_token>] or [<username> <password> <JDBC Bridge Driver JAR]");
62  throw new Exception("Invalid command line parameters");
63  }
64 
65 
66  // Run various tests
67  // ----------------------------------
68  TestDml(server_url, _ServerOptions);
69  TestOauth2Authentication( server_url, _ServerOptions );
70  TestAuthentication( server_url, _ServerOptions );
71  TestAllTypesAllShard( server_url, _ServerOptions );
72  TestAllTypesIpRegex3Shard0Pk(server_url, _ServerOptions);
73  TestAllTypes3Pk3Shard( server_url, _ServerOptions );
74  TestAllTypes3Pk0Shard( server_url, _ServerOptions );
75  TestRecordRetrievalByKey( server_url, _ServerOptions );
76  TestJdbc(server_url, _ServerOptions, _JdbcDriverPath);
77  }
78  catch ( kinetica.KineticaIngestor<RecordTypeAll>.InsertException<RecordTypeAll> ex )
79  {
80  Console.WriteLine( "Caught InsertException: {0}", ex.Message );
81  }
82  catch ( KineticaException ex )
83  {
84  Console.WriteLine( "Caught KineticaException: {0}", ex.Message );
85  }
86  catch ( Exception ex )
87  {
88  Console.WriteLine( "Caught Exception: {0}", ex.Message );
89  }
90 
91  Console.WriteLine();
92  Console.WriteLine("==========================");
93  Console.WriteLine("= Test C# Project - Done =");
94  Console.WriteLine("==========================");
95  } // end Main
96 
97  public static void ProcessArgs(string []args, out Kinetica.Options? options, out string? jdbcDriverPath) {
98  jdbcDriverPath = null;
99  if (args.Length <= 1)
100  {
101  // only host supplied no other options
102  options = null;
103  }
104  else if (args.Length <= 2)
105  {
106  // host and oauth_token have been passed
107  options = new()
108  {
109  OauthToken = args[1]
110  };
111  }
112  else
113  {
114  // host, username, & password have been passed
115  options = new()
116  {
117  Username = args[1],
118  Password = args[2]
119  };
120 
121  if (args.Length >= 4)
122  jdbcDriverPath = args[3];
123  }
124  }
125 
126 #region TestDml
127 
128  private static string GenerateRandomId()
129  {
130  Random random = new();
131  int randomNumber = random.Next(1000, 9999); // Generates a random number between 1000 and 9999
132  return $"ID_{randomNumber}";
133  }
134 
135  private static string GenerateRandomUrl()
136  {
137  string[] domains = ["com", "net", "org", "io", "dev"];
138  string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
139  Random random = new();
140 
141  string randomSubdomain = new(
142  [.. new char[8].Select(_ => chars[random.Next(chars.Length)])]);
143 
144  string randomDomain = new(
145  [.. new char[5].Select(_ => chars[random.Next(chars.Length)])]);
146 
147  string randomPath = new(
148  [.. new char[6].Select(_ => chars[random.Next(chars.Length)])]);
149 
150  string domainExtension = domains[random.Next(domains.Length)];
151 
152  return $"https://{randomSubdomain}.{randomDomain}.{domainExtension}/{randomPath}";
153  }
154 
155  private static string GenerateRandomName()
156  {
157  string[] firstNames = ["Alice", "Bob", "Charlie", "David", "Eve", "Frank", "Grace", "Helen", "Ivy", "Jack"];
158  string[] lastNames = ["Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller", "Davis", "Rodriguez", "Martinez"];
159 
160  Random random = new();
161  string firstName = firstNames[random.Next(firstNames.Length)];
162  string lastName = lastNames[random.Next(lastNames.Length)];
163 
164  return $"{firstName} {lastName}";
165  }
166 
167  private static string GenerateGeometry() {
168  GeometryFactory factory = new();
169 
170  // Create a Polygon
171  Polygon polygon = factory.CreatePolygon(
172  [
173  new Coordinate(0, 0),
174  new Coordinate(10, 0),
175  new Coordinate(10, 10),
176  new Coordinate(0, 10),
177  new Coordinate(0, 0) // Closing the polygon
178  ]);
179  return polygon.AsText();
180 
181  }
182 
183  private static string GenerateRandomPolygon()
184  {
185  GeometryFactory factory = new();
186  Random rand = new();
187 
188  // Generate a random number of vertices (between 3 and 10)
189  int numVertices = rand.Next(3, 11);
190 
191  // Generate random coordinate bounds
192  double minX = rand.NextDouble() * 50; // Min X in range [0, 50]
193  double maxX = minX + rand.NextDouble() * 50; // Max X in range [minX, minX + 50]
194  double minY = rand.NextDouble() * 50; // Min Y in range [0, 50]
195  double maxY = minY + rand.NextDouble() * 50; // Max Y in range [minY, minY + 50]
196 
197  Coordinate[] coordinates = new Coordinate[numVertices + 1];
198 
199  for (int i = 0; i < numVertices; i++)
200  {
201  double x = rand.NextDouble() * (maxX - minX) + minX;
202  double y = rand.NextDouble() * (maxY - minY) + minY;
203  coordinates[i] = new Coordinate(x, y);
204  }
205 
206  // Ensure the polygon is closed (first and last point must be the same)
207  coordinates[numVertices] = coordinates[0];
208 
209  // Create LinearRing and Polygon
210  LinearRing ring = factory.CreateLinearRing(coordinates);
211  Polygon polygon = factory.CreatePolygon(ring);
212 
213  return polygon.AsText();
214  }
215 
216  private static DateTime GenerateRandomDate(DateTime start, DateTime end)
217  {
218  Random random = new();
219  int range = (int)(end - start).TotalSeconds; // Get total seconds between the two dates
220  return start.AddSeconds(random.Next(range));
221  }
222 
223  private class LayerDTO
224  {
225  public string? ObjectId { get; set; }
226  public string? Name { get; set; }
227  public string? Url { get; set; }
228  public string? BoundingBox { get; set; }
229  public string? CreatedAt { get; set; }
230  public string? UpdatedAt { get; set; }
231  }
232 
233  private static void TestDml( string server_url, Kinetica.Options _ServerOptions )
234  {
235  Console.WriteLine("\n\n");
236  Console.WriteLine("Test DML");
237  Console.WriteLine("========");
238  Console.WriteLine();
239 
240  string Ddl = @"CREATE OR REPLACE TABLE layers
241  (
242  ObjectId VARCHAR (primary_key) NOT NULL,
243  Name VARCHAR NOT NULL,
244  Url VARCHAR NOT NULL,
245  BoundingBox GEOMETRY NOT NULL,
246  CreatedAt DATETIME NOT NULL,
247  UpdatedAt DATETIME NOT NULL
248  )";
249 
250  // Establish a connection with Kinetica
251  Kinetica kdb = new( server_url, _ServerOptions );
252  string table_name = "layers";
253 
254  kdb.executeSql(Ddl);
255 
256  // Next two lines mandatory to register user defined record types
257  KineticaType kineticaType = KineticaType.fromClass(typeof(LayerDTO));
258  kdb.SetKineticaSourceClassToTypeMapping(kineticaType.getSourceType(), kineticaType);
259 
260  List<LayerDTO> records = [];
261 
262  // Insert Records
263  for( int i=0; i < 10; i++ ) {
264  LayerDTO record = new()
265  {
266  ObjectId = GenerateRandomId(),
267  Name = GenerateRandomName(),
268  Url = GenerateRandomUrl(),
269  BoundingBox = GenerateRandomPolygon(),
270  CreatedAt = GenerateRandomDate(new DateTime(2024, 1, 1), DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss"),
271  UpdatedAt = GenerateRandomDate(new DateTime(2024, 1, 1), DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss")
272  };
273  records.Add(record);
274  }
275 
276  Console.WriteLine($"Inserting {records.Count} records...");
277  kdb.insertRecords(table_name, records);
278 
279  Console.WriteLine($"IDs inserted:");
280  string? firstId = null;
281  string? lastId = null;
282  GetRecordsResponse<LayerDTO> getRecordsResponse = kdb.getRecords<LayerDTO>(table_name);
283  foreach( var record in getRecordsResponse.data ) {
284  firstId ??= record.ObjectId;
285  lastId = record.ObjectId;
286  Console.WriteLine(lastId);
287  }
288  Console.WriteLine();
289 
290  // Update Records
291  Console.WriteLine($"Updating record {lastId}...");
292  string expression = $"ObjectId = '{lastId ?? ""}'";
293  var newValueMap = new Dictionary<string, string>
294  {
295  ["Name"] = "John Doe",
296  ["Url"] = "www.kinetica.com"
297  };
298  UpdateRecordsResponse updateRecordsResponse = kdb.updateRecords<LayerDTO>(table_name, [expression], [newValueMap]);
299  Console.WriteLine($"Updated {updateRecordsResponse.count_updated} record\n");
300 
301  // Delete Records
302  Console.WriteLine($"Deleting record {firstId}...");
303  expression = $"ObjectId = '{firstId ?? ""}'";
304  DeleteRecordsResponse deleteRecordsResponse = kdb.deleteRecords(table_name, [expression]);
305  Console.WriteLine($"Deleted {deleteRecordsResponse.count_deleted} record\n");
306  }
307 
308  #endregion TestDml
309 
310  private class RecordTypeShort
311  {
312  public int i { get; set; }
313  public int i8 { get; set; }
314 
315  public override string ToString()
316  {
317  return $"{{ i={i}, i8={i8} }}";
318  }
319  } // end class RecordTypeShort
320 
321 
322  private static void TestOauth2Authentication( string serverUrl, Kinetica.Options serverOptions )
323  {
324  Console.WriteLine( "\n\n" );
325  Console.WriteLine( "Test OAuth2 Authentication" );
326  Console.WriteLine( "==========================" );
327  Console.WriteLine();
328 
329  if (serverOptions.OauthToken == string.Empty)
330  Console.WriteLine("Skipping--OAuth token not passed");
331  else
332  {
333  // Establish a connection with Kinetica
334  Console.WriteLine("Token passed : " + serverOptions.OauthToken);
335  Kinetica kdb_ = new(serverUrl, serverOptions);
336  string json = JsonConvert.SerializeObject(kdb_.showSystemStatus(new Dictionary<string, string>()).status_map, Formatting.Indented);
337  Console.WriteLine(json);
338  }
339  } // end TestOauth2Authentication()
340 
341  private static void TestAuthentication(string serverUrl, Kinetica.Options serverOptions)
342  {
343  Console.WriteLine("\n\n");
344  Console.WriteLine("Test Authentication");
345  Console.WriteLine("===================");
346  Console.WriteLine();
347 
348  string username = "csharp_test_user";
349  string password = "csharp_test_pass";
350 
351  Console.WriteLine($"Establishing connection with {serverOptions.Username} user...\n");
352  Kinetica kdb_ = new(serverUrl, serverOptions);
353 
354 
355  Console.WriteLine($"Creating a user {username}...\n");
356  try
357  {
358  if (kdb_.showSecurity([username]).types.Count != 0)
359  kdb_.deleteUser(username);
360  kdb_.createUserInternal(username, password);
361  }
362  catch (KineticaException ex)
363  {
364  Console.WriteLine($"Error creating user: {ex.Message}");
365  }
366 
367 
368  Console.WriteLine($"Establishing a connection with {username} user and valid password...\n");
369  Kinetica.Options connectOptions = new()
370  {
371  Username = username,
372  Password = password
373  };
374  Kinetica kdbUser = new(serverUrl, connectOptions);
375  object gotUsername;
376  kdbUser.getRecordsByColumn("ITER", ["USER() AS username"]).data.First().TryGetValue("username", out gotUsername);
377 
378  Console.WriteLine($"Created user name: {gotUsername}\n");
379 
380 
381  Console.WriteLine($"Establishing a connection with {username} user and invalid password...\n");
382  try
383  {
384  connectOptions.Password = "";
385 
386  kdbUser = new(serverUrl, connectOptions);
387  kdbUser.getRecordsByColumn("ITER", ["USER() AS username"]).data.First().TryGetValue("username", out gotUsername);
388  Console.WriteLine($"Unexpected success logging in with invalid credentials for {gotUsername}!");
389  }
390  catch (KineticaException ex)
391  {
392  Console.WriteLine($"Expected error logging in with invalid credentials: {ex.Message}");
393  }
394  } // end TestAuthentication()
395 
396 
397  private class RecordTypeAll
398  {
399  public int? i { get; set; }
400  public int? i8 { get; set; }
401  public int? i16 { get; set; }
402  public long l { get; set; } // not making nullable here so that can be used as a primary key
403  public float? f { get; set; }
404  public double? d { get; set; } // nullable
405  public string? s { get; set; }
406  public string? c1 { get; set; }
407  public string? c2 { get; set; }
408  public string? c4 { get; set; }
409  public string? c8 { get; set; }
410  public string? c16 { get; set; }
411  public string? c32 { get; set; }
412  public string? c64 { get; set; }
413  public string? c128 { get; set; }
414  public string? c256 { get; set; }
415  public string? date { get; set; }
416  public string? datetime { get; set; }
417  public string? decimal_ { get; set; }
418  public string? ipv4 { get; set; }
419  public string? time { get; set; }
420  public long? timestamp { get; set; }
421 
422  public override string ToString()
423  {
424  string d_;
425  if ( d != null )
426  d_ = $"{d}";
427  else
428  d_ = "<null>";
429  return $"{{ i={i}, i8={i8}, i16={i16}, l={l}, f={f}, d={d_}, s={s}, c1={c1}, c2={c2}, c4={c4}, c8={c8}, c16={c16}, c32={c32}, c64={c64}, c128={c128}, c256={c256}, date={date}, datetime={datetime}, decimal_={decimal_}, ipv4={ipv4}, time={time}, timestamp={timestamp} }}";
430  }
431  } // end class RecordTypeAll
432 
433 
434  private static void TestAllTypesAllShard( string serverUrl, Kinetica.Options serverOptions )
435  {
436  // Establish a connection with Kinetica
437  Kinetica kdb = new( serverUrl, serverOptions );
438 
439  Console.WriteLine( "\n\n" );
440  Console.WriteLine( "Test Multihead Ingest: One column per Type; All are Shard Keys, 0 Primary Keys" );
441  Console.WriteLine( "==============================================================================" );
442  Console.WriteLine();
443 
444  Console.WriteLine( "Creating a type with all column types (all are nullable and shard columns).\n" );
445 
446  // Create a type for our RecordTypeAll class
447  // Add some interesting properties for some of the data types
448  Dictionary<string, IList<string>> column_properties = new()
449  {
450  { "i", [ColumnProperty.SHARD_KEY] },
453  { "d", [ColumnProperty.SHARD_KEY] },
454  { "f", [ColumnProperty.SHARD_KEY] },
472  };
473 
474  // Create the KineticaType object which facilitates creating types in the database
475  KineticaType allType = KineticaType.fromClass( typeof( RecordTypeAll ), column_properties );
476 
477  // Create the type in the database
478  string type_id = allType.create( kdb );
479  Console.WriteLine( "Created type.\n" );
480 
481  string tableName = "csharp_test_table_all_shards";
482  // Clear any previously made table with the same name
483  Console.WriteLine( $"Clearing any existing table named '{tableName}'..." );
484  kdb.clearTable(tableName, "", new Dictionary<string, string> { [ClearTableRequest.Options.NO_ERROR_IF_NOT_EXISTS] = ClearTableRequest.Options.TRUE });
485 
486  // Create a table of the given type
487  Console.WriteLine( $"Creating table named '{tableName}'\n" );
488  kdb.createTable( tableName, type_id );
489  Console.WriteLine();
490 
491  // Create the ingestor
492  int batchSize = 1000;
493  KineticaIngestor<RecordTypeAll> ingestor = new( kdb, tableName, batchSize, allType );
494 
495 
496  // Generate data to be inserted
497  int totalRecords = batchSize * 10;
498  Console.WriteLine( $"Starting to generate {totalRecords} records.\n" );
499  List<RecordTypeAll> records = [];
500  Random rng = new();
501  double nullProbability = 0.15; // 15% chance of creating nulls
502  for ( int i = 0; i < totalRecords; ++i )
503  {
504  // Restricting string length to 256
505  int max_str_len = rng.Next( 0, 256 );
506  RecordTypeAll record = new()
507  {
508  i = ( rng.NextDouble() < nullProbability ) ? null : (int?) rng.Next(),
509  i8 = ( rng.NextDouble() < nullProbability ) ? null : (int?) rng.Next( -128, 128 ), // upper exclusive
510  i16 = ( rng.NextDouble() < nullProbability ) ? null : (int?) rng.Next( -32768, 32768), // upper exclusive
511  l = (long)rng.Next(),
512  //l = ( rng.NextDouble() < nullProbability ) ? null : (long)rng.Next(), // can't be made nullable if not declared as long?
513  f = ( rng.NextDouble() < nullProbability ) ? null : (float?)(rng.NextDouble() * rng.Next()),
514  d = ( rng.NextDouble() < nullProbability ) ? null : ( double? ) ( rng.NextDouble() * rng.Next() ),
515  s = ( rng.NextDouble() < nullProbability ) ? null : System.IO.Path.GetRandomFileName().Truncate( max_str_len ),
516  c1 = ( rng.NextDouble() < nullProbability ) ? null : System.IO.Path.GetRandomFileName().Truncate( 1 ),
517  c2 = ( rng.NextDouble() < nullProbability ) ? null : System.IO.Path.GetRandomFileName().Truncate( 2 ),
518  c4 = ( rng.NextDouble() < nullProbability ) ? null : System.IO.Path.GetRandomFileName().Truncate( rng.Next( 0, 5) ), // any size between empty string to 4 length
519  c8 = ( rng.NextDouble() < nullProbability ) ? null : System.IO.Path.GetRandomFileName().Truncate( rng.Next( 0, 9) ), // any size between empty string to 8 length
520  c16 = ( rng.NextDouble() < nullProbability ) ? null : System.IO.Path.GetRandomFileName().Truncate( rng.Next( 0, 17) ), // any size between empty string to 16 length
521  c32 = ( rng.NextDouble() < nullProbability ) ? null : System.IO.Path.GetRandomFileName().Truncate( rng.Next( 5, 33) ), // any size between [5, 32] in length
522  c64 = ( rng.NextDouble() < nullProbability ) ? null : System.IO.Path.GetRandomFileName().Truncate( rng.Next( 10, 65) ), // any size between [10, 64] in length
523  c128 = ( rng.NextDouble() < nullProbability ) ? null : System.IO.Path.GetRandomFileName().Truncate( rng.Next( 10, 129) ), // any size between [10, 128] in length
524  c256 = ( rng.NextDouble() < nullProbability ) ? null : System.IO.Path.GetRandomFileName().Truncate( rng.Next( 25, 257) ), // any size between [25, 256] in length
525  date = ( rng.NextDouble() < nullProbability ) ? null : Test.GenerateDate( rng ),
526  datetime = (rng.NextDouble() < nullProbability) ? null : Test.GenerateDateTime(rng),
527  decimal_ = (rng.NextDouble() < nullProbability) ? null : Test.GenerateDecimal(rng),
528  ipv4 = ( rng.NextDouble() < nullProbability ) ? null : Test.GenerateIpv4( rng ),
529  time = (rng.NextDouble() < nullProbability) ? null : Test.GenerateTime(rng),
530  timestamp = ( rng.NextDouble() < nullProbability ) ? null : ((long?)rng.Next( -306102240, 293795424 ) * rng.Next( 100000 ))
531  };
532 
533  //Console.WriteLine( "#" + i + ": " + record.ToString() + "\n" ); // debug~~~~~~~~
534  records.Add( record );
535  ingestor.insert( record );
536  } // end for loop
537 
538  Console.WriteLine( $"Generated {totalRecords} records." );
539 
540  // Insert the records into the ingestor
541  Console.WriteLine( $"Inserting {totalRecords} records..." );
542  ingestor.insert( records );
543 
544  // Flush the ingestor (which actually inserts the records)
545  Console.WriteLine( "\nFlushing any remaining records." );
546  ingestor.flush();
547  } // end TestAllTypesAllShard()
548 
549 
550 
551  private static void TestAllTypesIpRegex3Shard0Pk( string serverUrl, Kinetica.Options serverOptions )
552  {
553  // Establish a connection with Kinetica
554  Kinetica kdb = new( serverUrl, serverOptions );
555 
556  Console.WriteLine( "\n\n" );
557  Console.WriteLine( "Test Multihead Ingest with a Regex Given for Worker IP Addresses (3 shard keys, no PKs)" );
558  Console.WriteLine( "=======================================================================================" );
559  Console.WriteLine();
560 
561  // Create a type for our record_type_1 class
562  // Add some interesting properties for some of the data types
563  Dictionary<string, IList<string>> column_properties = new()
564  {
565  { "i", [ColumnProperty.SHARD_KEY] },
566  { "d", [ColumnProperty.SHARD_KEY] },
567  { "i16", [ColumnProperty.SHARD_KEY] }
568  };
569 
570  // Create the KineticaType object which facilitates creating types in the database
571  KineticaType recordAllType = KineticaType.fromClass( typeof( RecordTypeAll ), column_properties );
572 
573  // Create the type in the database
574  string recordAllTypeId = recordAllType.create( kdb );
575 
576  string tableName = "csharp_test_table_3s0pk";
577  // Clear any previously made table with the same name
578  Console.WriteLine($"Clearing any existing table named '{tableName}'...");
579  kdb.clearTable(tableName, "", new Dictionary<string, string> { [ClearTableRequest.Options.NO_ERROR_IF_NOT_EXISTS] = ClearTableRequest.Options.TRUE });
580 
581  // Create a table of the given type
582  Console.WriteLine( $"Creating table named '{tableName}'...\n" );
583  kdb.createTable( tableName, recordAllTypeId );
584 
585  // Create the ingestor
586  int batchSize = 100;
587  // Note: May need to adjust the regex for this test to pass
588  Regex ipRegex = new( "127.0.*" );
589  kinetica.Utils.WorkerList workerList = new( kdb, ipRegex );
590  KineticaIngestor<RecordTypeAll> ingestor = new( kdb, tableName, batchSize, recordAllType, null, workerList );
591 
592  // Generate data to be inserted
593  int totalRecords = batchSize * 5;
594  List<RecordTypeAll> records = [];
595  Random rng = new();
596  double nullProbability = 0.2;
597  for ( int i = 0; i < totalRecords; ++i )
598  {
599  // Restricting string length to 256
600  int max_str_len = rng.Next( 0, 256 );
601  RecordTypeAll record = new()
602  {
603  i = rng.Next(),
604  i8 = rng.Next(),
605  i16 = rng.Next(),
606  l = (long)rng.Next(),
607  f = (float)(rng.NextDouble() * rng.Next()),
608  d = ( rng.NextDouble() < nullProbability ) ? null : ( double? ) ( rng.NextDouble() * rng.Next() ),
609  s = System.IO.Path.GetRandomFileName().Truncate( max_str_len ),
610  c1 = System.IO.Path.GetRandomFileName().Truncate( 1 ),
611  c2 = System.IO.Path.GetRandomFileName().Truncate( 2 ),
612  c4 = System.IO.Path.GetRandomFileName().Truncate( 4 ),
613  c8 = System.IO.Path.GetRandomFileName().Truncate( 8 ),
614  c16 = System.IO.Path.GetRandomFileName().Truncate( 16 ),
615  c32 = System.IO.Path.GetRandomFileName().Truncate( 32 ),
616  c64 = System.IO.Path.GetRandomFileName().Truncate( 64 ),
617  c128 = System.IO.Path.GetRandomFileName().Truncate( 128 ),
618  c256 = System.IO.Path.GetRandomFileName().Truncate( 256 ),
619  date = Test.GenerateDate( rng ),
620  datetime = Test.GenerateDateTime( rng ),
621  decimal_ = Test.GenerateDecimal( rng ),
622  ipv4 = Test.GenerateIpv4( rng ),
623  time = Test.GenerateTime( rng ),
624  timestamp = (long) rng.Next()
625  };
626 
627  //Console.WriteLine( record.ToString() ); // debug~~~~~~~~
628  records.Add( record );
629  } // end for loop
630 
631  Console.WriteLine( $"Generated {totalRecords} records." );
632 
633  // Insert the records into the ingestor
634  Console.WriteLine( $"Inserting {totalRecords} records..." );
635  ingestor.insert( records );
636 
637  // Flush the ingestor (which actually inserts the records)
638  Console.WriteLine( "\nFlushing any remaining records." );
639  ingestor.flush();
640  } // end TestAllTypesIpRegex3Shard0Pk()
641 
642 
643 
644 
645  private static void TestAllTypes3Pk3Shard( string serverUrl, Kinetica.Options serverOptions )
646  {
647  // Establish a connection with Kinetica
648  Kinetica kdb = new( serverUrl, serverOptions );
649 
650  Console.WriteLine( "\n\n" );
651  Console.WriteLine( "Test Multihead Ingest: One column per Type; 3 Primary Keys, 3 Shard Keys" );
652  Console.WriteLine( "========================================================================" );
653  Console.WriteLine();
654 
655  // Create a type for our record_type_1 class
656  // Add some interesting properties for some of the data types
657  IDictionary<string, IList<string>> column_properties = new Dictionary<string, IList<string>>
658  {
662  };
663 
664  // Create the KineticaType object which facilitates creating types in the database
665  KineticaType recordAllType = KineticaType.fromClass( typeof( RecordTypeAll ), column_properties );
666 
667  // Create the type in the database
668  string recordAllTypeId = recordAllType.create( kdb );
669 
670  string tableName = "csharp_test_table_3s3pk";
671  // Clear any previously made table with the same name
672  Console.WriteLine($"Clearing any existing table named '{tableName}'...");
673  kdb.clearTable(tableName, "", new Dictionary<string, string> { [ClearTableRequest.Options.NO_ERROR_IF_NOT_EXISTS] = ClearTableRequest.Options.TRUE });
674 
675  // Create a table of the given type
676  Console.WriteLine( $"Creating table named '{tableName}'...\n");
677  kdb.createTable( tableName, recordAllTypeId );
678 
679  // Create the ingestor
680  int batchSize = 100;
681  KineticaIngestor<RecordTypeAll> ingestor = new( kdb, tableName, batchSize, recordAllType );
682 
683  // Generate data to be inserted
684  int totalRecords = batchSize * 50;
685  Random rng = new();
686  double nullProbability = 0.2;
687  for ( int i = 0; i < totalRecords; ++i )
688  {
689  // Restricting string length to 256
690  int maxStringLength = rng.Next( 0, 256 );
691  RecordTypeAll record = new()
692  {
693  i = rng.Next(),
694  i8 = rng.Next(),
695  i16 = rng.Next(),
696  l = (long)rng.Next(),
697  f = (float)(rng.NextDouble() * rng.Next()),
698  d = ( rng.NextDouble() < nullProbability ) ? null : ( double? ) ( rng.NextDouble() * rng.Next() ),
699  s = System.IO.Path.GetRandomFileName().Truncate( maxStringLength ),
700  c1 = System.IO.Path.GetRandomFileName().Truncate( 1 ),
701  c2 = System.IO.Path.GetRandomFileName().Truncate( 2 ),
702  c4 = System.IO.Path.GetRandomFileName().Truncate( 4 ),
703  c8 = System.IO.Path.GetRandomFileName().Truncate( 8 ),
704  c16 = System.IO.Path.GetRandomFileName().Truncate( 16 ),
705  c32 = System.IO.Path.GetRandomFileName().Truncate( 32 ),
706  c64 = System.IO.Path.GetRandomFileName().Truncate( 64 ),
707  c128 = System.IO.Path.GetRandomFileName().Truncate( 128 ),
708  c256 = System.IO.Path.GetRandomFileName().Truncate( 256 ),
709  date = Test.GenerateDate( rng ),
710  datetime = Test.GenerateDateTime( rng ),
711  decimal_ = Test.GenerateDecimal( rng ),
712  ipv4 = Test.GenerateIpv4( rng ),
713  time = Test.GenerateTime( rng ),
714  timestamp = (long) rng.Next()
715  };
716 
717  ingestor.insert( record );
718  } // end for loop
719 
720  Console.WriteLine( $"Generated {totalRecords} records." );
721 
722  // Flush the ingestor (which actually inserts the records)
723  Console.WriteLine( "Flushing any remaining records..." );
724  ingestor.flush();
725  } // end TestAllTypes3Pk3Shard()
726 
727 
728 
729  private static void TestAllTypes3Pk0Shard( string serverUrl, Kinetica.Options serverOptions )
730  {
731  // Establish a connection with Kinetica
732  Kinetica kdb = new( serverUrl, serverOptions );
733 
734  Console.WriteLine( "\n\n" );
735  Console.WriteLine( "Test Multihead Ingest: One column per type; 3 Primary Keys, No Shard Key" );
736  Console.WriteLine( "========================================================================" );
737  Console.WriteLine();
738 
739  // Create a type for our record_type_1 class
740  // Add some interesting properties for some of the data types
741  Dictionary<string, IList<string>> column_properties = new()
742  {
743  { "l", [ColumnProperty.PRIMARY_KEY] },
744  { "date", [ColumnProperty.PRIMARY_KEY] },
745  { "time", [ColumnProperty.PRIMARY_KEY] }
746  };
747 
748  // Create the KineticaType object which facilitates creating types in the database
749  KineticaType recordAllType = KineticaType.fromClass( typeof( RecordTypeAll ), column_properties );
750 
751  // Create the type in the database
752  string recordAllTypeId = recordAllType.create( kdb );
753 
754  string tableName = "csharp_test_table_0s3pk";
755  // Clear any previously made table with the same name
756  Console.WriteLine($"Clearing any existing table named '{tableName}'...");
757  kdb.clearTable(tableName, "", new Dictionary<string, string> { [ClearTableRequest.Options.NO_ERROR_IF_NOT_EXISTS] = ClearTableRequest.Options.TRUE });
758 
759  // Create a table of the given type
760  Console.WriteLine( $"Creating table named '{tableName}'...\n" );
761  kdb.createTable( tableName, recordAllTypeId );
762 
763  // Create the ingestor
764  int batchSize = 100;
765  KineticaIngestor<RecordTypeAll> ingestor = new( kdb, tableName, batchSize, recordAllType );
766 
767  // Generate data to be inserted
768  int totalRecords = batchSize * 50;
769  Random rng = new();
770  double nullProbability = 0.2;
771  for ( int i = 0; i < totalRecords; ++i )
772  {
773  // Restricting string length to 256
774  int maxStringLength = rng.Next( 0, 256 );
775  RecordTypeAll record = new()
776  {
777  i = rng.Next(),
778  i8 = rng.Next(),
779  i16 = rng.Next(),
780  l = (long)rng.Next(),
781  f = (float)(rng.NextDouble() * rng.Next()),
782  d = ( rng.NextDouble() < nullProbability ) ? null : ( double? ) ( rng.NextDouble() * rng.Next() ),
783  s = System.IO.Path.GetRandomFileName().Truncate( maxStringLength ),
784  c1 = System.IO.Path.GetRandomFileName().Truncate( 1 ),
785  c2 = System.IO.Path.GetRandomFileName().Truncate( 2 ),
786  c4 = System.IO.Path.GetRandomFileName().Truncate( 4 ),
787  c8 = System.IO.Path.GetRandomFileName().Truncate( 8 ),
788  c16 = System.IO.Path.GetRandomFileName().Truncate( 16 ),
789  c32 = System.IO.Path.GetRandomFileName().Truncate( 32 ),
790  c64 = System.IO.Path.GetRandomFileName().Truncate( 64 ),
791  c128 = System.IO.Path.GetRandomFileName().Truncate( 128 ),
792  c256 = System.IO.Path.GetRandomFileName().Truncate( 256 ),
793  date = Test.GenerateDate( rng ),
794  datetime = Test.GenerateDateTime( rng ),
795  decimal_ = Test.GenerateDecimal( rng ),
796  ipv4 = Test.GenerateIpv4( rng ),
797  time = Test.GenerateTime( rng ),
798  timestamp = (long) rng.Next()
799  };
800 
801  ingestor.insert( record );
802  } // end for loop
803 
804  Console.WriteLine( $"Generated {totalRecords} records." );
805 
806  // Flush the ingestor (which actually inserts the records)
807  Console.WriteLine( "Flushing any remaining records..." );
808  ingestor.flush();
809  } // end TestAllTypes3Pk0Shard()
810 
811 
812 
813  private static void TestRecordRetrievalByKey(string serverUrl, Kinetica.Options serverOptions)
814  {
815  // Establish a connection with Kinetica
816  Kinetica kdb = new(serverUrl, serverOptions);
817 
818  Console.WriteLine("\n\n");
819  Console.WriteLine("Test Multihead Key Lookup: One column per Type; one numeric and one string");
820  Console.WriteLine("shard key (no primary key)");
821  Console.WriteLine("==========================================================================");
822  Console.WriteLine();
823 
824  Console.WriteLine("Creating a type with all column types (all are nullable; one numeric and one string shard columns)...\n");
825 
826  // Create a type for our record_type_1 class
827  // Add some interesting properties for some of the data types
828  Dictionary<string, IList<string>> column_properties = new()
829  {
830  { "i", [] },
832  { "i16", [ColumnProperty.INT16] },
833  { "d", [] },
834  { "f", [] },
835  { "l", [ColumnProperty.NULLABLE] },
836  { "s", [ColumnProperty.NULLABLE] },
847  { "datetime", [ColumnProperty.NULLABLE, ColumnProperty.DATETIME] },
848  { "decimal_", [ColumnProperty.NULLABLE, ColumnProperty.DECIMAL] },
851  { "timestamp", [ColumnProperty.NULLABLE, ColumnProperty.TIMESTAMP] }
852  };
853 
854  // Create the KineticaType object which facilitates creating types in the database
855  KineticaType recordAllType = KineticaType.fromClass(typeof(RecordTypeAll), column_properties);
856 
857  // Create the type in the database
858  string recordAllTypeId = recordAllType.create(kdb);
859 
860  string tableName = "csharp_test_record_retrieval_by_key";
861 
862  // Clear any previously made table with the same name
863  Console.WriteLine($"Clearing any existing table named '{tableName}'...");
864  kdb.clearTable(tableName, "", new Dictionary<string, string> { [ClearTableRequest.Options.NO_ERROR_IF_NOT_EXISTS] = ClearTableRequest.Options.TRUE });
865 
866  // Create a table of the given type
867  Console.WriteLine($"Creating table named '{tableName}'...\n");
868  kdb.createTable(tableName, recordAllTypeId);
869 
870  // Create indices on the shard columns (6.2 limitation for key lookup)
871  kdb.alterTable(tableName, "create_index", "i8");
872  kdb.alterTable(tableName, "create_index", "c1");
873 
874  // Create the ingestor
875  int batchSize = 1000;
876  KineticaIngestor<RecordTypeAll> ingestor = new(kdb, tableName, batchSize, recordAllType);
877 
878  // Generate data to be inserted
879  // Note that the current sharded columns (i8 and c1) will not
880  // get nulls since in 6.2, Kinetica does not support nulls for
881  // key lookup
882  int totalRecords = batchSize * 10;
883  Console.WriteLine($"Starting to generate {totalRecords} records...");
884  List<RecordTypeAll> records = [];
885  Random rng = new();
886  double nullProbability = 0.15; // 15% chance of creating nulls
887  double shardNullProbability = 0; // in 6.2, key lookup can't handle nulls
888  for (int i = 0; i < totalRecords; ++i)
889  {
890  // Restricting string length to 256
891  int maxStringLength = rng.Next(0, 256);
892  RecordTypeAll record = new()
893  {
894  i = (rng.NextDouble() < nullProbability) ? null : (int?)rng.Next(),
895  i8 = (rng.NextDouble() < shardNullProbability) ? null : (int?)rng.Next(110, 128), // Limiting the range in order to get multiple records per shard key
896  //i8 = ( rng.NextDouble() < shardNullProbability ) ? null : (int?) rng.Next( -128, 128 ), // upper exclusive
897  i16 = (rng.NextDouble() < nullProbability) ? null : (int?)rng.Next(-32768, 32768), // upper exclusive
898  l = (long)rng.Next(),
899  //l = ( rng.NextDouble() < nullProbability ) ? null : (long)rng.Next(), // can't be made nullable if not declared as long?
900  f = (rng.NextDouble() < nullProbability) ? null : (float?)(rng.NextDouble() * rng.Next()),
901  d = (rng.NextDouble() < nullProbability) ? null : (double?)(rng.NextDouble() * rng.Next()),
902  s = (rng.NextDouble() < nullProbability) ? null : System.IO.Path.GetRandomFileName().Truncate(maxStringLength),
903  c1 = (rng.NextDouble() < shardNullProbability) ? null : System.IO.Path.GetRandomFileName().Truncate(1),
904  c2 = (rng.NextDouble() < nullProbability) ? null : System.IO.Path.GetRandomFileName().Truncate(2),
905  c4 = (rng.NextDouble() < nullProbability) ? null : System.IO.Path.GetRandomFileName().Truncate(rng.Next(0, 5)), // any size between empty string to 4 length
906  c8 = (rng.NextDouble() < nullProbability) ? null : System.IO.Path.GetRandomFileName().Truncate(rng.Next(0, 9)), // any size between empty string to 8 length
907  c16 = (rng.NextDouble() < nullProbability) ? null : System.IO.Path.GetRandomFileName().Truncate(rng.Next(0, 17)), // any size between empty string to 16 length
908  c32 = (rng.NextDouble() < nullProbability) ? null : System.IO.Path.GetRandomFileName().Truncate(rng.Next(5, 33)), // any size between [5, 32] in length
909  c64 = (rng.NextDouble() < nullProbability) ? null : System.IO.Path.GetRandomFileName().Truncate(rng.Next(10, 65)), // any size between [10, 64] in length
910  c128 = (rng.NextDouble() < nullProbability) ? null : System.IO.Path.GetRandomFileName().Truncate(rng.Next(10, 129)), // any size between [10, 128] in length
911  c256 = (rng.NextDouble() < nullProbability) ? null : System.IO.Path.GetRandomFileName().Truncate(rng.Next(25, 257)), // any size between [25, 256] in length
912  date = (rng.NextDouble() < nullProbability) ? null : Test.GenerateDate(rng),
913  datetime = (rng.NextDouble() < nullProbability) ? null : Test.GenerateDateTime(rng),
914  decimal_ = (rng.NextDouble() < nullProbability) ? null : Test.GenerateDecimal(rng),
915  ipv4 = (rng.NextDouble() < nullProbability) ? null : Test.GenerateIpv4(rng),
916  time = (rng.NextDouble() < nullProbability) ? null : Test.GenerateTime(rng),
917  timestamp = (rng.NextDouble() < nullProbability) ? null : ((long?)rng.Next(-306102240, 293795424) * rng.Next(100000))
918  };
919 
920  //Console.WriteLine( "#" + i + ": " + record.ToString() + "\n" ); // debug~~~~~~~~
921  records.Add(record);
922  ingestor.insert(record);
923  } // end for loop
924 
925  Console.WriteLine($"Generated {totalRecords} records.\n");
926 
927  // Flush the ingestor (which actually inserts the records)
928  Console.WriteLine("Flushing any remaining records...");
929  ingestor.flush();
930 
931  // Look up records by any key
932  Console.WriteLine("Creating the record retriever...");
933  RecordRetriever<RecordTypeAll> retriever = new(kdb, tableName, recordAllType);
934  Console.WriteLine("Attempting record retrieval...");
935  GetRecordsResponse<RecordTypeAll> response = retriever.getRecordsByKey(records[0]);
936  Console.WriteLine("Number of records fetched: {0}", response.total_number_of_records);
937  Console.WriteLine("Records fetched: ");
938  foreach (var record in response.data)
939  Console.WriteLine(record.ToString());
940 
941  Console.WriteLine($"Are there more records to fetch?: {response.has_more_records}\n");
942  } // end TestRecordRetrievalByKey()
943 
944 
945 
946  public static void TestJdbc(string serverUrl, Kinetica.Options serverOptions, string? jdbcDriverPath)
947  {
948  Console.WriteLine("\n\n");
949  Console.WriteLine("JDBC Bridge Test");
950  Console.WriteLine("================");
951  Console.WriteLine();
952 
953  if (jdbcDriverPath == null)
954  Console.WriteLine("Skipping--JDBC driver JAR not passed");
955  else
956  {
957  string jdbcUrl = $"jdbc:kinetica:URL={serverUrl};UID={serverOptions.Username};PWD={serverOptions.Password}";
958 
959  var builder = new JdbcConnectionStringBuilder
960  {
961  DriverPath = jdbcDriverPath,
962  DriverClass = "com.kinetica.jdbc.Driver",
963  JdbcUrl = jdbcUrl
964  };
965 
966  Console.WriteLine($"JDBC URL: {jdbcUrl}");
967  using var connection = new JdbcConnection(builder);
968  connection.Open();
969  string? rows = connection.CreateCommand("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'information_schema'").ExecuteScalar().ToString();
970  Console.WriteLine($"Connection successful! {rows} tables in INFORMATION_SCHEMA.\n");
971  }
972  }
973 
974 
975 
981  public static string GenerateDate( Random rng )
982  {
983  int pastRange = -90 * 365; //980 years
984  int futureRange = 20 * 365; // 20 years
985  int offset = rng.Next( pastRange, futureRange );
986  DateTime randomDate = DateTime.Today.AddDays( offset );
987  return String.Format( "{0:yyyy-MM-dd}", randomDate );
988  } // end GenerateDate
989 
990 
991 
997  public static string GenerateDateTime( Random rng )
998  {
999  int year = rng.Next(1900, 2500);
1000  int month = rng.Next(1, 12);
1001  int day = rng.Next(1, 28);
1002  int hour = rng.Next(0, 23);
1003  int minute = rng.Next(0, 59);
1004  int second = rng.Next(0, 59);
1005  int msecond = rng.Next(0, 999);
1006 
1007  DateTime randomDateTime = new( year, month, day, hour, minute, second, msecond );
1008 
1009  // We don't have to have any time component
1010  int timeChancePercent = 90;
1011  if (rng.Next(101) > timeChancePercent)
1012  return String.Format("{0:yyyy-MM-dd}", randomDateTime);
1013  else
1014  {
1015  // Don't have to have the millisecond
1016  int numMsDigits = rng.Next(7);
1017  return numMsDigits switch
1018  {
1019  0 => String.Format("{0:yyyy-MM-dd HH:mm:ss}", randomDateTime),
1020  1 => String.Format("{0:yyyy-MM-dd HH:mm:ss.F}", randomDateTime),
1021  2 => String.Format("{0:yyyy-MM-dd HH:mm:ss.FF}", randomDateTime),
1022  3 => String.Format("{0:yyyy-MM-dd HH:mm:ss.FFF}", randomDateTime),
1023  4 => String.Format("{0:yyyy-MM-dd HH:mm:ss.FFFF}", randomDateTime),
1024  5 => String.Format("{0:yyyy-MM-dd HH:mm:ss.FFFFF}", randomDateTime),
1025  _ => String.Format("{0:yyyy-MM-dd HH:mm:ss.FFFFFF}", randomDateTime),
1026  };
1027  }
1028  } // end GenerateDateTime
1029 
1030 
1031 
1032  private static readonly string numbers = "0123456789";
1033 
1040  public static string GenerateDecimal( Random rng )
1041  {
1042  // Using up to 14 integral digits to keep things simple since the decimal
1043  // range is [-922337203685477.5808, 922337203685477.5807]
1044  string precision = new([.. Enumerable.Repeat( '1', rng.Next( 15 ) ).Select( i => Test.numbers[ rng.Next( numbers.Length ) ] )]);
1045  string scale = rng.Next( 0, 10000 ).ToString();
1046  string sign = (rng.Next(2) == 0 && Double.Parse(precision + "." + scale) != 0) ? "-" : "";
1047  return ( sign + precision + "." + scale );
1048  } // end GenerateDecimal
1049 
1050 
1051 
1057  public static string GenerateIpv4( Random rng )
1058  {
1059  string n1 = rng.Next( 256 ).ToString();
1060  string n2 = rng.Next( 256 ).ToString();
1061  string n3 = rng.Next( 256 ).ToString();
1062  string n4 = rng.Next( 256 ).ToString();
1063  string dot = ".";
1064  return ( n1 + dot + n2 + dot + n3 + dot + n4 );
1065  } // end generate_ipv4
1066 
1067 
1068 
1074  public static string GenerateTime( Random rng )
1075  {
1076  int maxMiliseconds = 86400000;
1077  DateTime time = DateTime.Today;
1078  time = time.Add( TimeSpan.FromMilliseconds( rng.Next( maxMiliseconds ) ) );
1079  string time_str;
1080  if ( (time.Millisecond > 0) && (rng.Next( 1, 6 ) > 3) ) // two in five will get the milliseconds
1081  time_str = String.Format( "{0:HH}:{0:mm}:{0:ss}.{0:FFF}", time );
1082  else
1083  time_str = String.Format( "{0:HH}:{0:mm}:{0:ss}", time );
1084  return time_str;
1085  } // end GenerateTime
1086 
1087 
1088  } // end class Test
1089 } // end namespace Test
A list of worker URLs to use for multi-head ingest.
Definition: WorkerList.cs:11
const string CHAR1
This property provides optimized memory, disk and query performance for string columns.
DeleteRecordsResponse deleteRecords(DeleteRecordsRequest request_)
Deletes record(s) matching the provided criteria from the given table.
const string DATETIME
Valid only for 'string' columns.
static void TestJdbc(string serverUrl, Kinetica.Options serverOptions, string? jdbcDriverPath)
Definition: Test.cs:946
const string INT16
This property provides optimized memory and query performance for int columns.
void insert(T record)
Queues a record for insertion into Kinetica.
const string PRIMARY_KEY
This property indicates that this column will be part of (or the entire) primary key.
const string CHAR128
This property provides optimized memory, disk and query performance for string columns.
void SetKineticaSourceClassToTypeMapping(Type? objectType, KineticaType kineticaType)
Saves an object class type to a KineticaType association.
Definition: Kinetica.cs:203
static string GenerateIpv4(Random rng)
Generate a random IPv4 address.
Definition: Test.cs:1057
IList< KineticaRecord > data
Avro binary encoded response.
CreateTableResponse createTable(CreateTableRequest request_)
Creates a new table.
A set of parameters for Kinetica.clearTable.
Definition: ClearTable.cs:19
static void ProcessArgs(string []args, out Kinetica.Options? options, out string? jdbcDriverPath)
Definition: Test.cs:97
ShowSecurityResponse showSecurity(ShowSecurityRequest request_)
Shows security information relating to users and/or roles.
ExecuteSqlResponse executeSql(ExecuteSqlRequest request_)
Execute a SQL statement (query, DML, or DDL).
static string GenerateDecimal(Random rng)
Generate a random decimal value (up to 15 digits of precision and up to four digits of scale).
Definition: Test.cs:1040
Column properties used for Kinetica types.
ShowSystemStatusResponse showSystemStatus(ShowSystemStatusRequest request_)
Provides server configuration and health related status to the caller.
A set of results returned by Kinetica.updateRecords.
const string TIMESTAMP
Valid only for 'long' columns.
const string CHAR16
This property provides optimized memory, disk and query performance for string columns.
Extension to string that has a truncate function.
Definition: Test.cs:19
const string CHAR64
This property provides optimized memory, disk and query performance for string columns.
A set of results returned by Kinetica.deleteRecords.
const string CHAR4
This property provides optimized memory, disk and query performance for string columns.
const string CHAR2
This property provides optimized memory, disk and query performance for string columns.
const string DATE
Valid only for 'string' columns.
const string CHAR8
This property provides optimized memory, disk and query performance for string columns.
const string DECIMAL
Valid only for 'string' columns.
IList< T > data
If the encoding was 'binary', then this list contains the binary encoded records retrieved from the t...
Definition: GetRecords.cs:478
A set of string constants for the parameter options.
Definition: ClearTable.cs:24
static string GenerateDateTime(Random rng)
Generate a random datetime.
Definition: Test.cs:997
const string CHAR32
This property provides optimized memory, disk and query performance for string columns.
Connection Options
Definition: Kinetica.cs:50
const string IPV4
This property provides optimized memory, disk and query performance for string columns representing I...
GetRecordsResponse< T > getRecordsByKey(T record, string expression=null)
Retrieves records for a given shard key, optionally further limited by an additional expression.
CreateUserInternalResponse createUserInternal(CreateUserInternalRequest request_)
Creates a new internal user (a user whose credentials are managed by the database system).
ClearTableResponse clearTable(ClearTableRequest request_)
Clears (drops) one or all tables in the database cluster.
Definition: Test.cs:14
DeleteUserResponse deleteUser(DeleteUserRequest request_)
Deletes an existing user.
Manages the insertion into GPUdb of large numbers of records in bulk, with automatic batch management...
const string CHAR256
This property provides optimized memory, disk and query performance for string columns.
static KineticaType fromClass(Type recordClass, IDictionary< string, IList< string >> properties=null)
Create a KineticaType object from properties of a record class and Kinetica column properties.
const string SHARD_KEY
This property indicates that this column will be part of (or the entire) shard key.
AlterTableResponse alterTable(AlterTableRequest request_)
Apply various modifications to a table or view.
IDictionary< string, string > status_map
A map of server configuration and health related status.
static string GenerateDate(Random rng)
Generate a random date.
Definition: Test.cs:981
long total_number_of_records
Total/Filtered number of records.
Definition: GetRecords.cs:481
const string INT8
This property provides optimized memory and query performance for int columns.
static string Truncate(this string value, int maxLength)
Definition: Test.cs:21
string create(Kinetica kinetica)
Given a handle to the server, creates a type in the database based on this data type.
IDictionary< string, string > types
Map of user/role name to the type of that user/role.
GetRecordsByColumnResponse getRecordsByColumn(GetRecordsByColumnRequest request_)
For a given table, retrieves the values from the requested column(s).
const string NO_ERROR_IF_NOT_EXISTS
If TRUE and if the table specified in table_name does not exist no error is returned.
Definition: ClearTable.cs:40
const string TIME
Valid only for 'string' columns.
static string GenerateTime(Random rng)
Generate a random time of the format HH:MM:SS[.mmm].
Definition: Test.cs:1074
const string NULLABLE
This property indicates that this column is nullable.
A set of results returned by Kinetica.getRecords.
Definition: GetRecords.cs:462
API to talk to Kinetica Database
Definition: Kinetica.cs:40
Manages the insertion into GPUdb of large numbers of records in bulk, with automatic batch management...
void flush()
Ensures that all queued records are inserted into Kinetica.