/** * Adds or replaces an element in the tree with the given node. * <p> * <!-- Implementation detail: If the number of cached entries (entries held directly by this * tree) reaches {@link #DEFAULT_NORMALIZATION_THRESHOLD}, this tree will {@link #normalize()} * itself. * * --> * * @param node The {@link org.locationtech.geogig.model.Node Node} to add or replace. * @return a reference to this {@link org.locationtech.geogig.model.impl.RevTreeBuilder * RevTreeBuilder} */ public synchronized boolean put(final Node node) { Preconditions.checkNotNull(node, "node can't be null"); putInternal(node); if (numPendingChanges() >= this.normalizationThreshold) { // hit the split factor modification tolerance, lets normalize normalize(); } return true; }
/** * @return the new tree, not saved to the object database. Any bucket tree though is saved when * this method returns. */ public RevTree build() { RevTree tree = normalize(); checkState(bucketTreesByBucket.isEmpty() || (featureChanges.isEmpty() && treeChanges.isEmpty())); if (obStore != null) { obStore.put(tree); } ObjectId oldid = HashObject.hashTree(original.trees(), original.features(), original.buckets()); ObjectId newid = HashObject.hashTree(tree.trees(), tree.features(), tree.buckets()); return oldid.equals(newid) ? original : tree; }
/** * Adds or replaces an element in the tree with the given node. * <p> * <!-- Implementation detail: If the number of cached entries (entries held directly by this * tree) reaches {@link #DEFAULT_NORMALIZATION_THRESHOLD}, this tree will {@link #normalize()} * itself. * * --> * * @param node The {@link org.locationtech.geogig.model.Node Node} to add or replace. * @return a reference to this {@link org.locationtech.geogig.model.RevTreeBuilder * RevTreeBuilder} */ public synchronized boolean put(final Node node) { Preconditions.checkNotNull(node, "node can't be null"); putInternal(node); if (numPendingChanges() >= this.normalizationThreshold) { // hit the split factor modification tolerance, lets normalize normalize(); } return true; }
/** * @return the new tree, not saved to the object database. Any bucket tree though is saved when * this method returns. */ public RevTree build() { RevTree tree = normalize(); checkState(bucketTreesByBucket.isEmpty() || (featureChanges.isEmpty() && treeChanges.isEmpty())); if (obStore != null) { obStore.put(tree); } ObjectId oldid = HashObject.hashTree(original.trees(), original.features(), original.getBuckets()); ObjectId newid = HashObject.hashTree(tree.trees(), tree.features(), tree.getBuckets()); return oldid.equals(newid) ? original : tree; }