commit
a446134d6f
|
@ -363,6 +363,9 @@ func (c *client) Write(bp BatchPoints) error {
|
|||
var b bytes.Buffer
|
||||
|
||||
for _, p := range bp.Points() {
|
||||
if p == nil {
|
||||
continue
|
||||
}
|
||||
if _, err := b.WriteString(p.pt.PrecisionString(bp.Precision())); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1299,7 +1299,8 @@ func unescapeStringField(in string) string {
|
|||
}
|
||||
|
||||
// NewPoint returns a new point with the given measurement name, tags, fields and timestamp. If
|
||||
// an unsupported field value (NaN) or out of range time is passed, this function returns an error.
|
||||
// an unsupported field value (NaN, or +/-Inf) or out of range time is passed, this function
|
||||
// returns an error.
|
||||
func NewPoint(name string, tags Tags, fields Fields, t time.Time) (Point, error) {
|
||||
key, err := pointKey(name, tags, fields, t)
|
||||
if err != nil {
|
||||
|
@ -1330,11 +1331,17 @@ func pointKey(measurement string, tags Tags, fields Fields, t time.Time) ([]byte
|
|||
switch value := value.(type) {
|
||||
case float64:
|
||||
// Ensure the caller validates and handles invalid field values
|
||||
if math.IsInf(value, 0) {
|
||||
return nil, fmt.Errorf("+/-Inf is an unsupported value for field %s", key)
|
||||
}
|
||||
if math.IsNaN(value) {
|
||||
return nil, fmt.Errorf("NaN is an unsupported value for field %s", key)
|
||||
}
|
||||
case float32:
|
||||
// Ensure the caller validates and handles invalid field values
|
||||
if math.IsInf(float64(value), 0) {
|
||||
return nil, fmt.Errorf("+/-Inf is an unsupported value for field %s", key)
|
||||
}
|
||||
if math.IsNaN(float64(value)) {
|
||||
return nil, fmt.Errorf("NaN is an unsupported value for field %s", key)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue