From 1309a2f47853ed81a3638774b02296b002f08ea3 Mon Sep 17 00:00:00 2001 From: Oliver Tonnhofer Date: Tue, 19 Nov 2013 15:07:40 +0100 Subject: [PATCH] add Flush to diff cache --- cache/diff.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cache/diff.go b/cache/diff.go index 96a8cc9..7bb69bd 100644 --- a/cache/diff.go +++ b/cache/diff.go @@ -42,6 +42,17 @@ func (c *DiffCache) Close() { } } +func (c *DiffCache) Flush() { + if c.Coords != nil { + c.Coords.Flush() + c.Coords = nil + } + if c.Ways != nil { + c.Ways.Flush() + c.Ways = nil + } +} + func (c *DiffCache) Open() error { var err error c.Coords, err = newCoordsRefIndex(filepath.Join(c.Dir, "coords_index")) @@ -213,6 +224,14 @@ func (index *bunchRefCache) getBunchId(id int64) int64 { return id / 64 } +func (index *bunchRefCache) Flush() { + if index.linearImport { + // disable linear import flushes buffer + index.SetLinearImport(false) + index.SetLinearImport(true) + } +} + func (index *bunchRefCache) Close() { if index.linearImport { // disable linear import first to flush buffer