4 using System.Collections.Generic;
14 public class KineticaRecord :
Avro.Generic.GenericRecord
24 System.Text.StringBuilder sb =
new System.Text.StringBuilder();
25 sb.Append(
"Contents: " );
33 sb.Append( field.Name );
39 value_string = $
"{value}";
41 value_string =
"<null>";
44 sb.Append( value_string );
47 sb.Remove( (sb.Length - 2), 2 );
62 Schema dynamic_table_schema;
65 dynamic_table_schema =
Avro.
Schema.
Parse( dynamic_table_schema_string );
67 catch ( Exception ex )
73 IList<KineticaRecord> records =
new List<KineticaRecord>();
77 using ( var ms =
new MemoryStream( encoded_data ) )
86 object column_headers_0 =
new object();
87 Object[] column_headers =
null;
88 if ( obj.TryGetValue(
"column_headers", out column_headers_0 ) )
90 column_headers = ( Object[] ) column_headers_0;
94 object column_types_0 =
new object();
95 Object[] column_types =
null;
96 if ( obj.TryGetValue(
"column_datatypes", out column_types_0 ) )
98 column_types = ( Object[] ) column_types_0;
102 int num_columns = column_headers.Length;
106 Object[][] encoded_column_data =
new Object[ num_columns ][];
108 for (
int i = 0; i < num_columns; ++i )
111 string column_name = $
"column_{i+1}";
114 object column_data_0 =
new object();
115 Object[] column_data =
null;
116 if ( obj.TryGetValue( column_name, out column_data_0 ) )
118 column_data = ( Object[] ) column_data_0;
122 encoded_column_data[i] = column_data;
127 int num_records = encoded_column_data[0].Length;
130 foreach ( Object[] l
in encoded_column_data )
132 if ( l.Length != num_records )
145 for (
int record_idx = 0; record_idx < num_records; ++record_idx )
151 for (
int column_idx = 0; column_idx < num_columns; ++column_idx )
154 var val = encoded_column_data[ column_idx ][ record_idx ];
157 var field = record_schema.Fields[ column_idx ];
160 record.Add( field.Name, val );
164 records.Add( record );
Schema Schema
Field type's schema
Class for fields defined in a record
The default implementation for the generic reader.
Base class for all schema types
Convenience class for using Avro.Generic.GenericRecord objects.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
KineticaRecord(RecordSchema schema)
The default type used by GenericReader and GenericWriter for RecordSchema.
static KineticaType fromDynamicSchema(string dynamicTableSchemaString, Object[] columnHeaders, Object[] columnTypes)
Create a KineticaType object based on information provided in a dynamic schema.
string ContentsToString()
Convert the contents of the record to a string.
static IList< KineticaRecord > DecodeDynamicTableRecords(string dynamic_table_schema_string, byte[] encoded_data)
Decodes binary encoded data of a dynamically created table returned by the server.
static Schema Parse(string json)
Parses a given JSON string to create a new schema object
bool TryGetValue(string fieldName, out object result)
Decoder for Avro binary format