Skip to content

Commit fd3aaed

Browse files
author
chengyitian
committed
AJ-855: fix issue about when both set 'enableActualSendTime'、'setStreamTableTimestamp';
1 parent b9619ff commit fd3aaed

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/com/xxdb/multithreadedtablewriter/MultithreadedTableWriter.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ void exit(){
330330
private boolean ifCallback_ = false;
331331
private ColInfo[] colInfos_;
332332
private boolean enableActualSendTime_ = false;
333+
private boolean isSetStreamTableTimestamp;
334+
333335
public MultithreadedTableWriter(String hostName, int port, String userId, String password,
334336
String dbName, String tableName, boolean useSSL,
335337
boolean enableHighAvailability, String[] highAvailabilitySites,
@@ -561,6 +563,17 @@ private void init(String hostName, int port, String userId, String password,
561563

562564
BasicTable colDefs = (BasicTable)schema.get(new BasicString("colDefs"));
563565
BasicIntVector colDefsTypeInt = (BasicIntVector)colDefs.getColumn("typeInt");
566+
try {
567+
BasicString streamTableTimestampColName = (BasicString) pConn.run("getStreamTableTimestamp(" + tableName_ + ")");
568+
if (Objects.nonNull(streamTableTimestampColName)) {
569+
isSetStreamTableTimestamp = true;
570+
}
571+
} catch (Exception e) {
572+
if (!e.getMessage().contains("Cannot recognize the token getStreamTableTimestamp")) {
573+
throw e;
574+
}
575+
}
576+
564577
int columnSize = colDefs.rows();
565578
if (Objects.nonNull(compressTypes_)) {
566579
if (!enableActualSendTime && compressTypes_.length != columnSize)
@@ -574,11 +587,18 @@ private void init(String hostName, int port, String userId, String password,
574587
compressTypes_ = copy;
575588
}
576589
}
577-
if (callbackHandler != null){
590+
591+
if (callbackHandler != null) {
578592
ifCallback_ = true;
579-
colInfos_ = new ColInfo[columnSize+1];
580-
}else
581-
colInfos_ = new ColInfo[columnSize];
593+
columnSize ++;
594+
}
595+
596+
if (isSetStreamTableTimestamp) {
597+
columnSize --;
598+
}
599+
600+
colInfos_ = new ColInfo[columnSize];
601+
582602
for (int i = 0; i < colInfos_.length; i++){
583603
ColInfo colInfo = new ColInfo();
584604
colInfos_[i] = colInfo;
@@ -852,7 +872,8 @@ public ErrorCodeInfo insert(Object... args){
852872
throw new RuntimeException("Thread is exiting. ");
853873
}
854874
if ((!enableActualSendTime_ && args.length != colInfos_.length) ||
855-
(enableActualSendTime_ && args.length != colInfos_.length - 1)) {
875+
(enableActualSendTime_ && !isSetStreamTableTimestamp && args.length != colInfos_.length - 1) ||
876+
enableActualSendTime_ && isSetStreamTableTimestamp && args.length != colInfos_.length - 1) {
856877
return new ErrorCodeInfo(ErrorCodeInfo.Code.EC_InvalidParameter, "Column counts don't match.");
857878
}
858879

0 commit comments

Comments
 (0)