Skip to content

Commit e86565b

Browse files
rsneddsymonds
authored andcommitted
s2: Add ShapeIndex.Build method.
This triggers an index build, which is useful in some circumstances. Fixes #62. Signed-off-by: David Symonds <dsymonds@golang.org>
1 parent 050ea44 commit e86565b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

s2/shapeindex.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,16 @@ func (s *ShapeIndex) Remove(shape Shape) {
769769
atomic.StoreInt32(&s.status, stale)
770770
}
771771

772+
// Build triggers the update of the index. Calls to Add and Release are normally
773+
// queued and processed on the first subsequent query. This has many advantages,
774+
// the most important of which is that sometimes there *is* no subsequent
775+
// query, which lets us avoid building the index completely.
776+
//
777+
// This method forces any pending updates to be applied immediately.
778+
func (s *ShapeIndex) Build() {
779+
s.maybeApplyUpdates()
780+
}
781+
772782
// IsFresh reports if there are no pending updates that need to be applied.
773783
// This can be useful to avoid building the index unnecessarily, or for
774784
// choosing between two different algorithms depending on whether the index

0 commit comments

Comments
 (0)