4
4
5
5
#include " Exports.h"
6
6
#include " Concurrent.h"
7
- #include " Types.h"
8
- #include " Exceptions.h"
9
7
#include " Constant.h"
10
8
#include " Dictionary.h"
9
+ #include " Exceptions.h"
11
10
#include " Table.h"
12
- #include < unordered_map>
13
- #include < string>
14
- #include < vector>
15
- #include < memory>
11
+ #include " Types.h"
12
+ #include < cassert>
16
13
#include < functional>
14
+ #include < memory>
15
+ #include < string>
16
+ #include < thread>
17
17
#include < tuple>
18
- #include < cassert>
18
+ #include < unordered_map>
19
+ #include < vector>
19
20
20
21
#ifdef _MSC_VER
21
22
#pragma warning( push )
@@ -30,7 +31,7 @@ class EXPORT_DECL BatchTableWriter {
30
31
/* *
31
32
* If fail to connect to the specified DolphinDB server, this function throw an exception.
32
33
*/
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 );
34
35
35
36
virtual ~BatchTableWriter ();
36
37
@@ -115,7 +116,7 @@ class EXPORT_DECL BatchTableWriter {
115
116
std::string createTmpSharedTable;
116
117
SynchronizedQueue<std::vector<ConstantSP>> writeQueue;
117
118
SynchronizedQueue<std::vector<ConstantSP>> saveQueue;
118
- ThreadSP writeThread;
119
+ std::thread writeThread;
119
120
TableSP writeTable;
120
121
121
122
Mutex writeMutex;
@@ -126,15 +127,15 @@ class EXPORT_DECL BatchTableWriter {
126
127
bool finished = false ;
127
128
};
128
129
// write failed or no data
129
- bool writeTableAllData (SmartPointer<DestTable> destTable,bool partitioned);
130
+ bool writeTableAllData (const SmartPointer<DestTable>& destTable,bool partitioned);
130
131
void insertRecursive (std::vector<ConstantSP>* row, DestTable* destTable, int colIndex){
131
132
assert (colIndex == destTable->columnNum );
132
133
std::ignore = colIndex;
133
134
RWLockGuard<RWLock> _ (&rwLock, false , acquireLock_);
134
135
if (destTable->finished ){
135
136
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 + " )." );
136
137
}
137
- destTable->writeQueue .push (std::move ( *row) );
138
+ destTable->writeQueue .push (*row);
138
139
destTable->writeNotifier .notify ();
139
140
}
140
141
@@ -161,19 +162,19 @@ class EXPORT_DECL BatchTableWriter {
161
162
throw RuntimeException (" Failed to insert data, unsupported data type." );
162
163
}
163
164
ConstantSP createObject (int dataType, Constant* val);
164
- ConstantSP createObject (int dataType, ConstantSP val);
165
+ ConstantSP createObject (int dataType, const ConstantSP& val);
165
166
ConstantSP createObject (int dataType, char val);
166
167
ConstantSP createObject (int dataType, short val);
167
168
ConstantSP createObject (int dataType, const char * val);
168
- ConstantSP createObject (int dataType, std::string val);
169
+ ConstantSP createObject (int dataType, const std::string& val);
169
170
ConstantSP createObject (int dataType, const unsigned char * val);
170
171
ConstantSP createObject (int dataType, unsigned char val[]);
171
172
ConstantSP createObject (int dataType, long long val);
172
173
ConstantSP createObject (int dataType, float val);
173
174
ConstantSP createObject (int dataType, double val);
174
175
ConstantSP createObject (int dataType, int val);
175
176
176
- private:
177
+
177
178
const std::string hostName_;
178
179
const int port_;
179
180
const std::string userId_;
@@ -192,7 +193,7 @@ class EXPORT_DECL BatchTableWriter {
192
193
};
193
194
194
195
195
- }
196
+ } // namespace dolphindb
196
197
197
198
#ifdef _MSC_VER
198
199
#pragma warning( pop )
0 commit comments