You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

plugin.go 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2020 Couchbase, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package segment
  15. import (
  16. "github.com/RoaringBitmap/roaring"
  17. "github.com/blevesearch/bleve/index"
  18. )
  19. // Plugin represents the essential functions required by a package to plug in
  20. // it's segment implementation
  21. type Plugin interface {
  22. // Type is the name for this segment plugin
  23. Type() string
  24. // Version is a numeric value identifying a specific version of this type.
  25. // When incompatible changes are made to a particular type of plugin, the
  26. // version must be incremented.
  27. Version() uint32
  28. // New takes a set of AnalysisResults and turns them into a new Segment
  29. New(results []*index.AnalysisResult) (Segment, uint64, error)
  30. // Open attempts to open the file at the specified path and
  31. // return the corresponding Segment
  32. Open(path string) (Segment, error)
  33. // Merge takes a set of Segments, and creates a new segment on disk at
  34. // the specified path.
  35. // Drops is a set of bitmaps (one for each segment) indicating which
  36. // documents can be dropped from the segments during the merge.
  37. // If the closeCh channel is closed, Merge will cease doing work at
  38. // the next opportunity, and return an error (closed).
  39. // StatsReporter can optionally be provided, in which case progress
  40. // made during the merge is reported while operation continues.
  41. // Returns:
  42. // A slice of new document numbers (one for each input segment),
  43. // this allows the caller to know a particular document's new
  44. // document number in the newly merged segment.
  45. // The number of bytes written to the new segment file.
  46. // An error, if any occurred.
  47. Merge(segments []Segment, drops []*roaring.Bitmap, path string,
  48. closeCh chan struct{}, s StatsReporter) (
  49. [][]uint64, uint64, error)
  50. }