You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2022/08/05 06:18:21 UTC

[iotdb] branch rel/0.13 updated: [To rel/0.13] [IOTDB-4023]C++ interface execute SQL query statement and the returned result set records error (#6871)

This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch rel/0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.13 by this push:
     new 4361c27b77 [To rel/0.13] [IOTDB-4023]C++  interface  execute SQL query statement and the returned result set records error (#6871)
4361c27b77 is described below

commit 4361c27b770b861a65c86e091c0700c163712e2e
Author: liruizhi19 <10...@users.noreply.github.com>
AuthorDate: Fri Aug 5 14:18:16 2022 +0800

    [To rel/0.13] [IOTDB-4023]C++  interface  execute SQL query statement and the returned result set records error (#6871)
---
 client-cpp/src/main/Session.cpp       | 12 ++++++++++++
 client-cpp/src/test/cpp/sessionIT.cpp | 28 ++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/client-cpp/src/main/Session.cpp b/client-cpp/src/main/Session.cpp
index 249e70ef65..b431cd4581 100644
--- a/client-cpp/src/main/Session.cpp
+++ b/client-cpp/src/main/Session.cpp
@@ -274,6 +274,18 @@ bool SessionDataSet::hasNext() {
             } else {
                 tsQueryDataSet = make_shared<TSQueryDataSet>(resp->queryDataSet);
                 tsQueryDataSetTimeBuffer.str = tsQueryDataSet->time;
+                tsQueryDataSetTimeBuffer.pos = 0;
+                for (size_t i = 0; i < columnNameList.size(); i++) {
+                    valueBuffers.pop_back();
+                    bitmapBuffers.pop_back();
+                }
+                for (size_t i = 0; i < columnNameList.size(); i++) {
+                    std::string name = columnNameList[i];
+                    valueBuffers.push_back(
+                        std::unique_ptr<MyStringBuffer>(new MyStringBuffer(tsQueryDataSet->valueList[columnMap[name]])));
+                    bitmapBuffers.push_back(
+                        std::unique_ptr<MyStringBuffer>(new MyStringBuffer(tsQueryDataSet->bitmapList[columnMap[name]])));
+                }
                 rowsIndex = 0;
             }
         }
diff --git a/client-cpp/src/test/cpp/sessionIT.cpp b/client-cpp/src/test/cpp/sessionIT.cpp
index 4f83e30965..a011220039 100644
--- a/client-cpp/src/test/cpp/sessionIT.cpp
+++ b/client-cpp/src/test/cpp/sessionIT.cpp
@@ -293,3 +293,31 @@ TEST_CASE("Test Last query ", "[testLastQuery]") {
         index++;
     }
 }
+
+TEST_CASE("Test Huge query ", "[testHugeQuery]") {
+    prepareTimeseries();
+    string deviceId = "root.test.d1";
+    vector<string> measurements = {"s1", "s2", "s3"};
+    vector<TSDataType::TSDataType> types = {TSDataType::INT32, TSDataType::INT32, TSDataType::INT32};
+    int value1 = 1, value2 = 2, value3 = 3;
+    vector<char*> values = {(char*)&value1, (char*)&value2, (char*)&value3};
+
+    for (long time = 0; time < 1000000; time++) {
+        session->insertRecord(deviceId, time, measurements, types, values);
+    }
+	
+    unique_ptr<SessionDataSet> sessionDataSet = session->executeQueryStatement("select * from root.test.d1");
+    sessionDataSet->setBatchSize(1024);
+    RowRecord* rowRecord;
+    int count = 0;
+    while (sessionDataSet->hasNext()) {
+        rowRecord = sessionDataSet->next();
+        REQUIRE(rowRecord->timestamp == count);
+        REQUIRE(rowRecord->fields[0].intV == 1);
+        REQUIRE(rowRecord->fields[1].intV == 2);
+        REQUIRE(rowRecord->fields[2].intV == 3);
+        count++;
+    }
+	
+    REQUIRE(count == 1000000);
+}