Function rebuildBucket

  • Rebuilds a bucket from the given updates.

    Parameters

    • bucket: Bucket

      The original bucket to be rebuilt.

    • leftovers: Entry[]

      Entries that were not included in the previous bucket.

    • updates: Update[]

      Updates to be applied to the bucket.

    • isHead: boolean

      Indicates if the bucket is the level head.

    • bucketsRebuilt: number
    • isBoundary: IsBoundary

      Function to determine if an entry is a boundary.

    Returns [Bucket[], Entry[], EntryDiff[]]

    A tuple containing the rebuilt buckets, leftover entries, and entry differences.

    The bucket must end in a boundary or be a head, otherwise this will throw an error. The leftovers array must be empty or contain entries which precede any entries inside bucket. If no updates result in changes to the bucket, the same bucket reference is returned. If isHead is true, no leftover entries will be returned. If no updates affect the bucket boundary then buckets.length will be 1. If a boundary is added by an add update then buckets.length will be +1. If a boundary is removed by an rm update then buckets.length will be -1. It writes +1 to bucketsRebuilt for each bucket rebuilt.