Changed the InMemory bool to a uint32 so that it can be used to alter how much space to reserve

This commit is contained in:
Tom Maxwell
2019-09-04 15:27:14 +01:00
parent 6ee65356e3
commit 4a878c0006
20 changed files with 111 additions and 67 deletions

View File

@@ -0,0 +1,14 @@
package needle
import "strconv"
func ReadMemoryMapMaxSizeMB(MemoryMapMaxSizeMBString string) (uint32, error) {
if MemoryMapMaxSizeMBString == "" {
return 0, nil
}
var MemoryMapMaxSize64 uint64
var err error
MemoryMapMaxSize64, err = strconv.ParseUint(MemoryMapMaxSizeMBString, 10, 32)
MemoryMapMaxSize := uint32(MemoryMapMaxSize64)
return MemoryMapMaxSize, err
}

View File

@@ -0,0 +1,10 @@
package needle
import "testing"
func TestMemoryMapMaxSizeReadWrite(t *testing.T) {
memoryMapSize, _ := ReadMemoryMapMaxSizeMB("5000")
if memoryMapSize != 5000 {
t.Errorf("empty memoryMapSize:%v", memoryMapSize)
}
}