Merge pull request #212 from travisturner/decimal-min-max-args

support pql.Decimal for decimal field min/max arguments
This commit is contained in:
Travis Turner 2020-03-30 14:32:02 -05:00 committed by GitHub
commit 2ad06f9423
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1165 additions and 398 deletions

View file

@ -447,39 +447,9 @@ 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.Fatalf("creating field: %v", err)
if err == nil {
t.Fatal("expected error creating field")
}
// 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) {

View file

@ -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, "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.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.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")

View file

@ -21,6 +21,7 @@ import (
"github.com/pilosa/pilosa/v2"
"github.com/pilosa/pilosa/v2/cmd"
"github.com/pilosa/pilosa/v2/pql"
)
func TestImportHelp(t *testing.T) {
@ -58,8 +59,8 @@ field = "f1"
v.Check(cmd.Importer.Field, "f1")
v.Check(cmd.Importer.FieldOptions, pilosa.FieldOptions{
Keys: true,
Max: 100,
Min: -10,
Max: pql.NewDecimal(100, 0),
Min: pql.NewDecimal(-10, 0),
CacheType: pilosa.CacheTypeRanked,
CacheSize: 50000,
})

View file

@ -28,6 +28,7 @@ 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"
)
@ -104,7 +105,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 != 0 || cmd.FieldOptions.Max != 0 {
} else if cmd.FieldOptions.Min != pql.NewDecimal(0, 0) || cmd.FieldOptions.Max != pql.NewDecimal(0, 0) {
cmd.FieldOptions.Type = pilosa.FieldTypeInt
} else {
cmd.FieldOptions.Type = pilosa.FieldTypeSet

View file

@ -21,6 +21,7 @@ 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"
)
@ -593,8 +594,8 @@ func encodeFieldOptions(o *pilosa.FieldOptions) *internal.FieldOptions {
Type: o.Type,
CacheType: o.CacheType,
CacheSize: o.CacheSize,
Min: o.Min,
Max: o.Max,
Min: &internal.Decimal{Value: o.Min.Value, Scale: o.Min.Scale},
Max: &internal.Decimal{Value: o.Max.Value, Scale: o.Max.Scale},
Base: o.Base,
Scale: o.Scale,
BitDepth: uint64(o.BitDepth),
@ -879,8 +880,8 @@ func decodeFieldOptions(options *internal.FieldOptions, m *pilosa.FieldOptions)
m.Type = options.Type
m.CacheType = options.CacheType
m.CacheSize = options.CacheSize
m.Min = options.Min
m.Max = options.Max
decodeDecimal(options.Min, &m.Min)
decodeDecimal(options.Max, &m.Max)
m.Base = options.Base
m.Scale = options.Scale
m.BitDepth = uint(options.BitDepth)
@ -889,6 +890,11 @@ 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{}
@ -1203,7 +1209,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()

View file

@ -1477,14 +1477,14 @@ func TestExecutor_Execute_MinMax(t *testing.T) {
tests := []struct {
scale int64
min int64
max int64
min pql.Decimal
max pql.Decimal
set pql.Decimal
}{
{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}},
{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}},
}
for i, test := range tests {
fld := fmt.Sprintf("f%d", i)
@ -2248,6 +2248,37 @@ 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)

149
field.go
View file

@ -178,55 +178,80 @@ func OptFieldTypeInt(min, max int64) FieldOption {
return errors.New("int field min cannot be greater than max")
}
fo.Type = FieldTypeInt
fo.Min = min
fo.Max = max
fo.Min = pql.NewDecimal(min, 0)
fo.Max = pql.NewDecimal(max, 0)
fo.Base = bsiBase(min, max)
return nil
}
}
func OptFieldTypeDecimal(scale int64, minmax ...int64) FieldOption {
// 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 {
return func(fo *FieldOptions) error {
if fo.Type != "" {
return errors.Errorf("can't set field type to 'decimal', already set to: %s", fo.Type)
}
fo.Min = math.MinInt64
fo.Max = math.MaxInt64
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)
if len(minmax) == 2 {
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)
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)
}
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 {
// 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)))
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)
}
fo.Min = min
}
fo.Type = FieldTypeDecimal
fo.Base = bsiBase(fo.Min, fo.Max)
fo.Base = bsiBase(fo.Min.ToInt64(scale), fo.Max.ToInt64(scale))
fo.Scale = scale
return nil
}
@ -692,10 +717,14 @@ 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 {
pb.Base = bsiBase(pb.Min, pb.Max)
pb.BitDepth = uint64(bitDepthInt64(pb.Max - pb.Min))
minInt64, maxInt64 := min.ToInt64(0), max.ToInt64(0)
pb.Base = bsiBase(minInt64, maxInt64)
pb.BitDepth = uint64(bitDepthInt64(maxInt64 - minInt64))
if pb.BitDepth == 0 {
pb.BitDepth = 1
}
@ -705,8 +734,8 @@ func (f *Field) loadMeta() error {
f.options.Type = pb.Type
f.options.CacheType = pb.CacheType
f.options.CacheSize = pb.CacheSize
f.options.Min = pb.Min
f.options.Max = pb.Max
f.options.Min = min
f.options.Max = max
f.options.Base = pb.Base
f.options.Scale = pb.Scale
f.options.BitDepth = uint(pb.BitDepth)
@ -766,8 +795,8 @@ func (f *Field) applyOptions(opt FieldOptions) error {
} else if opt.CacheSize != 0 {
f.options.CacheSize = opt.CacheSize
}
f.options.Min = 0
f.options.Max = 0
f.options.Min = pql.Decimal{}
f.options.Max = pql.Decimal{}
f.options.Base = 0
f.options.BitDepth = 0
f.options.TimeQuantum = ""
@ -790,8 +819,8 @@ func (f *Field) applyOptions(opt FieldOptions) error {
bsig := &bsiGroup{
Name: f.name,
Type: bsiGroupTypeInt,
Min: opt.Min,
Max: opt.Max,
Min: opt.Min.ToInt64(opt.Scale),
Max: opt.Max.ToInt64(opt.Scale),
Base: opt.Base,
Scale: opt.Scale,
BitDepth: opt.BitDepth,
@ -807,8 +836,8 @@ func (f *Field) applyOptions(opt FieldOptions) error {
f.options.Type = opt.Type
f.options.CacheType = CacheTypeNone
f.options.CacheSize = 0
f.options.Min = 0
f.options.Max = 0
f.options.Min = pql.Decimal{}
f.options.Max = pql.Decimal{}
f.options.Base = 0
f.options.BitDepth = 0
f.options.Keys = opt.Keys
@ -823,8 +852,8 @@ func (f *Field) applyOptions(opt FieldOptions) error {
f.options.Type = FieldTypeBool
f.options.CacheType = CacheTypeNone
f.options.CacheSize = 0
f.options.Min = 0
f.options.Max = 0
f.options.Min = pql.Decimal{}
f.options.Max = pql.Decimal{}
f.options.Base = 0
f.options.BitDepth = 0
f.options.TimeQuantum = ""
@ -1818,8 +1847,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 int64 `json:"min,omitempty"`
Max int64 `json:"max,omitempty"`
Min pql.Decimal `json:"min,omitempty"`
Max pql.Decimal `json:"max,omitempty"`
Scale int64 `json:"scale,omitempty"`
Keys bool `json:"keys"`
NoStandardView bool `json:"noStandardView,omitempty"`
@ -1881,8 +1910,8 @@ func encodeFieldOptions(o *FieldOptions) *internal.FieldOptions {
Base: o.Base,
Scale: o.Scale,
BitDepth: uint64(o.BitDepth),
Min: o.Min,
Max: o.Max,
Min: &internal.Decimal{Value: o.Min.Value, Scale: o.Min.Scale},
Max: &internal.Decimal{Value: o.Max.Value, Scale: o.Max.Scale},
TimeQuantum: string(o.TimeQuantum),
Keys: o.Keys,
NoStandardView: o.NoStandardView,
@ -1909,13 +1938,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 int64 `json:"min"`
Max int64 `json:"max"`
Keys bool `json:"keys"`
ForeignIndex string `json:"foreignIndex"`
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"`
}{
o.Type,
o.Base,
@ -1927,13 +1956,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 int64 `json:"min"`
Max int64 `json:"max"`
Keys bool `json:"keys"`
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"`
}{
o.Type,
o.Base,

View file

@ -22,6 +22,7 @@ import (
"path/filepath"
"reflect"
"strconv"
"strings"
"testing"
"time"
@ -160,7 +161,7 @@ func TestBSIGroup_BaseValue(t *testing.T) {
// Ensure field can open and retrieve a view.
func TestField_DeleteView(t *testing.T) {
f := MustOpenField(OptFieldTypeDefault())
f := OpenField(t, OptFieldTypeDefault())
defer f.Close()
viewName := viewStandard + "_v"
@ -197,23 +198,23 @@ type TestField struct {
}
// NewTestField returns a new instance of TestField d/0.
func NewTestField(opts FieldOption) *TestField {
func NewTestField(t *testing.T, opts FieldOption) *TestField {
path, err := ioutil.TempDir(*TempDir, "pilosa-field-")
if err != nil {
panic(err)
t.Fatal(err)
}
field, err := NewField(path, "i", "f", opts)
if err != nil {
panic(err)
t.Fatal(err)
}
return &TestField{Field: field}
}
// MustOpenField returns a new, opened field at a temporary path. Panic on error.
func MustOpenField(opts FieldOption) *TestField {
f := NewTestField(opts)
// OpenField returns a new, opened field at a temporary path.
func OpenField(t *testing.T, opts FieldOption) *TestField {
f := NewTestField(t, opts)
if err := f.Open(); err != nil {
panic(err)
t.Fatal(err)
}
return f
}
@ -260,7 +261,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 := MustOpenField(OptFieldTypeDefault())
f := OpenField(t, OptFieldTypeDefault())
defer f.Close()
// Create view.
@ -285,7 +286,7 @@ func TestField_CreateViewIfNotExists(t *testing.T) {
}
func TestField_SetTimeQuantum(t *testing.T) {
f := MustOpenField(OptFieldTypeTime(TimeQuantum("")))
f := OpenField(t, OptFieldTypeTime(TimeQuantum("")))
defer f.Close()
// Set & retrieve time quantum.
@ -304,7 +305,7 @@ func TestField_SetTimeQuantum(t *testing.T) {
}
func TestField_RowTime(t *testing.T) {
f := MustOpenField(OptFieldTypeTime(TimeQuantum("")))
f := OpenField(t, OptFieldTypeTime(TimeQuantum("")))
defer f.Close()
if err := f.setTimeQuantum(TimeQuantum("YMDH")); err != nil {
@ -350,7 +351,7 @@ func TestField_RowTime(t *testing.T) {
}
func TestField_PersistAvailableShards(t *testing.T) {
f := MustOpenField(OptFieldTypeDefault())
f := OpenField(t, OptFieldTypeDefault())
// bm represents remote available shards.
bm := roaring.NewBitmap(1, 2, 3)
@ -369,7 +370,7 @@ func TestField_PersistAvailableShards(t *testing.T) {
}
func TestField_CorruptAvailableShards(t *testing.T) {
f := MustOpenField(OptFieldTypeDefault())
f := OpenField(t, OptFieldTypeDefault())
// bm represents remote available shards.
bm := roaring.NewBitmap(1, 2, 3)
@ -399,7 +400,7 @@ func TestField_CorruptAvailableShards(t *testing.T) {
}
func TestField_TruncatedAvailableShards(t *testing.T) {
f := MustOpenField(OptFieldTypeDefault())
f := OpenField(t, OptFieldTypeDefault())
// bm represents remote available shards.
bm := roaring.NewBitmap(1, 2, 3)
@ -427,7 +428,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 := MustOpenField(OptFieldTypeDefault())
f := OpenField(t, OptFieldTypeDefault())
// bm represents remote available shards.
bm := roaring.NewBitmap()
@ -538,7 +539,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 := MustOpenField(OptFieldTypeInt(-100, 200))
f := OpenField(t, OptFieldTypeInt(-100, 200))
options := &ImportOptions{}
for i, tt := range []struct {
@ -579,7 +580,7 @@ func TestBSIGroup_importValue(t *testing.T) {
}
func TestIntField_MinMaxForShard(t *testing.T) {
f := MustOpenField(OptFieldTypeInt(-100, 200))
f := OpenField(t, OptFieldTypeInt(-100, 200))
options := &ImportOptions{}
for i, test := range []struct {
@ -654,33 +655,86 @@ 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
expmin int64
expmax int64
min pql.Decimal
max pql.Decimal
expErr bool
}{
{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},
{
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,
},
} {
t.Run("minmax"+strconv.Itoa(i), func(t *testing.T) {
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)
_, 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")
}
})
}
}
func TestDecimalField_MinMaxForShard(t *testing.T) {
f := MustOpenField(OptFieldTypeDecimal(3))
f := OpenField(t, OptFieldTypeDecimal(3))
options := &ImportOptions{}
for i, test := range []struct {

View file

@ -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: -1000, Max: 1000})
err = c.CreateFieldWithOptions(context.Background(), index, field, pilosa.FieldOptions{Type: pilosa.FieldTypeDecimal, Scale: 1, Min: pql.NewDecimal(-1000, 0), Max: pql.NewDecimal(1000, 0)})
if err != nil {
t.Fatalf("creating field: %v", err)
}

View file

@ -37,6 +37,7 @@ 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"
@ -796,24 +797,39 @@ 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, pilosa.FieldTypeDecimal:
case pilosa.FieldTypeInt:
if req.Options.Min == nil {
min := int64(math.MinInt64)
min := pql.NewDecimal(int64(math.MinInt64), 0)
req.Options.Min = &min
}
if req.Options.Max == nil {
max := int64(math.MaxInt64)
max := pql.NewDecimal(int64(math.MaxInt64), 0)
req.Options.Max = &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.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)
}
}
fos = append(fos, pilosa.OptFieldTypeDecimal(scale, minmax...))
case pilosa.FieldTypeTime:
fos = append(fos, pilosa.OptFieldTypeTime(*req.Options.TimeQuantum, req.Options.NoStandardView))
case pilosa.FieldTypeMutex:
@ -848,8 +864,8 @@ type fieldOptions struct {
Type string `json:"type,omitempty"`
CacheType *string `json:"cacheType,omitempty"`
CacheSize *uint32 `json:"cacheSize,omitempty"`
Min *int64 `json:"min,omitempty"`
Max *int64 `json:"max,omitempty"`
Min *pql.Decimal `json:"min,omitempty"`
Max *pql.Decimal `json:"max,omitempty"`
Scale *int64 `json:"scale,omitempty"`
TimeQuantum *pilosa.TimeQuantum `json:"timeQuantum,omitempty"`
Keys *bool `json:"keys,omitempty"`
@ -885,7 +901,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, pilosa.FieldTypeDecimal:
case pilosa.FieldTypeInt:
if o.CacheType != nil {
return pilosa.NewBadRequestError(errors.New("cacheType does not apply to field type int"))
} else if o.CacheSize != nil {
@ -895,6 +911,18 @@ 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"))

View file

@ -22,6 +22,7 @@ import (
"testing"
"github.com/pilosa/pilosa/v2"
"github.com/pilosa/pilosa/v2/pql"
)
// Test custom UnmarshalJSON for postIndexRequest object
@ -99,8 +100,8 @@ func stringPtr(s string) *string {
return &s
}
func int64Ptr(i int64) *int64 {
return &i
func decimalPtr(d pql.Decimal) *pql.Decimal {
return &d
}
// Test fieldOption validation.
@ -135,10 +136,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": 1000}}`, expected: postFieldRequest{Options: fieldOptions{
{json: `{"options": {"type": "int", "min": 0, "max": 1001}}`, expected: postFieldRequest{Options: fieldOptions{
Type: pilosa.FieldTypeInt,
Min: int64Ptr(0),
Max: int64Ptr(1000),
Min: decimalPtr(pql.NewDecimal(0, 0)),
Max: decimalPtr(pql.NewDecimal(1001, 0)),
}}},
{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"},

View file

@ -20,6 +20,7 @@ import (
"testing"
"github.com/pilosa/pilosa/v2"
"github.com/pilosa/pilosa/v2/pql"
"github.com/pilosa/pilosa/v2/test"
"github.com/pkg/errors"
)
@ -203,7 +204,7 @@ func TestIndex_CreateField(t *testing.T) {
index := test.MustOpenIndex()
defer index.Close()
_, err := index.CreateField("f", pilosa.OptFieldTypeDecimal(1, -1, 1), pilosa.OptFieldKeys())
_, err := index.CreateField("f", pilosa.OptFieldTypeDecimal(1, pql.Decimal{Value: -1}, pql.Decimal{Value: 1}), pilosa.OptFieldKeys())
if errors.Cause(err) != pilosa.ErrDecimalFieldWithKeys {
t.Fatal("decimal field cannot be created with keys=true")
}

View file

@ -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,20 +156,6 @@ 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
@ -212,6 +198,75 @@ 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:"-"`
@ -223,7 +278,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{2}
return fileDescriptor_d2a91b51c7bdc125, []int{3}
}
func (m *ImportResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -274,7 +329,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{3}
return fileDescriptor_d2a91b51c7bdc125, []int{4}
}
func (m *BlockDataRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -350,7 +405,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{4}
return fileDescriptor_d2a91b51c7bdc125, []int{5}
}
func (m *BlockDataResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -404,7 +459,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{5}
return fileDescriptor_d2a91b51c7bdc125, []int{6}
}
func (m *Cache) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -451,7 +506,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{6}
return fileDescriptor_d2a91b51c7bdc125, []int{7}
}
func (m *MaxShards) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -500,7 +555,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{7}
return fileDescriptor_d2a91b51c7bdc125, []int{8}
}
func (m *CreateShardMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -561,7 +616,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{8}
return fileDescriptor_d2a91b51c7bdc125, []int{9}
}
func (m *DeleteIndexMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -609,7 +664,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{9}
return fileDescriptor_d2a91b51c7bdc125, []int{10}
}
func (m *CreateIndexMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -665,7 +720,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{10}
return fileDescriptor_d2a91b51c7bdc125, []int{11}
}
func (m *CreateFieldMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -727,7 +782,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{11}
return fileDescriptor_d2a91b51c7bdc125, []int{12}
}
func (m *DeleteFieldMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -783,7 +838,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{12}
return fileDescriptor_d2a91b51c7bdc125, []int{13}
}
func (m *DeleteAvailableShardMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -846,7 +901,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{13}
return fileDescriptor_d2a91b51c7bdc125, []int{14}
}
func (m *Field) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -907,7 +962,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{14}
return fileDescriptor_d2a91b51c7bdc125, []int{15}
}
func (m *Schema) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -955,7 +1010,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{15}
return fileDescriptor_d2a91b51c7bdc125, []int{16}
}
func (m *Index) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1011,7 +1066,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{16}
return fileDescriptor_d2a91b51c7bdc125, []int{17}
}
func (m *URI) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1075,7 +1130,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{17}
return fileDescriptor_d2a91b51c7bdc125, []int{18}
}
func (m *Node) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1144,7 +1199,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{18}
return fileDescriptor_d2a91b51c7bdc125, []int{19}
}
func (m *NodeStateMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1199,7 +1254,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{19}
return fileDescriptor_d2a91b51c7bdc125, []int{20}
}
func (m *NodeEventMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1255,7 +1310,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{20}
return fileDescriptor_d2a91b51c7bdc125, []int{21}
}
func (m *NodeStatus) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1317,7 +1372,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{21}
return fileDescriptor_d2a91b51c7bdc125, []int{22}
}
func (m *IndexStatus) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1372,7 +1427,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{22}
return fileDescriptor_d2a91b51c7bdc125, []int{23}
}
func (m *FieldStatus) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1428,7 +1483,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{23}
return fileDescriptor_d2a91b51c7bdc125, []int{24}
}
func (m *ClusterStatus) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1492,7 +1547,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{24}
return fileDescriptor_d2a91b51c7bdc125, []int{25}
}
func (m *BSIGroup) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1562,7 +1617,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{25}
return fileDescriptor_d2a91b51c7bdc125, []int{26}
}
func (m *CreateViewMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1625,7 +1680,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{26}
return fileDescriptor_d2a91b51c7bdc125, []int{27}
}
func (m *DeleteViewMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1691,7 +1746,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{27}
return fileDescriptor_d2a91b51c7bdc125, []int{28}
}
func (m *ResizeInstruction) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1777,7 +1832,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{28}
return fileDescriptor_d2a91b51c7bdc125, []int{29}
}
func (m *ResizeSource) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1854,7 +1909,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{29}
return fileDescriptor_d2a91b51c7bdc125, []int{30}
}
func (m *ResizeInstructionComplete) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1915,7 +1970,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{30}
return fileDescriptor_d2a91b51c7bdc125, []int{31}
}
func (m *SetCoordinatorMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1962,7 +2017,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{31}
return fileDescriptor_d2a91b51c7bdc125, []int{32}
}
func (m *UpdateCoordinatorMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -2010,7 +2065,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{32}
return fileDescriptor_d2a91b51c7bdc125, []int{33}
}
func (m *Topology) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -2063,7 +2118,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{33}
return fileDescriptor_d2a91b51c7bdc125, []int{34}
}
func (m *RecalculateCaches) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -2095,6 +2150,7 @@ 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")
@ -2133,82 +2189,85 @@ func init() {
func init() { proto.RegisterFile("private.proto", fileDescriptor_d2a91b51c7bdc125) }
var fileDescriptor_d2a91b51c7bdc125 = []byte{
// 1191 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xdb, 0x6e, 0x1b, 0x45,
0x18, 0x66, 0x0f, 0x71, 0xec, 0xdf, 0x71, 0xea, 0x4e, 0x0f, 0x6c, 0x0b, 0x0a, 0x66, 0x54, 0x51,
0x53, 0x89, 0x50, 0xb5, 0x5c, 0x70, 0xaa, 0x54, 0x1c, 0xa7, 0x65, 0x29, 0x09, 0x65, 0x9c, 0xf6,
0x8e, 0x8b, 0xa9, 0x3d, 0x6a, 0x56, 0x59, 0xef, 0x98, 0xdd, 0x71, 0x12, 0xf7, 0x82, 0x5b, 0x90,
0x78, 0x01, 0x9e, 0x80, 0x67, 0x41, 0x5c, 0xf1, 0x08, 0x28, 0xbc, 0x08, 0x9a, 0x7f, 0x66, 0x0f,
0x76, 0x5c, 0x12, 0x02, 0x77, 0xf3, 0x7f, 0xff, 0xfc, 0xe7, 0xc3, 0xce, 0x42, 0x6b, 0x92, 0x46,
0x87, 0x5c, 0x89, 0xcd, 0x49, 0x2a, 0x95, 0x24, 0xf5, 0x28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x5b, 0x05, 0x35, 0x14, 0x7c, 0xb3, 0x14, 0x9c, 0x63, 0xb3, 0xf9,
0xdb, 0xf4, 0x27, 0x07, 0xd6, 0xaa, 0xee, 0x9c, 0x6b, 0x88, 0x8b, 0xea, 0xb8, 0x67, 0x7f, 0xf5,
0xf3, 0xea, 0xf8, 0xcb, 0xde, 0x59, 0x2b, 0xd5, 0x97, 0xc0, 0x01, 0xdc, 0x38, 0x55, 0xb2, 0x2d,
0x39, 0x9e, 0xe8, 0xde, 0xf8, 0x0f, 0xa5, 0xd3, 0xeb, 0x2d, 0x4d, 0x6d, 0xd1, 0x1a, 0xcc, 0x10,
0xf4, 0x13, 0xb8, 0x36, 0x10, 0xaa, 0x52, 0xb0, 0xbc, 0xf3, 0x3a, 0xe0, 0xed, 0x8a, 0xa3, 0xd7,
0x84, 0xaf, 0x59, 0xf4, 0x73, 0x08, 0x9e, 0x4d, 0x46, 0x5c, 0x89, 0x0b, 0x49, 0xf7, 0xa0, 0xbe,
0x27, 0x27, 0x32, 0x96, 0x2f, 0x67, 0x67, 0x6c, 0x80, 0x00, 0x56, 0xcd, 0x2e, 0x37, 0x2b, 0xa5,
0xc1, 0x72, 0x92, 0x5e, 0xd1, 0xcd, 0x3d, 0xe4, 0xf1, 0x70, 0x1a, 0x6b, 0x37, 0xf4, 0xdb, 0x31,
0xeb, 0xb5, 0x7f, 0x3b, 0xd9, 0x70, 0xfe, 0x38, 0xd9, 0x70, 0xfe, 0x3c, 0xd9, 0x70, 0x7e, 0xf9,
0x6b, 0xe3, 0x8d, 0x17, 0x35, 0xfc, 0xdb, 0xb9, 0xff, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xde,
0xfb, 0x46, 0xba, 0xfe, 0x0c, 0x00, 0x00,
// 1233 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xdd, 0x72, 0xdb, 0x44,
0x14, 0x46, 0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b7, 0x24, 0x31, 0x45, 0x6b, 0x30, 0x4d, 0xd0, 0x4f, 0xe0, 0xe6, 0x40,
0xc8, 0x52, 0xc1, 0xb2, 0xce, 0xeb, 0x80, 0xb3, 0x2d, 0x8e, 0xcf, 0x09, 0x5f, 0x89, 0xe8, 0xe7,
0xe0, 0xbe, 0x1c, 0x0f, 0xb9, 0x14, 0x57, 0xd2, 0xee, 0x41, 0x7d, 0x27, 0x1e, 0xc7, 0x61, 0xbc,
0x3f, 0xbd, 0x60, 0x03, 0xb8, 0x50, 0xd3, 0xbb, 0x5c, 0xaf, 0x94, 0x06, 0xcb, 0x48, 0x7a, 0x5d,
0x35, 0xb7, 0xcf, 0x43, 0x7f, 0x12, 0x2a, 0x18, 0xea, 0xdb, 0x31, 0xed, 0xb5, 0x7f, 0x3b, 0x5d,
0xb3, 0x7e, 0x3f, 0x5d, 0xb3, 0xfe, 0x38, 0x5d, 0xb3, 0x7e, 0xf9, 0x73, 0xed, 0xb5, 0xbd, 0x2a,
0xfe, 0x4a, 0x3d, 0xfa, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x50, 0x3d, 0x18, 0x31, 0x5b, 0x0d, 0x00,
0x00,
}
func (m *IndexMeta) Marshal() (dAtA []byte, err error) {
@ -2282,6 +2341,34 @@ 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)
@ -2326,16 +2413,6 @@ 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)
@ -2365,6 +2442,43 @@ 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)
@ -2482,27 +2596,9 @@ func (m *BlockDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
copy(dAtA[i:], m.XXX_unrecognized)
}
if len(m.ColumnIDs) > 0 {
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)
dAtA4 := make([]byte, len(m.ColumnIDs)*10)
var j3 int
for _, num := range m.RowIDs {
for _, num := range m.ColumnIDs {
for num >= 1<<7 {
dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80)
num >>= 7
@ -2515,6 +2611,24 @@ 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
@ -2545,20 +2659,20 @@ func (m *Cache) MarshalToSizedBuffer(dAtA []byte) (int, error) {
copy(dAtA[i:], m.XXX_unrecognized)
}
if len(m.IDs) > 0 {
dAtA6 := make([]byte, len(m.IDs)*10)
var j5 int
dAtA8 := make([]byte, len(m.IDs)*10)
var j7 int
for _, num := range m.IDs {
for num >= 1<<7 {
dAtA6[j5] = uint8(uint64(num)&0x7f | 0x80)
dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80)
num >>= 7
j5++
j7++
}
dAtA6[j5] = uint8(num)
j5++
dAtA8[j7] = uint8(num)
j7++
}
i -= j5
copy(dAtA[i:], dAtA6[:j5])
i = encodeVarintPrivate(dAtA, i, uint64(j5))
i -= j7
copy(dAtA[i:], dAtA8[:j7])
i = encodeVarintPrivate(dAtA, i, uint64(j7))
i--
dAtA[i] = 0xa
}
@ -3351,20 +3465,20 @@ func (m *FieldStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) {
copy(dAtA[i:], m.XXX_unrecognized)
}
if len(m.AvailableShards) > 0 {
dAtA15 := make([]byte, len(m.AvailableShards)*10)
var j14 int
dAtA17 := make([]byte, len(m.AvailableShards)*10)
var j16 int
for _, num := range m.AvailableShards {
for num >= 1<<7 {
dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80)
dAtA17[j16] = uint8(uint64(num)&0x7f | 0x80)
num >>= 7
j14++
j16++
}
dAtA15[j14] = uint8(num)
j14++
dAtA17[j16] = uint8(num)
j16++
}
i -= j14
copy(dAtA[i:], dAtA15[:j14])
i = encodeVarintPrivate(dAtA, i, uint64(j14))
i -= j16
copy(dAtA[i:], dAtA17[:j16])
i = encodeVarintPrivate(dAtA, i, uint64(j16))
i--
dAtA[i] = 0x12
}
@ -3988,12 +4102,6 @@ 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
}
@ -4013,6 +4121,32 @@ 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)
}
@ -4983,44 +5117,6 @@ 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)
@ -5150,6 +5246,170 @@ 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:])

View file

@ -12,14 +12,19 @@ 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 {

View file

@ -23,6 +23,38 @@ 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
@ -36,6 +68,147 @@ 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 {
@ -43,13 +216,17 @@ 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 = int64(float64(d.Value) * math.Pow10(int(scaleDiff)))
ret = d.Value * Pow10(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 {
@ -219,15 +396,19 @@ func ParseDecimal(s string) (Decimal, error) {
scale = 0
}
value, err = strconv.ParseInt(string(mantissa), 10, 64)
// 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)
if err != nil {
return Decimal{}, errors.Wrap(err, "converting mantissa to uint32")
return Decimal{}, errors.Wrap(err, "converting mantissa string to uint64")
}
// 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")
if (sign && uvalue > -1*math.MinInt64) || (!sign && uvalue > math.MaxInt64) {
return Decimal{}, errors.New("value out of range")
}
value = int64(uvalue)
if sign {
value *= -1
@ -238,3 +419,39 @@ func ParseDecimal(s string) (Decimal, error) {
Scale: scale,
}, 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
// of the byte string.
func (d *Decimal) UnmarshalJSON(data []byte) error {
o, err := ParseDecimal(string(data))
if err != nil {
return errors.Wrapf(err, "parsing decimal: %s", string(data))
}
d.Value = o.Value
d.Scale = o.Scale
return nil
}
// MarshalJSON is a custom marshaller for the Decimal type.
func (d Decimal) MarshalJSON() ([]byte, error) {
return []byte(d.String()), nil
}

View file

@ -15,6 +15,8 @@
package pql_test
import (
"encoding/json"
"reflect"
"strings"
"testing"
@ -59,7 +61,7 @@ func TestDecimal(t *testing.T) {
// int64 edges.
{".000009223372036854775807", pql.Decimal{9223372036854775807, 24}, ""},
{"-.000009223372036854775807", pql.Decimal{-9223372036854775807, 24}, ""},
{"-.000009223372036854775808", pql.Decimal{-9223372036854775808, 24}, ""},
{"92233720368547.75807", pql.Decimal{9223372036854775807, 5}, ""},
{"-92233720368547.75807", pql.Decimal{-9223372036854775807, 5}, ""},
{"9223372036854775807000", pql.Decimal{9223372036854775807, -3}, ""},
@ -71,11 +73,12 @@ 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 negative value"},
{"922337203685477580.8", pql.Decimal{}, "value out of range"},
{"-922337203685477580.8", pql.Decimal{}, "value out of range"},
{"--12300", pql.Decimal{}, "invalid syntax"},
{"922337203685477580.9", pql.Decimal{}, "value out of range"},
{"-922337203685477580.9", pql.Decimal{}, "value out of range"},
{"9223372036854775808000", pql.Decimal{}, "value out of range"},
{"-9223372036854775808000", pql.Decimal{}, "value out of range"},
{"-9223372036854775809000", pql.Decimal{}, "value out of range"},
}
for i, test := range tests {
dec, err := pql.ParseDecimal(test.s)
@ -161,4 +164,89 @@ 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)
}
}
})
})
}

View file

@ -34,6 +34,7 @@ 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"
)
@ -574,10 +575,10 @@ func TestHandler_Endpoints(t *testing.T) {
if field == nil {
t.Fatalf("field not found: %s", fieldName)
}
if math.MinInt64 != field.Options.Min {
if !reflect.DeepEqual(pql.NewDecimal(math.MinInt64, 0), field.Options.Min) {
t.Fatalf("field min %d != %d", int64(math.MinInt64), field.Options.Min)
}
if math.MaxInt64 != field.Options.Max {
if !reflect.DeepEqual(pql.NewDecimal(math.MaxInt64, 0), field.Options.Max) {
t.Fatalf("field max %d != %d", int64(math.MaxInt64), field.Options.Max)
}
})
@ -603,10 +604,10 @@ func TestHandler_Endpoints(t *testing.T) {
if field == nil {
t.Fatalf("field not found: %s", fieldName)
}
if math.MinInt64 != field.Options.Min {
if !reflect.DeepEqual(pql.NewDecimal(math.MinInt64, 0), field.Options.Min) {
t.Fatalf("field min %d != %d", int64(math.MinInt64), field.Options.Min)
}
if 10 != field.Options.Max {
if !reflect.DeepEqual(pql.NewDecimal(1, -1), field.Options.Max) {
t.Fatalf("field max %d != %d", 10, field.Options.Max)
}
})
@ -632,10 +633,10 @@ func TestHandler_Endpoints(t *testing.T) {
if field == nil {
t.Fatalf("field not found: %s", fieldName)
}
if -10 != field.Options.Min {
if !reflect.DeepEqual(pql.NewDecimal(-1, -1), field.Options.Min) {
t.Fatalf("field min %d != %d", 10, field.Options.Min)
}
if math.MaxInt64 != field.Options.Max {
if !reflect.DeepEqual(pql.NewDecimal(math.MaxInt64, 0), field.Options.Max) {
t.Fatalf("field max %d != %d", int64(math.MaxInt64), field.Options.Max)
}
})
@ -650,6 +651,79 @@ 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))

View file

@ -32,6 +32,7 @@ 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"
@ -307,7 +308,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: 100000}); err != nil {
if err := client.CreateFieldWithOptions(context.Background(), "i", "dec", pilosa.FieldOptions{Type: pilosa.FieldTypeDecimal, Scale: 3, Max: pql.NewDecimal(100000, 0)}); err != nil {
t.Fatal(err)
}