aboutsummaryrefslogtreecommitdiff
path: root/weed/storage/compact_map.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2017-01-18 08:34:44 -0800
committerChris Lu <chris.lu@gmail.com>2017-01-18 08:40:39 -0800
commit59022b6fe00f25ceef8d7a027cbc90bf14f7605e (patch)
tree815e5ce0367f4cc8db35db06d2a16734c62867c5 /weed/storage/compact_map.go
parent8b15523c9dae59b1338a54360ce3dbeadbae5124 (diff)
downloadseaweedfs-59022b6fe00f25ceef8d7a027cbc90bf14f7605e.tar.xz
seaweedfs-59022b6fe00f25ceef8d7a027cbc90bf14f7605e.zip
fix byte counter on loading index file
fix https://github.com/chrislusf/seaweedfs/issues/441
Diffstat (limited to 'weed/storage/compact_map.go')
-rw-r--r--weed/storage/compact_map.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/weed/storage/compact_map.go b/weed/storage/compact_map.go
index 721be2ec7..0f56922b8 100644
--- a/weed/storage/compact_map.go
+++ b/weed/storage/compact_map.go
@@ -39,14 +39,13 @@ func NewCompactSection(start Key) *CompactSection {
}
//return old entry size
-func (cs *CompactSection) Set(key Key, offset uint32, size uint32) uint32 {
- ret := uint32(0)
+func (cs *CompactSection) Set(key Key, offset, size uint32) (oldOffset, oldSize uint32) {
cs.Lock()
if key > cs.end {
cs.end = key
}
if i := cs.binarySearchValues(key); i >= 0 {
- ret = cs.values[i].Size
+ oldOffset, oldSize = cs.values[i].Offset, cs.values[i].Size
//println("key", key, "old size", ret)
cs.values[i].Offset, cs.values[i].Size = offset, size
} else {
@@ -55,7 +54,7 @@ func (cs *CompactSection) Set(key Key, offset uint32, size uint32) uint32 {
if needOverflow {
//println("start", cs.start, "counter", cs.counter, "key", key)
if oldValue, found := cs.overflow[key]; found {
- ret = oldValue.Size
+ oldOffset, oldSize = oldValue.Offset, oldValue.Size
}
cs.overflow[key] = NeedleValue{Key: key, Offset: offset, Size: size}
} else {
@@ -66,7 +65,7 @@ func (cs *CompactSection) Set(key Key, offset uint32, size uint32) uint32 {
}
}
cs.Unlock()
- return ret
+ return
}
//return old entry size
@@ -129,7 +128,7 @@ func NewCompactMap() CompactMap {
return CompactMap{}
}
-func (cm *CompactMap) Set(key Key, offset uint32, size uint32) uint32 {
+func (cm *CompactMap) Set(key Key, offset, size uint32) (oldOffset, oldSize uint32) {
x := cm.binarySearchCompactSection(key)
if x < 0 {
//println(x, "creating", len(cm.list), "section, starting", key)