Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultLevels are the default Level(s) used for compaction options. DefaultLevels = []Level{ Level{ MinSizeInclusive: 0, MaxSizeExclusive: 1 << 18, }, Level{ MinSizeInclusive: 1 << 18, MaxSizeExclusive: 1 << 20, }, Level{ MinSizeInclusive: 1 << 20, MaxSizeExclusive: 1 << 22, }, } // DefaultOptions are the default compaction PlannerOptions. DefaultOptions = PlannerOptions{ MutableSegmentSizeThreshold: 0, MutableCompactionAgeThreshold: 0, Levels: DefaultLevels, OrderBy: TasksOrderedByOldestMutableAndSize, } )
Functions ¶
This section is empty.
Types ¶
type Compactor ¶ added in v0.5.0
Compactor is a compactor.
func NewCompactor ¶ added in v0.5.0
func NewCompactor( docsPool doc.DocumentArrayPool, docsMaxBatch int, builderOpts builder.Options, fstOpts fst.Options, opts CompactorOptions, ) (*Compactor, error)
NewCompactor returns a new compactor which reuses buffers to avoid allocating intermediate buffers when compacting.
func (*Compactor) Compact ¶ added in v0.5.0
Compact will take a set of segments and compact them into an immutable FST segment, if there is a single mutable segment it can directly be converted into an FST segment, otherwise an intermediary mutable segment (reused by the compactor between runs) is used to combine all the segments together first before compacting into an FST segment. Note: This is not thread safe and only a single compaction may happen at a time.
func (*Compactor) CompactUsingBuilder ¶ added in v0.5.0
func (c *Compactor) CompactUsingBuilder( builder segment.DocumentsBuilder, segs []segment.Segment, ) (segment.Segment, error)
CompactUsingBuilder compacts segments together using a provided segment builder.
type CompactorOptions ¶ added in v0.5.0
type CompactorOptions struct { // FSTWriterOptions if not nil are the options used to // construct the FST writer. FSTWriterOptions *fst.WriterOptions // MmapDocsData when enabled will encode and mmmap the // documents data, rather than keeping the original // documents with references to substrings in the metric // IDs (done for memory savings). MmapDocsData bool }
CompactorOptions is a set of compactor options.
type Level ¶
Level defines a range of (min, max) sizes such that any segments within the Level are allowed to be compacted together.
type Plan ¶
type Plan struct { Tasks []Task UnusedSegments []Segment OrderBy TasksOrderBy }
Plan is a logical collection of compaction Tasks. The tasks do not depened on each other, and maybe performed sequentially or in parallel.
type PlannerOptions ¶
type PlannerOptions struct { // MutableSegmentSizeThreshold is the maximum size a mutable segment is // allowed to grow before it's rotated out for compactions. MutableSegmentSizeThreshold int64 // MutableCompactionAgeThreshold is minimum age required of a mutable segment // before it would be considered for compaction in steady state. MutableCompactionAgeThreshold time.Duration // Levels define the levels for compactions. Levels []Level // OrderBy defines the order of tasks in the compaction plan returned. OrderBy TasksOrderBy }
PlannerOptions are the knobs to tweak planning behaviour.
func (PlannerOptions) Validate ¶
func (o PlannerOptions) Validate() error
Validate ensures the receiver PlannerOptions specify valid values for each of the knobs.
type Segment ¶
type Segment struct { Age time.Duration Size int64 Type segments.Type // Either builder or segment should be set, not both. Builder segment.Builder Segment segment.Segment }
Segment identifies a candidate for compaction.
type Task ¶
type Task struct {
Segments []Segment
}
Task identifies a collection of segments to compact.
func (Task) Summary ¶
func (t Task) Summary() TaskSummary
Summary returns the TaskSummary for the given task.
type TaskSummary ¶
type TaskSummary struct { NumMutable int NumFST int CumulativeMutableAge time.Duration CumulativeSize int64 }
TaskSummary is a collection of statistics about a compaction task.
type TasksOrderBy ¶
type TasksOrderBy byte
TasksOrderBy controls the order of tasks returned in the plan.
const ( // TasksOrderedByOldestMutableAndSize orders tasks with oldest mutable segment age (cumulative), and then by size. TasksOrderedByOldestMutableAndSize TasksOrderBy = iota )