From 741ba9b268c5e400799632d0eb011b79e2fae165 Mon Sep 17 00:00:00 2001 From: Travis Date: Wed, 1 Apr 2020 11:10:33 -0500 Subject: [PATCH] back out the pql.Decimal changes --- api_test.go | 34 +- cmd/import.go | 4 +- cmd/import_test.go | 5 +- ctl/import.go | 3 +- encoding/proto/proto.go | 16 +- executor_test.go | 43 +-- field.go | 149 +++----- field_internal_test.go | 118 ++---- http/client_test.go | 2 +- http/handler.go | 54 +-- http/handler_internal_test.go | 11 +- index_test.go | 3 +- internal/private.pb.go | 700 +++++++++++----------------------- internal/private.proto | 9 +- pql/decimal.go | 211 +--------- pql/decimal_test.go | 98 +---- server/handler_test.go | 86 +---- server/server_test.go | 3 +- 18 files changed, 401 insertions(+), 1148 deletions(-) diff --git a/api_test.go b/api_test.go index b7f0fc06f..955f01f81 100644 --- a/api_test.go +++ b/api_test.go @@ -447,9 +447,39 @@ func TestAPI_ImportValue(t *testing.T) { t.Fatalf("creating index: %v", err) } _, err = m0.API.CreateField(ctx, index, field, pilosa.OptFieldTypeDecimal(-1)) - if err == nil { - t.Fatal("expected error creating field") + if err != nil { + t.Fatalf("creating field: %v", err) } + + // Generate some keyed records. + values := []float64{} + colIDs := []uint64{} + for i := 0; i < 10; i++ { + values = append(values, float64(i)*100+10) + colIDs = append(colIDs, uint64(i)) + } + + // Import data with keys to the coordinator (node0) and verify that it gets + // translated and forwarded to the owner of shard 0 (node1; because of offsetModHasher) + req := &pilosa.ImportValueRequest{ + Index: index, + Field: field, + ColumnIDs: colIDs, + FloatValues: values, + } + if err := m1.API.ImportValue(ctx, req); err != nil { + t.Fatal(err) + } + + pql := fmt.Sprintf("Row(%s>600)", field) + + // Query node0. + if res, err := m0.API.Query(ctx, &pilosa.QueryRequest{Index: index, Query: pql}); err != nil { + t.Fatal(err) + } else if ids := res.Results[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(ids, colIDs[6:]) { + t.Fatalf("unexpected column keys: %+v", ids) + } + }) t.Run("ValStringField", func(t *testing.T) { diff --git a/cmd/import.go b/cmd/import.go index c18db2b0d..8f013977c 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -54,8 +54,8 @@ omitted. If it is present then its format should be YYYY-MM-DDTHH:MM. flags.BoolVar(&Importer.IndexOptions.Keys, "index-keys", false, "Specify keys=true when creating an index") flags.BoolVar(&Importer.FieldOptions.Keys, "field-keys", false, "Specify keys=true when creating a field") flags.StringVar(&Importer.FieldOptions.Type, "field-type", "", "Specify the field type when creating a field. One of: set, int, decimal, time, bool, mutex") - flags.Int64Var(&Importer.FieldOptions.Min.Value, "field-min", 0, "Specify the minimum for an int field on creation") // TODO: noting that decimal field min/max are not supported here. - flags.Int64Var(&Importer.FieldOptions.Max.Value, "field-max", 0, "Specify the maximum for an int field on creation") + flags.Int64Var(&Importer.FieldOptions.Min, "field-min", 0, "Specify the minimum for an int field on creation") + flags.Int64Var(&Importer.FieldOptions.Max, "field-max", 0, "Specify the maximum for an int field on creation") flags.StringVar(&Importer.FieldOptions.CacheType, "field-cache-type", pilosa.CacheTypeRanked, "Specify the cache type for a set field on creation. One of: none, lru, ranked") flags.Uint32Var(&Importer.FieldOptions.CacheSize, "field-cache-size", 50000, "Specify the cache size for a set field on creation") flags.Var(&Importer.FieldOptions.TimeQuantum, "field-time-quantum", "Specify the time quantum for a time field on creation. One of: D, DH, H, M, MD, MDH, Y, YM, YMD, YMDH") diff --git a/cmd/import_test.go b/cmd/import_test.go index e8c0ff2fb..fc7899851 100644 --- a/cmd/import_test.go +++ b/cmd/import_test.go @@ -21,7 +21,6 @@ import ( "github.com/pilosa/pilosa/v2" "github.com/pilosa/pilosa/v2/cmd" - "github.com/pilosa/pilosa/v2/pql" ) func TestImportHelp(t *testing.T) { @@ -59,8 +58,8 @@ field = "f1" v.Check(cmd.Importer.Field, "f1") v.Check(cmd.Importer.FieldOptions, pilosa.FieldOptions{ Keys: true, - Max: pql.NewDecimal(100, 0), - Min: pql.NewDecimal(-10, 0), + Max: 100, + Min: -10, CacheType: pilosa.CacheTypeRanked, CacheSize: 50000, }) diff --git a/ctl/import.go b/ctl/import.go index fefbd819a..32a49be49 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -28,7 +28,6 @@ import ( "github.com/pilosa/pilosa/v2" "github.com/pilosa/pilosa/v2/http" - "github.com/pilosa/pilosa/v2/pql" "github.com/pilosa/pilosa/v2/server" "github.com/pkg/errors" ) @@ -105,7 +104,7 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { // set the correct type for the field if cmd.FieldOptions.TimeQuantum != "" { cmd.FieldOptions.Type = pilosa.FieldTypeTime - } else if cmd.FieldOptions.Min != pql.NewDecimal(0, 0) || cmd.FieldOptions.Max != pql.NewDecimal(0, 0) { + } else if cmd.FieldOptions.Min != 0 || cmd.FieldOptions.Max != 0 { cmd.FieldOptions.Type = pilosa.FieldTypeInt } else { cmd.FieldOptions.Type = pilosa.FieldTypeSet diff --git a/encoding/proto/proto.go b/encoding/proto/proto.go index eca95de2f..43f17ce37 100644 --- a/encoding/proto/proto.go +++ b/encoding/proto/proto.go @@ -21,7 +21,6 @@ import ( "github.com/gogo/protobuf/proto" "github.com/pilosa/pilosa/v2" "github.com/pilosa/pilosa/v2/internal" - "github.com/pilosa/pilosa/v2/pql" "github.com/pilosa/pilosa/v2/roaring" "github.com/pkg/errors" ) @@ -612,8 +611,8 @@ func encodeFieldOptions(o *pilosa.FieldOptions) *internal.FieldOptions { Type: o.Type, CacheType: o.CacheType, CacheSize: o.CacheSize, - Min: &internal.Decimal{Value: o.Min.Value, Scale: o.Min.Scale}, - Max: &internal.Decimal{Value: o.Max.Value, Scale: o.Max.Scale}, + Min: o.Min, + Max: o.Max, Base: o.Base, Scale: o.Scale, BitDepth: uint64(o.BitDepth), @@ -916,8 +915,8 @@ func decodeFieldOptions(options *internal.FieldOptions, m *pilosa.FieldOptions) m.Type = options.Type m.CacheType = options.CacheType m.CacheSize = options.CacheSize - decodeDecimal(options.Min, &m.Min) - decodeDecimal(options.Max, &m.Max) + m.Min = options.Min + m.Max = options.Max m.Base = options.Base m.Scale = options.Scale m.BitDepth = uint(options.BitDepth) @@ -926,11 +925,6 @@ func decodeFieldOptions(options *internal.FieldOptions, m *pilosa.FieldOptions) m.ForeignIndex = options.ForeignIndex } -func decodeDecimal(d *internal.Decimal, m *pql.Decimal) { - m.Value = d.Value - m.Scale = d.Scale -} - func decodeNodes(a []*internal.Node, m []*pilosa.Node) { for i := range a { m[i] = &pilosa.Node{} @@ -1245,7 +1239,7 @@ func decodeQueryResult(pb *internal.QueryResult) interface{} { panic(fmt.Sprintf("unknown type: %d", pb.Type)) } -// decodeRow converts r from its internal representation. +// DecodeRow converts r from its internal representation. func decodeRow(pr *internal.Row) *pilosa.Row { if pr == nil { return pilosa.NewRow() diff --git a/executor_test.go b/executor_test.go index 3a09c678b..f6ab0d286 100644 --- a/executor_test.go +++ b/executor_test.go @@ -1478,14 +1478,14 @@ func TestExecutor_Execute_MinMax(t *testing.T) { tests := []struct { scale int64 - min pql.Decimal - max pql.Decimal + min int64 + max int64 set pql.Decimal }{ - {2, pql.Decimal{Value: 1, Scale: -1}, pql.Decimal{Value: 2, Scale: -1}, pql.Decimal{Value: 115, Scale: 1}}, - {2, pql.Decimal{Value: -1, Scale: -1}, pql.Decimal{Value: 2, Scale: -1}, pql.Decimal{Value: 115, Scale: 1}}, - {2, pql.Decimal{Value: -1, Scale: -1}, pql.Decimal{Value: 2, Scale: -1}, pql.Decimal{Value: -95, Scale: 1}}, - {2, pql.Decimal{Value: -2, Scale: -1}, pql.Decimal{Value: -1, Scale: -1}, pql.Decimal{Value: -115, Scale: 1}}, + {2, 10, 20, pql.Decimal{Value: 115, Scale: 1}}, + {2, -10, 20, pql.Decimal{Value: 115, Scale: 1}}, + {2, -10, 20, pql.Decimal{Value: -95, Scale: 1}}, + {2, -20, -10, pql.Decimal{Value: -115, Scale: 1}}, } for i, test := range tests { fld := fmt.Sprintf("f%d", i) @@ -2249,37 +2249,6 @@ func TestExecutor_Execute_Range_Deprecated(t *testing.T) { }) } -// Ensure decimal args are supported for Decimal fields. -func TestExecutor_DecimalArgs(t *testing.T) { - c := test.MustRunCluster(t, 1) - defer c.Close() - hldr := test.Holder{Holder: c[0].Server.Holder()} - - idx, err := hldr.CreateIndex("i", pilosa.IndexOptions{}) - if err != nil { - t.Fatal(err) - } - - min, err := pql.ParseDecimal("-10.5") - if err != nil { - t.Fatal(err) - } - max, err := pql.ParseDecimal("10.5") - if err != nil { - t.Fatal(err) - } - - if _, err := idx.CreateField("f", pilosa.OptFieldTypeDecimal(2, min, max)); err != nil { - t.Fatal(err) - } - - if _, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: ` - Set(0, f=0) - `}); err != nil { - t.Fatal(err) - } -} - // Ensure a Row(bsiGroup) query can be executed. func TestExecutor_Execute_Row_BSIGroup(t *testing.T) { c := test.MustRunCluster(t, 1) diff --git a/field.go b/field.go index a98d1360f..96ccfa278 100644 --- a/field.go +++ b/field.go @@ -178,80 +178,55 @@ func OptFieldTypeInt(min, max int64) FieldOption { return errors.New("int field min cannot be greater than max") } fo.Type = FieldTypeInt - fo.Min = pql.NewDecimal(min, 0) - fo.Max = pql.NewDecimal(max, 0) + fo.Min = min + fo.Max = max fo.Base = bsiBase(min, max) return nil } } -// OptFieldTypeDecimal is a functional option for creating a `decimal` field. -// Unless we decide to expand the range of supported values, `scale` is -// restricted to the range [0,19]. This supports anything from: -// -// scale = 0: -// min: -9223372036854775808. -// max: 9223372036854775807. -// -// to: -// -// scale = 19: -// min: -0.9223372036854775808 -// max: 0.9223372036854775807 -// -// While it's possible to support scale values outside of this range, -// the coverage for those scales are no longer continuous. For example, -// -// scale = -2: -// min : [-922337203685477580800, -100] -// GAPs: [-99, -1], [-199, -101] ... [-922337203685477580799, -922337203685477580701] -// 0 -// max : [100, 922337203685477580700] -// GAPs: [1, 99], [101, 199] ... [922337203685477580601, 922337203685477580699] -// -// An alternative to this gap strategy would be to scale the supported range -// to a continuous 64-bit space (which is not unreasonable using bsiGroup.Base). -// The issue with this approach is that we would need to know which direction -// to favor. For example, there are two possible ranges for `scale = -2`: -// -// min : [-922337203685477580800, -922337203685477580800+(2^64)] -// max : [922337203685477580700-(2^64), 922337203685477580700] -// -func OptFieldTypeDecimal(scale int64, minmax ...pql.Decimal) FieldOption { +func OptFieldTypeDecimal(scale int64, minmax ...int64) FieldOption { return func(fo *FieldOptions) error { if fo.Type != "" { return errors.Errorf("can't set field type to 'decimal', already set to: %s", fo.Type) } - if scale < 0 || scale > 19 { - return errors.Errorf("scale values outside the range [0,19] are not supported: %d", scale) - } - - fo.Min, fo.Max = pql.MinMax(scale) + fo.Min = math.MinInt64 + fo.Max = math.MaxInt64 if len(minmax) == 2 { - min := minmax[0] - max := minmax[1] - if !min.IsValid() || !max.IsValid() { - return errors.Errorf("min/max range %s-%s is not supported", min, max) - } else if !min.SupportedByScale(scale) || !max.SupportedByScale(scale) { - return errors.Errorf("min/max range %s-%s is not supported by scale %d", min, max, scale) - } else if min.GreaterThan(max) { - return errors.Errorf("decimal field min cannot be greater than max, got %s, %s", min, max) + min, max := minmax[0], minmax[1] + if scale != 0 { + // If the min/max provided are already on the boundary of int64, + // then we don't want to operate on them and cause overflow. + // There are still overflow scenarios where a user provides a + // min/max which is not on the boundary, but overflow once the + // scale is applied. This does not address those cases, but at + // least it addresses the default case (where a min/max is not + // provided). + if min != math.MinInt64 { + min = int64(float64(min) * math.Pow10(int(scale))) + } + if max != math.MaxInt64 { + max = int64(float64(max) * math.Pow10(int(scale))) + } + } + if min > max { + return errors.Errorf("decimal field min cannot be greater than max, got %d, %d", min, max) } fo.Min = min fo.Max = max } else if len(minmax) > 2 { return errors.Errorf("unknown extra parameters beyond min and max: %v", minmax) } else if len(minmax) == 1 { - min := minmax[0] - if !min.IsValid() { - return errors.Errorf("min %s is not supported", min) - } else if !min.SupportedByScale(scale) { - return errors.Errorf("min %s is not supported by scale %d", min, scale) + // It's not necessary to handle the scale==0 case separately, + // but it avoids the type conversion. + if scale == 0 || minmax[0] == math.MinInt64 { + fo.Min = minmax[0] + } else { + fo.Min = int64(float64(minmax[0]) * math.Pow10(int(scale))) } - fo.Min = min } fo.Type = FieldTypeDecimal - fo.Base = bsiBase(fo.Min.ToInt64(scale), fo.Max.ToInt64(scale)) + fo.Base = bsiBase(fo.Min, fo.Max) fo.Scale = scale return nil } @@ -717,14 +692,10 @@ func (f *Field) loadMeta() error { } } - min := pql.NewDecimal(pb.Min.Value, pb.Min.Scale) - max := pql.NewDecimal(pb.Max.Value, pb.Max.Scale) - // Initialize "base" to "min" when upgrading from v1 BSI format. if pb.BitDepth == 0 { - minInt64, maxInt64 := min.ToInt64(0), max.ToInt64(0) - pb.Base = bsiBase(minInt64, maxInt64) - pb.BitDepth = uint64(bitDepthInt64(maxInt64 - minInt64)) + pb.Base = bsiBase(pb.Min, pb.Max) + pb.BitDepth = uint64(bitDepthInt64(pb.Max - pb.Min)) if pb.BitDepth == 0 { pb.BitDepth = 1 } @@ -734,8 +705,8 @@ func (f *Field) loadMeta() error { f.options.Type = pb.Type f.options.CacheType = pb.CacheType f.options.CacheSize = pb.CacheSize - f.options.Min = min - f.options.Max = max + f.options.Min = pb.Min + f.options.Max = pb.Max f.options.Base = pb.Base f.options.Scale = pb.Scale f.options.BitDepth = uint(pb.BitDepth) @@ -795,8 +766,8 @@ func (f *Field) applyOptions(opt FieldOptions) error { } else if opt.CacheSize != 0 { f.options.CacheSize = opt.CacheSize } - f.options.Min = pql.Decimal{} - f.options.Max = pql.Decimal{} + f.options.Min = 0 + f.options.Max = 0 f.options.Base = 0 f.options.BitDepth = 0 f.options.TimeQuantum = "" @@ -819,8 +790,8 @@ func (f *Field) applyOptions(opt FieldOptions) error { bsig := &bsiGroup{ Name: f.name, Type: bsiGroupTypeInt, - Min: opt.Min.ToInt64(opt.Scale), - Max: opt.Max.ToInt64(opt.Scale), + Min: opt.Min, + Max: opt.Max, Base: opt.Base, Scale: opt.Scale, BitDepth: opt.BitDepth, @@ -836,8 +807,8 @@ func (f *Field) applyOptions(opt FieldOptions) error { f.options.Type = opt.Type f.options.CacheType = CacheTypeNone f.options.CacheSize = 0 - f.options.Min = pql.Decimal{} - f.options.Max = pql.Decimal{} + f.options.Min = 0 + f.options.Max = 0 f.options.Base = 0 f.options.BitDepth = 0 f.options.Keys = opt.Keys @@ -852,8 +823,8 @@ func (f *Field) applyOptions(opt FieldOptions) error { f.options.Type = FieldTypeBool f.options.CacheType = CacheTypeNone f.options.CacheSize = 0 - f.options.Min = pql.Decimal{} - f.options.Max = pql.Decimal{} + f.options.Min = 0 + f.options.Max = 0 f.options.Base = 0 f.options.BitDepth = 0 f.options.TimeQuantum = "" @@ -1847,8 +1818,8 @@ func (p fieldInfoSlice) Less(i, j int) bool { return p[i].Name < p[j].Name } type FieldOptions struct { Base int64 `json:"base,omitempty"` BitDepth uint `json:"bitDepth,omitempty"` - Min pql.Decimal `json:"min,omitempty"` - Max pql.Decimal `json:"max,omitempty"` + Min int64 `json:"min,omitempty"` + Max int64 `json:"max,omitempty"` Scale int64 `json:"scale,omitempty"` Keys bool `json:"keys"` NoStandardView bool `json:"noStandardView,omitempty"` @@ -1910,8 +1881,8 @@ func encodeFieldOptions(o *FieldOptions) *internal.FieldOptions { Base: o.Base, Scale: o.Scale, BitDepth: uint64(o.BitDepth), - Min: &internal.Decimal{Value: o.Min.Value, Scale: o.Min.Scale}, - Max: &internal.Decimal{Value: o.Max.Value, Scale: o.Max.Scale}, + Min: o.Min, + Max: o.Max, TimeQuantum: string(o.TimeQuantum), Keys: o.Keys, NoStandardView: o.NoStandardView, @@ -1938,13 +1909,13 @@ func (o *FieldOptions) MarshalJSON() ([]byte, error) { }) case FieldTypeInt: return json.Marshal(struct { - Type string `json:"type"` - Base int64 `json:"base"` - BitDepth uint `json:"bitDepth"` - Min pql.Decimal `json:"min"` - Max pql.Decimal `json:"max"` - Keys bool `json:"keys"` - ForeignIndex string `json:"foreignIndex"` + Type string `json:"type"` + Base int64 `json:"base"` + BitDepth uint `json:"bitDepth"` + Min int64 `json:"min"` + Max int64 `json:"max"` + Keys bool `json:"keys"` + ForeignIndex string `json:"foreignIndex"` }{ o.Type, o.Base, @@ -1956,13 +1927,13 @@ func (o *FieldOptions) MarshalJSON() ([]byte, error) { }) case FieldTypeDecimal: return json.Marshal(struct { - Type string `json:"type"` - Base int64 `json:"base"` - Scale int64 `json:"scale"` - BitDepth uint `json:"bitDepth"` - Min pql.Decimal `json:"min"` - Max pql.Decimal `json:"max"` - Keys bool `json:"keys"` + Type string `json:"type"` + Base int64 `json:"base"` + Scale int64 `json:"scale"` + BitDepth uint `json:"bitDepth"` + Min int64 `json:"min"` + Max int64 `json:"max"` + Keys bool `json:"keys"` }{ o.Type, o.Base, diff --git a/field_internal_test.go b/field_internal_test.go index 2b7be19f5..c7a3015a1 100644 --- a/field_internal_test.go +++ b/field_internal_test.go @@ -22,7 +22,6 @@ import ( "path/filepath" "reflect" "strconv" - "strings" "testing" "time" @@ -161,7 +160,7 @@ func TestBSIGroup_BaseValue(t *testing.T) { // Ensure field can open and retrieve a view. func TestField_DeleteView(t *testing.T) { - f := OpenField(t, OptFieldTypeDefault()) + f := MustOpenField(OptFieldTypeDefault()) defer f.Close() viewName := viewStandard + "_v" @@ -198,23 +197,23 @@ type TestField struct { } // NewTestField returns a new instance of TestField d/0. -func NewTestField(t *testing.T, opts FieldOption) *TestField { +func NewTestField(opts FieldOption) *TestField { path, err := ioutil.TempDir(*TempDir, "pilosa-field-") if err != nil { - t.Fatal(err) + panic(err) } field, err := NewField(path, "i", "f", opts) if err != nil { - t.Fatal(err) + panic(err) } return &TestField{Field: field} } -// OpenField returns a new, opened field at a temporary path. -func OpenField(t *testing.T, opts FieldOption) *TestField { - f := NewTestField(t, opts) +// MustOpenField returns a new, opened field at a temporary path. Panic on error. +func MustOpenField(opts FieldOption) *TestField { + f := NewTestField(opts) if err := f.Open(); err != nil { - t.Fatal(err) + panic(err) } return f } @@ -261,7 +260,7 @@ func (f *TestField) MustSetBit(row, col uint64, ts ...time.Time) { // Ensure field can open and retrieve a view. func TestField_CreateViewIfNotExists(t *testing.T) { - f := OpenField(t, OptFieldTypeDefault()) + f := MustOpenField(OptFieldTypeDefault()) defer f.Close() // Create view. @@ -286,7 +285,7 @@ func TestField_CreateViewIfNotExists(t *testing.T) { } func TestField_SetTimeQuantum(t *testing.T) { - f := OpenField(t, OptFieldTypeTime(TimeQuantum(""))) + f := MustOpenField(OptFieldTypeTime(TimeQuantum(""))) defer f.Close() // Set & retrieve time quantum. @@ -305,7 +304,7 @@ func TestField_SetTimeQuantum(t *testing.T) { } func TestField_RowTime(t *testing.T) { - f := OpenField(t, OptFieldTypeTime(TimeQuantum(""))) + f := MustOpenField(OptFieldTypeTime(TimeQuantum(""))) defer f.Close() if err := f.setTimeQuantum(TimeQuantum("YMDH")); err != nil { @@ -351,7 +350,7 @@ func TestField_RowTime(t *testing.T) { } func TestField_PersistAvailableShards(t *testing.T) { - f := OpenField(t, OptFieldTypeDefault()) + f := MustOpenField(OptFieldTypeDefault()) // bm represents remote available shards. bm := roaring.NewBitmap(1, 2, 3) @@ -370,7 +369,7 @@ func TestField_PersistAvailableShards(t *testing.T) { } func TestField_CorruptAvailableShards(t *testing.T) { - f := OpenField(t, OptFieldTypeDefault()) + f := MustOpenField(OptFieldTypeDefault()) // bm represents remote available shards. bm := roaring.NewBitmap(1, 2, 3) @@ -400,7 +399,7 @@ func TestField_CorruptAvailableShards(t *testing.T) { } func TestField_TruncatedAvailableShards(t *testing.T) { - f := OpenField(t, OptFieldTypeDefault()) + f := MustOpenField(OptFieldTypeDefault()) // bm represents remote available shards. bm := roaring.NewBitmap(1, 2, 3) @@ -428,7 +427,7 @@ func TestField_TruncatedAvailableShards(t *testing.T) { // Ensure that persisting available shards having a smaller footprint (for example, // when going from a bitmap to a smaller, RLE representation) succeeds. func TestField_PersistAvailableShardsFootprint(t *testing.T) { - f := OpenField(t, OptFieldTypeDefault()) + f := MustOpenField(OptFieldTypeDefault()) // bm represents remote available shards. bm := roaring.NewBitmap() @@ -539,7 +538,7 @@ func TestField_ApplyOptions(t *testing.T) { // into consideration. This would cause an import of 1/8/1 // to result in a value of 9 instead of 1. func TestBSIGroup_importValue(t *testing.T) { - f := OpenField(t, OptFieldTypeInt(-100, 200)) + f := MustOpenField(OptFieldTypeInt(-100, 200)) options := &ImportOptions{} for i, tt := range []struct { @@ -580,7 +579,7 @@ func TestBSIGroup_importValue(t *testing.T) { } func TestIntField_MinMaxForShard(t *testing.T) { - f := OpenField(t, OptFieldTypeInt(-100, 200)) + f := MustOpenField(OptFieldTypeInt(-100, 200)) options := &ImportOptions{} for i, test := range []struct { @@ -655,86 +654,33 @@ func TestIntField_MinMaxForShard(t *testing.T) { } } -// Ensure we get errors when they are expected. func TestDecimalField_MinMaxBoundaries(t *testing.T) { for i, test := range []struct { + min int64 + max int64 scale int64 - min pql.Decimal - max pql.Decimal - expErr bool + expmin int64 + expmax int64 }{ - { - scale: 3, - min: pql.NewDecimal(math.MinInt64, 0), - max: pql.NewDecimal(math.MaxInt64, 0), - expErr: true, - }, - { - scale: 3, - min: pql.NewDecimal(math.MinInt64, 3), - max: pql.NewDecimal(math.MaxInt64, 3), - expErr: false, - }, - { - scale: 3, - min: pql.NewDecimal(44, 0), - max: pql.NewDecimal(88, 0), - expErr: false, - }, - { - scale: 3, - min: pql.NewDecimal(-44, 0), - max: pql.NewDecimal(88, 0), - expErr: false, - }, - { - scale: 19, - min: pql.NewDecimal(1, 0), - max: pql.NewDecimal(2, 0), - expErr: true, - }, - { - scale: 19, - min: pql.NewDecimal(math.MinInt64, 18), - max: pql.NewDecimal(math.MaxInt64, 18), - expErr: true, - }, - { - scale: 0, - min: pql.NewDecimal(1, 20), - max: pql.NewDecimal(2, 20), - expErr: true, - }, - { - scale: 0, - min: pql.NewDecimal(1, -1), - max: pql.NewDecimal(2, -1), - expErr: false, - }, - { - scale: 0, - min: pql.NewDecimal(1, -19), - max: pql.NewDecimal(2, -19), - expErr: true, - }, + {min: math.MinInt64, max: math.MaxInt64, scale: 3, expmin: math.MinInt64, expmax: math.MaxInt64}, + {min: 44, max: 88, scale: 3, expmin: 44000, expmax: 88000}, + {min: -44, max: 88, scale: 3, expmin: -44000, expmax: 88000}, } { t.Run("minmax"+strconv.Itoa(i), func(t *testing.T) { - _, err := NewField("no-path", "i", "f", OptFieldTypeDecimal(test.scale, test.min, test.max)) - if err != nil && test.expErr { - if !strings.Contains(err.Error(), "is not supported") { - t.Fatal(err) - } - } else if err != nil && !test.expErr { - t.Fatalf("did not expect error, but got: %s", err) - } else if err == nil && test.expErr { - t.Fatal("expected error, but got none") + f := MustOpenField(OptFieldTypeDecimal(test.scale, test.min, test.max)) + + if f.Options().Min != test.expmin { + t.Fatalf("expected min: %v, but got: %v", test.expmin, f.Options().Min) + } + if f.Options().Max != test.expmax { + t.Fatalf("expected max: %v, but got: %v", test.expmax, f.Options().Max) } }) } } func TestDecimalField_MinMaxForShard(t *testing.T) { - f := OpenField(t, OptFieldTypeDecimal(3)) + f := MustOpenField(OptFieldTypeDecimal(3)) options := &ImportOptions{} for i, test := range []struct { diff --git a/http/client_test.go b/http/client_test.go index 9d8f61aca..3990e23ea 100644 --- a/http/client_test.go +++ b/http/client_test.go @@ -1147,7 +1147,7 @@ func TestClient_CreateDecimalField(t *testing.T) { t.Fatalf("creating index: %v", err) } field := "dfield" - err = c.CreateFieldWithOptions(context.Background(), index, field, pilosa.FieldOptions{Type: pilosa.FieldTypeDecimal, Scale: 1, Min: pql.NewDecimal(-1000, 0), Max: pql.NewDecimal(1000, 0)}) + err = c.CreateFieldWithOptions(context.Background(), index, field, pilosa.FieldOptions{Type: pilosa.FieldTypeDecimal, Scale: 1, Min: -1000, Max: 1000}) if err != nil { t.Fatalf("creating field: %v", err) } diff --git a/http/handler.go b/http/handler.go index 584791d75..923d37819 100644 --- a/http/handler.go +++ b/http/handler.go @@ -37,7 +37,6 @@ import ( "github.com/gorilla/mux" "github.com/pilosa/pilosa/v2" "github.com/pilosa/pilosa/v2/logger" - "github.com/pilosa/pilosa/v2/pql" "github.com/pilosa/pilosa/v2/tracing" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus/promhttp" @@ -798,39 +797,24 @@ func (h *Handler) handlePostField(w http.ResponseWriter, r *http.Request) { switch req.Options.Type { case pilosa.FieldTypeSet: fos = append(fos, pilosa.OptFieldTypeSet(*req.Options.CacheType, *req.Options.CacheSize)) - case pilosa.FieldTypeInt: + case pilosa.FieldTypeInt, pilosa.FieldTypeDecimal: if req.Options.Min == nil { - min := pql.NewDecimal(int64(math.MinInt64), 0) + min := int64(math.MinInt64) req.Options.Min = &min } if req.Options.Max == nil { - max := pql.NewDecimal(int64(math.MaxInt64), 0) + max := int64(math.MaxInt64) req.Options.Max = &max } - fos = append(fos, pilosa.OptFieldTypeInt(req.Options.Min.ToInt64(0), req.Options.Max.ToInt64(0))) - case pilosa.FieldTypeDecimal: - scale := int64(0) - if req.Options.Scale != nil { - scale = *req.Options.Scale - } - if req.Options.Min == nil { - min := pql.NewDecimal(int64(math.MinInt64), scale) - req.Options.Min = &min - } - if req.Options.Max == nil { - max := pql.NewDecimal(int64(math.MaxInt64), scale) - req.Options.Max = &max - } - var minmax []pql.Decimal - if req.Options.Min != nil { - minmax = []pql.Decimal{ - *req.Options.Min, - } - if req.Options.Max != nil { - minmax = append(minmax, *req.Options.Max) + if req.Options.Type == pilosa.FieldTypeDecimal { + scale := int64(0) + if req.Options.Scale != nil { + scale = *req.Options.Scale } + fos = append(fos, pilosa.OptFieldTypeDecimal(scale, *req.Options.Min, *req.Options.Max)) + } else { + fos = append(fos, pilosa.OptFieldTypeInt(*req.Options.Min, *req.Options.Max)) } - fos = append(fos, pilosa.OptFieldTypeDecimal(scale, minmax...)) case pilosa.FieldTypeTime: fos = append(fos, pilosa.OptFieldTypeTime(*req.Options.TimeQuantum, req.Options.NoStandardView)) case pilosa.FieldTypeMutex: @@ -865,8 +849,8 @@ type fieldOptions struct { Type string `json:"type,omitempty"` CacheType *string `json:"cacheType,omitempty"` CacheSize *uint32 `json:"cacheSize,omitempty"` - Min *pql.Decimal `json:"min,omitempty"` - Max *pql.Decimal `json:"max,omitempty"` + Min *int64 `json:"min,omitempty"` + Max *int64 `json:"max,omitempty"` Scale *int64 `json:"scale,omitempty"` TimeQuantum *pilosa.TimeQuantum `json:"timeQuantum,omitempty"` Keys *bool `json:"keys,omitempty"` @@ -902,7 +886,7 @@ func (o *fieldOptions) validate() error { } else if o.ForeignIndex != nil { return pilosa.NewBadRequestError(errors.New("set field cannot be a foreign key")) } - case pilosa.FieldTypeInt: + case pilosa.FieldTypeInt, pilosa.FieldTypeDecimal: if o.CacheType != nil { return pilosa.NewBadRequestError(errors.New("cacheType does not apply to field type int")) } else if o.CacheSize != nil { @@ -912,18 +896,6 @@ func (o *fieldOptions) validate() error { } else if o.ForeignIndex != nil && o.Type == pilosa.FieldTypeDecimal { return pilosa.NewBadRequestError(errors.New("decimal field cannot be a foreign key")) } - case pilosa.FieldTypeDecimal: - if o.Scale == nil { - return pilosa.NewBadRequestError(errors.New("decimal field requires a scale argument")) - } else if o.CacheType != nil { - return pilosa.NewBadRequestError(errors.New("cacheType does not apply to field type int")) - } else if o.CacheSize != nil { - return pilosa.NewBadRequestError(errors.New("cacheSize does not apply to field type int")) - } else if o.TimeQuantum != nil { - return pilosa.NewBadRequestError(errors.New("timeQuantum does not apply to field type int")) - } else if o.ForeignIndex != nil && o.Type == pilosa.FieldTypeDecimal { - return pilosa.NewBadRequestError(errors.New("decimal field cannot be a foreign key")) - } case pilosa.FieldTypeTime: if o.CacheType != nil { return pilosa.NewBadRequestError(errors.New("cacheType does not apply to field type time")) diff --git a/http/handler_internal_test.go b/http/handler_internal_test.go index 466030a24..f9d67a077 100644 --- a/http/handler_internal_test.go +++ b/http/handler_internal_test.go @@ -22,7 +22,6 @@ import ( "testing" "github.com/pilosa/pilosa/v2" - "github.com/pilosa/pilosa/v2/pql" ) // Test custom UnmarshalJSON for postIndexRequest object @@ -100,8 +99,8 @@ func stringPtr(s string) *string { return &s } -func decimalPtr(d pql.Decimal) *pql.Decimal { - return &d +func int64Ptr(i int64) *int64 { + return &i } // Test fieldOption validation. @@ -136,10 +135,10 @@ func TestFieldOptionValidation(t *testing.T) { // FieldType: Int {json: `{"options": {"type": "int"}}`, err: "min is required for field type int"}, {json: `{"options": {"type": "int", "min": 0}}`, err: "max is required for field type int"}, - {json: `{"options": {"type": "int", "min": 0, "max": 1001}}`, expected: postFieldRequest{Options: fieldOptions{ + {json: `{"options": {"type": "int", "min": 0, "max": 1000}}`, expected: postFieldRequest{Options: fieldOptions{ Type: pilosa.FieldTypeInt, - Min: decimalPtr(pql.NewDecimal(0, 0)), - Max: decimalPtr(pql.NewDecimal(1001, 0)), + Min: int64Ptr(0), + Max: int64Ptr(1000), }}}, {json: `{"options": {"type": "int", "min": 0, "max": 1000, "cacheType": "ranked"}}`, err: "cacheType does not apply to field type int"}, {json: `{"options": {"type": "int", "min": 0, "max": 1000, "cacheSize": 1000}}`, err: "cacheSize does not apply to field type int"}, diff --git a/index_test.go b/index_test.go index 63e9b6179..6a5811c03 100644 --- a/index_test.go +++ b/index_test.go @@ -20,7 +20,6 @@ import ( "testing" "github.com/pilosa/pilosa/v2" - "github.com/pilosa/pilosa/v2/pql" "github.com/pilosa/pilosa/v2/test" "github.com/pkg/errors" ) @@ -204,7 +203,7 @@ func TestIndex_CreateField(t *testing.T) { index := test.MustOpenIndex() defer index.Close() - _, err := index.CreateField("f", pilosa.OptFieldTypeDecimal(1, pql.Decimal{Value: -1}, pql.Decimal{Value: 1}), pilosa.OptFieldKeys()) + _, err := index.CreateField("f", pilosa.OptFieldTypeDecimal(1, -1, 1), pilosa.OptFieldKeys()) if errors.Cause(err) != pilosa.ErrDecimalFieldWithKeys { t.Fatal("decimal field cannot be created with keys=true") } diff --git a/internal/private.pb.go b/internal/private.pb.go index 4ca901b58..563b23f0d 100644 --- a/internal/private.pb.go +++ b/internal/private.pb.go @@ -82,14 +82,14 @@ type FieldOptions struct { CacheType string `protobuf:"bytes,3,opt,name=CacheType,proto3" json:"CacheType,omitempty"` CacheSize uint32 `protobuf:"varint,4,opt,name=CacheSize,proto3" json:"CacheSize,omitempty"` TimeQuantum string `protobuf:"bytes,5,opt,name=TimeQuantum,proto3" json:"TimeQuantum,omitempty"` + Min int64 `protobuf:"varint,9,opt,name=Min,proto3" json:"Min,omitempty"` + Max int64 `protobuf:"varint,10,opt,name=Max,proto3" json:"Max,omitempty"` Keys bool `protobuf:"varint,11,opt,name=Keys,proto3" json:"Keys,omitempty"` NoStandardView bool `protobuf:"varint,12,opt,name=NoStandardView,proto3" json:"NoStandardView,omitempty"` Base int64 `protobuf:"varint,13,opt,name=Base,proto3" json:"Base,omitempty"` BitDepth uint64 `protobuf:"varint,14,opt,name=BitDepth,proto3" json:"BitDepth,omitempty"` Scale int64 `protobuf:"varint,15,opt,name=Scale,proto3" json:"Scale,omitempty"` ForeignIndex string `protobuf:"bytes,16,opt,name=ForeignIndex,proto3" json:"ForeignIndex,omitempty"` - Min *Decimal `protobuf:"bytes,17,opt,name=Min,proto3" json:"Min,omitempty"` - Max *Decimal `protobuf:"bytes,18,opt,name=Max,proto3" json:"Max,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -156,6 +156,20 @@ func (m *FieldOptions) GetTimeQuantum() string { return "" } +func (m *FieldOptions) GetMin() int64 { + if m != nil { + return m.Min + } + return 0 +} + +func (m *FieldOptions) GetMax() int64 { + if m != nil { + return m.Max + } + return 0 +} + func (m *FieldOptions) GetKeys() bool { if m != nil { return m.Keys @@ -198,75 +212,6 @@ func (m *FieldOptions) GetForeignIndex() string { return "" } -func (m *FieldOptions) GetMin() *Decimal { - if m != nil { - return m.Min - } - return nil -} - -func (m *FieldOptions) GetMax() *Decimal { - if m != nil { - return m.Max - } - return nil -} - -type Decimal struct { - Value int64 `protobuf:"varint,1,opt,name=Value,proto3" json:"Value,omitempty"` - Scale int64 `protobuf:"varint,2,opt,name=Scale,proto3" json:"Scale,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Decimal) Reset() { *m = Decimal{} } -func (m *Decimal) String() string { return proto.CompactTextString(m) } -func (*Decimal) ProtoMessage() {} -func (*Decimal) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{2} -} -func (m *Decimal) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Decimal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Decimal.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Decimal) XXX_Merge(src proto.Message) { - xxx_messageInfo_Decimal.Merge(m, src) -} -func (m *Decimal) XXX_Size() int { - return m.Size() -} -func (m *Decimal) XXX_DiscardUnknown() { - xxx_messageInfo_Decimal.DiscardUnknown(m) -} - -var xxx_messageInfo_Decimal proto.InternalMessageInfo - -func (m *Decimal) GetValue() int64 { - if m != nil { - return m.Value - } - return 0 -} - -func (m *Decimal) GetScale() int64 { - if m != nil { - return m.Scale - } - return 0 -} - type ImportResponse struct { Err string `protobuf:"bytes,1,opt,name=Err,proto3" json:"Err,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -278,7 +223,7 @@ func (m *ImportResponse) Reset() { *m = ImportResponse{} } func (m *ImportResponse) String() string { return proto.CompactTextString(m) } func (*ImportResponse) ProtoMessage() {} func (*ImportResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{3} + return fileDescriptor_d2a91b51c7bdc125, []int{2} } func (m *ImportResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -329,7 +274,7 @@ func (m *BlockDataRequest) Reset() { *m = BlockDataRequest{} } func (m *BlockDataRequest) String() string { return proto.CompactTextString(m) } func (*BlockDataRequest) ProtoMessage() {} func (*BlockDataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{4} + return fileDescriptor_d2a91b51c7bdc125, []int{3} } func (m *BlockDataRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -405,7 +350,7 @@ func (m *BlockDataResponse) Reset() { *m = BlockDataResponse{} } func (m *BlockDataResponse) String() string { return proto.CompactTextString(m) } func (*BlockDataResponse) ProtoMessage() {} func (*BlockDataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{5} + return fileDescriptor_d2a91b51c7bdc125, []int{4} } func (m *BlockDataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -459,7 +404,7 @@ func (m *Cache) Reset() { *m = Cache{} } func (m *Cache) String() string { return proto.CompactTextString(m) } func (*Cache) ProtoMessage() {} func (*Cache) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{6} + return fileDescriptor_d2a91b51c7bdc125, []int{5} } func (m *Cache) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -506,7 +451,7 @@ func (m *MaxShards) Reset() { *m = MaxShards{} } func (m *MaxShards) String() string { return proto.CompactTextString(m) } func (*MaxShards) ProtoMessage() {} func (*MaxShards) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{7} + return fileDescriptor_d2a91b51c7bdc125, []int{6} } func (m *MaxShards) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -555,7 +500,7 @@ func (m *CreateShardMessage) Reset() { *m = CreateShardMessage{} } func (m *CreateShardMessage) String() string { return proto.CompactTextString(m) } func (*CreateShardMessage) ProtoMessage() {} func (*CreateShardMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{8} + return fileDescriptor_d2a91b51c7bdc125, []int{7} } func (m *CreateShardMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -616,7 +561,7 @@ func (m *DeleteIndexMessage) Reset() { *m = DeleteIndexMessage{} } func (m *DeleteIndexMessage) String() string { return proto.CompactTextString(m) } func (*DeleteIndexMessage) ProtoMessage() {} func (*DeleteIndexMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{9} + return fileDescriptor_d2a91b51c7bdc125, []int{8} } func (m *DeleteIndexMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -664,7 +609,7 @@ func (m *CreateIndexMessage) Reset() { *m = CreateIndexMessage{} } func (m *CreateIndexMessage) String() string { return proto.CompactTextString(m) } func (*CreateIndexMessage) ProtoMessage() {} func (*CreateIndexMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{10} + return fileDescriptor_d2a91b51c7bdc125, []int{9} } func (m *CreateIndexMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -720,7 +665,7 @@ func (m *CreateFieldMessage) Reset() { *m = CreateFieldMessage{} } func (m *CreateFieldMessage) String() string { return proto.CompactTextString(m) } func (*CreateFieldMessage) ProtoMessage() {} func (*CreateFieldMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{11} + return fileDescriptor_d2a91b51c7bdc125, []int{10} } func (m *CreateFieldMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -782,7 +727,7 @@ func (m *DeleteFieldMessage) Reset() { *m = DeleteFieldMessage{} } func (m *DeleteFieldMessage) String() string { return proto.CompactTextString(m) } func (*DeleteFieldMessage) ProtoMessage() {} func (*DeleteFieldMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{12} + return fileDescriptor_d2a91b51c7bdc125, []int{11} } func (m *DeleteFieldMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -838,7 +783,7 @@ func (m *DeleteAvailableShardMessage) Reset() { *m = DeleteAvailableShar func (m *DeleteAvailableShardMessage) String() string { return proto.CompactTextString(m) } func (*DeleteAvailableShardMessage) ProtoMessage() {} func (*DeleteAvailableShardMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{13} + return fileDescriptor_d2a91b51c7bdc125, []int{12} } func (m *DeleteAvailableShardMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -901,7 +846,7 @@ func (m *Field) Reset() { *m = Field{} } func (m *Field) String() string { return proto.CompactTextString(m) } func (*Field) ProtoMessage() {} func (*Field) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{14} + return fileDescriptor_d2a91b51c7bdc125, []int{13} } func (m *Field) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -962,7 +907,7 @@ func (m *Schema) Reset() { *m = Schema{} } func (m *Schema) String() string { return proto.CompactTextString(m) } func (*Schema) ProtoMessage() {} func (*Schema) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{15} + return fileDescriptor_d2a91b51c7bdc125, []int{14} } func (m *Schema) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1011,7 +956,7 @@ func (m *Index) Reset() { *m = Index{} } func (m *Index) String() string { return proto.CompactTextString(m) } func (*Index) ProtoMessage() {} func (*Index) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{16} + return fileDescriptor_d2a91b51c7bdc125, []int{15} } func (m *Index) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1074,7 +1019,7 @@ func (m *URI) Reset() { *m = URI{} } func (m *URI) String() string { return proto.CompactTextString(m) } func (*URI) ProtoMessage() {} func (*URI) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{17} + return fileDescriptor_d2a91b51c7bdc125, []int{16} } func (m *URI) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1138,7 +1083,7 @@ func (m *Node) Reset() { *m = Node{} } func (m *Node) String() string { return proto.CompactTextString(m) } func (*Node) ProtoMessage() {} func (*Node) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{18} + return fileDescriptor_d2a91b51c7bdc125, []int{17} } func (m *Node) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1207,7 +1152,7 @@ func (m *NodeStateMessage) Reset() { *m = NodeStateMessage{} } func (m *NodeStateMessage) String() string { return proto.CompactTextString(m) } func (*NodeStateMessage) ProtoMessage() {} func (*NodeStateMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{19} + return fileDescriptor_d2a91b51c7bdc125, []int{18} } func (m *NodeStateMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1262,7 +1207,7 @@ func (m *NodeEventMessage) Reset() { *m = NodeEventMessage{} } func (m *NodeEventMessage) String() string { return proto.CompactTextString(m) } func (*NodeEventMessage) ProtoMessage() {} func (*NodeEventMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{20} + return fileDescriptor_d2a91b51c7bdc125, []int{19} } func (m *NodeEventMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1318,7 +1263,7 @@ func (m *NodeStatus) Reset() { *m = NodeStatus{} } func (m *NodeStatus) String() string { return proto.CompactTextString(m) } func (*NodeStatus) ProtoMessage() {} func (*NodeStatus) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{21} + return fileDescriptor_d2a91b51c7bdc125, []int{20} } func (m *NodeStatus) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1380,7 +1325,7 @@ func (m *IndexStatus) Reset() { *m = IndexStatus{} } func (m *IndexStatus) String() string { return proto.CompactTextString(m) } func (*IndexStatus) ProtoMessage() {} func (*IndexStatus) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{22} + return fileDescriptor_d2a91b51c7bdc125, []int{21} } func (m *IndexStatus) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1435,7 +1380,7 @@ func (m *FieldStatus) Reset() { *m = FieldStatus{} } func (m *FieldStatus) String() string { return proto.CompactTextString(m) } func (*FieldStatus) ProtoMessage() {} func (*FieldStatus) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{23} + return fileDescriptor_d2a91b51c7bdc125, []int{22} } func (m *FieldStatus) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1491,7 +1436,7 @@ func (m *ClusterStatus) Reset() { *m = ClusterStatus{} } func (m *ClusterStatus) String() string { return proto.CompactTextString(m) } func (*ClusterStatus) ProtoMessage() {} func (*ClusterStatus) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{24} + return fileDescriptor_d2a91b51c7bdc125, []int{23} } func (m *ClusterStatus) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1555,7 +1500,7 @@ func (m *BSIGroup) Reset() { *m = BSIGroup{} } func (m *BSIGroup) String() string { return proto.CompactTextString(m) } func (*BSIGroup) ProtoMessage() {} func (*BSIGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{25} + return fileDescriptor_d2a91b51c7bdc125, []int{24} } func (m *BSIGroup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1625,7 +1570,7 @@ func (m *CreateViewMessage) Reset() { *m = CreateViewMessage{} } func (m *CreateViewMessage) String() string { return proto.CompactTextString(m) } func (*CreateViewMessage) ProtoMessage() {} func (*CreateViewMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{26} + return fileDescriptor_d2a91b51c7bdc125, []int{25} } func (m *CreateViewMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1688,7 +1633,7 @@ func (m *DeleteViewMessage) Reset() { *m = DeleteViewMessage{} } func (m *DeleteViewMessage) String() string { return proto.CompactTextString(m) } func (*DeleteViewMessage) ProtoMessage() {} func (*DeleteViewMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{27} + return fileDescriptor_d2a91b51c7bdc125, []int{26} } func (m *DeleteViewMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1755,7 +1700,7 @@ func (m *ResizeInstruction) Reset() { *m = ResizeInstruction{} } func (m *ResizeInstruction) String() string { return proto.CompactTextString(m) } func (*ResizeInstruction) ProtoMessage() {} func (*ResizeInstruction) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{28} + return fileDescriptor_d2a91b51c7bdc125, []int{27} } func (m *ResizeInstruction) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1848,7 +1793,7 @@ func (m *ResizeSource) Reset() { *m = ResizeSource{} } func (m *ResizeSource) String() string { return proto.CompactTextString(m) } func (*ResizeSource) ProtoMessage() {} func (*ResizeSource) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{29} + return fileDescriptor_d2a91b51c7bdc125, []int{28} } func (m *ResizeSource) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1925,7 +1870,7 @@ func (m *TranslationResizeSource) Reset() { *m = TranslationResizeSource func (m *TranslationResizeSource) String() string { return proto.CompactTextString(m) } func (*TranslationResizeSource) ProtoMessage() {} func (*TranslationResizeSource) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{30} + return fileDescriptor_d2a91b51c7bdc125, []int{29} } func (m *TranslationResizeSource) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1988,7 +1933,7 @@ func (m *ResizeInstructionComplete) Reset() { *m = ResizeInstructionComp func (m *ResizeInstructionComplete) String() string { return proto.CompactTextString(m) } func (*ResizeInstructionComplete) ProtoMessage() {} func (*ResizeInstructionComplete) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{31} + return fileDescriptor_d2a91b51c7bdc125, []int{30} } func (m *ResizeInstructionComplete) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2049,7 +1994,7 @@ func (m *SetCoordinatorMessage) Reset() { *m = SetCoordinatorMessage{} } func (m *SetCoordinatorMessage) String() string { return proto.CompactTextString(m) } func (*SetCoordinatorMessage) ProtoMessage() {} func (*SetCoordinatorMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{32} + return fileDescriptor_d2a91b51c7bdc125, []int{31} } func (m *SetCoordinatorMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2096,7 +2041,7 @@ func (m *UpdateCoordinatorMessage) Reset() { *m = UpdateCoordinatorMessa func (m *UpdateCoordinatorMessage) String() string { return proto.CompactTextString(m) } func (*UpdateCoordinatorMessage) ProtoMessage() {} func (*UpdateCoordinatorMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{33} + return fileDescriptor_d2a91b51c7bdc125, []int{32} } func (m *UpdateCoordinatorMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2144,7 +2089,7 @@ func (m *Topology) Reset() { *m = Topology{} } func (m *Topology) String() string { return proto.CompactTextString(m) } func (*Topology) ProtoMessage() {} func (*Topology) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{34} + return fileDescriptor_d2a91b51c7bdc125, []int{33} } func (m *Topology) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2197,7 +2142,7 @@ func (m *RecalculateCaches) Reset() { *m = RecalculateCaches{} } func (m *RecalculateCaches) String() string { return proto.CompactTextString(m) } func (*RecalculateCaches) ProtoMessage() {} func (*RecalculateCaches) Descriptor() ([]byte, []int) { - return fileDescriptor_d2a91b51c7bdc125, []int{35} + return fileDescriptor_d2a91b51c7bdc125, []int{34} } func (m *RecalculateCaches) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2229,7 +2174,6 @@ var xxx_messageInfo_RecalculateCaches proto.InternalMessageInfo func init() { proto.RegisterType((*IndexMeta)(nil), "internal.IndexMeta") proto.RegisterType((*FieldOptions)(nil), "internal.FieldOptions") - proto.RegisterType((*Decimal)(nil), "internal.Decimal") proto.RegisterType((*ImportResponse)(nil), "internal.ImportResponse") proto.RegisterType((*BlockDataRequest)(nil), "internal.BlockDataRequest") proto.RegisterType((*BlockDataResponse)(nil), "internal.BlockDataResponse") @@ -2269,88 +2213,85 @@ func init() { func init() { proto.RegisterFile("private.proto", fileDescriptor_d2a91b51c7bdc125) } var fileDescriptor_d2a91b51c7bdc125 = []byte{ - // 1287 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xdb, 0x72, 0xdb, 0xc4, - 0x1b, 0xff, 0x4b, 0x72, 0x62, 0xfb, 0x73, 0x9c, 0x3a, 0xdb, 0x93, 0xda, 0x3f, 0x13, 0xcc, 0xd2, - 0xa1, 0xa6, 0x33, 0x84, 0x4e, 0x0b, 0x33, 0x9c, 0x3a, 0x53, 0x12, 0xa7, 0xc5, 0x94, 0x84, 0x76, - 0x9d, 0xe6, 0x8e, 0x8b, 0xad, 0xbc, 0xd3, 0x68, 0x22, 0x4b, 0x46, 0x5a, 0xe5, 0xd0, 0x0b, 0x6e, - 0x61, 0x86, 0x17, 0xe0, 0x91, 0xb8, 0xe4, 0x11, 0x98, 0xf2, 0x02, 0xdc, 0x72, 0xc7, 0xec, 0xb7, - 0xbb, 0x3a, 0xb8, 0x09, 0x29, 0x29, 0x77, 0xfa, 0xce, 0xbf, 0xfd, 0x4e, 0xbb, 0x82, 0xee, 0x2c, - 0x0d, 0x0f, 0xb8, 0x14, 0x6b, 0xb3, 0x34, 0x91, 0x09, 0x69, 0x85, 0xb1, 0x14, 0x69, 0xcc, 0x23, - 0xfa, 0x10, 0xda, 0xa3, 0x78, 0x22, 0x8e, 0xb6, 0x84, 0xe4, 0x84, 0x40, 0xe3, 0x91, 0x38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 0xb2, 0x66, 0x2b, 0xb1, 0x36, 0x14, 0x41, 0x38, 0xe5, 0x11, 0x53, 0x52, - 0x54, 0xe2, 0x47, 0x3e, 0x39, 0x5d, 0x89, 0x1f, 0xd1, 0x8f, 0xa1, 0x69, 0x68, 0x05, 0x67, 0x97, - 0x47, 0xb9, 0xf0, 0x1d, 0x0d, 0x07, 0x89, 0x12, 0xa4, 0x5b, 0x01, 0x49, 0x29, 0x2c, 0x8f, 0xa6, - 0xb3, 0x24, 0x95, 0x4c, 0x64, 0xb3, 0x24, 0xce, 0x04, 0xe9, 0x81, 0xb7, 0x99, 0xa6, 0x68, 0xdb, - 0x66, 0xea, 0x93, 0xfe, 0x00, 0xbd, 0xf5, 0x28, 0x09, 0xf6, 0x87, 0x5c, 0x72, 0x26, 0xbe, 0xcf, - 0x45, 0x26, 0x95, 0x37, 0x7d, 0x2a, 0xad, 0xa7, 0x09, 0xc5, 0xc5, 0xb2, 0x63, 0x8c, 0x36, 0xd3, - 0x84, 0x4a, 0x27, 0x26, 0x5b, 0x57, 0x09, 0xbf, 0x11, 0xcd, 0x1e, 0x4f, 0x27, 0x58, 0xda, 0x06, - 0xd3, 0x84, 0xe2, 0x62, 0x24, 0x6c, 0x87, 0x06, 0xd3, 0x04, 0x1d, 0xc1, 0x4a, 0x25, 0xbe, 0x81, - 0x79, 0x05, 0x16, 0x59, 0x72, 0x38, 0x1a, 0x66, 0xbe, 0xd3, 0xf7, 0x06, 0x0d, 0x66, 0x28, 0xec, - 0x9b, 0x24, 0xca, 0xa7, 0xb1, 0x12, 0xb9, 0x28, 0x2a, 0x19, 0xf4, 0x1a, 0x2c, 0x60, 0x13, 0xa9, - 0x53, 0x96, 0xb6, 0xea, 0x93, 0xfe, 0xe8, 0x40, 0x7b, 0x8b, 0x1f, 0x21, 0x90, 0x8c, 0xdc, 0x83, - 0x96, 0x6d, 0x09, 0x54, 0xea, 0xdc, 0x79, 0xa7, 0x4c, 0x7c, 0xa1, 0xb6, 0x66, 0x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, 0xbc, 0x0f, 0x4d, 0x44, 0x28, 0x32, 0xd3, 0xd1, 0x17, 0xe6, 0x2a, 0xc5, - 0xac, 0x9c, 0x66, 0xe6, 0x64, 0x27, 0x62, 0xfa, 0x00, 0x9a, 0x26, 0x30, 0x4e, 0xf4, 0x29, 0x15, - 0xb7, 0x3a, 0xe4, 0x26, 0x2c, 0x22, 0xd8, 0xcc, 0x6f, 0xcc, 0x47, 0x45, 0x3e, 0x33, 0x62, 0xba, - 0x09, 0xde, 0x53, 0x36, 0x52, 0x83, 0x8d, 0x80, 0x6d, 0x50, 0x43, 0x29, 0x28, 0x5f, 0x25, 0x99, - 0x34, 0x69, 0xc5, 0x6f, 0xc5, 0x7b, 0x9c, 0xa4, 0x12, 0x53, 0xda, 0x65, 0xf8, 0x4d, 0x33, 0x68, - 0x6c, 0x27, 0x13, 0x41, 0x96, 0xc1, 0x1d, 0x0d, 0x8d, 0x0f, 0x77, 0x34, 0x24, 0x6f, 0xa3, 0x7b, - 0x93, 0xc9, 0x6e, 0x09, 0xe2, 0x29, 0x1b, 0x31, 0x0c, 0x7c, 0x03, 0xba, 0xa3, 0x6c, 0x23, 0x49, - 0xd2, 0x49, 0x18, 0x73, 0x99, 0xa4, 0xe6, 0xe6, 0xab, 0x33, 0x71, 0xb4, 0x24, 0x97, 0xfa, 0x4e, - 0x6a, 0x33, 0x4d, 0xd0, 0xfb, 0xd0, 0x53, 0x41, 0x91, 0xb0, 0xed, 0x71, 0x05, 0x16, 0x15, 0xaf, - 0x00, 0x61, 0xa8, 0xd2, 0x83, 0x5b, 0xf5, 0xf0, 0x8d, 0xf6, 0xb0, 0x79, 0x20, 0x62, 0x59, 0x69, - 0x30, 0xa4, 0xd1, 0x41, 0x97, 0x69, 0x82, 0x50, 0x7d, 0x40, 0x73, 0x92, 0xe5, 0xf2, 0x24, 0x8a, - 0xcb, 0x50, 0x46, 0x7f, 0x76, 0x00, 0x2c, 0xa0, 0x3c, 0x2b, 0x4c, 0x9c, 0xd3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, 0xf1, 0x19, 0xbb, 0xcc, 0x87, 0xa6, 0xbe, 0x95, 0xf4, 0x72, - 0x6c, 0x33, 0x4b, 0xd2, 0x8b, 0x6a, 0x4c, 0x03, 0x1e, 0x05, 0x79, 0xa4, 0x60, 0xa8, 0x47, 0x73, - 0xb6, 0xde, 0xfb, 0xf5, 0xe5, 0xaa, 0xf3, 0xdb, 0xcb, 0x55, 0xe7, 0xf7, 0x97, 0xab, 0xce, 0x2f, - 0x7f, 0xac, 0xfe, 0xef, 0xd9, 0x22, 0xfe, 0x43, 0xde, 0xfd, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xa0, - 0x67, 0xe6, 0x48, 0x54, 0x0e, 0x00, 0x00, + // 1247 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xdb, 0x6e, 0x1b, 0xc5, + 0x1b, 0xff, 0xef, 0x21, 0x89, 0xfd, 0x39, 0x4e, 0xd3, 0xe9, 0x69, 0xdb, 0x3f, 0x0a, 0x66, 0x54, + 0x51, 0x53, 0x89, 0x50, 0xb5, 0x5c, 0x70, 0xaa, 0x54, 0x12, 0xa7, 0x65, 0x29, 0x09, 0xed, 0x38, + 0xed, 0x1d, 0x17, 0x53, 0x7b, 0xd4, 0xac, 0xb2, 0xde, 0x35, 0xbb, 0xb3, 0x69, 0xdc, 0x0b, 0x6e, + 0x41, 0xe2, 0x05, 0x78, 0x24, 0xc4, 0x15, 0x8f, 0x80, 0xca, 0x53, 0x70, 0x87, 0xe6, 0x9b, 0x99, + 0x3d, 0x38, 0x0e, 0x29, 0x2d, 0x77, 0xf3, 0xfd, 0xbe, 0xf3, 0x69, 0x76, 0x16, 0xba, 0xd3, 0x2c, + 0x3a, 0xe2, 0x52, 0x6c, 0x4e, 0xb3, 0x54, 0xa6, 0xa4, 0x15, 0x25, 0x52, 0x64, 0x09, 0x8f, 0xe9, + 0x03, 0x68, 0x87, 0xc9, 0x58, 0x1c, 0xef, 0x0a, 0xc9, 0x09, 0x01, 0xff, 0xa1, 0x98, 0xe5, 0x81, + 0xd7, 0x73, 0xfa, 0x2d, 0x86, 0x67, 0xf2, 0x3e, 0xac, 0xed, 0x67, 0x7c, 0x74, 0xb8, 0x73, 0x1c, + 0xe5, 0x52, 0x24, 0x23, 0x11, 0xf8, 0xc8, 0x9d, 0x43, 0xe9, 0x6f, 0x2e, 0xac, 0xde, 0x8f, 0x44, + 0x3c, 0xfe, 0x76, 0x2a, 0xa3, 0x34, 0xc9, 0x95, 0xb1, 0xfd, 0xd9, 0x54, 0x04, 0xad, 0x9e, 0xd3, + 0x6f, 0x33, 0x3c, 0x93, 0x77, 0xa0, 0xbd, 0xcd, 0x47, 0x07, 0x02, 0x19, 0x1e, 0x32, 0x2a, 0xa0, + 0xe4, 0x0e, 0xa3, 0x97, 0xda, 0x4b, 0x97, 0x55, 0x00, 0xe9, 0x41, 0x67, 0x3f, 0x9a, 0x88, 0xc7, + 0x05, 0x4f, 0x64, 0x31, 0x09, 0x96, 0x50, 0xbb, 0x0e, 0x91, 0x75, 0xf0, 0x76, 0xa3, 0x24, 0x68, + 0xf7, 0x9c, 0xbe, 0xc7, 0xd4, 0x11, 0x11, 0x7e, 0x1c, 0x80, 0x41, 0xf8, 0x71, 0x99, 0x62, 0xa7, + 0x99, 0xe2, 0x5e, 0x3a, 0x94, 0x3c, 0x19, 0xf3, 0x6c, 0xfc, 0x34, 0x12, 0x2f, 0x82, 0x55, 0x9d, + 0x62, 0x13, 0x55, 0xba, 0x5b, 0x3c, 0x17, 0x41, 0x17, 0xcd, 0xe1, 0x99, 0x5c, 0x83, 0xd6, 0x56, + 0x24, 0x07, 0x62, 0x2a, 0x0f, 0x82, 0xb5, 0x9e, 0xd3, 0xf7, 0x59, 0x49, 0x93, 0x8b, 0xb0, 0x34, + 0x1c, 0xf1, 0x58, 0x04, 0xe7, 0x50, 0x41, 0x13, 0x84, 0xc2, 0xea, 0xfd,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xaf, 0xaf, 0x36, 0x9c, 0xdf, 0x5f, + 0x6d, 0x38, 0x7f, 0xbc, 0xda, 0x70, 0x7e, 0xf9, 0x73, 0xe3, 0x7f, 0xcf, 0x96, 0xf1, 0x37, 0xef, + 0xce, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x7f, 0x7d, 0xeb, 0xf7, 0x0d, 0x00, 0x00, } func (m *IndexMeta) Marshal() (dAtA []byte, err error) { @@ -2424,34 +2365,6 @@ func (m *FieldOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } - if m.Max != nil { - { - size, err := m.Max.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPrivate(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x92 - } - if m.Min != nil { - { - size, err := m.Min.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPrivate(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x8a - } if len(m.ForeignIndex) > 0 { i -= len(m.ForeignIndex) copy(dAtA[i:], m.ForeignIndex) @@ -2496,6 +2409,16 @@ func (m *FieldOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x58 } + if m.Max != 0 { + i = encodeVarintPrivate(dAtA, i, uint64(m.Max)) + i-- + dAtA[i] = 0x50 + } + if m.Min != 0 { + i = encodeVarintPrivate(dAtA, i, uint64(m.Min)) + i-- + dAtA[i] = 0x48 + } if len(m.Type) > 0 { i -= len(m.Type) copy(dAtA[i:], m.Type) @@ -2525,43 +2448,6 @@ func (m *FieldOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Decimal) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Decimal) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Decimal) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Scale != 0 { - i = encodeVarintPrivate(dAtA, i, uint64(m.Scale)) - i-- - dAtA[i] = 0x10 - } - if m.Value != 0 { - i = encodeVarintPrivate(dAtA, i, uint64(m.Value)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func (m *ImportResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2679,9 +2565,27 @@ func (m *BlockDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.XXX_unrecognized) } if len(m.ColumnIDs) > 0 { - dAtA4 := make([]byte, len(m.ColumnIDs)*10) - var j3 int + dAtA2 := make([]byte, len(m.ColumnIDs)*10) + var j1 int for _, num := range m.ColumnIDs { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintPrivate(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x12 + } + if len(m.RowIDs) > 0 { + dAtA4 := make([]byte, len(m.RowIDs)*10) + var j3 int + for _, num := range m.RowIDs { for num >= 1<<7 { dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 @@ -2694,24 +2598,6 @@ func (m *BlockDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], dAtA4[:j3]) i = encodeVarintPrivate(dAtA, i, uint64(j3)) i-- - dAtA[i] = 0x12 - } - if len(m.RowIDs) > 0 { - dAtA6 := make([]byte, len(m.RowIDs)*10) - var j5 int - for _, num := range m.RowIDs { - for num >= 1<<7 { - dAtA6[j5] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j5++ - } - dAtA6[j5] = uint8(num) - j5++ - } - i -= j5 - copy(dAtA[i:], dAtA6[:j5]) - i = encodeVarintPrivate(dAtA, i, uint64(j5)) - i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -2742,20 +2628,20 @@ func (m *Cache) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.XXX_unrecognized) } if len(m.IDs) > 0 { - dAtA8 := make([]byte, len(m.IDs)*10) - var j7 int + dAtA6 := make([]byte, len(m.IDs)*10) + var j5 int for _, num := range m.IDs { for num >= 1<<7 { - dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) + dAtA6[j5] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j7++ + j5++ } - dAtA8[j7] = uint8(num) - j7++ + dAtA6[j5] = uint8(num) + j5++ } - i -= j7 - copy(dAtA[i:], dAtA8[:j7]) - i = encodeVarintPrivate(dAtA, i, uint64(j7)) + i -= j5 + copy(dAtA[i:], dAtA6[:j5]) + i = encodeVarintPrivate(dAtA, i, uint64(j5)) i-- dAtA[i] = 0xa } @@ -3560,20 +3446,20 @@ func (m *FieldStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.XXX_unrecognized) } if len(m.AvailableShards) > 0 { - dAtA18 := make([]byte, len(m.AvailableShards)*10) - var j17 int + dAtA16 := make([]byte, len(m.AvailableShards)*10) + var j15 int for _, num := range m.AvailableShards { for num >= 1<<7 { - dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) + dAtA16[j15] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j17++ + j15++ } - dAtA18[j17] = uint8(num) - j17++ + dAtA16[j15] = uint8(num) + j15++ } - i -= j17 - copy(dAtA[i:], dAtA18[:j17]) - i = encodeVarintPrivate(dAtA, i, uint64(j17)) + i -= j15 + copy(dAtA[i:], dAtA16[:j15]) + i = encodeVarintPrivate(dAtA, i, uint64(j15)) i-- dAtA[i] = 0x12 } @@ -4262,6 +4148,12 @@ func (m *FieldOptions) Size() (n int) { if l > 0 { n += 1 + l + sovPrivate(uint64(l)) } + if m.Min != 0 { + n += 1 + sovPrivate(uint64(m.Min)) + } + if m.Max != 0 { + n += 1 + sovPrivate(uint64(m.Max)) + } if m.Keys { n += 2 } @@ -4281,32 +4173,6 @@ func (m *FieldOptions) Size() (n int) { if l > 0 { n += 2 + l + sovPrivate(uint64(l)) } - if m.Min != nil { - l = m.Min.Size() - n += 2 + l + sovPrivate(uint64(l)) - } - if m.Max != nil { - l = m.Max.Size() - n += 2 + l + sovPrivate(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Decimal) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Value != 0 { - n += 1 + sovPrivate(uint64(m.Value)) - } - if m.Scale != 0 { - n += 1 + sovPrivate(uint64(m.Scale)) - } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -5310,6 +5176,44 @@ func (m *FieldOptions) Unmarshal(dAtA []byte) error { } m.Type = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Min", wireType) + } + m.Min = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Min |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Max", wireType) + } + m.Max = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Max |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } case 11: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) @@ -5439,170 +5343,6 @@ func (m *FieldOptions) Unmarshal(dAtA []byte) error { } m.ForeignIndex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 17: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Min", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthPrivate - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPrivate - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Min == nil { - m.Min = &Decimal{} - } - if err := m.Min.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 18: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Max", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthPrivate - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPrivate - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Max == nil { - m.Max = &Decimal{} - } - if err := m.Max.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPrivate(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthPrivate - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthPrivate - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Decimal) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Decimal: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Decimal: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - m.Value = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Value |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Scale", wireType) - } - m.Scale = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPrivate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Scale |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipPrivate(dAtA[iNdEx:]) diff --git a/internal/private.proto b/internal/private.proto index df4365c06..944478c87 100644 --- a/internal/private.proto +++ b/internal/private.proto @@ -12,19 +12,14 @@ message FieldOptions { string CacheType = 3; uint32 CacheSize = 4; string TimeQuantum = 5; + int64 Min = 9; + int64 Max = 10; bool Keys = 11; bool NoStandardView = 12; int64 Base = 13; uint64 BitDepth = 14; int64 Scale = 15; string ForeignIndex = 16; - Decimal Min = 17; - Decimal Max = 18; -} - -message Decimal { - int64 Value = 1; - int64 Scale = 2; } message ImportResponse { diff --git a/pql/decimal.go b/pql/decimal.go index 186fff037..c7dbeb98f 100644 --- a/pql/decimal.go +++ b/pql/decimal.go @@ -23,38 +23,6 @@ import ( "github.com/pkg/errors" ) -// pow10 is a map used to avoid the float64 required by math.Pow10() -var pow10 = map[int64]int64{ - 0: 1, - 1: 10, - 2: 100, - 3: 1000, - 4: 10000, - 5: 100000, - 6: 1000000, - 7: 10000000, - 8: 100000000, - 9: 1000000000, - 10: 10000000000, - 11: 100000000000, - 12: 1000000000000, - 13: 10000000000000, - 14: 100000000000000, - 15: 1000000000000000, - 16: 10000000000000000, - 17: 100000000000000000, - 18: 1000000000000000000, - //19: 10000000000000000000, -} - -// Pow10 is a function which can be used in place of math.Pow10() -// to avoid the float64 logic. Note that only powers 0-18 are -// currently supported; anything else will return 0, which is -// probably going to result in incorrect values. -func Pow10(p int64) int64 { - return pow10[p] -} - // Decimal represents a decimal value; the intention // is to avoid relying on float64, and the primary // purpose is to have a predictable way to encode such @@ -68,147 +36,6 @@ type Decimal struct { Scale int64 } -// NewDecimal returns a Decimal based on the provided arguments. -func NewDecimal(value, scale int64) Decimal { - return Decimal{ - Value: value, - Scale: scale, - } -} - -// MinMax returns the minimum and maximum values -// supported by the provided scale. -func MinMax(scale int64) (Decimal, Decimal) { - min := NewDecimal(math.MinInt64, scale) - max := NewDecimal(math.MaxInt64, scale) - return min, max -} - -// LessThan returns true if d < d2. -func (d Decimal) LessThan(d2 Decimal) bool { - return d.lessThan(d2, false) -} - -// LessThanOrEqualTo returns true if d <= d2. -func (d Decimal) LessThanOrEqualTo(d2 Decimal) bool { - return d.lessThan(d2, true) -} - -// GreaterThan returns true if d > d2. -func (d Decimal) GreaterThan(d2 Decimal) bool { - return d.greaterThan(d2, false) -} - -// GreaterThanOrEqualTo returns true if d >= d2. -func (d Decimal) GreaterThanOrEqualTo(d2 Decimal) bool { - return d.greaterThan(d2, true) -} - -// EqualTo returns true if d == d2. -func (d Decimal) EqualTo(d2 Decimal) bool { - if d.Scale == d2.Scale { - return d.Value == d2.Value - } - - quotientD := quotient(d) - quotientD2 := quotient(d2) - if quotientD != quotientD2 { - return false - } - remainderD, remainderD2 := remainder(d), remainder(d2) - if d.Scale < d2.Scale { - scaleDiff := d2.Scale - d.Scale - return (remainderD * pow10[scaleDiff]) == remainderD2 - } - scaleDiff := d.Scale - d2.Scale - return remainderD == (remainderD2 * pow10[scaleDiff]) -} - -func (d Decimal) lessThan(d2 Decimal, eq bool) bool { - if d.Scale == d2.Scale { - if eq { - return d.Value <= d2.Value - } - return d.Value < d2.Value - } - - quotientD, quotientD2 := quotient(d), quotient(d2) - if quotientD < quotientD2 { - return true - } else if quotientD == quotientD2 { - remainderD, remainderD2 := remainder(d), remainder(d2) - if d.Scale < d2.Scale { - scaleDiff := d2.Scale - d.Scale - if eq { - return (remainderD * pow10[scaleDiff]) <= remainderD2 - } - return (remainderD * pow10[scaleDiff]) < remainderD2 - } - scaleDiff := d.Scale - d2.Scale - if eq { - return remainderD <= (remainderD2 * pow10[scaleDiff]) - } - return remainderD < (remainderD2 * pow10[scaleDiff]) - } - - return false -} - -func (d Decimal) greaterThan(d2 Decimal, eq bool) bool { - if d.Scale == d2.Scale { - if eq { - return d.Value >= d2.Value - } - return d.Value > d2.Value - } - - quotientD, quotientD2 := quotient(d), quotient(d2) - if quotientD > quotientD2 { - return true - } else if quotientD == quotientD2 { - remainderD, remainderD2 := remainder(d), remainder(d2) - if d.Scale < d2.Scale { - scaleDiff := d2.Scale - d.Scale - if eq { - return (remainderD * pow10[scaleDiff]) >= remainderD2 - } - return (remainderD * pow10[scaleDiff]) > remainderD2 - } - scaleDiff := d.Scale - d2.Scale - if eq { - return remainderD >= (remainderD2 * pow10[scaleDiff]) - } - return remainderD > (remainderD2 * pow10[scaleDiff]) - } - - return false -} - -// SupportedByScale returns true if d can be represented -// by a decimal based on scale. -// For example: -// scale = 2: -// min: -92233720368547758.08 -// max: 92233720368547758.07 -// would not support: NewDecimal(9223372036854775807, 0) -func (d Decimal) SupportedByScale(scale int64) bool { - min, max := MinMax(scale) - - if d.GreaterThanOrEqualTo(min) && d.LessThanOrEqualTo(max) { - return true - } - return false -} - -// IsValid returns true if the decimal does not break -// any assumption or resrictions on input. -func (d Decimal) IsValid() bool { - if d.Scale < -18 || d.Scale > 19 { - return false - } - return true -} - // ToInt64 returns d as an int64 adjusted to the // provided scale. func (d Decimal) ToInt64(scale int64) int64 { @@ -216,17 +43,13 @@ func (d Decimal) ToInt64(scale int64) int64 { scaleDiff := scale - d.Scale if scaleDiff == 0 { ret = d.Value - } else if scaleDiff < 0 { - ret = d.Value / Pow10(-1*scaleDiff) } else { - ret = d.Value * Pow10(scaleDiff) + ret = int64(float64(d.Value) * math.Pow10(int(scaleDiff))) } return ret } // Float64 returns d as a float64. -// TODO: this could potentially lose precision; we should audit -// its use and protect against unexpected results. func (d Decimal) Float64() float64 { var ret float64 if d.Scale == 0 { @@ -396,19 +219,15 @@ func ParseDecimal(s string) (Decimal, error) { scale = 0 } - // We have to use ParseUint here (as opposed to ParseInt) because - // math.MinInt64 is a valid value, but its absolute value is not. - // So this allows us to handle that one value without overflow, and - // then we check for the uint bounds in the next step. - uvalue, err := strconv.ParseUint(string(mantissa), 10, 64) + value, err = strconv.ParseInt(string(mantissa), 10, 64) if err != nil { - return Decimal{}, errors.Wrap(err, "converting mantissa string to uint64") + return Decimal{}, errors.Wrap(err, "converting mantissa to uint32") } - - if (sign && uvalue > -1*math.MinInt64) || (!sign && uvalue > math.MaxInt64) { - return Decimal{}, errors.New("value out of range") + // Because we pulled the sign off at the beginning, if value is + // negative here, it likely means the string had two "-"" characters. + if value < 0 { + return Decimal{}, errors.New("invalid negative value") } - value = int64(uvalue) if sign { value *= -1 @@ -420,22 +239,6 @@ func ParseDecimal(s string) (Decimal, error) { }, nil } -func quotient(d Decimal) int64 { - if d.Scale == 0 { - return d.Value - } else if d.Scale > 0 && d.Scale < 19 { - return d.Value / pow10[d.Scale] - } - return 0 -} - -func remainder(d Decimal) int64 { - if d.Scale >= 0 && d.Scale < 19 { - return d.Value % pow10[d.Scale] - } - return 0 -} - // UnmarshalJSON is a custom unmarshaller for the Decimal // type. The intention is to avoid the use of float64 // anywhere, so this unmarhaller parses the decimal out diff --git a/pql/decimal_test.go b/pql/decimal_test.go index 84a781b70..6c6e2150b 100644 --- a/pql/decimal_test.go +++ b/pql/decimal_test.go @@ -15,8 +15,6 @@ package pql_test import ( - "encoding/json" - "reflect" "strings" "testing" @@ -61,7 +59,7 @@ func TestDecimal(t *testing.T) { // int64 edges. {".000009223372036854775807", pql.Decimal{9223372036854775807, 24}, ""}, - {"-.000009223372036854775808", pql.Decimal{-9223372036854775808, 24}, ""}, + {"-.000009223372036854775807", pql.Decimal{-9223372036854775807, 24}, ""}, {"92233720368547.75807", pql.Decimal{9223372036854775807, 5}, ""}, {"-92233720368547.75807", pql.Decimal{-9223372036854775807, 5}, ""}, {"9223372036854775807000", pql.Decimal{9223372036854775807, -3}, ""}, @@ -73,12 +71,11 @@ func TestDecimal(t *testing.T) { {"*0.123", pql.Decimal{}, "invalid syntax"}, {"abc", pql.Decimal{}, "invalid syntax"}, {"0.12.3", pql.Decimal{}, "invalid decimal string"}, - {"--12300", pql.Decimal{}, "invalid syntax"}, - - {"922337203685477580.9", pql.Decimal{}, "value out of range"}, - {"-922337203685477580.9", pql.Decimal{}, "value out of range"}, + {"--12300", pql.Decimal{}, "invalid negative value"}, + {"922337203685477580.8", pql.Decimal{}, "value out of range"}, + {"-922337203685477580.8", pql.Decimal{}, "value out of range"}, {"9223372036854775808000", pql.Decimal{}, "value out of range"}, - {"-9223372036854775809000", pql.Decimal{}, "value out of range"}, + {"-9223372036854775808000", pql.Decimal{}, "value out of range"}, } for i, test := range tests { dec, err := pql.ParseDecimal(test.s) @@ -164,89 +161,4 @@ func TestDecimal(t *testing.T) { } } }) - - t.Run("Comparisons", func(t *testing.T) { - tests := []struct { - d1 pql.Decimal - d2 pql.Decimal - expLT bool - expLTE bool - expGT bool - expGTE bool - expEQ bool - }{ - {pql.NewDecimal(0, 0), pql.NewDecimal(0, 0), false, true, false, true, true}, - {pql.NewDecimal(0, 0), pql.NewDecimal(10, 0), true, true, false, false, false}, - {pql.NewDecimal(10, 0), pql.NewDecimal(0, 0), false, false, true, true, false}, - {pql.NewDecimal(123456, 3), pql.NewDecimal(123456, 3), false, true, false, true, true}, - {pql.NewDecimal(123456, 3), pql.NewDecimal(123456, 4), false, false, true, true, false}, - {pql.NewDecimal(123456, 4), pql.NewDecimal(123456, 3), true, true, false, false, false}, - {pql.NewDecimal(1233456, 4), pql.NewDecimal(123456, 3), true, true, false, false, false}, - - {pql.NewDecimal(0, 0), pql.NewDecimal(-10, 0), false, false, true, true, false}, - {pql.NewDecimal(-10, 0), pql.NewDecimal(0, 0), true, true, false, false, false}, - {pql.NewDecimal(-123456, 3), pql.NewDecimal(-123456, 3), false, true, false, true, true}, - {pql.NewDecimal(-123456, 3), pql.NewDecimal(-123456, 4), true, true, false, false, false}, - {pql.NewDecimal(-123456, 4), pql.NewDecimal(-123456, 3), false, false, true, true, false}, - {pql.NewDecimal(-1233456, 4), pql.NewDecimal(-123456, 3), false, false, true, true, false}, - - {pql.NewDecimal(10, 0), pql.NewDecimal(-10, 0), false, false, true, true, false}, - {pql.NewDecimal(-10, 0), pql.NewDecimal(10, 0), true, true, false, false, false}, - {pql.NewDecimal(-123456, 3), pql.NewDecimal(123456, 3), true, true, false, false, false}, - {pql.NewDecimal(123456, 3), pql.NewDecimal(-123456, 3), false, false, true, true, false}, - {pql.NewDecimal(-123456, 3), pql.NewDecimal(123456, 4), true, true, false, false, false}, - {pql.NewDecimal(123456, 3), pql.NewDecimal(-123456, 4), false, false, true, true, false}, - {pql.NewDecimal(-123456, 4), pql.NewDecimal(123456, 3), true, true, false, false, false}, - {pql.NewDecimal(123456, 4), pql.NewDecimal(-123456, 3), false, false, true, true, false}, - {pql.NewDecimal(-1233456, 4), pql.NewDecimal(123456, 3), true, true, false, false, false}, - {pql.NewDecimal(1233456, 4), pql.NewDecimal(-123456, 3), false, false, true, true, false}, - - {pql.NewDecimal(9223372036854775807, 0), pql.NewDecimal(9223372036854775807, 0), false, true, false, true, true}, - {pql.NewDecimal(9223372036854775807, 2), pql.NewDecimal(9223372036854775807, 0), true, true, false, false, false}, - {pql.NewDecimal(9223372036854775807, 19), pql.NewDecimal(9223372036854775807, 0), true, true, false, false, false}, - - {pql.NewDecimal(-9223372036854775808, 0), pql.NewDecimal(-9223372036854775808, 0), false, true, false, true, true}, - {pql.NewDecimal(-9223372036854775808, 0), pql.NewDecimal(-9223372036854775807, 0), true, true, false, false, false}, - {pql.NewDecimal(-9223372036854775808, 2), pql.NewDecimal(-9223372036854775808, 0), false, false, true, true, false}, - {pql.NewDecimal(-9223372036854775808, 19), pql.NewDecimal(-9223372036854775807, 0), false, false, true, true, false}, - } - for i, test := range tests { - if got := test.d1.LessThan(test.d2); got != test.expLT { - t.Fatalf("test LT %d expected %s < %s to be %v, but got: %v", i, test.d1, test.d2, test.expLT, got) - } - if got := test.d1.LessThanOrEqualTo(test.d2); got != test.expLTE { - t.Fatalf("test LTE %d expected %s <= %s to be %v, but got: %v", i, test.d1, test.d2, test.expLTE, got) - } - if got := test.d1.GreaterThan(test.d2); got != test.expGT { - t.Fatalf("test GT %d expected %s > %s to be %v, but got: %v", i, test.d1, test.d2, test.expGT, got) - } - if got := test.d1.GreaterThanOrEqualTo(test.d2); got != test.expGTE { - t.Fatalf("test GTE %d expected %s >= %s to be %v, but got: %v", i, test.d1, test.d2, test.expGTE, got) - } - if got := test.d1.EqualTo(test.d2); got != test.expEQ { - t.Fatalf("test EQ %d expected %s == %s to be %v, but got: %v", i, test.d1, test.d2, test.expEQ, got) - } - } - }) - - t.Run("JSON", func(t *testing.T) { - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - json string - exp pql.Decimal - }{ - {"1234.56", pql.NewDecimal(123456, 2)}, - } - for i, test := range tests { - b := []byte(test.json) - dec := &pql.Decimal{} - if err := json.Unmarshal(b, &dec); err != nil { - panic(err) - } - if !reflect.DeepEqual(*dec, test.exp) { - t.Fatalf("test %d expected: %T, but got: %T", i, test.exp, dec) - } - } - }) - }) } diff --git a/server/handler_test.go b/server/handler_test.go index 31e084243..df87e6d64 100644 --- a/server/handler_test.go +++ b/server/handler_test.go @@ -34,7 +34,6 @@ import ( "github.com/pilosa/pilosa/v2/boltdb" "github.com/pilosa/pilosa/v2/encoding/proto" "github.com/pilosa/pilosa/v2/http" - "github.com/pilosa/pilosa/v2/pql" "github.com/pilosa/pilosa/v2/server" "github.com/pilosa/pilosa/v2/test" ) @@ -575,10 +574,10 @@ func TestHandler_Endpoints(t *testing.T) { if field == nil { t.Fatalf("field not found: %s", fieldName) } - if !reflect.DeepEqual(pql.NewDecimal(math.MinInt64, 0), field.Options.Min) { + if math.MinInt64 != field.Options.Min { t.Fatalf("field min %d != %d", int64(math.MinInt64), field.Options.Min) } - if !reflect.DeepEqual(pql.NewDecimal(math.MaxInt64, 0), field.Options.Max) { + if math.MaxInt64 != field.Options.Max { t.Fatalf("field max %d != %d", int64(math.MaxInt64), field.Options.Max) } }) @@ -604,10 +603,10 @@ func TestHandler_Endpoints(t *testing.T) { if field == nil { t.Fatalf("field not found: %s", fieldName) } - if !reflect.DeepEqual(pql.NewDecimal(math.MinInt64, 0), field.Options.Min) { + if math.MinInt64 != field.Options.Min { t.Fatalf("field min %d != %d", int64(math.MinInt64), field.Options.Min) } - if !reflect.DeepEqual(pql.NewDecimal(1, -1), field.Options.Max) { + if 10 != field.Options.Max { t.Fatalf("field max %d != %d", 10, field.Options.Max) } }) @@ -633,10 +632,10 @@ func TestHandler_Endpoints(t *testing.T) { if field == nil { t.Fatalf("field not found: %s", fieldName) } - if !reflect.DeepEqual(pql.NewDecimal(-1, -1), field.Options.Min) { + if -10 != field.Options.Min { t.Fatalf("field min %d != %d", 10, field.Options.Min) } - if !reflect.DeepEqual(pql.NewDecimal(math.MaxInt64, 0), field.Options.Max) { + if math.MaxInt64 != field.Options.Max { t.Fatalf("field max %d != %d", int64(math.MaxInt64), field.Options.Max) } }) @@ -651,79 +650,6 @@ func TestHandler_Endpoints(t *testing.T) { } }) - t.Run("Query decimal field unbounded", func(t *testing.T) { - w := httptest.NewRecorder() - fieldName := "f-decimal-ubound" - h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName), - strings.NewReader(`{"options":{"type":"decimal", "scale": 0}}`))) - if w.Code != gohttp.StatusOK { - t.Fatalf("unexpected status code: %d", w.Code) - } - w = httptest.NewRecorder() - h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", strings.NewReader(""))) - if w.Code != gohttp.StatusOK { - t.Fatalf("unexpected status code: %d", w.Code) - } - rsp := getSchemaResponse{} - if err := json.Unmarshal(w.Body.Bytes(), &rsp); err != nil { - t.Fatalf("json decode: %s", err) - } - field := rsp.findField("i0", fieldName) - if field == nil { - t.Fatalf("field not found: %s", fieldName) - } - if !reflect.DeepEqual(pql.NewDecimal(math.MinInt64, 0), field.Options.Min) { - t.Fatalf("field min %d != %d", int64(math.MinInt64), field.Options.Min) - } - if !reflect.DeepEqual(pql.NewDecimal(math.MaxInt64, 0), field.Options.Max) { - t.Fatalf("field max %d != %d", int64(math.MaxInt64), field.Options.Max) - } - }) - - t.Run("Query decimal field unbounded min", func(t *testing.T) { - w := httptest.NewRecorder() - fieldName := "f-decimal-ubound-min" - h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName), - strings.NewReader(`{"options":{"type":"decimal", "scale": 1, "max": 10.5}}`))) - if w.Code != gohttp.StatusOK { - fmt.Println(w.Body.String()) - t.Fatalf("unexpected status code: %d", w.Code) - } - w = httptest.NewRecorder() - h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/schema", strings.NewReader(""))) - if w.Code != gohttp.StatusOK { - t.Fatalf("unexpected status code: %d", w.Code) - } - rsp := getSchemaResponse{} - if err := json.Unmarshal(w.Body.Bytes(), &rsp); err != nil { - t.Fatalf("json decode: %s", err) - } - field := rsp.findField("i0", fieldName) - if field == nil { - t.Fatalf("field not found: %s", fieldName) - } - if !reflect.DeepEqual(pql.NewDecimal(math.MinInt64, 1), field.Options.Min) { - t.Fatalf("field min %d != %d", pql.NewDecimal(math.MinInt64, 1), field.Options.Min) - } - if !reflect.DeepEqual(pql.NewDecimal(105, 1), field.Options.Max) { - t.Fatalf("field max %s != %d", pql.NewDecimal(105, 1), field.Options.Max) - } - }) - - // Ensure that decimal fields error when scale is not provided. - t.Run("Query decimal field scale error", func(t *testing.T) { - w := httptest.NewRecorder() - fieldName := "f-decimal-ubound" - h.ServeHTTP(w, test.MustNewHTTPRequest("POST", fmt.Sprintf("/index/i0/field/%s", fieldName), - strings.NewReader(`{"options":{"type":"decimal"}}`))) - expErr := "decimal field requires a scale argument" - if w.Code != gohttp.StatusBadRequest { - t.Fatalf("unexpected status code: %d", w.Code) - } else if !strings.Contains(w.Body.String(), expErr) { - t.Fatalf("expected error to contain: %s, but got: %s", expErr, w.Body.String()) - } - }) - t.Run("Method not allowed", func(t *testing.T) { w := httptest.NewRecorder() h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/index/i0/query", nil)) diff --git a/server/server_test.go b/server/server_test.go index 03f7ab703..113347197 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -32,7 +32,6 @@ import ( "github.com/pelletier/go-toml" "github.com/pilosa/pilosa/v2" "github.com/pilosa/pilosa/v2/http" - "github.com/pilosa/pilosa/v2/pql" "github.com/pilosa/pilosa/v2/roaring" "github.com/pilosa/pilosa/v2/server" "github.com/pilosa/pilosa/v2/test" @@ -308,7 +307,7 @@ func TestMain_MinMaxFloat(t *testing.T) { if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { t.Fatal(err) } - if err := client.CreateFieldWithOptions(context.Background(), "i", "dec", pilosa.FieldOptions{Type: pilosa.FieldTypeDecimal, Scale: 3, Max: pql.NewDecimal(100000, 0)}); err != nil { + if err := client.CreateFieldWithOptions(context.Background(), "i", "dec", pilosa.FieldOptions{Type: pilosa.FieldTypeDecimal, Scale: 3, Max: 100000}); err != nil { t.Fatal(err) }