Skip to content

Commit 29743fd

Browse files
committed
set lastReadWasNull for time column
1 parent 0d2c5af commit 29743fd

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

client/rpcdataset.go

+11-22
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ func (s *IoTDBRpcDataSet) getLong(columnName string) (int64, error) {
386386
return 0, err
387387
}
388388
if columnName == TimestampColumnName {
389+
s.lastReadWasNull = false
389390
return s.curTsBlock.GetTimeByIndex(s.tsBlockIndex)
390391
}
391392
index := s.columnOrdinalMap[columnName] - startIndex
@@ -433,6 +434,7 @@ func (s *IoTDBRpcDataSet) getObject(columnName string) (interface{}, error) {
433434
return nil, err
434435
}
435436
if columnName == TimestampColumnName {
437+
s.lastReadWasNull = false
436438
if value, err := s.curTsBlock.GetTimeByIndex(s.tsBlockIndex); err != nil {
437439
return nil, err
438440
} else {
@@ -465,21 +467,14 @@ func (s *IoTDBRpcDataSet) getTimestampByIndex(columnIndex int32) (time.Time, err
465467
}
466468

467469
func (s *IoTDBRpcDataSet) getTimestamp(columnName string) (time.Time, error) {
468-
err := s.checkRecord()
470+
longValue, err := s.getLong(columnName)
469471
if err != nil {
470472
return time.Time{}, err
471473
}
472-
index := s.columnOrdinalMap[columnName] - startIndex
473-
if !s.isNull(index, s.tsBlockIndex) {
474-
s.lastReadWasNull = false
475-
if longValue, err := s.curTsBlock.GetColumn(index).GetLong(s.tsBlockIndex); err != nil {
476-
return time.Time{}, err
477-
} else {
478-
return time.Unix(longValue/1e3, (longValue%1e3)*1e6), nil
479-
}
474+
if s.lastReadWasNull {
475+
return time.Time{}, err
480476
} else {
481-
s.lastReadWasNull = true
482-
return time.Time{}, nil
477+
return time.Unix(longValue/1e3, (longValue%1e3)*1e6), nil
483478
}
484479
}
485480

@@ -492,21 +487,14 @@ func (s *IoTDBRpcDataSet) GetDateByIndex(columnIndex int32) (time.Time, error) {
492487
}
493488

494489
func (s *IoTDBRpcDataSet) GetDate(columnName string) (time.Time, error) {
495-
err := s.checkRecord()
490+
intValue, err := s.getInt(columnName)
496491
if err != nil {
497492
return time.Time{}, err
498493
}
499-
index := s.columnOrdinalMap[columnName] - startIndex
500-
if !s.isNull(index, s.tsBlockIndex) {
501-
s.lastReadWasNull = false
502-
if value, err := s.curTsBlock.GetColumn(index).GetInt(s.tsBlockIndex); err != nil {
503-
return time.Time{}, err
504-
} else {
505-
return Int32ToDate(value)
506-
}
494+
if s.lastReadWasNull {
495+
return time.Time{}, err
507496
} else {
508-
s.lastReadWasNull = true
509-
return time.Time{}, nil
497+
return Int32ToDate(intValue)
510498
}
511499
}
512500

@@ -520,6 +508,7 @@ func (s *IoTDBRpcDataSet) getValueByName(columnName string) (string, error) {
520508
return "", err
521509
}
522510
if columnName == TimestampColumnName {
511+
s.lastReadWasNull = false
523512
if t, err := s.curTsBlock.GetTimeByIndex(s.tsBlockIndex); err != nil {
524513
return "", err
525514
} else {

0 commit comments

Comments
 (0)