Only limit field count for non-tsm engines

pull/4308/head
Paul Dix 2015-10-06 15:49:37 -07:00
parent 40ff4f4a86
commit b11308133a
3 changed files with 9 additions and 7 deletions

View File

@ -21,7 +21,7 @@ func TestEngine_WritePoints(t *testing.T) {
// Create metadata.
mf := &tsdb.MeasurementFields{Fields: make(map[string]*tsdb.Field)}
mf.CreateFieldIfNotExists("value", influxql.Float)
mf.CreateFieldIfNotExists("value", influxql.Float, true)
seriesToCreate := []*tsdb.SeriesCreate{
{Series: tsdb.NewSeries(string(models.MakeKey([]byte("temperature"), nil)), nil)},
}
@ -84,7 +84,7 @@ func TestEngine_WritePoints_Reverse(t *testing.T) {
// Create metadata.
mf := &tsdb.MeasurementFields{Fields: make(map[string]*tsdb.Field)}
mf.CreateFieldIfNotExists("value", influxql.Float)
mf.CreateFieldIfNotExists("value", influxql.Float, true)
seriesToCreate := []*tsdb.SeriesCreate{
{Series: tsdb.NewSeries(string(models.MakeKey([]byte("temperature"), nil)), nil)},
}

View File

@ -1078,7 +1078,7 @@ func TestEngine_Deletes(t *testing.T) {
fields := []string{"value"}
// Create metadata.
mf := &tsdb.MeasurementFields{Fields: make(map[string]*tsdb.Field)}
mf.CreateFieldIfNotExists("value", influxql.Float)
mf.CreateFieldIfNotExists("value", influxql.Float, false)
atag := map[string]string{"host": "A"}
btag := map[string]string{"host": "B"}
seriesToCreate := []*tsdb.SeriesCreate{

View File

@ -367,7 +367,9 @@ func (s *Shard) createFieldsAndMeasurements(fieldsToCreate []*FieldCreate) (map[
measurementsToSave[f.Measurement] = m
// add the field to the in memory index
if err := m.CreateFieldIfNotExists(f.Field.Name, f.Field.Type); err != nil {
// only limit the field count for non-tsm eninges
limitFieldCount := s.engine.Format() == B1Format || s.engine.Format() == BZ1Format
if err := m.CreateFieldIfNotExists(f.Field.Name, f.Field.Type, limitFieldCount); err != nil {
return nil, err
}
@ -475,7 +477,7 @@ func (m *MeasurementFields) UnmarshalBinary(buf []byte) error {
// CreateFieldIfNotExists creates a new field with an autoincrementing ID.
// Returns an error if 255 fields have already been created on the measurement or
// the fields already exists with a different type.
func (m *MeasurementFields) CreateFieldIfNotExists(name string, typ influxql.DataType) error {
func (m *MeasurementFields) CreateFieldIfNotExists(name string, typ influxql.DataType, limitCount bool) error {
// Ignore if the field already exists.
if f := m.Fields[name]; f != nil {
if f.Type != typ {
@ -484,8 +486,8 @@ func (m *MeasurementFields) CreateFieldIfNotExists(name string, typ influxql.Dat
return nil
}
// Only 255 fields are allowed. If we go over that then return an error.
if len(m.Fields)+1 > math.MaxUint8 {
// If we're supposed to limit the number of fields, only 255 are allowed. If we go over that then return an error.
if len(m.Fields)+1 > math.MaxUint8 && limitCount {
return ErrFieldOverflow
}