mirror of https://github.com/tidwall/tile38.git
More test fields
This commit is contained in:
parent
92c1ce8ef9
commit
14b616b150
|
@ -14,8 +14,6 @@ import (
|
||||||
|
|
||||||
// MASSINSERT num_keys num_points [minx miny maxx maxy]
|
// MASSINSERT num_keys num_points [minx miny maxx maxy]
|
||||||
|
|
||||||
const useRandField = true
|
|
||||||
|
|
||||||
func randMassInsertPosition(minLat, minLon, maxLat, maxLon float64) (float64, float64) {
|
func randMassInsertPosition(minLat, minLon, maxLat, maxLon float64) (float64, float64) {
|
||||||
lat, lon := (rand.Float64()*(maxLat-minLat))+minLat, (rand.Float64()*(maxLon-minLon))+minLon
|
lat, lon := (rand.Float64()*(maxLat-minLat))+minLat, (rand.Float64()*(maxLon-minLon))+minLon
|
||||||
return lat, lon
|
return lat, lon
|
||||||
|
@ -100,16 +98,31 @@ func (c *Server) cmdMassInsert(msg *Message) (res resp.Value, err error) {
|
||||||
for j := 0; j < objs; j++ {
|
for j := 0; j < objs; j++ {
|
||||||
id := strconv.FormatInt(int64(j), 10)
|
id := strconv.FormatInt(int64(j), 10)
|
||||||
var values []string
|
var values []string
|
||||||
|
values = append(values, "set", key, id)
|
||||||
|
fvals := []float64{
|
||||||
|
1, // one
|
||||||
|
0, // zero
|
||||||
|
-1, // negOne
|
||||||
|
14, // nibble
|
||||||
|
20.5, // tinyDiv10
|
||||||
|
120, // int8
|
||||||
|
-120, // int8
|
||||||
|
20000, // int16
|
||||||
|
-20000, // int16
|
||||||
|
214748300, // int32
|
||||||
|
-214748300, // int32
|
||||||
|
2014748300, // float64
|
||||||
|
123.12312301, // float64
|
||||||
|
}
|
||||||
|
for i, fval := range fvals {
|
||||||
|
values = append(values, "FIELD",
|
||||||
|
fmt.Sprintf("fname:%d", i),
|
||||||
|
strconv.FormatFloat(fval, 'f', -1, 64))
|
||||||
|
}
|
||||||
if j%8 == 0 {
|
if j%8 == 0 {
|
||||||
values = append(values, "set", key, id, "STRING", fmt.Sprintf("str%v", j))
|
values = append(values, "STRING", fmt.Sprintf("str%v", j))
|
||||||
} else {
|
} else {
|
||||||
lat, lon := randMassInsertPosition(minLat, minLon, maxLat, maxLon)
|
lat, lon := randMassInsertPosition(minLat, minLon, maxLat, maxLon)
|
||||||
values = make([]string, 0, 16)
|
|
||||||
values = append(values, "set", key, id)
|
|
||||||
if useRandField {
|
|
||||||
values = append(values, "FIELD", "fname",
|
|
||||||
strconv.FormatFloat(rand.Float64()*10, 'f', -1, 64))
|
|
||||||
}
|
|
||||||
values = append(values, "POINT",
|
values = append(values, "POINT",
|
||||||
strconv.FormatFloat(lat, 'f', -1, 64),
|
strconv.FormatFloat(lat, 'f', -1, 64),
|
||||||
strconv.FormatFloat(lon, 'f', -1, 64),
|
strconv.FormatFloat(lon, 'f', -1, 64),
|
||||||
|
|
Loading…
Reference in New Issue