diff --git a/samples/Apache.IoTDB.Samples/SessionPoolTest.AlignedRecord.cs b/samples/Apache.IoTDB.Samples/SessionPoolTest.AlignedRecord.cs index 011c480..ecad735 100644 --- a/samples/Apache.IoTDB.Samples/SessionPoolTest.AlignedRecord.cs +++ b/samples/Apache.IoTDB.Samples/SessionPoolTest.AlignedRecord.cs @@ -218,7 +218,7 @@ public async Task TestInsertAlignedRecords() while (res.Next()) { res_count += 1; - Console.WriteLine(res.GetRow()); + Console.WriteLine(res.Next()); } await res.Close(); @@ -299,7 +299,7 @@ public async Task TestInsertAlignedStringRecords() var res_count = 0; while (res.Next()) { - Console.WriteLine(res.GetRow()); + Console.WriteLine(res.Next()); res_count += 1; } diff --git a/samples/Apache.IoTDB.Samples/SessionPoolTest.Record.cs b/samples/Apache.IoTDB.Samples/SessionPoolTest.Record.cs index d75e605..544692a 100644 --- a/samples/Apache.IoTDB.Samples/SessionPoolTest.Record.cs +++ b/samples/Apache.IoTDB.Samples/SessionPoolTest.Record.cs @@ -382,7 +382,7 @@ public async Task TestInsertStringRecords() var res_count = 0; while (res.Next()) { - Console.WriteLine(res.GetRow()); + Console.WriteLine(res.Next()); res_count += 1; } diff --git a/samples/Apache.IoTDB.Samples/SessionPoolTest.cs b/samples/Apache.IoTDB.Samples/SessionPoolTest.cs index 284fba0..5783268 100644 --- a/samples/Apache.IoTDB.Samples/SessionPoolTest.cs +++ b/samples/Apache.IoTDB.Samples/SessionPoolTest.cs @@ -621,7 +621,7 @@ public async Task TestMultiNodeDataFetch() Console.WriteLine(); var count = 0; - while (res.Next()) count++; + while (res.HasNext()) count++; Console.WriteLine(count + " " + (fetchSize * processedSize * 4 + 783)); System.Diagnostics.Debug.Assert(count == fetchSize * processedSize * 4 + 783); diff --git a/samples/Apache.IoTDB.Samples/UtilsTest.cs b/samples/Apache.IoTDB.Samples/UtilsTest.cs index 6a31901..af3a46f 100644 --- a/samples/Apache.IoTDB.Samples/UtilsTest.cs +++ b/samples/Apache.IoTDB.Samples/UtilsTest.cs @@ -90,7 +90,7 @@ static public void PrintDataSetByType(SessionDataSet sessionDataSet) } Console.WriteLine(); - while (sessionDataSet.Next()) + while (sessionDataSet.HasNext()) { for (int i = 0; i < columns.Count; i++) { @@ -147,7 +147,7 @@ static public void PrintDataSetByObject(SessionDataSet sessionDataSet) } Console.WriteLine(); - while (sessionDataSet.Next()) + while (sessionDataSet.HasNext()) { for (int i = 0; i < columns.Count; i++) { @@ -169,7 +169,7 @@ static public void PrintDataSetByString(SessionDataSet sessionDataSet) } Console.WriteLine(); - while (sessionDataSet.Next()) + while (sessionDataSet.HasNext()) { for (int i = 0; i < columns.Count; i++) { diff --git a/src/Apache.IoTDB.Data/IoTDBDataReader.cs b/src/Apache.IoTDB.Data/IoTDBDataReader.cs index 0c5a5c4..fa01449 100644 --- a/src/Apache.IoTDB.Data/IoTDBDataReader.cs +++ b/src/Apache.IoTDB.Data/IoTDBDataReader.cs @@ -457,7 +457,7 @@ public override DataTable GetSchemaTable() { if (_dataSet.Next()) { - rowdata = _dataSet.GetRow(); + rowdata = _dataSet.Next(); } var schemaTable = new DataTable("SchemaTable"); if (_metas != null && rowdata != null) diff --git a/src/Apache.IoTDB/DataStructure/ByteBuffer.cs b/src/Apache.IoTDB/DataStructure/ByteBuffer.cs index d190dd2..7fade31 100644 --- a/src/Apache.IoTDB/DataStructure/ByteBuffer.cs +++ b/src/Apache.IoTDB/DataStructure/ByteBuffer.cs @@ -146,7 +146,7 @@ public byte[] GetBuffer() return _buffer[.._writePos]; } - public byte[] GetBytesbyLength(int length) + public byte[] GetBytesByLengthh(int length) { if (_readPos + length > _buffer.Length) throw new ArgumentOutOfRangeException(nameof(length), diff --git a/src/Apache.IoTDB/DataStructure/Column.cs b/src/Apache.IoTDB/DataStructure/Column.cs index e594883..52d816f 100644 --- a/src/Apache.IoTDB/DataStructure/Column.cs +++ b/src/Apache.IoTDB/DataStructure/Column.cs @@ -175,7 +175,7 @@ public BinaryColumn(int arrayOffset, int positionCount, bool[] valueIsNull, Bina ColumnEncoding.BinaryArray, arrayOffset: arrayOffset, positionCount: positionCount, - valueIsNull: null, + valueIsNull: valueIsNull, values: values) { } @@ -193,7 +193,7 @@ public IntColumn(int arrayOffset, int positionCount, bool[] valueIsNull, int[] v ColumnEncoding.Int32Array, arrayOffset: arrayOffset, positionCount: positionCount, - valueIsNull: null, + valueIsNull: valueIsNull, values: values) { } @@ -211,7 +211,7 @@ public FloatColumn(int arrayOffset, int positionCount, bool[] valueIsNull, float ColumnEncoding.Int32Array, arrayOffset: arrayOffset, positionCount: positionCount, - valueIsNull: null, + valueIsNull: valueIsNull, values: values) { } @@ -229,7 +229,7 @@ public LongColumn(int arrayOffset, int positionCount, bool[] valueIsNull, long[] ColumnEncoding.Int64Array, arrayOffset: arrayOffset, positionCount: positionCount, - valueIsNull: null, + valueIsNull: valueIsNull, values: values) { } @@ -247,7 +247,7 @@ public DoubleColumn(int arrayOffset, int positionCount, bool[] valueIsNull, doub ColumnEncoding.Int64Array, arrayOffset: arrayOffset, positionCount: positionCount, - valueIsNull: null, + valueIsNull: valueIsNull, values: values) { } @@ -265,7 +265,7 @@ public BooleanColumn(int arrayOffset, int positionCount, bool[] valueIsNull, boo ColumnEncoding.ByteArray, arrayOffset: arrayOffset, positionCount: positionCount, - valueIsNull: null, + valueIsNull: valueIsNull, values: values) { } diff --git a/src/Apache.IoTDB/DataStructure/ColumnDecoder.cs b/src/Apache.IoTDB/DataStructure/ColumnDecoder.cs index 83ce03a..a903498 100644 --- a/src/Apache.IoTDB/DataStructure/ColumnDecoder.cs +++ b/src/Apache.IoTDB/DataStructure/ColumnDecoder.cs @@ -68,7 +68,7 @@ public static bool[] DeserializeNullIndicators(ByteBuffer reader, int positionCo public static bool[] DeserializeBooleanArray(ByteBuffer reader, int size) { int packedSize = (size + 7) / 8; - byte[] packedBytes = reader.GetBytesbyLength(packedSize); + byte[] packedBytes = reader.GetBytesByLengthh(packedSize); if (packedBytes.Length < packedSize) throw new InvalidDataException( $"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 if (nullIndicators != null && nullIndicators[i]) continue; int length = reader.GetInt(); - byte[] value = reader.GetBytesbyLength(length); + byte[] value = reader.GetBytesByLengthh(length); values[i] = new Binary(value); } diff --git a/src/Apache.IoTDB/DataStructure/RpcDataSet.cs b/src/Apache.IoTDB/DataStructure/RpcDataSet.cs index 74346a4..5eeed48 100644 --- a/src/Apache.IoTDB/DataStructure/RpcDataSet.cs +++ b/src/Apache.IoTDB/DataStructure/RpcDataSet.cs @@ -185,7 +185,7 @@ public async Task Close() try { - var status = await _client.ServiceClient.closeOperation(closeRequest); + var status = await _client.ServiceClient.closeOperationAsync(closeRequest); } catch (TException e) { @@ -242,8 +242,7 @@ private bool FetchResults() try { - var task = _client.ServiceClient.fetchResultsV2(req); - + var task = _client.ServiceClient.fetchResultsV2Async(req); var resp = task.ConfigureAwait(false).GetAwaiter().GetResult(); if (!resp.HasResultSet) diff --git a/src/Apache.IoTDB/DataStructure/SessionDataSet.cs b/src/Apache.IoTDB/DataStructure/SessionDataSet.cs index d8c8b5d..5a0e853 100644 --- a/src/Apache.IoTDB/DataStructure/SessionDataSet.cs +++ b/src/Apache.IoTDB/DataStructure/SessionDataSet.cs @@ -33,11 +33,7 @@ public class SessionDataSet : System.IDisposable private readonly List _columnNames; private readonly Dictionary _columnNameIndexMap; private readonly List _columnTypeLst; - private readonly int _columnSize; - private List _valueBufferLst, _bitmapBufferLst; private Client _client; - private int _rowIndex; - private RowRecord _cachedRowRecord; private bool _isClosed = false; private bool disposedValue; private RpcDataSet _rpcDataSet; @@ -52,35 +48,28 @@ public class SessionDataSet : System.IDisposable public SessionDataSet( string sql, List ColumnNameList, List ColumnTypeList, Dictionary ColumnNameIndexMap, long QueryId, long statementId, Client client, List QueryResult, - bool IgnoreTimeStamp, bool MoreData, string zoneId, List ColumnIndex2TsBlockColumnIndexList, ConcurrentClientQueue _clientQueueS + bool IgnoreTimeStamp, bool MoreData, string zoneId, List ColumnIndex2TsBlockColumnIndexList, ConcurrentClientQueue clientQueue ) { _client = client; _sql = sql; _queryId = QueryId; _statementId = statementId; - _columnSize = ColumnNameList.Count; _columnNameIndexMap = ColumnNameIndexMap; - _rowIndex = 0; _columnNames = ColumnNameList; _columnTypeLst = ColumnTypeList; _zoneId = zoneId; - _clientQueue = _clientQueueS; - + _clientQueue = clientQueue; + _rpcDataSet = new RpcDataSet( _sql, _columnNames, _columnTypeLst, _columnNameIndexMap, IgnoreTimeStamp, MoreData, _queryId, _statementId, _client, _client.SessionId, QueryResult, FetchSize, DefaultTimeout, _zoneId, ColumnIndex2TsBlockColumnIndexList ); } - public bool HasNext() - { - if (_rpcDataSet.HasCachedRecord) return true; - return Next(); - } - - public bool Next() => _rpcDataSet.Next(); + public bool HasNext() => _rpcDataSet.Next(); + public RowRecord Next() => _rpcDataSet.GetRow(); public bool IsNull(string columnName) => _rpcDataSet.IsNullByColumnName(columnName); public bool IsNullByIndex(int columnIndex) => _rpcDataSet.IsNullByIndex(columnIndex); @@ -119,9 +108,7 @@ public bool HasNext() public IReadOnlyList GetColumnNames() => _rpcDataSet._columnNameList; public IReadOnlyList GetColumnTypes() => _rpcDataSet._columnTypeList; - public RowRecord GetRow() => _rpcDataSet.GetRow(); public int RowCount() => _rpcDataSet._tsBlockSize; - public void ShowTableNames() { IReadOnlyList columns = GetColumnNames(); @@ -173,8 +160,6 @@ protected virtual void Dispose(bool disposing) { } } - _valueBufferLst = null; - _bitmapBufferLst = null; disposedValue = true; } } diff --git a/src/Apache.IoTDB/DataStructure/TsBlock.cs b/src/Apache.IoTDB/DataStructure/TsBlock.cs index e399c22..14d598c 100644 --- a/src/Apache.IoTDB/DataStructure/TsBlock.cs +++ b/src/Apache.IoTDB/DataStructure/TsBlock.cs @@ -77,10 +77,10 @@ public static TsBlock Deserialize(ByteBuffer reader) ColumnEncoding timeColumnEncodings = DeserializeColumnEncoding(reader); // Read value column encodings - var valuecolumnEncodings = new ColumnEncoding[valueColumnCount]; + var valueColumnEncodings = new ColumnEncoding[valueColumnCount]; for (int i = 1; i < valueColumnCount + 1; i++) { - valuecolumnEncodings[i - 1] = DeserializeColumnEncoding(reader); + valueColumnEncodings[i - 1] = DeserializeColumnEncoding(reader); } // Read time column @@ -91,7 +91,7 @@ public static TsBlock Deserialize(ByteBuffer reader) var valueColumns = new Column[valueColumnCount]; for (int i = 1; i < valueColumnCount + 1; i++) { - var decoder = BaseColumnDecoder.GetDecoder(valuecolumnEncodings[i - 1]); + var decoder = BaseColumnDecoder.GetDecoder(valueColumnEncodings[i - 1]); valueColumns[i - 1] = decoder.ReadColumn(reader, valueColumnDataTypes[i - 1], positionCount); } diff --git a/src/Apache.IoTDB/SessionPool.cs b/src/Apache.IoTDB/SessionPool.cs index 9428379..f08ccf8 100644 --- a/src/Apache.IoTDB/SessionPool.cs +++ b/src/Apache.IoTDB/SessionPool.cs @@ -1327,7 +1327,7 @@ public async Task ExecuteQueryStatementAsync(string sql, long ti Timeout = timeoutInMs }; - var resp = await client.ServiceClient.executeQueryStatementV2(req); + var resp = await client.ServiceClient.executeQueryStatementV2Async(req); var status = resp.Status; if (_utilFunctions.VerifySuccess(status) == -1) @@ -1360,7 +1360,7 @@ public async Task ExecuteStatementAsync(string sql, long timeout Timeout = timeout }; - var resp = await client.ServiceClient.executeStatementV2(req); + var resp = await client.ServiceClient.executeStatementV2Async(req); var status = resp.Status; if (_utilFunctions.VerifySuccess(status) == -1) @@ -1440,7 +1440,7 @@ public async Task ExecuteRawDataQuery(List paths, long s EnableRedirectQuery = false }; - var resp = await client.ServiceClient.executeRawDataQueryV2(req); + var resp = await client.ServiceClient.executeRawDataQueryV2Async(req); var status = resp.Status; if (_utilFunctions.VerifySuccess(status) == -1) @@ -1472,7 +1472,7 @@ public async Task ExecuteLastDataQueryAsync(List paths, EnableRedirectQuery = false }; - var resp = await client.ServiceClient.executeLastDataQueryV2(req); + var resp = await client.ServiceClient.executeLastDataQueryV2Async(req); var status = resp.Status; if (_utilFunctions.VerifySuccess(status) == -1)