Class DeltaBuilder


public class DeltaBuilder extends FixedLeafBuilder
Builds an incrementally bigger tree by only recalculating and maintaining deltas. Note this is an implementation path to building file-backed trees that would otherwise have trouble fitting in memory.
See Also:
  • Constructor Details

    • DeltaBuilder

      public DeltaBuilder(Tree tree)
      Constructs a copy-on-write instance.
      Parameters:
      tree - the base tree to start from
      See Also:
    • DeltaBuilder

      public DeltaBuilder(Tree tree, boolean copyOnWrite)
      Creates a new instance.
      Parameters:
      tree - the base tree to start from
      copyOnWrite - if true, then every Builder.add(byte[]) is argument is copied (the argument's value is considered volatile). When you know you won't be modifying the input arguments set this to false
  • Method Details

    • build

      public Tree build()
      Description copied from class: Builder
      Builds and returns the tree. On return the builder is cleared.
      Overrides:
      build in class FixedLeafBuilder
      See Also:
    • packageTree

      protected DeltaTree packageTree()
      Overrides:
      packageTree in class FixedLeafBuilder
    • clear

      public void clear()
      Description copied from class: Builder
      Clears the state of the instance, as if new.
      Overrides:
      clear in class Builder
    • add

      public int add(byte[] item, int off, int len) throws IndexOutOfBoundsException

      Items only the width of the (hash) digest width are allowed because this is an omni-width tree.

      Adds the specified item as the next leaf node are returns its leaf index.
      Overrides:
      add in class FixedLeafBuilder
      Parameters:
      item - the item's data (copied)
      off - starting offset into item
      len - = FixedLeafBuilder.leafWidth()
      Returns:
      the item's leaf node index in the to-be built tree
      Throws:
      IndexOutOfBoundsException
    • itemsAdded

      public int itemsAdded()
      Returns the total number of items added (appended).