Skip to content

Commit 83d780f

Browse files
Merge pull request #80 from Workiva/deletion_fix
Fixed an issue in the check for interval deletion.
2 parents 5449ae6 + ecf987f commit 83d780f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

augmentedtree/atree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func insertInterval(dimension uint64, interval Interval, index, count int64) int
306306
return 1
307307
}
308308

309-
if index <= low && count*-1 >= high-low {
309+
if index <= low && count*-1 >= high-index {
310310
return -1
311311
}
312312

augmentedtree/atree_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,3 +771,14 @@ func TestInsertDuplicateIntervalChildren(t *testing.T) {
771771
result := tree.Query(constructSingleDimensionInterval(0, 10, 0))
772772
assert.Contains(t, result, iv1)
773773
}
774+
775+
func TestDeleteAtDimensionalSinglePositionReference(t *testing.T) {
776+
tree := newTree(2)
777+
iv := constructMultiDimensionInterval(
778+
0, &dimension{low: 0, high: 1}, &dimension{low: 4, high: 5},
779+
)
780+
tree.Add(iv)
781+
modified, deleted := tree.Insert(2, 1, -1)
782+
assert.Equal(t, Intervals{iv}, modified)
783+
assert.Len(t, deleted, 0)
784+
}

0 commit comments

Comments
 (0)