44
55#include " Exports.h"
66#include " Concurrent.h"
7- #include " Types.h"
8- #include " Exceptions.h"
97#include " Constant.h"
108#include " Dictionary.h"
9+ #include " Exceptions.h"
1110#include " Table.h"
12- #include < unordered_map>
13- #include < string>
14- #include < vector>
15- #include < memory>
11+ #include " Types.h"
12+ #include < cassert>
1613#include < functional>
14+ #include < memory>
15+ #include < string>
16+ #include < thread>
1717#include < tuple>
18- #include < cassert>
18+ #include < unordered_map>
19+ #include < vector>
1920
2021#ifdef _MSC_VER
2122#pragma warning( push )
@@ -30,7 +31,7 @@ class EXPORT_DECL BatchTableWriter {
3031 /* *
3132 * If fail to connect to the specified DolphinDB server, this function throw an exception.
3233 */
33- BatchTableWriter (const std::string& hostName, int port, const std::string& userId, const std::string& password, bool acquireLock=true );
34+ BatchTableWriter (std::string hostName, int port, std::string userId, std::string password, bool acquireLock=true );
3435
3536 virtual ~BatchTableWriter ();
3637
@@ -115,7 +116,7 @@ class EXPORT_DECL BatchTableWriter {
115116 std::string createTmpSharedTable;
116117 SynchronizedQueue<std::vector<ConstantSP>> writeQueue;
117118 SynchronizedQueue<std::vector<ConstantSP>> saveQueue;
118- ThreadSP writeThread;
119+ std::thread writeThread;
119120 TableSP writeTable;
120121
121122 Mutex writeMutex;
@@ -126,15 +127,15 @@ class EXPORT_DECL BatchTableWriter {
126127 bool finished = false ;
127128 };
128129 // write failed or no data
129- bool writeTableAllData (SmartPointer<DestTable> destTable,bool partitioned);
130+ bool writeTableAllData (const SmartPointer<DestTable>& destTable,bool partitioned);
130131 void insertRecursive (std::vector<ConstantSP>* row, DestTable* destTable, int colIndex){
131132 assert (colIndex == destTable->columnNum );
132133 std::ignore = colIndex;
133134 RWLockGuard<RWLock> _ (&rwLock, false , acquireLock_);
134135 if (destTable->finished ){
135136 throw RuntimeException (std::string (" Failed to insert data. Error writing data in backgroud thread. Please use getUnwrittenData to get data not written to server and remove talbe (" ) + destTable->dbName + " " + destTable->tableName + " )." );
136137 }
137- destTable->writeQueue .push (std::move ( *row) );
138+ destTable->writeQueue .push (*row);
138139 destTable->writeNotifier .notify ();
139140 }
140141
@@ -161,19 +162,19 @@ class EXPORT_DECL BatchTableWriter {
161162 throw RuntimeException (" Failed to insert data, unsupported data type." );
162163 }
163164 ConstantSP createObject (int dataType, Constant* val);
164- ConstantSP createObject (int dataType, ConstantSP val);
165+ ConstantSP createObject (int dataType, const ConstantSP& val);
165166 ConstantSP createObject (int dataType, char val);
166167 ConstantSP createObject (int dataType, short val);
167168 ConstantSP createObject (int dataType, const char * val);
168- ConstantSP createObject (int dataType, std::string val);
169+ ConstantSP createObject (int dataType, const std::string& val);
169170 ConstantSP createObject (int dataType, const unsigned char * val);
170171 ConstantSP createObject (int dataType, unsigned char val[]);
171172 ConstantSP createObject (int dataType, long long val);
172173 ConstantSP createObject (int dataType, float val);
173174 ConstantSP createObject (int dataType, double val);
174175 ConstantSP createObject (int dataType, int val);
175176
176- private:
177+
177178 const std::string hostName_;
178179 const int port_;
179180 const std::string userId_;
@@ -192,7 +193,7 @@ class EXPORT_DECL BatchTableWriter {
192193};
193194
194195
195- }
196+ } // namespace dolphindb
196197
197198#ifdef _MSC_VER
198199#pragma warning( pop )
0 commit comments