Skip to content

Commit 357307a

Browse files
lausannelfpddmw
andauthored
fix comments (#2)
* add tsblock * develop tsblock and rpcdataset * improve code specifications * develop RpcDataSet api * coding api in SessionDataSet and rpcDataSet * fix bugs & pass test * adapted to IoTDBDataReader * adopted comments * add license and change ubuntu version * format code * fix pull request * fix valueIsNull --------- Co-authored-by: xxhz22 <[email protected]>
1 parent 9c49167 commit 357307a

File tree

12 files changed

+31
-47
lines changed

12 files changed

+31
-47
lines changed

samples/Apache.IoTDB.Samples/SessionPoolTest.AlignedRecord.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public async Task TestInsertAlignedRecords()
218218
while (res.Next())
219219
{
220220
res_count += 1;
221-
Console.WriteLine(res.GetRow());
221+
Console.WriteLine(res.Next());
222222
}
223223

224224
await res.Close();
@@ -299,7 +299,7 @@ public async Task TestInsertAlignedStringRecords()
299299
var res_count = 0;
300300
while (res.Next())
301301
{
302-
Console.WriteLine(res.GetRow());
302+
Console.WriteLine(res.Next());
303303
res_count += 1;
304304
}
305305

samples/Apache.IoTDB.Samples/SessionPoolTest.Record.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public async Task TestInsertStringRecords()
382382
var res_count = 0;
383383
while (res.Next())
384384
{
385-
Console.WriteLine(res.GetRow());
385+
Console.WriteLine(res.Next());
386386
res_count += 1;
387387
}
388388

samples/Apache.IoTDB.Samples/SessionPoolTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ public async Task TestMultiNodeDataFetch()
621621
Console.WriteLine();
622622

623623
var count = 0;
624-
while (res.Next()) count++;
624+
while (res.HasNext()) count++;
625625

626626
Console.WriteLine(count + " " + (fetchSize * processedSize * 4 + 783));
627627
System.Diagnostics.Debug.Assert(count == fetchSize * processedSize * 4 + 783);

samples/Apache.IoTDB.Samples/UtilsTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static public void PrintDataSetByType(SessionDataSet sessionDataSet)
9090
}
9191
Console.WriteLine();
9292

93-
while (sessionDataSet.Next())
93+
while (sessionDataSet.HasNext())
9494
{
9595
for (int i = 0; i < columns.Count; i++)
9696
{
@@ -147,7 +147,7 @@ static public void PrintDataSetByObject(SessionDataSet sessionDataSet)
147147
}
148148
Console.WriteLine();
149149

150-
while (sessionDataSet.Next())
150+
while (sessionDataSet.HasNext())
151151
{
152152
for (int i = 0; i < columns.Count; i++)
153153
{
@@ -169,7 +169,7 @@ static public void PrintDataSetByString(SessionDataSet sessionDataSet)
169169
}
170170
Console.WriteLine();
171171

172-
while (sessionDataSet.Next())
172+
while (sessionDataSet.HasNext())
173173
{
174174
for (int i = 0; i < columns.Count; i++)
175175
{

src/Apache.IoTDB.Data/IoTDBDataReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ public override DataTable GetSchemaTable()
457457
{
458458
if (_dataSet.Next())
459459
{
460-
rowdata = _dataSet.GetRow();
460+
rowdata = _dataSet.Next();
461461
}
462462
var schemaTable = new DataTable("SchemaTable");
463463
if (_metas != null && rowdata != null)

src/Apache.IoTDB/DataStructure/ByteBuffer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public byte[] GetBuffer()
146146
return _buffer[.._writePos];
147147
}
148148

149-
public byte[] GetBytesbyLength(int length)
149+
public byte[] GetBytesByLengthh(int length)
150150
{
151151
if (_readPos + length > _buffer.Length)
152152
throw new ArgumentOutOfRangeException(nameof(length),

src/Apache.IoTDB/DataStructure/Column.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public BinaryColumn(int arrayOffset, int positionCount, bool[] valueIsNull, Bina
175175
ColumnEncoding.BinaryArray,
176176
arrayOffset: arrayOffset,
177177
positionCount: positionCount,
178-
valueIsNull: null,
178+
valueIsNull: valueIsNull,
179179
values: values)
180180
{ }
181181

@@ -193,7 +193,7 @@ public IntColumn(int arrayOffset, int positionCount, bool[] valueIsNull, int[] v
193193
ColumnEncoding.Int32Array,
194194
arrayOffset: arrayOffset,
195195
positionCount: positionCount,
196-
valueIsNull: null,
196+
valueIsNull: valueIsNull,
197197
values: values)
198198
{ }
199199

@@ -211,7 +211,7 @@ public FloatColumn(int arrayOffset, int positionCount, bool[] valueIsNull, float
211211
ColumnEncoding.Int32Array,
212212
arrayOffset: arrayOffset,
213213
positionCount: positionCount,
214-
valueIsNull: null,
214+
valueIsNull: valueIsNull,
215215
values: values)
216216
{ }
217217

@@ -229,7 +229,7 @@ public LongColumn(int arrayOffset, int positionCount, bool[] valueIsNull, long[]
229229
ColumnEncoding.Int64Array,
230230
arrayOffset: arrayOffset,
231231
positionCount: positionCount,
232-
valueIsNull: null,
232+
valueIsNull: valueIsNull,
233233
values: values)
234234
{ }
235235

@@ -247,7 +247,7 @@ public DoubleColumn(int arrayOffset, int positionCount, bool[] valueIsNull, doub
247247
ColumnEncoding.Int64Array,
248248
arrayOffset: arrayOffset,
249249
positionCount: positionCount,
250-
valueIsNull: null,
250+
valueIsNull: valueIsNull,
251251
values: values)
252252
{ }
253253

@@ -265,7 +265,7 @@ public BooleanColumn(int arrayOffset, int positionCount, bool[] valueIsNull, boo
265265
ColumnEncoding.ByteArray,
266266
arrayOffset: arrayOffset,
267267
positionCount: positionCount,
268-
valueIsNull: null,
268+
valueIsNull: valueIsNull,
269269
values: values)
270270
{ }
271271

src/Apache.IoTDB/DataStructure/ColumnDecoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static bool[] DeserializeNullIndicators(ByteBuffer reader, int positionCo
6868
public static bool[] DeserializeBooleanArray(ByteBuffer reader, int size)
6969
{
7070
int packedSize = (size + 7) / 8;
71-
byte[] packedBytes = reader.GetBytesbyLength(packedSize);
71+
byte[] packedBytes = reader.GetBytesByLengthh(packedSize);
7272
if (packedBytes.Length < packedSize)
7373
throw new InvalidDataException(
7474
$"Boolean array decoding failed: expected {packedSize} bytes for {size} bits, but only received {packedBytes.Length} bytes from buffer."
@@ -199,7 +199,7 @@ public Column ReadColumn(ByteBuffer reader, TSDataType dataType, int positionCou
199199
if (nullIndicators != null && nullIndicators[i])
200200
continue;
201201
int length = reader.GetInt();
202-
byte[] value = reader.GetBytesbyLength(length);
202+
byte[] value = reader.GetBytesByLengthh(length);
203203
values[i] = new Binary(value);
204204
}
205205

src/Apache.IoTDB/DataStructure/RpcDataSet.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public async Task Close()
185185

186186
try
187187
{
188-
var status = await _client.ServiceClient.closeOperation(closeRequest);
188+
var status = await _client.ServiceClient.closeOperationAsync(closeRequest);
189189
}
190190
catch (TException e)
191191
{
@@ -242,8 +242,7 @@ private bool FetchResults()
242242

243243
try
244244
{
245-
var task = _client.ServiceClient.fetchResultsV2(req);
246-
245+
var task = _client.ServiceClient.fetchResultsV2Async(req);
247246
var resp = task.ConfigureAwait(false).GetAwaiter().GetResult();
248247

249248
if (!resp.HasResultSet)

src/Apache.IoTDB/DataStructure/SessionDataSet.cs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ public class SessionDataSet : System.IDisposable
3333
private readonly List<string> _columnNames;
3434
private readonly Dictionary<string, int> _columnNameIndexMap;
3535
private readonly List<string> _columnTypeLst;
36-
private readonly int _columnSize;
37-
private List<ByteBuffer> _valueBufferLst, _bitmapBufferLst;
3836
private Client _client;
39-
private int _rowIndex;
40-
private RowRecord _cachedRowRecord;
4137
private bool _isClosed = false;
4238
private bool disposedValue;
4339
private RpcDataSet _rpcDataSet;
@@ -52,35 +48,28 @@ public class SessionDataSet : System.IDisposable
5248
public SessionDataSet(
5349
string sql, List<string> ColumnNameList, List<string> ColumnTypeList,
5450
Dictionary<string, int> ColumnNameIndexMap, long QueryId, long statementId, Client client, List<byte[]> QueryResult,
55-
bool IgnoreTimeStamp, bool MoreData, string zoneId, List<int> ColumnIndex2TsBlockColumnIndexList, ConcurrentClientQueue _clientQueueS
51+
bool IgnoreTimeStamp, bool MoreData, string zoneId, List<int> ColumnIndex2TsBlockColumnIndexList, ConcurrentClientQueue clientQueue
5652
)
5753
{
5854
_client = client;
5955
_sql = sql;
6056
_queryId = QueryId;
6157
_statementId = statementId;
62-
_columnSize = ColumnNameList.Count;
6358
_columnNameIndexMap = ColumnNameIndexMap;
64-
_rowIndex = 0;
6559

6660
_columnNames = ColumnNameList;
6761
_columnTypeLst = ColumnTypeList;
6862
_zoneId = zoneId;
69-
_clientQueue = _clientQueueS;
70-
63+
_clientQueue = clientQueue;
64+
7165
_rpcDataSet = new RpcDataSet(
7266
_sql, _columnNames, _columnTypeLst, _columnNameIndexMap, IgnoreTimeStamp,
7367
MoreData, _queryId, _statementId, _client, _client.SessionId, QueryResult, FetchSize,
7468
DefaultTimeout, _zoneId, ColumnIndex2TsBlockColumnIndexList
7569
);
7670
}
77-
public bool HasNext()
78-
{
79-
if (_rpcDataSet.HasCachedRecord) return true;
80-
return Next();
81-
}
82-
83-
public bool Next() => _rpcDataSet.Next();
71+
public bool HasNext() => _rpcDataSet.Next();
72+
public RowRecord Next() => _rpcDataSet.GetRow();
8473
public bool IsNull(string columnName) => _rpcDataSet.IsNullByColumnName(columnName);
8574
public bool IsNullByIndex(int columnIndex) => _rpcDataSet.IsNullByIndex(columnIndex);
8675

@@ -119,9 +108,7 @@ public bool HasNext()
119108
public IReadOnlyList<string> GetColumnNames() => _rpcDataSet._columnNameList;
120109
public IReadOnlyList<string> GetColumnTypes() => _rpcDataSet._columnTypeList;
121110

122-
public RowRecord GetRow() => _rpcDataSet.GetRow();
123111
public int RowCount() => _rpcDataSet._tsBlockSize;
124-
125112
public void ShowTableNames()
126113
{
127114
IReadOnlyList<string> columns = GetColumnNames();
@@ -173,8 +160,6 @@ protected virtual void Dispose(bool disposing)
173160
{
174161
}
175162
}
176-
_valueBufferLst = null;
177-
_bitmapBufferLst = null;
178163
disposedValue = true;
179164
}
180165
}

0 commit comments

Comments
 (0)