jt2594838 commented on code in PR #214:
URL: https://github.com/apache/tsfile/pull/214#discussion_r1746393827


##########
cpp/examples/cpp_examples/demo_write.cpp:
##########
@@ -20,39 +20,97 @@
 #include <time.h>
 
 #include <iostream>
+#include <random>
 #include <string>
 
 #include "cpp_examples.h"
 
+using namespace storage;
+
+long getNowTime() { return time(nullptr); }
+
+static std::string generate_random_string(int length) {
+    std::random_device rd;
+    std::mt19937 gen(rd());
+    std::uniform_int_distribution<> dis(0, 61);
+
+    const std::string chars =
+        "0123456789"
+        "abcdefghijklmnopqrstuvwxyz"
+        "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+    std::string random_string;
+
+    for (int i = 0; i < length; ++i) {
+        random_string += chars[dis(gen)];
+    }
+
+    return random_string;
+}
+
 int demo_write() {
-    storage::TsFileWriter tsfile_writer;
-    std::string device_name = "root.db001.dev001";
-    std::string measurement_name = "m001";
-    storage::libtsfile_init();
-    int ret = tsfile_writer.open("cpp_rw.tsfile", O_CREAT | O_RDWR, 0644);
-    ASSERT(ret == 0);
-    ret = tsfile_writer.register_timeseries(device_name, measurement_name,
-                                            common::INT32, common::PLAIN,
-                                            common::UNCOMPRESSED);
-    ASSERT(ret == 0);
-    std::cout << "get open ret: " << ret << std::endl;
-
-    int row_count = 100;
-    for (int i = 1; i < row_count; ++i) {
-        storage::DataPoint point(measurement_name, 10000 + i);
-        storage::TsRecord record(i, device_name, 1);
-        record.points_.push_back(point);
-        ret = tsfile_writer.write_record(record);
-        ASSERT(ret == 0);
+    TsFileWriter* tsfile_writer_ = new TsFileWriter();
+    libtsfile_init();
+    std::cout << "input tablesize" << std::endl;

Review Comment:
   This line should be moved to the line before line 85, namely 'std::cin >> 
table_size;'.
   And beware of the terms "Table" and "Tablet".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to