BREAKING CHANGE - rename numeric_util to numeric
This commit is contained in:
parent
f90856b8d3
commit
c487f29a46
|
@ -15,7 +15,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/blevesearch/bleve/analysis"
|
||||
"github.com/blevesearch/bleve/numeric_util"
|
||||
"github.com/blevesearch/bleve/numeric"
|
||||
)
|
||||
|
||||
const DefaultDateTimeIndexingOptions = StoreField | IndexField
|
||||
|
@ -28,7 +28,7 @@ type DateTimeField struct {
|
|||
name string
|
||||
arrayPositions []uint64
|
||||
options IndexingOptions
|
||||
value numeric_util.PrefixCoded
|
||||
value numeric.PrefixCoded
|
||||
numPlainTextBytes uint64
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ func (n *DateTimeField) Analyze() (int, analysis.TokenFrequencies) {
|
|||
|
||||
shift := DefaultDateTimePrecisionStep
|
||||
for shift < 64 {
|
||||
shiftEncoded, err := numeric_util.NewPrefixCodedInt64(original, shift)
|
||||
shiftEncoded, err := numeric.NewPrefixCodedInt64(original, shift)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ func NewDateTimeField(name string, arrayPositions []uint64, dt time.Time) (*Date
|
|||
func NewDateTimeFieldWithIndexingOptions(name string, arrayPositions []uint64, dt time.Time, options IndexingOptions) (*DateTimeField, error) {
|
||||
if canRepresent(dt) {
|
||||
dtInt64 := dt.UnixNano()
|
||||
prefixCoded := numeric_util.MustNewPrefixCodedInt64(dtInt64, 0)
|
||||
prefixCoded := numeric.MustNewPrefixCodedInt64(dtInt64, 0)
|
||||
return &DateTimeField{
|
||||
name: name,
|
||||
arrayPositions: arrayPositions,
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/blevesearch/bleve/analysis"
|
||||
"github.com/blevesearch/bleve/numeric_util"
|
||||
"github.com/blevesearch/bleve/numeric"
|
||||
)
|
||||
|
||||
const DefaultNumericIndexingOptions = StoreField | IndexField
|
||||
|
@ -24,7 +24,7 @@ type NumericField struct {
|
|||
name string
|
||||
arrayPositions []uint64
|
||||
options IndexingOptions
|
||||
value numeric_util.PrefixCoded
|
||||
value numeric.PrefixCoded
|
||||
numPlainTextBytes uint64
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ func (n *NumericField) Analyze() (int, analysis.TokenFrequencies) {
|
|||
|
||||
shift := DefaultPrecisionStep
|
||||
for shift < 64 {
|
||||
shiftEncoded, err := numeric_util.NewPrefixCodedInt64(original, shift)
|
||||
shiftEncoded, err := numeric.NewPrefixCodedInt64(original, shift)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ func (n *NumericField) Number() (float64, error) {
|
|||
if err != nil {
|
||||
return 0.0, err
|
||||
}
|
||||
return numeric_util.Int64ToFloat64(i64), nil
|
||||
return numeric.Int64ToFloat64(i64), nil
|
||||
}
|
||||
|
||||
func (n *NumericField) GoString() string {
|
||||
|
@ -111,8 +111,8 @@ func NewNumericField(name string, arrayPositions []uint64, number float64) *Nume
|
|||
}
|
||||
|
||||
func NewNumericFieldWithIndexingOptions(name string, arrayPositions []uint64, number float64, options IndexingOptions) *NumericField {
|
||||
numberInt64 := numeric_util.Float64ToInt64(number)
|
||||
prefixCoded := numeric_util.MustNewPrefixCodedInt64(numberInt64, 0)
|
||||
numberInt64 := numeric.Float64ToInt64(number)
|
||||
prefixCoded := numeric.MustNewPrefixCodedInt64(numberInt64, 0)
|
||||
return &NumericField{
|
||||
name: name,
|
||||
arrayPositions: arrayPositions,
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/index/store"
|
||||
"github.com/blevesearch/bleve/mapping"
|
||||
"github.com/blevesearch/bleve/numeric_util"
|
||||
"github.com/blevesearch/bleve/numeric"
|
||||
"github.com/blevesearch/bleve/search"
|
||||
)
|
||||
|
||||
|
@ -378,8 +378,8 @@ func TestIndexAliasEmpty(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestIndexAliasMulti(t *testing.T) {
|
||||
score1, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(1.0), 0)
|
||||
score2, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(2.0), 0)
|
||||
score1, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(1.0), 0)
|
||||
score2, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(2.0), 0)
|
||||
ei1Count := uint64(7)
|
||||
ei1 := &stubIndex{
|
||||
err: nil,
|
||||
|
@ -519,8 +519,8 @@ func TestIndexAliasMulti(t *testing.T) {
|
|||
|
||||
// TestMultiSearchNoError
|
||||
func TestMultiSearchNoError(t *testing.T) {
|
||||
score1, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(1.0), 0)
|
||||
score2, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(2.0), 0)
|
||||
score1, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(1.0), 0)
|
||||
score2, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(2.0), 0)
|
||||
ei1 := &stubIndex{err: nil, searchResult: &SearchResult{
|
||||
Status: &SearchStatus{
|
||||
Total: 1,
|
||||
|
@ -708,8 +708,8 @@ func TestMultiSearchSecondPage(t *testing.T) {
|
|||
// 2. no searchers finish before the timeout
|
||||
// 3. no searches finish before cancellation
|
||||
func TestMultiSearchTimeout(t *testing.T) {
|
||||
score1, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(1.0), 0)
|
||||
score2, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(2.0), 0)
|
||||
score1, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(1.0), 0)
|
||||
score2, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(2.0), 0)
|
||||
ei1 := &stubIndex{
|
||||
name: "ei1",
|
||||
checkRequest: func(req *SearchRequest) error {
|
||||
|
@ -837,9 +837,9 @@ func TestMultiSearchTimeout(t *testing.T) {
|
|||
// TestMultiSearchTimeoutPartial tests the case where some indexes exceed
|
||||
// the timeout, while others complete successfully
|
||||
func TestMultiSearchTimeoutPartial(t *testing.T) {
|
||||
score1, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(1.0), 0)
|
||||
score2, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(2.0), 0)
|
||||
score3, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(3.0), 0)
|
||||
score1, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(1.0), 0)
|
||||
score2, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(2.0), 0)
|
||||
score3, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(3.0), 0)
|
||||
ei1 := &stubIndex{
|
||||
name: "ei1",
|
||||
err: nil,
|
||||
|
@ -950,10 +950,10 @@ func TestMultiSearchTimeoutPartial(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestIndexAliasMultipleLayer(t *testing.T) {
|
||||
score1, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(1.0), 0)
|
||||
score2, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(2.0), 0)
|
||||
score3, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(3.0), 0)
|
||||
score4, _ := numeric_util.NewPrefixCodedInt64(numeric_util.Float64ToInt64(4.0), 0)
|
||||
score1, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(1.0), 0)
|
||||
score2, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(2.0), 0)
|
||||
score3, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(3.0), 0)
|
||||
score4, _ := numeric.NewPrefixCodedInt64(numeric.Float64ToInt64(4.0), 0)
|
||||
ei1 := &stubIndex{
|
||||
name: "ei1",
|
||||
err: nil,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// either express or implied. See the License for the specific language governing permissions
|
||||
// and limitations under the License.
|
||||
|
||||
package numeric_util
|
||||
package numeric
|
||||
|
||||
import (
|
||||
"math"
|
|
@ -7,7 +7,7 @@
|
|||
// either express or implied. See the License for the specific language governing permissions
|
||||
// and limitations under the License.
|
||||
|
||||
package numeric_util
|
||||
package numeric
|
||||
|
||||
import (
|
||||
"testing"
|
|
@ -7,7 +7,7 @@
|
|||
// either express or implied. See the License for the specific language governing permissions
|
||||
// and limitations under the License.
|
||||
|
||||
package numeric_util
|
||||
package numeric
|
||||
|
||||
import "fmt"
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
// either express or implied. See the License for the specific language governing permissions
|
||||
// and limitations under the License.
|
||||
|
||||
package numeric_util
|
||||
package numeric
|
||||
|
||||
import (
|
||||
"reflect"
|
|
@ -14,7 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/numeric_util"
|
||||
"github.com/blevesearch/bleve/numeric"
|
||||
"github.com/blevesearch/bleve/search"
|
||||
)
|
||||
|
||||
|
@ -58,7 +58,7 @@ func (fb *DateTimeFacetBuilder) Update(ft index.FieldTerms) {
|
|||
if ok {
|
||||
for _, term := range terms {
|
||||
// only consider the values which are shifted 0
|
||||
prefixCoded := numeric_util.PrefixCoded(term)
|
||||
prefixCoded := numeric.PrefixCoded(term)
|
||||
shift, err := prefixCoded.Shift()
|
||||
if err == nil && shift == 0 {
|
||||
i64, err := prefixCoded.Int64()
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"sort"
|
||||
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/numeric_util"
|
||||
"github.com/blevesearch/bleve/numeric"
|
||||
"github.com/blevesearch/bleve/search"
|
||||
)
|
||||
|
||||
|
@ -57,12 +57,12 @@ func (fb *NumericFacetBuilder) Update(ft index.FieldTerms) {
|
|||
if ok {
|
||||
for _, term := range terms {
|
||||
// only consider the values which are shifted 0
|
||||
prefixCoded := numeric_util.PrefixCoded(term)
|
||||
prefixCoded := numeric.PrefixCoded(term)
|
||||
shift, err := prefixCoded.Shift()
|
||||
if err == nil && shift == 0 {
|
||||
i64, err := prefixCoded.Int64()
|
||||
if err == nil {
|
||||
f64 := numeric_util.Int64ToFloat64(i64)
|
||||
f64 := numeric.Int64ToFloat64(i64)
|
||||
|
||||
// look at each of the ranges for a match
|
||||
for rangeName, r := range fb.ranges {
|
||||
|
|
|
@ -5,13 +5,13 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/blevesearch/bleve/index"
|
||||
nu "github.com/blevesearch/bleve/numeric_util"
|
||||
"github.com/blevesearch/bleve/numeric"
|
||||
)
|
||||
|
||||
var pcodedvalues []nu.PrefixCoded
|
||||
var pcodedvalues []numeric.PrefixCoded
|
||||
|
||||
func init() {
|
||||
pcodedvalues = []nu.PrefixCoded{{0x20, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, {0x20, 0x0, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f}, {0x20, 0x0, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7a, 0x1d, 0xa}, {0x20, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x16, 0x9, 0x4a, 0x7b}}
|
||||
pcodedvalues = []numeric.PrefixCoded{{0x20, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, {0x20, 0x0, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f}, {0x20, 0x0, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7a, 0x1d, 0xa}, {0x20, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x16, 0x9, 0x4a, 0x7b}}
|
||||
}
|
||||
|
||||
func BenchmarkNumericFacet10(b *testing.B) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
"github.com/blevesearch/bleve/analysis/datetime/optional"
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/mapping"
|
||||
"github.com/blevesearch/bleve/numeric_util"
|
||||
"github.com/blevesearch/bleve/numeric"
|
||||
"github.com/blevesearch/bleve/registry"
|
||||
"github.com/blevesearch/bleve/search"
|
||||
"github.com/blevesearch/bleve/search/searchers"
|
||||
|
@ -130,10 +130,10 @@ func (q *DateRangeQuery) parseEndpoints() (*float64, *float64, error) {
|
|||
min := math.Inf(-1)
|
||||
max := math.Inf(1)
|
||||
if !q.Start.IsZero() {
|
||||
min = numeric_util.Int64ToFloat64(q.Start.UnixNano())
|
||||
min = numeric.Int64ToFloat64(q.Start.UnixNano())
|
||||
}
|
||||
if !q.End.IsZero() {
|
||||
max = numeric_util.Int64ToFloat64(q.End.UnixNano())
|
||||
max = numeric.Int64ToFloat64(q.End.UnixNano())
|
||||
}
|
||||
|
||||
return &min, &max, nil
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"math"
|
||||
|
||||
"github.com/blevesearch/bleve/index"
|
||||
"github.com/blevesearch/bleve/numeric_util"
|
||||
"github.com/blevesearch/bleve/numeric"
|
||||
"github.com/blevesearch/bleve/search"
|
||||
)
|
||||
|
||||
|
@ -46,11 +46,11 @@ func NewNumericRangeSearcher(indexReader index.IndexReader, min *float64, max *f
|
|||
inclusiveMax = &defaultInclusiveMax
|
||||
}
|
||||
// find all the ranges
|
||||
minInt64 := numeric_util.Float64ToInt64(*min)
|
||||
minInt64 := numeric.Float64ToInt64(*min)
|
||||
if !*inclusiveMin && minInt64 != math.MaxInt64 {
|
||||
minInt64++
|
||||
}
|
||||
maxInt64 := numeric_util.Float64ToInt64(*max)
|
||||
maxInt64 := numeric.Float64ToInt64(*max)
|
||||
if !*inclusiveMax && maxInt64 != math.MinInt64 {
|
||||
maxInt64--
|
||||
}
|
||||
|
@ -200,8 +200,8 @@ func splitInt64Range(minBound, maxBound int64, precisionStep uint) termRanges {
|
|||
|
||||
func newRange(minBound, maxBound int64, shift uint) *termRange {
|
||||
maxBound |= (int64(1) << shift) - int64(1)
|
||||
minBytes := numeric_util.MustNewPrefixCodedInt64(minBound, shift)
|
||||
maxBytes := numeric_util.MustNewPrefixCodedInt64(maxBound, shift)
|
||||
minBytes := numeric.MustNewPrefixCodedInt64(minBound, shift)
|
||||
maxBytes := numeric.MustNewPrefixCodedInt64(maxBound, shift)
|
||||
return newRangeBytes(minBytes, maxBytes)
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/blevesearch/bleve/numeric_util"
|
||||
"github.com/blevesearch/bleve/numeric"
|
||||
)
|
||||
|
||||
func TestSplitRange(t *testing.T) {
|
||||
min := numeric_util.Float64ToInt64(1.0)
|
||||
max := numeric_util.Float64ToInt64(5.0)
|
||||
min := numeric.Float64ToInt64(1.0)
|
||||
max := numeric.Float64ToInt64(5.0)
|
||||
ranges := splitInt64Range(min, max, 4)
|
||||
enumerated := ranges.Enumerate()
|
||||
if len(enumerated) != 135 {
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/blevesearch/bleve/numeric_util"
|
||||
"github.com/blevesearch/bleve/numeric"
|
||||
)
|
||||
|
||||
var HighTerm = strings.Repeat(string([]byte{0xff}), 10)
|
||||
|
@ -348,7 +348,7 @@ func (s *SortField) filterTermsByType(terms []string) []string {
|
|||
allTermsPrefixCoded := true
|
||||
var termsWithShiftZero []string
|
||||
for _, term := range terms {
|
||||
valid, shift := numeric_util.ValidPrefixCodedTerm(term)
|
||||
valid, shift := numeric.ValidPrefixCodedTerm(term)
|
||||
if valid && shift == 0 {
|
||||
termsWithShiftZero = append(termsWithShiftZero, term)
|
||||
} else if !valid {
|
||||
|
@ -361,7 +361,7 @@ func (s *SortField) filterTermsByType(terms []string) []string {
|
|||
} else if stype == SortFieldAsNumber || stype == SortFieldAsDate {
|
||||
var termsWithShiftZero []string
|
||||
for _, term := range terms {
|
||||
valid, shift := numeric_util.ValidPrefixCodedTerm(term)
|
||||
valid, shift := numeric.ValidPrefixCodedTerm(term)
|
||||
if valid && shift == 0 {
|
||||
termsWithShiftZero = append(termsWithShiftZero)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue