mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactor
This commit is contained in:
parent
c1288e9eb4
commit
8d94564f41
|
@ -26,9 +26,9 @@ const (
|
|||
// all keys are sorted in ascending order
|
||||
func WriteSortedFileFromIdx(baseFileName string, ext string) (e error) {
|
||||
|
||||
cm, err := readCompactMap(baseFileName)
|
||||
nm, err := readNeedleMap(baseFileName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("readCompactMap: %v", err)
|
||||
return fmt.Errorf("readNeedleMap: %v", err)
|
||||
}
|
||||
|
||||
ecxFile, err := os.OpenFile(baseFileName+ext, os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
|
@ -37,7 +37,7 @@ func WriteSortedFileFromIdx(baseFileName string, ext string) (e error) {
|
|||
}
|
||||
defer ecxFile.Close()
|
||||
|
||||
err = cm.AscendingVisit(func(value needle_map.NeedleValue) error {
|
||||
err = nm.AscendingVisit(func(value needle_map.NeedleValue) error {
|
||||
bytes := value.ToBytes()
|
||||
_, writeErr := ecxFile.Write(bytes)
|
||||
return writeErr
|
||||
|
@ -281,7 +281,7 @@ func rebuildEcFiles(shardHasData []bool, inputFiles []*os.File, outputFiles []*o
|
|||
|
||||
}
|
||||
|
||||
func readCompactMap(baseFileName string) (*needle_map.MemDb, error) {
|
||||
func readNeedleMap(baseFileName string) (*needle_map.MemDb, error) {
|
||||
indexFile, err := os.OpenFile(baseFileName+".idx", os.O_RDONLY, 0644)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot read Volume Index %s.idx: %v", baseFileName, err)
|
||||
|
|
|
@ -41,9 +41,9 @@ func TestEncodingDecoding(t *testing.T) {
|
|||
}
|
||||
|
||||
func validateFiles(baseFileName string) error {
|
||||
cm, err := readCompactMap(baseFileName)
|
||||
nm, err := readNeedleMap(baseFileName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("readCompactMap: %v", err)
|
||||
return fmt.Errorf("readNeedleMap: %v", err)
|
||||
}
|
||||
|
||||
datFile, err := os.OpenFile(baseFileName+".dat", os.O_RDONLY, 0)
|
||||
|
@ -60,7 +60,7 @@ func validateFiles(baseFileName string) error {
|
|||
ecFiles, err := openEcFiles(baseFileName, true)
|
||||
defer closeEcFiles(ecFiles)
|
||||
|
||||
err = cm.AscendingVisit(func(value needle_map.NeedleValue) error {
|
||||
err = nm.AscendingVisit(func(value needle_map.NeedleValue) error {
|
||||
return assertSame(datFile, fi.Size(), ecFiles, value.Offset, value.Size)
|
||||
})
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue