Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion samples/Apache.IoTDB.Samples/TableSessionPoolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public async Task Test()

await TestSelectAndInsert();
await TestUseDatabase();
// await TestCleanup();
await TestInsertWithNull();
await TestCleanup();
}


Expand Down Expand Up @@ -161,6 +162,87 @@ public async Task TestUseDatabase()
await tableSessionPool.Close();
}

public async Task TestInsertWithNull()
{
var tableName = "t1";

var tableSessionPool = new TableSessionPool.Builder()
.SetNodeUrls(sessionPoolTest.nodeUrls)
.SetUsername(sessionPoolTest.username)
.SetPassword(sessionPoolTest.password)
.SetFetchSize(1024)
.SetDatabase("test1")
.Build();

await tableSessionPool.Open(false);

if (sessionPoolTest.debug) tableSessionPool.OpenDebugMode();

await tableSessionPool.ExecuteNonQueryStatementAsync(
"create table " + tableName + "(" +
"t1 STRING TAG," +
"f1 DATE FIELD)");

List<string> columnNames =
new List<string> {
"t1",
"f1" };
List<TSDataType> dataTypes =
new List<TSDataType>{
TSDataType.STRING,
TSDataType.DATE};
List<ColumnCategory> columnCategories =
new List<ColumnCategory>{
ColumnCategory.TAG,
ColumnCategory.FIELD};
var timestamps = new List<long>
{
0L,
1L,
2L,
3L,
4L,
5L,
6L,
7L,
8L,
9L
};
var values = new List<List<object>> { };
values.Add(new List<object> { "t1", DateTime.Parse("2024-08-15") });
values.Add(new List<object> { "t1", DateTime.Parse("2024-08-15") });
values.Add(new List<object> { "t1", DateTime.Parse("2024-08-15") });
values.Add(new List<object> { "t1", DateTime.Parse("2024-08-15") });
values.Add(new List<object> { "t1", DateTime.Parse("2024-08-15") });
values.Add(new List<object> { "t1", null });
values.Add(new List<object> { "t1", null });
values.Add(new List<object> { "t1", null });
values.Add(new List<object> { "t1", null });
values.Add(new List<object> { "t1", null });
var tablet = new Tablet(tableName, columnNames, columnCategories, dataTypes, values, timestamps);

await tableSessionPool.InsertAsync(tablet);


var res = await tableSessionPool.ExecuteQueryStatementAsync("select count(*) from " + tableName + " where f1 is null");
while (res.HasNext())
{
var row = res.Next();
Console.WriteLine(row);
var value = row.Values[0];
if (value is long longValue)
{
if (longValue != 5)
{
throw new Exception("Expected value is 5, but got " + longValue);
}
}
}
await res.Close();

await tableSessionPool.Close();
}

public async Task TestCleanup()
{
var tableSessionPool = new TableSessionPool.Builder()
Expand Down
4 changes: 2 additions & 2 deletions src/Apache.IoTDB/DataStructure/BitMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#endif
public class BitMap
{
private static byte[] BIT_UTIL = new byte[] { 1, 2, 4, 8, 16, 32, 64, 255 };
private static byte[] BIT_UTIL = new byte[] { 1, 2, 4, 8, 16, 32, 64, unchecked((byte)-128) };
private static byte[] UNMARK_BIT_UTIL =
new byte[] {
(byte) 0XFE, // 11111110
Expand Down Expand Up @@ -94,7 +94,7 @@ public void mark(int position)
public void reset()
{
#if NET461_OR_GREATER || NETSTANDARD2_0
bits.Fill((byte)0xFF);
bits.Fill((byte)0);
#else
Array.Fill(bits, (byte)0);
#endif
Expand Down
4 changes: 3 additions & 1 deletion src/Apache.IoTDB/DataStructure/Tablet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ namespace Apache.IoTDB.DataStructure
*/
public class Tablet
{

private static int EMPTY_DATE_INT = 10000101;
private readonly List<long> _timestamps;
private readonly List<List<object>> _values;

Expand Down Expand Up @@ -434,7 +436,7 @@ public byte[] GetBinaryValues()
for (int j = 0; j < RowNumber; j++)
{
var value = _values[j][i];
buffer.AddInt(value != null ? Utils.ParseDateToInt((DateTime)value) : int.MinValue);
buffer.AddInt(value != null ? Utils.ParseDateToInt((DateTime)value) : EMPTY_DATE_INT);
}
break;
}
Expand Down
Loading