summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/blevesearch/bleve/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/blevesearch/bleve/analysis')
-rw-r--r--vendor/github.com/blevesearch/bleve/analysis/freq.go41
-rw-r--r--vendor/github.com/blevesearch/bleve/analysis/token/camelcase/parser.go8
-rw-r--r--vendor/github.com/blevesearch/bleve/analysis/token/unique/unique.go2
3 files changed, 46 insertions, 5 deletions
diff --git a/vendor/github.com/blevesearch/bleve/analysis/freq.go b/vendor/github.com/blevesearch/bleve/analysis/freq.go
index e1ca2cd6fd..198c149b2b 100644
--- a/vendor/github.com/blevesearch/bleve/analysis/freq.go
+++ b/vendor/github.com/blevesearch/bleve/analysis/freq.go
@@ -14,6 +14,22 @@
package analysis
+import (
+ "reflect"
+
+ "github.com/blevesearch/bleve/size"
+)
+
+var reflectStaticSizeTokenLocation int
+var reflectStaticSizeTokenFreq int
+
+func init() {
+ var tl TokenLocation
+ reflectStaticSizeTokenLocation = int(reflect.TypeOf(tl).Size())
+ var tf TokenFreq
+ reflectStaticSizeTokenFreq = int(reflect.TypeOf(tf).Size())
+}
+
// TokenLocation represents one occurrence of a term at a particular location in
// a field. Start, End and Position have the same meaning as in analysis.Token.
// Field and ArrayPositions identify the field value in the source document.
@@ -26,6 +42,12 @@ type TokenLocation struct {
Position int
}
+func (tl *TokenLocation) Size() int {
+ rv := reflectStaticSizeTokenLocation
+ rv += len(tl.ArrayPositions) * size.SizeOfUint64
+ return rv
+}
+
// TokenFreq represents all the occurrences of a term in all fields of a
// document.
type TokenFreq struct {
@@ -34,6 +56,15 @@ type TokenFreq struct {
frequency int
}
+func (tf *TokenFreq) Size() int {
+ rv := reflectStaticSizeTokenFreq
+ rv += len(tf.Term)
+ for _, loc := range tf.Locations {
+ rv += loc.Size()
+ }
+ return rv
+}
+
func (tf *TokenFreq) Frequency() int {
return tf.frequency
}
@@ -42,6 +73,16 @@ func (tf *TokenFreq) Frequency() int {
// fields.
type TokenFrequencies map[string]*TokenFreq
+func (tfs TokenFrequencies) Size() int {
+ rv := size.SizeOfMap
+ rv += len(tfs) * (size.SizeOfString + size.SizeOfPtr)
+ for k, v := range tfs {
+ rv += len(k)
+ rv += v.Size()
+ }
+ return rv
+}
+
func (tfs TokenFrequencies) MergeAll(remoteField string, other TokenFrequencies) {
// walk the new token frequencies
for tfk, tf := range other {
diff --git a/vendor/github.com/blevesearch/bleve/analysis/token/camelcase/parser.go b/vendor/github.com/blevesearch/bleve/analysis/token/camelcase/parser.go
index d691e56463..ff4ce2fea7 100644
--- a/vendor/github.com/blevesearch/bleve/analysis/token/camelcase/parser.go
+++ b/vendor/github.com/blevesearch/bleve/analysis/token/camelcase/parser.go
@@ -46,11 +46,11 @@ type Parser struct {
index int
}
-func NewParser(len, position, index int) *Parser {
+func NewParser(length, position, index int) *Parser {
return &Parser{
- bufferLen: len,
- buffer: make([]rune, 0, len),
- tokens: make([]*analysis.Token, 0, len),
+ bufferLen: length,
+ buffer: make([]rune, 0, length),
+ tokens: make([]*analysis.Token, 0, length),
position: position,
index: index,
}
diff --git a/vendor/github.com/blevesearch/bleve/analysis/token/unique/unique.go b/vendor/github.com/blevesearch/bleve/analysis/token/unique/unique.go
index f0d96c5048..c60e8c9793 100644
--- a/vendor/github.com/blevesearch/bleve/analysis/token/unique/unique.go
+++ b/vendor/github.com/blevesearch/bleve/analysis/token/unique/unique.go
@@ -21,7 +21,7 @@ import (
const Name = "unique"
-// UniqueTermFilter retains only the tokens which mark the first occurence of
+// UniqueTermFilter retains only the tokens which mark the first occurrence of
// a term. Tokens whose term appears in a preceding token are dropped.
type UniqueTermFilter struct{}