diff --git a/document/field_geopoint.go b/document/field_geopoint.go index de6f262c5..ef8938f70 100644 --- a/document/field_geopoint.go +++ b/document/field_geopoint.go @@ -182,8 +182,12 @@ func NewGeoPointFieldWithIndexingOptions(name string, arrayPositions []uint64, l prefixCoded := numeric.MustNewPrefixCodedInt64(int64(mhash), 0) // docvalues are always enabled for geopoint fields, even if the - // indexing options are set to not include them + // indexing options are set to not include docvalues. + // snappy compression and chunking are always skipped for geopoint + // to avoid mem copies and faster lookups. options |= index.DocValues + options |= index.SkipDVChunking + options |= index.SkipDVCompression return &GeoPointField{ name: name, diff --git a/document/field_geoshape.go b/document/field_geoshape.go index 6282ff12b..2eb7aa3f2 100644 --- a/document/field_geoshape.go +++ b/document/field_geoshape.go @@ -180,7 +180,11 @@ func NewGeoShapeFieldFromShapeWithIndexingOptions(name string, arrayPositions [] // docvalues are always enabled for geoshape fields, even if the // indexing options are set to not include docvalues. + // snappy compression and chunking are always skipped for geoshape + // to avoid mem copies and faster lookups. options |= index.DocValues + options |= index.SkipDVChunking + options |= index.SkipDVCompression return &GeoShapeField{ shape: shape, @@ -232,7 +236,11 @@ func NewGeometryCollectionFieldFromShapesWithIndexingOptions(name string, // docvalues are always enabled for geoshape fields, even if the // indexing options are set to not include docvalues. + // snappy compression and chunking are always skipped for geoshape + // to avoid mem copies and faster lookups. options |= index.DocValues + options |= index.SkipDVChunking + options |= index.SkipDVCompression return &GeoShapeField{ shape: shape, diff --git a/index/scorch/snapshot_segment.go b/index/scorch/snapshot_segment.go index 85b69c1ef..2348c08ca 100644 --- a/index/scorch/snapshot_segment.go +++ b/index/scorch/snapshot_segment.go @@ -26,10 +26,6 @@ import ( segment "github.com/blevesearch/scorch_segment_api/v2" ) -var TermSeparator byte = 0xff - -var TermSeparatorSplitSlice = []byte{TermSeparator} - type SegmentSnapshot struct { // this flag is needed to identify whether this // segment was mmaped recently, in which case @@ -233,7 +229,7 @@ func (cfd *cachedFieldDocs) prepareField(field string, ss *SegmentSnapshot) { for err2 == nil && nextPosting != nil { docNum := nextPosting.Number() cfd.docs[docNum] = append(cfd.docs[docNum], []byte(next.Term)...) - cfd.docs[docNum] = append(cfd.docs[docNum], TermSeparator) + cfd.docs[docNum] = append(cfd.docs[docNum], index.DocValueTermSeparator) cfd.size += uint64(len(next.Term) + 1) // map value nextPosting, err2 = postingsItr.Next() } @@ -334,7 +330,7 @@ func (c *cachedDocs) visitDoc(localDocNum uint64, if tlist, exists := cachedFieldDocs.docs[localDocNum]; exists { for { - i := bytes.Index(tlist, TermSeparatorSplitSlice) + i := bytes.IndexByte(tlist, index.DocValueTermSeparator) if i < 0 { break } diff --git a/search/searcher/search_geoshape.go b/search/searcher/search_geoshape.go index 4f90808a1..cd020fafc 100644 --- a/search/searcher/search_geoshape.go +++ b/search/searcher/search_geoshape.go @@ -58,11 +58,6 @@ func NewGeoShapeSearcher(ctx context.Context, indexReader index.IndexReader, sha return NewFilteringSearcher(ctx, mSearcher, buildRelationFilterOnShapes(ctx, dvReader, field, relation, shape)), nil } -// Using the same term splitter slice used in the doc values in zap. -// TODO: This needs to be revisited whenever we change the zap -// implementation of doc values. -var termSeparatorSplitSlice = []byte{0xff} - func buildRelationFilterOnShapes(ctx context.Context, dvReader index.DocValueReader, field string, relation string, shape index.GeoJSON, ) FilterFunc { @@ -104,7 +99,7 @@ func buildRelationFilterOnShapes(ctx context.Context, dvReader index.DocValueRea finishReading = true } - dvShapeValue = append(dvShapeValue, termSeparatorSplitSlice...) + dvShapeValue = append(dvShapeValue, index.DocValueTermSeparator) dvShapeValue = append(dvShapeValue, term...) }