Skip to content

Commit 465d5fd

Browse files
MB-59633: Disable DocValues Chunking & Compression for Geo Fields (#2269)
- Added docValues, skipSnappy and skipChunking to all geo fields - Switched out bytes.Index with bytes.IndexByte - Fixed relavent test cases --------- Co-authored-by: Rahul Rampure <rahul.rampure@couchbase.com>
1 parent f7b13b9 commit 465d5fd

6 files changed

Lines changed: 22 additions & 19 deletions

File tree

document/field_geopoint.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,12 @@ func NewGeoPointFieldWithIndexingOptions(name string, arrayPositions []uint64, l
182182
prefixCoded := numeric.MustNewPrefixCodedInt64(int64(mhash), 0)
183183

184184
// docvalues are always enabled for geopoint fields, even if the
185-
// indexing options are set to not include them
185+
// indexing options are set to not include docvalues.
186+
// snappy compression and chunking are always skipped for geopoint
187+
// to avoid mem copies and faster lookups.
186188
options |= index.DocValues
189+
options |= index.SkipDVChunking
190+
options |= index.SkipDVCompression
187191

188192
return &GeoPointField{
189193
name: name,

document/field_geoshape.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ func NewGeoShapeFieldFromShapeWithIndexingOptions(name string, arrayPositions []
180180

181181
// docvalues are always enabled for geoshape fields, even if the
182182
// indexing options are set to not include docvalues.
183+
// snappy compression and chunking are always skipped for geoshape
184+
// to avoid mem copies and faster lookups.
183185
options |= index.DocValues
186+
options |= index.SkipDVChunking
187+
options |= index.SkipDVCompression
184188

185189
return &GeoShapeField{
186190
shape: shape,
@@ -232,7 +236,11 @@ func NewGeometryCollectionFieldFromShapesWithIndexingOptions(name string,
232236

233237
// docvalues are always enabled for geoshape fields, even if the
234238
// indexing options are set to not include docvalues.
239+
// snappy compression and chunking are always skipped for geoshape
240+
// to avoid mem copies and faster lookups.
235241
options |= index.DocValues
242+
options |= index.SkipDVChunking
243+
options |= index.SkipDVCompression
236244

237245
return &GeoShapeField{
238246
shape: shape,

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.24.0
55
require (
66
github.com/RoaringBitmap/roaring/v2 v2.14.4
77
github.com/bits-and-blooms/bitset v1.24.2
8-
github.com/blevesearch/bleve_index_api v1.3.1
8+
github.com/blevesearch/bleve_index_api v1.3.2
99
github.com/blevesearch/geo v0.2.4
1010
github.com/blevesearch/go-faiss v1.0.27
1111
github.com/blevesearch/go-metrics v0.0.0-20201227073835-cf1acfcdf475
@@ -25,7 +25,7 @@ require (
2525
github.com/blevesearch/zapx/v14 v14.4.3
2626
github.com/blevesearch/zapx/v15 v15.4.3
2727
github.com/blevesearch/zapx/v16 v16.3.1
28-
github.com/blevesearch/zapx/v17 v17.0.2-0.20260204210735-148661f2ddf6
28+
github.com/blevesearch/zapx/v17 v17.0.2-0.20260223150039-6b9420e5caf3
2929
github.com/couchbase/moss v0.2.0
3030
github.com/spf13/cobra v1.10.2
3131
go.etcd.io/bbolt v1.4.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ github.com/RoaringBitmap/roaring/v2 v2.14.4 h1:4aKySrrg9G/5oRtJ3TrZLObVqxgQ9f1zn
22
github.com/RoaringBitmap/roaring/v2 v2.14.4/go.mod h1:oMvV6omPWr+2ifRdeZvVJyaz+aoEUopyv5iH0u/+wbY=
33
github.com/bits-and-blooms/bitset v1.24.2 h1:M7/NzVbsytmtfHbumG+K2bremQPMJuqv1JD3vOaFxp0=
44
github.com/bits-and-blooms/bitset v1.24.2/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
5-
github.com/blevesearch/bleve_index_api v1.3.1 h1:LdH3CQgBbIZ5UI/5Pykz87e0jfeQtVnrdZ2WUBrHHwU=
6-
github.com/blevesearch/bleve_index_api v1.3.1/go.mod h1:xvd48t5XMeeioWQ5/jZvgLrV98flT2rdvEJ3l/ki4Ko=
5+
github.com/blevesearch/bleve_index_api v1.3.2 h1:y4VLXBF7nQR01CvF+QzmCJKMpVPCLp1CJ5FsRSZXzRE=
6+
github.com/blevesearch/bleve_index_api v1.3.2/go.mod h1:xvd48t5XMeeioWQ5/jZvgLrV98flT2rdvEJ3l/ki4Ko=
77
github.com/blevesearch/geo v0.2.4 h1:ECIGQhw+QALCZaDcogRTNSJYQXRtC8/m8IKiA706cqk=
88
github.com/blevesearch/geo v0.2.4/go.mod h1:K56Q33AzXt2YExVHGObtmRSFYZKYGv0JEN5mdacJJR8=
99
github.com/blevesearch/go-faiss v1.0.27 h1:7cBImYDDQ82WJd5RUZ1ie6zXztCsC73W94ZzwOjkatk=
@@ -45,8 +45,8 @@ github.com/blevesearch/zapx/v15 v15.4.3 h1:iJiMJOHrz216jyO6lS0m9RTCEkprUnzvqAI2l
4545
github.com/blevesearch/zapx/v15 v15.4.3/go.mod h1:1pssev/59FsuWcgSnTa0OeEpOzmhtmr/0/11H0Z8+Nw=
4646
github.com/blevesearch/zapx/v16 v16.3.1 h1:ERxZUSC9UcuKggCQ6b3y4sTkyL4WnGOWuopzglR874g=
4747
github.com/blevesearch/zapx/v16 v16.3.1/go.mod h1:zCFjv7McXWm1C8rROL+3mUoD5WYe2RKsZP3ufqcYpLY=
48-
github.com/blevesearch/zapx/v17 v17.0.2-0.20260204210735-148661f2ddf6 h1:eqJh5al0dcPq6VsY6C+G4kva5BBffzMG+sN/SWg2/Eg=
49-
github.com/blevesearch/zapx/v17 v17.0.2-0.20260204210735-148661f2ddf6/go.mod h1:gvr+JMDB9XvQUkT+CaYJhY7aMlez5EmXbkzOBCVyc7U=
48+
github.com/blevesearch/zapx/v17 v17.0.2-0.20260223150039-6b9420e5caf3 h1:xW1V3blKBPem6GYDcwibpnJ/UzZAwOSRqAEiiQOwanw=
49+
github.com/blevesearch/zapx/v17 v17.0.2-0.20260223150039-6b9420e5caf3/go.mod h1:70Z2efizAb00jpeLJA7r8DuqWzEtUdcLcWqaHIaOols=
5050
github.com/couchbase/ghistogram v0.1.0 h1:b95QcQTCzjTUocDXp/uMgSNQi8oj1tGwnJ4bODWZnps=
5151
github.com/couchbase/ghistogram v0.1.0/go.mod h1:s1Jhy76zqfEecpNWJfWUiKZookAFaiGOEoyzgHt9i7k=
5252
github.com/couchbase/moss v0.2.0 h1:VCYrMzFwEryyhRSeI+/b3tRBSeTpi/8gn5Kf6dxqn+o=

index/scorch/snapshot_segment.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ import (
2626
segment "github.com/blevesearch/scorch_segment_api/v2"
2727
)
2828

29-
var TermSeparator byte = 0xff
30-
31-
var TermSeparatorSplitSlice = []byte{TermSeparator}
32-
3329
type SegmentSnapshot struct {
3430
// this flag is needed to identify whether this
3531
// segment was mmaped recently, in which case
@@ -233,7 +229,7 @@ func (cfd *cachedFieldDocs) prepareField(field string, ss *SegmentSnapshot) {
233229
for err2 == nil && nextPosting != nil {
234230
docNum := nextPosting.Number()
235231
cfd.docs[docNum] = append(cfd.docs[docNum], []byte(next.Term)...)
236-
cfd.docs[docNum] = append(cfd.docs[docNum], TermSeparator)
232+
cfd.docs[docNum] = append(cfd.docs[docNum], index.DocValueTermSeparator)
237233
cfd.size += uint64(len(next.Term) + 1) // map value
238234
nextPosting, err2 = postingsItr.Next()
239235
}
@@ -334,7 +330,7 @@ func (c *cachedDocs) visitDoc(localDocNum uint64,
334330

335331
if tlist, exists := cachedFieldDocs.docs[localDocNum]; exists {
336332
for {
337-
i := bytes.Index(tlist, TermSeparatorSplitSlice)
333+
i := bytes.IndexByte(tlist, index.DocValueTermSeparator)
338334
if i < 0 {
339335
break
340336
}

search/searcher/search_geoshape.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ func NewGeoShapeSearcher(ctx context.Context, indexReader index.IndexReader, sha
5858
return NewFilteringSearcher(ctx, mSearcher, buildRelationFilterOnShapes(ctx, dvReader, field, relation, shape)), nil
5959
}
6060

61-
// Using the same term splitter slice used in the doc values in zap.
62-
// TODO: This needs to be revisited whenever we change the zap
63-
// implementation of doc values.
64-
var termSeparatorSplitSlice = []byte{0xff}
65-
6661
func buildRelationFilterOnShapes(ctx context.Context, dvReader index.DocValueReader, field string,
6762
relation string, shape index.GeoJSON,
6863
) FilterFunc {
@@ -104,7 +99,7 @@ func buildRelationFilterOnShapes(ctx context.Context, dvReader index.DocValueRea
10499
finishReading = true
105100
}
106101

107-
dvShapeValue = append(dvShapeValue, termSeparatorSplitSlice...)
102+
dvShapeValue = append(dvShapeValue, index.DocValueTermSeparator)
108103
dvShapeValue = append(dvShapeValue, term...)
109104
}
110105

0 commit comments

Comments
 (0)