Skip to content

Commit

Permalink
Merge pull request #41 from eedalong/feature/dynamic_type
Browse files Browse the repository at this point in the history
Feature/dynamic type
  • Loading branch information
eedalong committed Apr 28, 2021
2 parents 9751bc5 + 5e6ce89 commit 2e8f4cb
Show file tree
Hide file tree
Showing 18 changed files with 834 additions and 2,474 deletions.
737 changes: 0 additions & 737 deletions client/Session.cs

This file was deleted.

244 changes: 123 additions & 121 deletions client/SessionPool.cs

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions client/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ namespace iotdb_client_csharp.client
public class Test
{
static void Main(){
// Unit Test
UnitTest unit_test = new UnitTest();
unit_test.Test();

// session test
SessionTest session_test = new SessionTest();
session_test.Test();

// Session Async Test
SessionPoolTest session_pool_test = new SessionPoolTest();
session_pool_test.Test();
Expand Down
901 changes: 0 additions & 901 deletions client/tests/SessionTest.cs

This file was deleted.

509 changes: 370 additions & 139 deletions client/tests/SessioonPoolTest.cs

Large diffs are not rendered by default.

107 changes: 0 additions & 107 deletions client/tests/UnitTest.cs

This file was deleted.

2 changes: 0 additions & 2 deletions client/utils/Client.cs → client/utils/Concurent/Client.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Thrift;
using Thrift.Protocol;
using Thrift.Transport;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using System;
using iotdb_client_csharp.client.utils;

namespace iotdb_client_csharp.client.utils
{
Expand Down
106 changes: 106 additions & 0 deletions client/utils/DataStructure/RowRecord.cs
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;
}




}
}
Loading

0 comments on commit 2e8f4cb

Please sign in to comment.