mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Merge pull request #285 from thinxer/needle-mutex
storage: do not copy sync.Mutex by value
This commit is contained in:
commit
113392bce8
|
@ -39,7 +39,7 @@ type baseNeedleMapper struct {
|
||||||
mapMetric
|
mapMetric
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm baseNeedleMapper) IndexFileSize() uint64 {
|
func (nm *baseNeedleMapper) IndexFileSize() uint64 {
|
||||||
stat, err := nm.indexFile.Stat()
|
stat, err := nm.indexFile.Stat()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return uint64(stat.Size())
|
return uint64(stat.Size())
|
||||||
|
@ -47,7 +47,7 @@ func (nm baseNeedleMapper) IndexFileSize() uint64 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nm baseNeedleMapper) IndexFileName() string {
|
func (nm *baseNeedleMapper) IndexFileName() string {
|
||||||
return nm.indexFile.Name()
|
return nm.indexFile.Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ func idxFileEntry(bytes []byte) (key uint64, offset uint32, size uint32) {
|
||||||
size = binary.BigEndian.Uint32(bytes[12:16])
|
size = binary.BigEndian.Uint32(bytes[12:16])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (nm baseNeedleMapper) appendToIndexFile(key uint64, offset uint32, size uint32) error {
|
func (nm *baseNeedleMapper) appendToIndexFile(key uint64, offset uint32, size uint32) error {
|
||||||
bytes := make([]byte, 16)
|
bytes := make([]byte, 16)
|
||||||
binary.BigEndian.PutUint64(bytes[0:8], key)
|
binary.BigEndian.PutUint64(bytes[0:8], key)
|
||||||
binary.BigEndian.PutUint32(bytes[8:12], offset)
|
binary.BigEndian.PutUint32(bytes[8:12], offset)
|
||||||
|
@ -72,7 +72,7 @@ func (nm baseNeedleMapper) appendToIndexFile(key uint64, offset uint32, size uin
|
||||||
_, err := nm.indexFile.Write(bytes)
|
_, err := nm.indexFile.Write(bytes)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
func (nm baseNeedleMapper) IndexFileContent() ([]byte, error) {
|
func (nm *baseNeedleMapper) IndexFileContent() ([]byte, error) {
|
||||||
nm.indexFileAccessLock.Lock()
|
nm.indexFileAccessLock.Lock()
|
||||||
defer nm.indexFileAccessLock.Unlock()
|
defer nm.indexFileAccessLock.Unlock()
|
||||||
return ioutil.ReadFile(nm.indexFile.Name())
|
return ioutil.ReadFile(nm.indexFile.Name())
|
||||||
|
|
Loading…
Reference in a new issue