-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from eedalong/feature/dynamic_type
Feature/dynamic type
- Loading branch information
Showing
18 changed files
with
834 additions
and
2,474 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using Thrift; | ||
using Thrift.Protocol; | ||
using Thrift.Transport; | ||
|
||
|
||
|
2 changes: 0 additions & 2 deletions
2
client/utils/ConcurentClientQueue.cs → ...t/utils/Concurent/ConcurentClientQueue.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
using System.Collections.Generic; | ||
using Thrift; | ||
using System; | ||
namespace iotdb_client_csharp.client.utils | ||
{ | ||
public class RowRecord | ||
{ | ||
public long timestamp{get;set;} | ||
public List<Object> values {get;set;} | ||
public List<string> measurements{get;set;} | ||
public RowRecord(long timestamp, List<Object> values, List<string> measurements){ | ||
this.timestamp = timestamp; | ||
this.values = values; | ||
this.measurements = measurements; | ||
} | ||
public void append(string measurement, Object value){ | ||
values.Add(value); | ||
measurements.Add(measurement); | ||
} | ||
public DateTime get_date_time(){ | ||
return DateTimeOffset.FromUnixTimeMilliseconds(timestamp).DateTime.ToLocalTime();; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
var str = "TimeStamp"; | ||
foreach(var measurement in measurements){ | ||
str += "\t\t"; | ||
str += measurement.ToString(); | ||
} | ||
str += "\n"; | ||
|
||
str += timestamp.ToString(); | ||
foreach(var row_value in values){ | ||
str += "\t\t"; | ||
str += row_value.ToString(); | ||
} | ||
return str; | ||
} | ||
public List<int> get_datatypes(){ | ||
List<int> data_type_values = new List<int>(){}; | ||
foreach(var value in values){ | ||
var value_type = value.GetType(); | ||
if(value_type.Equals(typeof(bool))){ | ||
data_type_values.Add((int)TSDataType.BOOLEAN); | ||
} | ||
else if(value_type.Equals(typeof(Int32))){ | ||
data_type_values.Add((int)TSDataType.INT32); | ||
} | ||
else if(value_type.Equals(typeof(Int64))){ | ||
data_type_values.Add((int)TSDataType.INT64); | ||
} | ||
else if(value_type.Equals(typeof(float))){ | ||
data_type_values.Add((int)TSDataType.FLOAT); | ||
} | ||
else if(value_type.Equals(typeof(double))){ | ||
data_type_values.Add((int)TSDataType.DOUBLE); | ||
} | ||
else if(value_type.Equals(typeof(string))){ | ||
data_type_values.Add((int)TSDataType.TEXT); | ||
} | ||
} | ||
return data_type_values; | ||
|
||
} | ||
public byte[] ToBytes(){ | ||
ByteBuffer buffer = new ByteBuffer(values.Count * 8); | ||
foreach(var value in values){ | ||
if(value.GetType().Equals(typeof(bool))){ | ||
buffer.add_char((char)TSDataType.BOOLEAN); | ||
buffer.add_bool((bool)value); | ||
} | ||
else if((value.GetType().Equals(typeof(Int32)))){ | ||
buffer.add_char((char)TSDataType.INT32); | ||
buffer.add_int((int)value); | ||
} | ||
else if((value.GetType().Equals(typeof(Int64)))){ | ||
buffer.add_char((char)TSDataType.INT64); | ||
buffer.add_long((long)value); | ||
} | ||
else if((value.GetType().Equals(typeof(double)))){ | ||
buffer.add_char((char)TSDataType.DOUBLE); | ||
buffer.add_double((double)value); | ||
} | ||
else if((value.GetType().Equals(typeof(float)))){ | ||
buffer.add_char((char)TSDataType.FLOAT); | ||
buffer.add_float((float)value); | ||
} | ||
else if((value.GetType().Equals(typeof(string)))){ | ||
buffer.add_char((char)TSDataType.TEXT); | ||
buffer.add_str((string)value); | ||
} | ||
else{ | ||
var message = String.Format("Unsupported data type:{0}",value.GetType().ToString()); | ||
throw new TException(message, null); | ||
} | ||
} | ||
var buf = buffer.get_buffer(); | ||
return buf; | ||
} | ||
|
||
|
||
|
||
|
||
} | ||
} |
Oops, something went wrong.