LCOV - code coverage report
Current view: top level - pebble - overlap.go (source / functions) Hit Total Coverage
Test: 2024-07-12 08:16Z e762e056 - tests only.lcov Lines: 16 22 72.7 %
Date: 2024-07-12 08:17:09 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2024 The LevelDB-Go and Pebble Authors. All rights reserved. Use
       2             : // of this source code is governed by a BSD-style license that can be found in
       3             : // the LICENSE file.
       4             : 
       5             : package pebble
       6             : 
       7             : import (
       8             :         "context"
       9             : 
      10             :         "github.com/cockroachdb/pebble/internal/base"
      11             :         "github.com/cockroachdb/pebble/internal/keyspan"
      12             :         "github.com/cockroachdb/pebble/internal/manifest"
      13             :         "github.com/cockroachdb/pebble/internal/overlap"
      14             : )
      15             : 
      16             : // An overlapChecker provides facilities for checking whether any keys within a
      17             : // particular LSM version overlap a set of bounds. It is a thin wrapper for
      18             : // dataoverlap.Checker.
      19             : type overlapChecker struct {
      20             :         comparer *base.Comparer
      21             :         newIters tableNewIters
      22             :         opts     IterOptions
      23             :         v        *version
      24             : }
      25             : 
      26             : // DetermineLSMOverlap calculates the overlap.WithLSM for the given bounds.
      27             : func (c *overlapChecker) DetermineLSMOverlap(
      28             :         ctx context.Context, bounds base.UserKeyBounds,
      29           1 : ) (overlap.WithLSM, error) {
      30           1 :         checker := overlap.MakeChecker(c.comparer.Compare, c)
      31           1 :         return checker.LSMOverlap(ctx, bounds, c.v)
      32           1 : }
      33             : 
      34             : var _ overlap.IteratorFactory = (*overlapChecker)(nil)
      35             : 
      36             : // Points is part of the overlap.IteratorFactory implementation.
      37             : func (c *overlapChecker) Points(
      38             :         ctx context.Context, m *manifest.FileMetadata,
      39           1 : ) (base.InternalIterator, error) {
      40           1 :         iters, err := c.newIters(ctx, m, &c.opts, internalIterOpts{}, iterPointKeys)
      41           1 :         if err != nil {
      42           0 :                 return nil, err
      43           0 :         }
      44           1 :         return iters.point, nil
      45             : }
      46             : 
      47             : // RangeDels is part of the overlap.IteratorFactory implementation.
      48             : func (c *overlapChecker) RangeDels(
      49             :         ctx context.Context, m *manifest.FileMetadata,
      50           1 : ) (keyspan.FragmentIterator, error) {
      51           1 :         iters, err := c.newIters(ctx, m, &c.opts, internalIterOpts{}, iterRangeDeletions)
      52           1 :         if err != nil {
      53           0 :                 return nil, err
      54           0 :         }
      55           1 :         return iters.rangeDeletion, nil
      56             : }
      57             : 
      58             : // RangeKeys is part of the overlap.IteratorFactory implementation.
      59             : func (c *overlapChecker) RangeKeys(
      60             :         ctx context.Context, m *manifest.FileMetadata,
      61           1 : ) (keyspan.FragmentIterator, error) {
      62           1 :         iters, err := c.newIters(ctx, m, &c.opts, internalIterOpts{}, iterRangeKeys)
      63           1 :         if err != nil {
      64           0 :                 return nil, err
      65           0 :         }
      66           1 :         return iters.rangeKey, nil
      67             : }

Generated by: LCOV version 1.14