in client/rpcdataset.go [259:346]
func (s *IoTDBRpcDataSet) scan(dest ...interface{}) error {
if s.closed {
return errClosed
}
count := s.columnCount
if count > len(dest) {
count = len(dest)
}
for i := 0; i < count; i++ {
columnName := s.columnNameList[i]
columnIndex := int(s.getColumnIndex(columnName))
if s.isNull(columnIndex, s.rowsIndex-1) {
continue
}
dataType := s.getColumnType(columnName)
d := dest[i]
valueBytes := s.values[columnIndex]
switch dataType {
case BOOLEAN:
switch t := d.(type) {
case *bool:
*t = bool(valueBytes[0] != 0)
case *string:
if valueBytes[0] != 0 {
*t = "true"
} else {
*t = "false"
}
default:
return fmt.Errorf("dest[%d] types must be *bool or *string", i)
}
case INT32:
switch t := d.(type) {
case *int32:
*t = bytesToInt32(valueBytes)
case *string:
*t = int32ToString(bytesToInt32(valueBytes))
default:
return fmt.Errorf("dest[%d] types must be *int32 or *string", i)
}
case INT64:
switch t := d.(type) {
case *int64:
*t = bytesToInt64(valueBytes)
case *string:
*t = int64ToString(bytesToInt64(valueBytes))
default:
return fmt.Errorf("dest[%d] types must be *int64 or *string", i)
}
case FLOAT:
switch t := d.(type) {
case *float32:
bits := binary.BigEndian.Uint32(valueBytes)
*t = math.Float32frombits(bits)
case *string:
bits := binary.BigEndian.Uint32(valueBytes)
*t = float32ToString(math.Float32frombits(bits))
default:
return fmt.Errorf("dest[%d] types must be *float32 or *string", i)
}
case DOUBLE:
switch t := d.(type) {
case *float64:
bits := binary.BigEndian.Uint64(valueBytes)
*t = math.Float64frombits(bits)
case *string:
bits := binary.BigEndian.Uint64(valueBytes)
*t = float64ToString(math.Float64frombits(bits))
default:
return fmt.Errorf("dest[%d] types must be *float64 or *string", i)
}
case TEXT:
switch t := d.(type) {
case *string:
*t = string(valueBytes)
default:
return fmt.Errorf("dest[%d] types must be *string", i)
}
default:
return nil
}
}
return nil
}