Files
opencloud/vendor/github.com/blevesearch/zapx/v16/section.go
dependabot[bot] 0c84ba3ad2 build(deps): bump github.com/blevesearch/bleve/v2 from 2.4.4 to 2.5.0
Bumps [github.com/blevesearch/bleve/v2](https://github.com/blevesearch/bleve) from 2.4.4 to 2.5.0.
- [Release notes](https://github.com/blevesearch/bleve/releases)
- [Commits](https://github.com/blevesearch/bleve/compare/v2.4.4...v2.5.0)

---
updated-dependencies:
- dependency-name: github.com/blevesearch/bleve/v2
  dependency-version: 2.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-29 08:41:09 +00:00

79 lines
2.8 KiB
Go

// Copyright (c) 2023 Couchbase, Inc.
//
// 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.
package zap
import (
"sync"
"github.com/RoaringBitmap/roaring/v2"
index "github.com/blevesearch/bleve_index_api"
)
type section interface {
// process is essentially parsing of a specific field's content in a specific
// document. any tracking of processed data *specific to this section* should
// be done in opaque which will be passed to the Persist() API.
Process(opaque map[int]resetable, docNum uint32, f index.Field, fieldID uint16)
// flush the processed data in the opaque to the writer.
Persist(opaque map[int]resetable, w *CountHashWriter) (n int64, err error)
// this API is used to fetch the file offset of the field for this section.
// this is used during search time to parse the section, and fetch results
// for the specific "index" thats part of the section.
AddrForField(opaque map[int]resetable, fieldID int) int
// for every field in the fieldsInv (relevant to this section) merge the section
// contents from all the segments into a single section data for the field.
// as part of the merge API, write the merged data to the writer and also track
// the starting offset of this newly merged section data.
Merge(opaque map[int]resetable, segments []*SegmentBase, drops []*roaring.Bitmap, fieldsInv []string,
newDocNumsIn [][]uint64, w *CountHashWriter, closeCh chan struct{}) error
// opaque is used to track the data specific to this section. its not visible
// to the other sections and is only visible and freely modifiable by this specifc
// section.
InitOpaque(args map[string]interface{}) resetable
}
type resetable interface {
Reset() error
Set(key string, value interface{})
}
// -----------------------------------------------------------------------------
const (
SectionInvertedTextIndex = iota
SectionFaissVectorIndex
SectionSynonymIndex
)
// -----------------------------------------------------------------------------
var (
segmentSectionsMutex sync.Mutex
// writes to segmentSections within init()s ONLY within lock,
// reads will not require lock access
segmentSections = make(map[uint16]section)
)
// Method to be invoked within init()s ONLY.
func registerSegmentSection(key uint16, val section) {
segmentSectionsMutex.Lock()
segmentSections[key] = val
segmentSectionsMutex.Unlock()
}