Repository: influxdata/influxdb
File: tsdb/shard.go (Go)

Code before:
			}
			validField = true
			break
		}
		if !validField {
			if reason == "" {
				reason = fmt.Sprintf(
					"invalid field name: input field \"%s\" on measurement \"%s\" is invalid",
					"time", string(p.Name()))
			}
			dropped++
			continue
		}

		// Skip any points whose keys have been dropped. Dropped has already been incremented for them.
		if len(droppedKeys) > 0 && bytesutil.Contains(droppedKeys, keys[i]) {
			continue
		}

		name := p.Name()
		mf := engine.MeasurementFields(name)
		// Check with the field validator.
		newFields, partialWriteError := ValidateAndCreateFields(mf, p, s.options.Config.SkipFieldSizeValidation, s.logger)
		createdFieldsToSave = append(createdFieldsToSave, newFields...)

		if partialWriteError != nil {
			if reason == "" {
				reason = partialWriteError.Reason
			}
			dropped += partialWriteError.Dropped
			atomic.AddInt64(&s.stats.WritePointsDropped, int64(partialWriteError.Dropped))
			continue
		}
		points[j] = points[i]
		j++
	}
	if dropped > 0 {
		err = PartialWriteError{Reason: reason, Dropped: dropped, Database: s.database, RetentionPolicy: s.retentionPolicy}
	}

	return points[:j], createdFieldsToSave, err
}

const unPrintReplRune = '?'
const unPrintMaxReplRune = 3

// makePrintable - replace invalid and non-printable unicode characters with a few '?' runes
func makePrintable(s string) string {
	b := strings.Builder{}
	b.Grow(len(s))
	c := 0

Review comment (suggestion):
Here we would only want to `continue` if the `PartialWriteError.Dropped > 0`, otherwise do the point assignment a increment `j`.  Then in the test on 730, check a bool if we had any PartialWriteError, rather than the count of dropped lines.

Code after:
			}
			validField = true
			break
		}
		if !validField {
			if reason == "" {
				reason = fmt.Sprintf(
					"invalid field name: input field \"%s\" on measurement \"%s\" is invalid",
					"time", string(p.Name()))
			}
			dropped++
			continue
		}

		// Skip any points whose keys have been dropped. Dropped has already been incremented for them.
		if len(droppedKeys) > 0 && bytesutil.Contains(droppedKeys, keys[i]) {
			continue
		}

		name := p.Name()
		mf := engine.MeasurementFields(name)
		// Check with the field validator.
		newFields, partialWriteError := ValidateAndCreateFields(mf, p, s.options.Config.SkipFieldSizeValidation)
		createdFieldsToSave = append(createdFieldsToSave, newFields...)

		if partialWriteError != nil && partialWriteError.Dropped > 0 {
			if reason == "" {
				reason = partialWriteError.Reason
			}
			dropped += partialWriteError.Dropped
			atomic.AddInt64(&s.stats.WritePointsDropped, int64(partialWriteError.Dropped))
			continue
			// Sometimes we will drop fields like 'time' but not an entire point
			// we want to inform the writer that something occurred.
		} else if partialWriteError != nil {
			partialWriteError.Database = s.Database()
			partialWriteError.RetentionPolicy = s.RetentionPolicy()
			err = *partialWriteError
		}
		points[j] = points[i]
		j++
	}
	if dropped > 0 {
		err = PartialWriteError{Reason: reason, Dropped: dropped, Database: s.database, RetentionPolicy: s.retentionPolicy}
	}

	return points[:j], createdFieldsToSave, err
}

const unPrintReplRune = '?'
const unPrintMaxReplRune = 3