Integrate BACKBEAT SDK and resolve KACHING license validation
Major integrations and fixes: - Added BACKBEAT SDK integration for P2P operation timing - Implemented beat-aware status tracking for distributed operations - Added Docker secrets support for secure license management - Resolved KACHING license validation via HTTPS/TLS - Updated docker-compose configuration for clean stack deployment - Disabled rollback policies to prevent deployment failures - Added license credential storage (CHORUS-DEV-MULTI-001) Technical improvements: - BACKBEAT P2P operation tracking with phase management - Enhanced configuration system with file-based secrets - Improved error handling for license validation - Clean separation of KACHING and CHORUS deployment stacks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
37
vendor/github.com/blevesearch/bleve_index_api/.golangci.yml
generated
vendored
Normal file
37
vendor/github.com/blevesearch/bleve_index_api/.golangci.yml
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
linters:
|
||||
# please, do not use `enable-all`: it's deprecated and will be removed soon.
|
||||
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
|
||||
disable-all: true
|
||||
enable:
|
||||
- bodyclose
|
||||
- deadcode
|
||||
- depguard
|
||||
- dogsled
|
||||
- dupl
|
||||
- errcheck
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofmt
|
||||
- goimports
|
||||
- gomnd
|
||||
- goprintffuncname
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- interfacer
|
||||
- lll
|
||||
- misspell
|
||||
- nakedret
|
||||
- nolintlint
|
||||
- rowserrcheck
|
||||
- scopelint
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- stylecheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- varcheck
|
||||
- whitespace
|
||||
202
vendor/github.com/blevesearch/bleve_index_api/LICENSE
generated
vendored
Normal file
202
vendor/github.com/blevesearch/bleve_index_api/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
||||
11
vendor/github.com/blevesearch/bleve_index_api/README.md
generated
vendored
Normal file
11
vendor/github.com/blevesearch/bleve_index_api/README.md
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Bleve Index API
|
||||
|
||||
[](https://pkg.go.dev/github.com/blevesearch/bleve_index_api)
|
||||
[](https://github.com/blevesearch/bleve_index_api/actions?query=workflow%3ATests+event%3Apush+branch%3Amaster)
|
||||
[](https://github.com/blevesearch/bleve_index_api/actions?query=workflow%3ALint+event%3Apush+branch%3Amaster)
|
||||
|
||||
Bleve supports a pluggable Index interface.
|
||||
|
||||
By placing these interfaces in their own, *hopefully* slowly evolving module, it frees up Bleve and the underlying index to each introduce new major versions without interfering with one another.
|
||||
|
||||
With that in mind, we anticipate introducing non-breaking changes only to this module, and keeping the major version at 1.x for some time.
|
||||
53
vendor/github.com/blevesearch/bleve_index_api/analysis.go
generated
vendored
Normal file
53
vendor/github.com/blevesearch/bleve_index_api/analysis.go
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2015 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 index
|
||||
|
||||
type AnalysisWork func()
|
||||
|
||||
type AnalysisQueue struct {
|
||||
queue chan AnalysisWork
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
func (q *AnalysisQueue) Queue(work AnalysisWork) {
|
||||
q.queue <- work
|
||||
}
|
||||
|
||||
func (q *AnalysisQueue) Close() {
|
||||
close(q.done)
|
||||
}
|
||||
|
||||
func NewAnalysisQueue(numWorkers int) *AnalysisQueue {
|
||||
rv := AnalysisQueue{
|
||||
queue: make(chan AnalysisWork),
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
for i := 0; i < numWorkers; i++ {
|
||||
go AnalysisWorker(rv)
|
||||
}
|
||||
return &rv
|
||||
}
|
||||
|
||||
func AnalysisWorker(q AnalysisQueue) {
|
||||
// read work off the queue
|
||||
for {
|
||||
select {
|
||||
case <-q.done:
|
||||
return
|
||||
case w := <-q.queue:
|
||||
w()
|
||||
}
|
||||
}
|
||||
}
|
||||
101
vendor/github.com/blevesearch/bleve_index_api/batch.go
generated
vendored
Normal file
101
vendor/github.com/blevesearch/bleve_index_api/batch.go
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
// Copyright (c) 2020 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 index
|
||||
|
||||
import "fmt"
|
||||
|
||||
type BatchCallback func(error)
|
||||
|
||||
type Batch struct {
|
||||
IndexOps map[string]Document
|
||||
InternalOps map[string][]byte
|
||||
persistedCallback BatchCallback
|
||||
}
|
||||
|
||||
func NewBatch() *Batch {
|
||||
return &Batch{
|
||||
IndexOps: make(map[string]Document),
|
||||
InternalOps: make(map[string][]byte),
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Batch) Update(doc Document) {
|
||||
b.IndexOps[doc.ID()] = doc
|
||||
}
|
||||
|
||||
func (b *Batch) Delete(id string) {
|
||||
b.IndexOps[id] = nil
|
||||
}
|
||||
|
||||
func (b *Batch) SetInternal(key, val []byte) {
|
||||
b.InternalOps[string(key)] = val
|
||||
}
|
||||
|
||||
func (b *Batch) DeleteInternal(key []byte) {
|
||||
b.InternalOps[string(key)] = nil
|
||||
}
|
||||
|
||||
func (b *Batch) SetPersistedCallback(f BatchCallback) {
|
||||
b.persistedCallback = f
|
||||
}
|
||||
|
||||
func (b *Batch) PersistedCallback() BatchCallback {
|
||||
return b.persistedCallback
|
||||
}
|
||||
|
||||
func (b *Batch) String() string {
|
||||
rv := fmt.Sprintf("Batch (%d ops, %d internal ops)\n", len(b.IndexOps), len(b.InternalOps))
|
||||
for k, v := range b.IndexOps {
|
||||
if v != nil {
|
||||
rv += fmt.Sprintf("\tINDEX - '%s'\n", k)
|
||||
} else {
|
||||
rv += fmt.Sprintf("\tDELETE - '%s'\n", k)
|
||||
}
|
||||
}
|
||||
for k, v := range b.InternalOps {
|
||||
if v != nil {
|
||||
rv += fmt.Sprintf("\tSET INTERNAL - '%s'\n", k)
|
||||
} else {
|
||||
rv += fmt.Sprintf("\tDELETE INTERNAL - '%s'\n", k)
|
||||
}
|
||||
}
|
||||
return rv
|
||||
}
|
||||
|
||||
func (b *Batch) Reset() {
|
||||
b.IndexOps = make(map[string]Document)
|
||||
b.InternalOps = make(map[string][]byte)
|
||||
b.persistedCallback = nil
|
||||
}
|
||||
|
||||
func (b *Batch) Merge(o *Batch) {
|
||||
for k, v := range o.IndexOps {
|
||||
b.IndexOps[k] = v
|
||||
}
|
||||
for k, v := range o.InternalOps {
|
||||
b.InternalOps[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Batch) TotalDocSize() int {
|
||||
var s int
|
||||
for k, v := range b.IndexOps {
|
||||
if v != nil {
|
||||
s += v.Size() + sizeOfString
|
||||
}
|
||||
s += len(k)
|
||||
}
|
||||
return s
|
||||
}
|
||||
23
vendor/github.com/blevesearch/bleve_index_api/directory.go
generated
vendored
Normal file
23
vendor/github.com/blevesearch/bleve_index_api/directory.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2021 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 index
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
type Directory interface {
|
||||
GetWriter(filePath string) (io.WriteCloser, error)
|
||||
}
|
||||
126
vendor/github.com/blevesearch/bleve_index_api/document.go
generated
vendored
Normal file
126
vendor/github.com/blevesearch/bleve_index_api/document.go
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
// Copyright (c) 2015 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 index
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Document interface {
|
||||
ID() string
|
||||
Size() int
|
||||
|
||||
VisitFields(visitor FieldVisitor)
|
||||
VisitComposite(visitor CompositeFieldVisitor)
|
||||
HasComposite() bool
|
||||
|
||||
NumPlainTextBytes() uint64
|
||||
|
||||
AddIDField()
|
||||
|
||||
StoredFieldsBytes() uint64
|
||||
|
||||
Indexed() bool
|
||||
}
|
||||
|
||||
type FieldVisitor func(Field)
|
||||
|
||||
type Field interface {
|
||||
Name() string
|
||||
Value() []byte
|
||||
ArrayPositions() []uint64
|
||||
|
||||
EncodedFieldType() byte
|
||||
|
||||
Analyze()
|
||||
|
||||
Options() FieldIndexingOptions
|
||||
|
||||
AnalyzedLength() int
|
||||
AnalyzedTokenFrequencies() TokenFrequencies
|
||||
|
||||
NumPlainTextBytes() uint64
|
||||
}
|
||||
|
||||
type CompositeFieldVisitor func(field CompositeField)
|
||||
|
||||
type CompositeField interface {
|
||||
Field
|
||||
|
||||
Compose(field string, length int, freq TokenFrequencies)
|
||||
}
|
||||
|
||||
type TextField interface {
|
||||
Text() string
|
||||
}
|
||||
|
||||
type NumericField interface {
|
||||
Number() (float64, error)
|
||||
}
|
||||
|
||||
type DateTimeField interface {
|
||||
DateTime() (time.Time, string, error)
|
||||
}
|
||||
|
||||
type BooleanField interface {
|
||||
Boolean() (bool, error)
|
||||
}
|
||||
|
||||
type GeoPointField interface {
|
||||
Lon() (float64, error)
|
||||
Lat() (float64, error)
|
||||
}
|
||||
|
||||
type GeoShapeField interface {
|
||||
GeoShape() (GeoJSON, error)
|
||||
EncodedShape() []byte
|
||||
}
|
||||
|
||||
type IPField interface {
|
||||
IP() (net.IP, error)
|
||||
}
|
||||
|
||||
// TokenizableSpatialField is an optional interface for fields that
|
||||
// supports pluggable custom hierarchial spatial token generation.
|
||||
type TokenizableSpatialField interface {
|
||||
// SetSpatialAnalyzerPlugin lets the index implementations to
|
||||
// initialise relevant spatial analyzer plugins for the field
|
||||
// to override the spatial token generations during the analysis phase.
|
||||
SetSpatialAnalyzerPlugin(SpatialAnalyzerPlugin)
|
||||
}
|
||||
|
||||
// SynonymField represents a field that contains a list of synonyms for a set of terms.
|
||||
// Each SynonymField is generated from a single synonym definition, and its name corresponds
|
||||
// to the synonym source to which the synonym definition belongs.
|
||||
type SynonymField interface {
|
||||
Field
|
||||
// IterateSynonyms iterates over the synonyms for the term in the field.
|
||||
// The provided visitor function is called with each term and its corresponding synonyms.
|
||||
IterateSynonyms(visitor func(term string, synonyms []string))
|
||||
}
|
||||
|
||||
// SynonymFieldVisitor is a function type used to visit a SynonymField within a document.
|
||||
type SynonymFieldVisitor func(SynonymField)
|
||||
|
||||
// SynonymDocument represents a special type of document that contains synonym fields.
|
||||
// Each SynonymField is a field with a list of synonyms for a set of terms.
|
||||
// These fields are derived from synonym definitions, and their names correspond to the synonym sources.
|
||||
type SynonymDocument interface {
|
||||
Document
|
||||
// VisitSynonymFields allows iteration over all synonym fields in the document.
|
||||
// The provided visitor function is called for each synonym field.
|
||||
VisitSynonymFields(visitor SynonymFieldVisitor)
|
||||
}
|
||||
106
vendor/github.com/blevesearch/bleve_index_api/freq.go
generated
vendored
Normal file
106
vendor/github.com/blevesearch/bleve_index_api/freq.go
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
// Copyright (c) 2020 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 index
|
||||
|
||||
import "reflect"
|
||||
|
||||
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.
|
||||
// See document.Field for details.
|
||||
type TokenLocation struct {
|
||||
Field string
|
||||
ArrayPositions []uint64
|
||||
Start int
|
||||
End int
|
||||
Position int
|
||||
}
|
||||
|
||||
func (tl *TokenLocation) Size() int {
|
||||
rv := reflectStaticSizeTokenLocation
|
||||
rv += len(tl.ArrayPositions) * sizeOfUint64
|
||||
return rv
|
||||
}
|
||||
|
||||
// TokenFreq represents all the occurrences of a term in all fields of a
|
||||
// document.
|
||||
type TokenFreq struct {
|
||||
Term []byte
|
||||
Locations []*TokenLocation
|
||||
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
|
||||
}
|
||||
|
||||
func (tf *TokenFreq) SetFrequency(frequency int) {
|
||||
tf.frequency = frequency
|
||||
}
|
||||
|
||||
// TokenFrequencies maps document terms to their combined frequencies from all
|
||||
// fields.
|
||||
type TokenFrequencies map[string]*TokenFreq
|
||||
|
||||
func (tfs TokenFrequencies) Size() int {
|
||||
rv := sizeOfMap
|
||||
rv += len(tfs) * (sizeOfString + 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 {
|
||||
// set the remoteField value in incoming token freqs
|
||||
for _, l := range tf.Locations {
|
||||
l.Field = remoteField
|
||||
}
|
||||
existingTf, exists := tfs[tfk]
|
||||
if exists {
|
||||
existingTf.Locations = append(existingTf.Locations, tf.Locations...)
|
||||
existingTf.frequency += tf.frequency
|
||||
} else {
|
||||
tfs[tfk] = &TokenFreq{
|
||||
Term: tf.Term,
|
||||
frequency: tf.frequency,
|
||||
Locations: make([]*TokenLocation, len(tf.Locations)),
|
||||
}
|
||||
copy(tfs[tfk].Locations, tf.Locations)
|
||||
}
|
||||
}
|
||||
}
|
||||
354
vendor/github.com/blevesearch/bleve_index_api/index.go
generated
vendored
Normal file
354
vendor/github.com/blevesearch/bleve_index_api/index.go
generated
vendored
Normal file
@@ -0,0 +1,354 @@
|
||||
// Copyright (c) 2014 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 index
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
var reflectStaticSizeTermFieldDoc int
|
||||
var reflectStaticSizeTermFieldVector int
|
||||
|
||||
func init() {
|
||||
var tfd TermFieldDoc
|
||||
reflectStaticSizeTermFieldDoc = int(reflect.TypeOf(tfd).Size())
|
||||
var tfv TermFieldVector
|
||||
reflectStaticSizeTermFieldVector = int(reflect.TypeOf(tfv).Size())
|
||||
}
|
||||
|
||||
type Index interface {
|
||||
Open() error
|
||||
Close() error
|
||||
|
||||
Update(doc Document) error
|
||||
Delete(id string) error
|
||||
Batch(batch *Batch) error
|
||||
|
||||
SetInternal(key, val []byte) error
|
||||
DeleteInternal(key []byte) error
|
||||
|
||||
// Reader returns a low-level accessor on the index data. Close it to
|
||||
// release associated resources.
|
||||
Reader() (IndexReader, error)
|
||||
|
||||
StatsMap() map[string]interface{}
|
||||
}
|
||||
|
||||
// CopyIndex is an extended index that supports copying to a new location online.
|
||||
// Use the CopyReader method to obtain a reader for initiating the copy operation.
|
||||
type CopyIndex interface {
|
||||
Index
|
||||
// Obtain a copy reader for the online copy/backup operation,
|
||||
// to handle necessary bookkeeping, instead of using the regular IndexReader.
|
||||
CopyReader() CopyReader
|
||||
}
|
||||
|
||||
// EventIndex is an optional interface for exposing the support for firing event
|
||||
// callbacks for various events in the index.
|
||||
type EventIndex interface {
|
||||
// FireIndexEvent is used to fire an event callback when Index() is called,
|
||||
// to notify the caller that a document has been added to the index.
|
||||
FireIndexEvent()
|
||||
}
|
||||
|
||||
type IndexReader interface {
|
||||
TermFieldReader(ctx context.Context, term []byte, field string, includeFreq, includeNorm, includeTermVectors bool) (TermFieldReader, error)
|
||||
|
||||
// DocIDReader returns an iterator over all doc ids
|
||||
// The caller must close returned instance to release associated resources.
|
||||
DocIDReaderAll() (DocIDReader, error)
|
||||
|
||||
DocIDReaderOnly(ids []string) (DocIDReader, error)
|
||||
|
||||
FieldDict(field string) (FieldDict, error)
|
||||
|
||||
// FieldDictRange is currently defined to include the start and end terms
|
||||
FieldDictRange(field string, startTerm []byte, endTerm []byte) (FieldDict, error)
|
||||
FieldDictPrefix(field string, termPrefix []byte) (FieldDict, error)
|
||||
|
||||
Document(id string) (Document, error)
|
||||
|
||||
DocValueReader(fields []string) (DocValueReader, error)
|
||||
|
||||
Fields() ([]string, error)
|
||||
|
||||
GetInternal(key []byte) ([]byte, error)
|
||||
|
||||
DocCount() (uint64, error)
|
||||
|
||||
ExternalID(id IndexInternalID) (string, error)
|
||||
InternalID(id string) (IndexInternalID, error)
|
||||
|
||||
Close() error
|
||||
}
|
||||
|
||||
type BM25Reader interface {
|
||||
IndexReader
|
||||
FieldCardinality(field string) (int, error)
|
||||
}
|
||||
|
||||
// CopyReader is an extended index reader for backup or online copy operations, replacing the regular index reader.
|
||||
type CopyReader interface {
|
||||
IndexReader
|
||||
// CopyTo performs an online copy or backup of the index to the specified directory.
|
||||
CopyTo(d Directory) error
|
||||
// CloseCopyReader must be used instead of Close() to close the copy reader.
|
||||
CloseCopyReader() error
|
||||
}
|
||||
|
||||
// RegexAutomaton abstracts an automaton built using a regex pattern.
|
||||
type RegexAutomaton interface {
|
||||
// MatchesRegex returns true if the given string matches the regex pattern
|
||||
// used to build the automaton.
|
||||
MatchesRegex(string) bool
|
||||
}
|
||||
|
||||
// IndexReaderRegexp provides functionality to work with regex-based field dictionaries.
|
||||
type IndexReaderRegexp interface {
|
||||
// FieldDictRegexp returns a FieldDict for terms matching the specified regex pattern
|
||||
// in the dictionary of the given field.
|
||||
FieldDictRegexp(field string, regex string) (FieldDict, error)
|
||||
|
||||
// FieldDictRegexpAutomaton returns a FieldDict and a RegexAutomaton that can be used
|
||||
// to match strings against the regex pattern.
|
||||
FieldDictRegexpAutomaton(field string, regex string) (FieldDict, RegexAutomaton, error)
|
||||
}
|
||||
|
||||
// FuzzyAutomaton abstracts a Levenshtein automaton built using a term and a fuzziness value.
|
||||
type FuzzyAutomaton interface {
|
||||
// MatchAndDistance checks if the given string is within the fuzziness distance
|
||||
// of the term used to build the automaton. It also returns the edit (Levenshtein)
|
||||
// distance between the string and the term.
|
||||
MatchAndDistance(term string) (bool, uint8)
|
||||
}
|
||||
|
||||
// IndexReaderFuzzy provides functionality to work with fuzzy matching in field dictionaries.
|
||||
type IndexReaderFuzzy interface {
|
||||
// FieldDictFuzzy returns a FieldDict for terms that are within the specified fuzziness
|
||||
// distance of the given term and match the specified prefix in the given field.
|
||||
FieldDictFuzzy(field string, term string, fuzziness int, prefix string) (FieldDict, error)
|
||||
|
||||
// FieldDictFuzzyAutomaton returns a FieldDict and a FuzzyAutomaton that can be used
|
||||
// to calculate the edit distance between the term and other strings.
|
||||
FieldDictFuzzyAutomaton(field string, term string, fuzziness int, prefix string) (FieldDict, FuzzyAutomaton, error)
|
||||
}
|
||||
|
||||
type IndexReaderContains interface {
|
||||
FieldDictContains(field string) (FieldDictContains, error)
|
||||
}
|
||||
|
||||
// SpatialIndexPlugin is an optional interface for exposing the
|
||||
// support for any custom analyzer plugins that are capable of
|
||||
// generating hierarchial spatial tokens for both indexing and
|
||||
// query purposes from the geo location data.
|
||||
type SpatialIndexPlugin interface {
|
||||
GetSpatialAnalyzerPlugin(typ string) (SpatialAnalyzerPlugin, error)
|
||||
}
|
||||
|
||||
type TermFieldVector struct {
|
||||
Field string
|
||||
ArrayPositions []uint64
|
||||
Pos uint64
|
||||
Start uint64
|
||||
End uint64
|
||||
}
|
||||
|
||||
func (tfv *TermFieldVector) Size() int {
|
||||
return reflectStaticSizeTermFieldVector + sizeOfPtr +
|
||||
len(tfv.Field) + len(tfv.ArrayPositions)*sizeOfUint64
|
||||
}
|
||||
|
||||
// IndexInternalID is an opaque document identifier interal to the index impl
|
||||
type IndexInternalID []byte
|
||||
|
||||
func (id IndexInternalID) Equals(other IndexInternalID) bool {
|
||||
return id.Compare(other) == 0
|
||||
}
|
||||
|
||||
func (id IndexInternalID) Compare(other IndexInternalID) int {
|
||||
return bytes.Compare(id, other)
|
||||
}
|
||||
|
||||
type TermFieldDoc struct {
|
||||
Term string
|
||||
ID IndexInternalID
|
||||
Freq uint64
|
||||
Norm float64
|
||||
Vectors []*TermFieldVector
|
||||
}
|
||||
|
||||
func (tfd *TermFieldDoc) Size() int {
|
||||
sizeInBytes := reflectStaticSizeTermFieldDoc + sizeOfPtr +
|
||||
len(tfd.Term) + len(tfd.ID)
|
||||
|
||||
for _, entry := range tfd.Vectors {
|
||||
sizeInBytes += entry.Size()
|
||||
}
|
||||
|
||||
return sizeInBytes
|
||||
}
|
||||
|
||||
// Reset allows an already allocated TermFieldDoc to be reused
|
||||
func (tfd *TermFieldDoc) Reset() *TermFieldDoc {
|
||||
// remember the []byte used for the ID
|
||||
id := tfd.ID
|
||||
vectors := tfd.Vectors
|
||||
// idiom to copy over from empty TermFieldDoc (0 allocations)
|
||||
*tfd = TermFieldDoc{}
|
||||
// reuse the []byte already allocated (and reset len to 0)
|
||||
tfd.ID = id[:0]
|
||||
tfd.Vectors = vectors[:0]
|
||||
return tfd
|
||||
}
|
||||
|
||||
// TermFieldReader is the interface exposing the enumeration of documents
|
||||
// containing a given term in a given field. Documents are returned in byte
|
||||
// lexicographic order over their identifiers.
|
||||
type TermFieldReader interface {
|
||||
// Next returns the next document containing the term in this field, or nil
|
||||
// when it reaches the end of the enumeration. The preAlloced TermFieldDoc
|
||||
// is optional, and when non-nil, will be used instead of allocating memory.
|
||||
Next(preAlloced *TermFieldDoc) (*TermFieldDoc, error)
|
||||
|
||||
// Advance resets the enumeration at specified document or its immediate
|
||||
// follower.
|
||||
Advance(ID IndexInternalID, preAlloced *TermFieldDoc) (*TermFieldDoc, error)
|
||||
|
||||
// Count returns the number of documents contains the term in this field.
|
||||
Count() uint64
|
||||
Close() error
|
||||
|
||||
Size() int
|
||||
}
|
||||
|
||||
type DictEntry struct {
|
||||
Term string
|
||||
Count uint64
|
||||
EditDistance uint8
|
||||
}
|
||||
|
||||
type FieldDict interface {
|
||||
Next() (*DictEntry, error)
|
||||
Close() error
|
||||
|
||||
Cardinality() int
|
||||
BytesRead() uint64
|
||||
}
|
||||
|
||||
type FieldDictContains interface {
|
||||
Contains(key []byte) (bool, error)
|
||||
|
||||
BytesRead() uint64
|
||||
}
|
||||
|
||||
// DocIDReader is the interface exposing enumeration of documents identifiers.
|
||||
// Close the reader to release associated resources.
|
||||
type DocIDReader interface {
|
||||
// Next returns the next document internal identifier in the natural
|
||||
// index order, nil when the end of the sequence is reached.
|
||||
Next() (IndexInternalID, error)
|
||||
|
||||
// Advance resets the iteration to the first internal identifier greater than
|
||||
// or equal to ID. If ID is smaller than the start of the range, the iteration
|
||||
// will start there instead. If ID is greater than or equal to the end of
|
||||
// the range, Next() call will return io.EOF.
|
||||
Advance(ID IndexInternalID) (IndexInternalID, error)
|
||||
|
||||
Size() int
|
||||
|
||||
Close() error
|
||||
}
|
||||
|
||||
type DocValueVisitor func(field string, term []byte)
|
||||
|
||||
type DocValueReader interface {
|
||||
VisitDocValues(id IndexInternalID, visitor DocValueVisitor) error
|
||||
|
||||
BytesRead() uint64
|
||||
}
|
||||
|
||||
// IndexBuilder is an interface supported by some index schemes
|
||||
// to allow direct write-only index building
|
||||
type IndexBuilder interface {
|
||||
Index(doc Document) error
|
||||
Close() error
|
||||
}
|
||||
|
||||
// ThesaurusTermReader is an interface for enumerating synonyms of a term in a thesaurus.
|
||||
type ThesaurusTermReader interface {
|
||||
// Next returns the next synonym of the term, or an error if something goes wrong.
|
||||
// Returns nil when the enumeration is complete.
|
||||
Next() (string, error)
|
||||
|
||||
// Close releases any resources associated with the reader.
|
||||
Close() error
|
||||
|
||||
Size() int
|
||||
}
|
||||
|
||||
// ThesaurusEntry represents a term in the thesaurus for which synonyms are stored.
|
||||
type ThesaurusEntry struct {
|
||||
Term string
|
||||
}
|
||||
|
||||
// ThesaurusKeys is an interface for enumerating terms (keys) in a thesaurus.
|
||||
type ThesaurusKeys interface {
|
||||
// Next returns the next key in the thesaurus, or an error if something goes wrong.
|
||||
// Returns nil when the enumeration is complete.
|
||||
Next() (*ThesaurusEntry, error)
|
||||
|
||||
// Close releases any resources associated with the reader.
|
||||
Close() error
|
||||
}
|
||||
|
||||
// ThesaurusReader is an interface for accessing a thesaurus in the index.
|
||||
type ThesaurusReader interface {
|
||||
IndexReader
|
||||
|
||||
// ThesaurusTermReader returns a reader for the synonyms of a given term in the
|
||||
// specified thesaurus.
|
||||
ThesaurusTermReader(ctx context.Context, name string, term []byte) (ThesaurusTermReader, error)
|
||||
|
||||
// ThesaurusKeys returns a reader for all terms in the specified thesaurus.
|
||||
ThesaurusKeys(name string) (ThesaurusKeys, error)
|
||||
|
||||
// ThesaurusKeysFuzzy returns a reader for terms in the specified thesaurus that
|
||||
// match the given prefix and are within the specified fuzziness distance from
|
||||
// the provided term.
|
||||
ThesaurusKeysFuzzy(name string, term string, fuzziness int, prefix string) (ThesaurusKeys, error)
|
||||
|
||||
// ThesaurusKeysRegexp returns a reader for terms in the specified thesaurus that
|
||||
// match the given regular expression pattern.
|
||||
ThesaurusKeysRegexp(name string, regex string) (ThesaurusKeys, error)
|
||||
|
||||
// ThesaurusKeysPrefix returns a reader for terms in the specified thesaurus that
|
||||
// start with the given prefix.
|
||||
ThesaurusKeysPrefix(name string, termPrefix []byte) (ThesaurusKeys, error)
|
||||
}
|
||||
|
||||
// EligibleDocumentSelector filters documents based on specific eligibility criteria.
|
||||
// It can be extended with additional methods for filtering and retrieval.
|
||||
type EligibleDocumentSelector interface {
|
||||
// AddEligibleDocumentMatch marks a document as eligible for selection.
|
||||
// id is the internal identifier of the document to be added.
|
||||
AddEligibleDocumentMatch(id IndexInternalID) error
|
||||
|
||||
// SegmentEligibleDocs returns a list of eligible document IDs within a given segment.
|
||||
// segmentID identifies the segment for which eligible documents are retrieved.
|
||||
// This must be called after all eligible documents have been added.
|
||||
SegmentEligibleDocs(segmentID int) []uint64
|
||||
}
|
||||
92
vendor/github.com/blevesearch/bleve_index_api/indexing_options.go
generated
vendored
Normal file
92
vendor/github.com/blevesearch/bleve_index_api/indexing_options.go
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
// Copyright (c) 2014 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 index
|
||||
|
||||
type FieldIndexingOptions int
|
||||
|
||||
const (
|
||||
IndexField FieldIndexingOptions = 1 << iota
|
||||
StoreField
|
||||
IncludeTermVectors
|
||||
DocValues
|
||||
SkipFreqNorm
|
||||
)
|
||||
|
||||
const (
|
||||
BM25Scoring = "bm25"
|
||||
TFIDFScoring = "tfidf"
|
||||
)
|
||||
|
||||
// Scoring model indicates the algorithm used to rank documents fetched
|
||||
// for a query performed on a text field.
|
||||
const DefaultScoringModel = TFIDFScoring
|
||||
|
||||
// Supported similarity models
|
||||
var SupportedScoringModels = map[string]struct{}{
|
||||
BM25Scoring: {},
|
||||
TFIDFScoring: {},
|
||||
}
|
||||
|
||||
func (o FieldIndexingOptions) IsIndexed() bool {
|
||||
return o&IndexField != 0
|
||||
}
|
||||
|
||||
func (o FieldIndexingOptions) IsStored() bool {
|
||||
return o&StoreField != 0
|
||||
}
|
||||
|
||||
func (o FieldIndexingOptions) IncludeTermVectors() bool {
|
||||
return o&IncludeTermVectors != 0
|
||||
}
|
||||
|
||||
func (o FieldIndexingOptions) IncludeDocValues() bool {
|
||||
return o&DocValues != 0
|
||||
}
|
||||
|
||||
func (o FieldIndexingOptions) SkipFreqNorm() bool {
|
||||
return o&SkipFreqNorm != 0
|
||||
}
|
||||
|
||||
func (o FieldIndexingOptions) String() string {
|
||||
rv := ""
|
||||
if o.IsIndexed() {
|
||||
rv += "INDEXED"
|
||||
}
|
||||
if o.IsStored() {
|
||||
if rv != "" {
|
||||
rv += ", "
|
||||
}
|
||||
rv += "STORE"
|
||||
}
|
||||
if o.IncludeTermVectors() {
|
||||
if rv != "" {
|
||||
rv += ", "
|
||||
}
|
||||
rv += "TV"
|
||||
}
|
||||
if o.IncludeDocValues() {
|
||||
if rv != "" {
|
||||
rv += ", "
|
||||
}
|
||||
rv += "DV"
|
||||
}
|
||||
if !o.SkipFreqNorm() {
|
||||
if rv != "" {
|
||||
rv += ", "
|
||||
}
|
||||
rv += "FN"
|
||||
}
|
||||
return rv
|
||||
}
|
||||
39
vendor/github.com/blevesearch/bleve_index_api/optimize.go
generated
vendored
Normal file
39
vendor/github.com/blevesearch/bleve_index_api/optimize.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) 2020 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 index
|
||||
|
||||
// Optimizable represents an optional interface that implementable by
|
||||
// optimizable resources (e.g., TermFieldReaders, Searchers). These
|
||||
// optimizable resources are provided the same OptimizableContext
|
||||
// instance, so that they can coordinate via dynamic interface
|
||||
// casting.
|
||||
type Optimizable interface {
|
||||
Optimize(kind string, octx OptimizableContext) (OptimizableContext, error)
|
||||
}
|
||||
|
||||
// Represents a result of optimization -- see the Finish() method.
|
||||
type Optimized interface{}
|
||||
|
||||
type OptimizableContext interface {
|
||||
// Once all the optimzable resources have been provided the same
|
||||
// OptimizableContext instance, the optimization preparations are
|
||||
// finished or completed via the Finish() method.
|
||||
//
|
||||
// Depending on the optimization being performed, the Finish()
|
||||
// method might return a non-nil Optimized instance. For example,
|
||||
// the Optimized instance might represent an optimized
|
||||
// TermFieldReader instance.
|
||||
Finish() (Optimized, error)
|
||||
}
|
||||
35
vendor/github.com/blevesearch/bleve_index_api/sizes.go
generated
vendored
Normal file
35
vendor/github.com/blevesearch/bleve_index_api/sizes.go
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) 2020 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 index
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func init() {
|
||||
var m map[int]int
|
||||
sizeOfMap = int(reflect.TypeOf(m).Size())
|
||||
var ptr *int
|
||||
sizeOfPtr = int(reflect.TypeOf(ptr).Size())
|
||||
var str string
|
||||
sizeOfString = int(reflect.TypeOf(str).Size())
|
||||
var u64 uint64
|
||||
sizeOfUint64 = int(reflect.TypeOf(u64).Size())
|
||||
}
|
||||
|
||||
var sizeOfMap int
|
||||
var sizeOfPtr int
|
||||
var sizeOfString int
|
||||
var sizeOfUint64 int
|
||||
47
vendor/github.com/blevesearch/bleve_index_api/spatial_plugin.go
generated
vendored
Normal file
47
vendor/github.com/blevesearch/bleve_index_api/spatial_plugin.go
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2022 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 index
|
||||
|
||||
// SpatialAnalyzerPlugin is an interface for the custom spatial
|
||||
// tokenizer implementations that supports the generation of spatial
|
||||
// hierarchial tokens for both indexing and querying of geoJSON data.
|
||||
type SpatialAnalyzerPlugin interface {
|
||||
// Type returns the plugin type. eg: "s2".
|
||||
Type() string
|
||||
|
||||
// GetIndexTokens returns the tokens to be indexed for the
|
||||
// given GeoJSON type data in the document.
|
||||
GetIndexTokens(GeoJSON) []string
|
||||
|
||||
// GetQueryTokens returns the tokens to be queried for the
|
||||
// given GeoJSON type data in the document.
|
||||
GetQueryTokens(GeoJSON) []string
|
||||
}
|
||||
|
||||
// GeoJSON is generic interface for any geoJSON shapes like
|
||||
// points, polygon etc.
|
||||
type GeoJSON interface {
|
||||
// Returns the type of geoJSON shape.
|
||||
Type() string
|
||||
|
||||
// Checks whether the given shape intersects with current shape.
|
||||
Intersects(GeoJSON) (bool, error)
|
||||
|
||||
// Checks whether the given shape resides within the current shape.
|
||||
Contains(GeoJSON) (bool, error)
|
||||
|
||||
// Value returns the byte value for the shape.
|
||||
Value() ([]byte, error)
|
||||
}
|
||||
70
vendor/github.com/blevesearch/bleve_index_api/vector.go
generated
vendored
Normal file
70
vendor/github.com/blevesearch/bleve_index_api/vector.go
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// 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.
|
||||
|
||||
//go:build vectors
|
||||
// +build vectors
|
||||
|
||||
package index
|
||||
|
||||
type VectorField interface {
|
||||
Vector() []float32
|
||||
// Dimensionality of the vector
|
||||
Dims() int
|
||||
// Similarity metric to be used for scoring the vectors
|
||||
Similarity() string
|
||||
// nlist/nprobe config (recall/latency) the index is optimized for
|
||||
IndexOptimizedFor() string
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const (
|
||||
EuclideanDistance = "l2_norm"
|
||||
|
||||
InnerProduct = "dot_product"
|
||||
|
||||
CosineSimilarity = "cosine"
|
||||
)
|
||||
|
||||
const DefaultVectorSimilarityMetric = EuclideanDistance
|
||||
|
||||
// Supported similarity metrics for vector fields
|
||||
var SupportedVectorSimilarityMetrics = map[string]struct{}{
|
||||
EuclideanDistance: {},
|
||||
InnerProduct: {},
|
||||
CosineSimilarity: {},
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const (
|
||||
IndexOptimizedForRecall = "recall"
|
||||
IndexOptimizedForLatency = "latency"
|
||||
IndexOptimizedForMemoryEfficient = "memory-efficient"
|
||||
)
|
||||
|
||||
const DefaultIndexOptimization = IndexOptimizedForRecall
|
||||
|
||||
var SupportedVectorIndexOptimizations = map[string]int{
|
||||
IndexOptimizedForRecall: 0,
|
||||
IndexOptimizedForLatency: 1,
|
||||
IndexOptimizedForMemoryEfficient: 2,
|
||||
}
|
||||
|
||||
// Reverse maps vector index optimizations': int -> string
|
||||
var VectorIndexOptimizationsReverseLookup = map[int]string{
|
||||
0: IndexOptimizedForRecall,
|
||||
1: IndexOptimizedForLatency,
|
||||
2: IndexOptimizedForMemoryEfficient,
|
||||
}
|
||||
87
vendor/github.com/blevesearch/bleve_index_api/vector_index.go
generated
vendored
Normal file
87
vendor/github.com/blevesearch/bleve_index_api/vector_index.go
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
// 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.
|
||||
|
||||
//go:build vectors
|
||||
// +build vectors
|
||||
|
||||
package index
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
var reflectStaticSizeVectorDoc int
|
||||
|
||||
func init() {
|
||||
var vd VectorDoc
|
||||
reflectStaticSizeVectorDoc = int(reflect.TypeOf(vd).Size())
|
||||
}
|
||||
|
||||
type VectorReader interface {
|
||||
// Next returns the next document similar to the vector, in this field, or nil
|
||||
// when it reaches the end of the enumeration. The preAlloced VectorDoc
|
||||
// is optional, and when non-nil, will be used instead of allocating memory.
|
||||
Next(preAlloced *VectorDoc) (*VectorDoc, error)
|
||||
|
||||
// Advance resets the enumeration at specified document or its immediate
|
||||
// follower.
|
||||
Advance(ID IndexInternalID, preAlloced *VectorDoc) (*VectorDoc, error)
|
||||
|
||||
// Count returns the number of documents similar to the vector, in this field.
|
||||
Count() uint64
|
||||
Close() error
|
||||
|
||||
Size() int
|
||||
}
|
||||
|
||||
// VectorIndexReader is an index reader that can retrieve similar vectors from a vector-based index.
|
||||
type VectorIndexReader interface {
|
||||
// NewEligibleDocumentSelector returns an instance of an eligible document selector.
|
||||
// This selector filters documents for KNN search based on a pre-filter query.
|
||||
NewEligibleDocumentSelector() EligibleDocumentSelector
|
||||
|
||||
// VectorReader creates a new vector reader for performing KNN search.
|
||||
// - vector: the query vector
|
||||
// - field: the field to search in
|
||||
// - k: the number of similar vectors to return
|
||||
// - searchParams: additional search parameters
|
||||
// - selector: an eligible document selector to filter documents before KNN search
|
||||
VectorReader(ctx context.Context, vector []float32, field string, k int64,
|
||||
searchParams json.RawMessage, selector EligibleDocumentSelector) (
|
||||
VectorReader, error)
|
||||
}
|
||||
|
||||
type VectorDoc struct {
|
||||
Vector []float32
|
||||
ID IndexInternalID
|
||||
Score float64
|
||||
}
|
||||
|
||||
func (vd *VectorDoc) Size() int {
|
||||
return reflectStaticSizeVectorDoc + sizeOfPtr + len(vd.Vector) +
|
||||
len(vd.ID)
|
||||
}
|
||||
|
||||
// Reset allows an already allocated VectorDoc to be reused
|
||||
func (vd *VectorDoc) Reset() *VectorDoc {
|
||||
// remember the []byte used for the ID
|
||||
id := vd.ID
|
||||
// idiom to copy over from empty VectorDoc (0 allocations)
|
||||
*vd = VectorDoc{}
|
||||
// reuse the []byte already allocated (and reset len to 0)
|
||||
vd.ID = id[:0]
|
||||
return vd
|
||||
}
|
||||
38
vendor/github.com/blevesearch/bleve_index_api/vector_optimize.go
generated
vendored
Normal file
38
vendor/github.com/blevesearch/bleve_index_api/vector_optimize.go
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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.
|
||||
|
||||
//go:build vectors
|
||||
// +build vectors
|
||||
|
||||
package index
|
||||
|
||||
import "context"
|
||||
|
||||
// VectorOptimizable represents an optional interface that implementable by
|
||||
// optimizable resources (e.g., VectorReaders, Searchers). These
|
||||
// optimizable resources are provided the same OptimizableContext
|
||||
// instance, so that they can coordinate via dynamic interface
|
||||
// casting.
|
||||
// To avoid KNNSearchers' OptimizableContext being casted to ones used for
|
||||
// TFRs, term searchers, etc.
|
||||
type VectorOptimizable interface {
|
||||
VectorOptimize(ctx context.Context, octx VectorOptimizableContext) (VectorOptimizableContext, error)
|
||||
}
|
||||
|
||||
type VectorOptimizableContext interface {
|
||||
// Once all the optimzable resources have been provided the same
|
||||
// OptimizableContext instance, the optimization preparations are
|
||||
// finished or completed via the Finish() method.
|
||||
Finish() error
|
||||
}
|
||||
Reference in New Issue
Block a user