sortorder

package
v0.0.0-...-7b3ddb2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Copyright 2019 The Vearch Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 The Vearch Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 The Vearch Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 The Vearch Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var NegativeInfinity *big.Int
View Source
var PositiveInfinity *big.Int

Functions

func SelectKMin

func SelectKMin(s []float64, k int) []float64

选出k个最小元素,k为1~len(s)

func SelectKthMin

func SelectKthMin(s []float64, k int) float64

func SelectMid

func SelectMid(s []float64) float64

选出中位数(比一半的元素小,比另一半的大)

Types

type DateSortValue

type DateSortValue struct {
	Val time.Time
}

func (*DateSortValue) Compare

func (sv *DateSortValue) Compare(other SortValue) int

func (*DateSortValue) Value

func (sv *DateSortValue) Value() interface{}

type FloatSortValue

type FloatSortValue struct {
	Val float64
}

func (*FloatSortValue) Compare

func (sv *FloatSortValue) Compare(other SortValue) int

func (*FloatSortValue) Value

func (sv *FloatSortValue) Value() interface{}

type GeoDistanceSortValue

type GeoDistanceSortValue struct {
	Val  float64
	Unit string
}

func (*GeoDistanceSortValue) Compare

func (sv *GeoDistanceSortValue) Compare(other SortValue) int

func (*GeoDistanceSortValue) Value

func (sv *GeoDistanceSortValue) Value() interface{}

type InfinitySortValue

type InfinitySortValue struct {
	Typ      ValueType
	Negative bool
}

func (*InfinitySortValue) Compare

func (sv *InfinitySortValue) Compare(other SortValue) int

func (*InfinitySortValue) Value

func (sv *InfinitySortValue) Value() interface{}

type IntSortValue

type IntSortValue struct {
	Val int64
}

func (*IntSortValue) Compare

func (sv *IntSortValue) Compare(other SortValue) int

func (*IntSortValue) Value

func (sv *IntSortValue) Value() interface{}

type Sort

type Sort interface {
	Compare(i, j SortValue) int
	SortField() string
}

type SortDoc

type SortDoc struct {
}

func (*SortDoc) Compare

func (s *SortDoc) Compare(i, j interface{}) int

func (*SortDoc) SortField

func (s *SortDoc) SortField() string

type SortField

type SortField struct {
	Field        string
	Desc         bool
	Mode         SortFieldMode
	Missing      SortFieldMissing
	MissingValue interface{}
	// contains filtered or unexported fields
}

func NewSortField

func NewSortField(field string) *SortField

func (*SortField) Compare

func (s *SortField) Compare(i, j SortValue) int

If i < j return -1; if i == j return 0; if i > j return 1

func (*SortField) SetMissing

func (s *SortField) SetMissing(missingMode SortFieldMissing, missingValue interface{})

func (*SortField) SetMode

func (s *SortField) SetMode(mode SortFieldMode)

func (*SortField) SetOrder

func (s *SortField) SetOrder(desc bool)

func (*SortField) SortField

func (s *SortField) SortField() string

type SortFieldMissing

type SortFieldMissing int

SortFieldMissing controls where documents missing a field value should be sorted

const (
	// SortFieldMissingLast sorts documents missing a field at the end
	SortFieldMissingLast SortFieldMissing = iota

	// SortFieldMissingFirst sorts documents missing a field at the beginning
	SortFieldMissingFirst

	// SortFieldMissingCustom sorts documents missing a field with a custom value
	SortFieldMissingCustom
)

type SortFieldMode

type SortFieldMode int

SortFieldMode describes the behavior if the field has multiple values

const (
	// SortFieldDefault uses the first (or only) value, this is the default zero-value
	SortFieldDefault SortFieldMode = iota // FIXME name is confusing
	// SortFieldMin uses the minimum value
	SortFieldMin
	// SortFieldMax uses the maximum value
	SortFieldMax
	// Use the sum of all values as sort value. Only applicable for number based array fields.
	SortFieldSum
	// Use the average of all values as sort value. Only applicable for number based array fields.
	SortFieldAvg
	// Use the median of all values as sort value. Only applicable for number based array fields.
	SortFieldMedian
)

type SortOrder

type SortOrder []Sort

func ParseSort

func ParseSort(bytes []byte) (SortOrder, error)

func (SortOrder) Compare

func (so SortOrder) Compare(a, b SortValues) int

Compare will compare two document matches using the specified sort order if both are numbers, we avoid converting back to term

type SortScore

type SortScore struct {
	Desc bool
}

func (*SortScore) Compare

func (s *SortScore) Compare(i, j SortValue) int

func (*SortScore) SortField

func (s *SortScore) SortField() string

type SortValue

type SortValue interface {
	Value() interface{}
	Compare(SortValue) int
}

type SortValues

type SortValues []SortValue

func (SortValues) Len

func (svs SortValues) Len() int

func (SortValues) Less

func (svs SortValues) Less(i, j int) bool

func (SortValues) Reset

func (vs SortValues) Reset() SortValues

func (SortValues) Swap

func (svs SortValues) Swap(i, j int)

Swap swaps the elements with indexes i and j.

func (SortValues) Values

func (vs SortValues) Values() []interface{}

type StringSortValue

type StringSortValue struct {
	Val string
}

func (*StringSortValue) Compare

func (sv *StringSortValue) Compare(other SortValue) int

func (*StringSortValue) Type

func (sv *StringSortValue) Type() ValueType

func (*StringSortValue) Value

func (sv *StringSortValue) Value() interface{}

type ValueType

type ValueType int
const (
	ValueType_Null ValueType = iota
	ValueType_String
	ValueType_Int
	ValueType_Float
	ValueType_Bool
	ValueType_Date
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL