summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/blevesearch/bleve/document
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-02-18 08:50:26 +0800
committertechknowlogick <matti@mdranta.net>2019-02-17 19:50:26 -0500
commita380cfd8e03148a05859a7496d235fa14bde4796 (patch)
tree9ef2f4b66804e73e242d0d07fd30769898a0ca23 /vendor/github.com/blevesearch/bleve/document
parent11e316654e523bd668a20e1e6a95da3f5b9b22de (diff)
downloadgitea-a380cfd8e03148a05859a7496d235fa14bde4796.tar.gz
gitea-a380cfd8e03148a05859a7496d235fa14bde4796.zip
Update bleve dependency to latest master revision (#6100)
* update bleve to master b17287a86f6cac923a5d886e10618df994eeb54b6724eac2e3b8dde89cfbe3a2 * remove unused pkg from dep file * change bleve from master to recent revision
Diffstat (limited to 'vendor/github.com/blevesearch/bleve/document')
-rw-r--r--vendor/github.com/blevesearch/bleve/document/document.go29
-rw-r--r--vendor/github.com/blevesearch/bleve/document/field.go2
-rw-r--r--vendor/github.com/blevesearch/bleve/document/field_boolean.go16
-rw-r--r--vendor/github.com/blevesearch/bleve/document/field_composite.go25
-rw-r--r--vendor/github.com/blevesearch/bleve/document/field_datetime.go15
-rw-r--r--vendor/github.com/blevesearch/bleve/document/field_geopoint.go15
-rw-r--r--vendor/github.com/blevesearch/bleve/document/field_numeric.go15
-rw-r--r--vendor/github.com/blevesearch/bleve/document/field_text.go16
8 files changed, 132 insertions, 1 deletions
diff --git a/vendor/github.com/blevesearch/bleve/document/document.go b/vendor/github.com/blevesearch/bleve/document/document.go
index c37585c661..6ac17b9ab7 100644
--- a/vendor/github.com/blevesearch/bleve/document/document.go
+++ b/vendor/github.com/blevesearch/bleve/document/document.go
@@ -14,7 +14,19 @@
package document
-import "fmt"
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/blevesearch/bleve/size"
+)
+
+var reflectStaticSizeDocument int
+
+func init() {
+ var d Document
+ reflectStaticSizeDocument = int(reflect.TypeOf(d).Size())
+}
type Document struct {
ID string `json:"id"`
@@ -30,6 +42,21 @@ func NewDocument(id string) *Document {
}
}
+func (d *Document) Size() int {
+ sizeInBytes := reflectStaticSizeDocument + size.SizeOfPtr +
+ len(d.ID)
+
+ for _, entry := range d.Fields {
+ sizeInBytes += entry.Size()
+ }
+
+ for _, entry := range d.CompositeFields {
+ sizeInBytes += entry.Size()
+ }
+
+ return sizeInBytes
+}
+
func (d *Document) AddField(f Field) *Document {
switch f := f.(type) {
case *CompositeField:
diff --git a/vendor/github.com/blevesearch/bleve/document/field.go b/vendor/github.com/blevesearch/bleve/document/field.go
index c17f81e5d4..2fe9166985 100644
--- a/vendor/github.com/blevesearch/bleve/document/field.go
+++ b/vendor/github.com/blevesearch/bleve/document/field.go
@@ -36,4 +36,6 @@ type Field interface {
// that this field represents - this is a common metric for tracking
// the rate of indexing
NumPlainTextBytes() uint64
+
+ Size() int
}
diff --git a/vendor/github.com/blevesearch/bleve/document/field_boolean.go b/vendor/github.com/blevesearch/bleve/document/field_boolean.go
index c226374c07..6864b16f44 100644
--- a/vendor/github.com/blevesearch/bleve/document/field_boolean.go
+++ b/vendor/github.com/blevesearch/bleve/document/field_boolean.go
@@ -16,10 +16,19 @@ package document
import (
"fmt"
+ "reflect"
"github.com/blevesearch/bleve/analysis"
+ "github.com/blevesearch/bleve/size"
)
+var reflectStaticSizeBooleanField int
+
+func init() {
+ var f BooleanField
+ reflectStaticSizeBooleanField = int(reflect.TypeOf(f).Size())
+}
+
const DefaultBooleanIndexingOptions = StoreField | IndexField | DocValues
type BooleanField struct {
@@ -30,6 +39,13 @@ type BooleanField struct {
numPlainTextBytes uint64
}
+func (b *BooleanField) Size() int {
+ return reflectStaticSizeBooleanField + size.SizeOfPtr +
+ len(b.name) +
+ len(b.arrayPositions)*size.SizeOfUint64 +
+ len(b.value)
+}
+
func (b *BooleanField) Name() string {
return b.name
}
diff --git a/vendor/github.com/blevesearch/bleve/document/field_composite.go b/vendor/github.com/blevesearch/bleve/document/field_composite.go
index b41b1b8ed9..a8285880fd 100644
--- a/vendor/github.com/blevesearch/bleve/document/field_composite.go
+++ b/vendor/github.com/blevesearch/bleve/document/field_composite.go
@@ -15,9 +15,19 @@
package document
import (
+ "reflect"
+
"github.com/blevesearch/bleve/analysis"
+ "github.com/blevesearch/bleve/size"
)
+var reflectStaticSizeCompositeField int
+
+func init() {
+ var cf CompositeField
+ reflectStaticSizeCompositeField = int(reflect.TypeOf(cf).Size())
+}
+
const DefaultCompositeIndexingOptions = IndexField
type CompositeField struct {
@@ -54,6 +64,21 @@ func NewCompositeFieldWithIndexingOptions(name string, defaultInclude bool, incl
return rv
}
+func (c *CompositeField) Size() int {
+ sizeInBytes := reflectStaticSizeCompositeField + size.SizeOfPtr +
+ len(c.name)
+
+ for k, _ := range c.includedFields {
+ sizeInBytes += size.SizeOfString + len(k) + size.SizeOfBool
+ }
+
+ for k, _ := range c.excludedFields {
+ sizeInBytes += size.SizeOfString + len(k) + size.SizeOfBool
+ }
+
+ return sizeInBytes
+}
+
func (c *CompositeField) Name() string {
return c.name
}
diff --git a/vendor/github.com/blevesearch/bleve/document/field_datetime.go b/vendor/github.com/blevesearch/bleve/document/field_datetime.go
index 1db068c87b..583b44cdeb 100644
--- a/vendor/github.com/blevesearch/bleve/document/field_datetime.go
+++ b/vendor/github.com/blevesearch/bleve/document/field_datetime.go
@@ -17,12 +17,21 @@ package document
import (
"fmt"
"math"
+ "reflect"
"time"
"github.com/blevesearch/bleve/analysis"
"github.com/blevesearch/bleve/numeric"
+ "github.com/blevesearch/bleve/size"
)
+var reflectStaticSizeDateTimeField int
+
+func init() {
+ var f DateTimeField
+ reflectStaticSizeDateTimeField = int(reflect.TypeOf(f).Size())
+}
+
const DefaultDateTimeIndexingOptions = StoreField | IndexField | DocValues
const DefaultDateTimePrecisionStep uint = 4
@@ -37,6 +46,12 @@ type DateTimeField struct {
numPlainTextBytes uint64
}
+func (n *DateTimeField) Size() int {
+ return reflectStaticSizeDateTimeField + size.SizeOfPtr +
+ len(n.name) +
+ len(n.arrayPositions)*size.SizeOfUint64
+}
+
func (n *DateTimeField) Name() string {
return n.name
}
diff --git a/vendor/github.com/blevesearch/bleve/document/field_geopoint.go b/vendor/github.com/blevesearch/bleve/document/field_geopoint.go
index f508b36254..91fe23f96e 100644
--- a/vendor/github.com/blevesearch/bleve/document/field_geopoint.go
+++ b/vendor/github.com/blevesearch/bleve/document/field_geopoint.go
@@ -16,12 +16,21 @@ package document
import (
"fmt"
+ "reflect"
"github.com/blevesearch/bleve/analysis"
"github.com/blevesearch/bleve/geo"
"github.com/blevesearch/bleve/numeric"
+ "github.com/blevesearch/bleve/size"
)
+var reflectStaticSizeGeoPointField int
+
+func init() {
+ var f GeoPointField
+ reflectStaticSizeGeoPointField = int(reflect.TypeOf(f).Size())
+}
+
var GeoPrecisionStep uint = 9
type GeoPointField struct {
@@ -32,6 +41,12 @@ type GeoPointField struct {
numPlainTextBytes uint64
}
+func (n *GeoPointField) Size() int {
+ return reflectStaticSizeGeoPointField + size.SizeOfPtr +
+ len(n.name) +
+ len(n.arrayPositions)*size.SizeOfUint64
+}
+
func (n *GeoPointField) Name() string {
return n.name
}
diff --git a/vendor/github.com/blevesearch/bleve/document/field_numeric.go b/vendor/github.com/blevesearch/bleve/document/field_numeric.go
index e32993c887..46c685e84e 100644
--- a/vendor/github.com/blevesearch/bleve/document/field_numeric.go
+++ b/vendor/github.com/blevesearch/bleve/document/field_numeric.go
@@ -16,11 +16,20 @@ package document
import (
"fmt"
+ "reflect"
"github.com/blevesearch/bleve/analysis"
"github.com/blevesearch/bleve/numeric"
+ "github.com/blevesearch/bleve/size"
)
+var reflectStaticSizeNumericField int
+
+func init() {
+ var f NumericField
+ reflectStaticSizeNumericField = int(reflect.TypeOf(f).Size())
+}
+
const DefaultNumericIndexingOptions = StoreField | IndexField | DocValues
const DefaultPrecisionStep uint = 4
@@ -33,6 +42,12 @@ type NumericField struct {
numPlainTextBytes uint64
}
+func (n *NumericField) Size() int {
+ return reflectStaticSizeNumericField + size.SizeOfPtr +
+ len(n.name) +
+ len(n.arrayPositions)*size.SizeOfPtr
+}
+
func (n *NumericField) Name() string {
return n.name
}
diff --git a/vendor/github.com/blevesearch/bleve/document/field_text.go b/vendor/github.com/blevesearch/bleve/document/field_text.go
index 5f7a3ab648..c8e871c9d5 100644
--- a/vendor/github.com/blevesearch/bleve/document/field_text.go
+++ b/vendor/github.com/blevesearch/bleve/document/field_text.go
@@ -16,10 +16,19 @@ package document
import (
"fmt"
+ "reflect"
"github.com/blevesearch/bleve/analysis"
+ "github.com/blevesearch/bleve/size"
)
+var reflectStaticSizeTextField int
+
+func init() {
+ var f TextField
+ reflectStaticSizeTextField = int(reflect.TypeOf(f).Size())
+}
+
const DefaultTextIndexingOptions = IndexField | DocValues
type TextField struct {
@@ -31,6 +40,13 @@ type TextField struct {
numPlainTextBytes uint64
}
+func (t *TextField) Size() int {
+ return reflectStaticSizeTextField + size.SizeOfPtr +
+ len(t.name) +
+ len(t.arrayPositions)*size.SizeOfUint64 +
+ len(t.value)
+}
+
func (t *TextField) Name() string {
return t.name
}