SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
renaming NeedleMapType to NeedleMapKind
bingoohuang94ea3bd3a56d
diff --git a/weed/server/volume_server.go b/weed/server/volume_server.goindex 468f758904..0443309fb0 100644--- a/weed/server/volume_server.go+++ b/weed/server/volume_server.go@@ -24,7 +24,7 @@ type VolumeServer struct {guard *security.GuardgrpcDialOption grpc.DialOption- needleMapKind storage.NeedleMapType+ needleMapKind storage.NeedleMapKindFixJpgOrientation boolReadRedirect boolcompactionBytePerSecond int64@@ -39,7 +39,7 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,port int, publicUrl string,folders []string, maxCounts []int, minFreeSpacePercents []float32,idxFolder string,- needleMapKind storage.NeedleMapType,+ needleMapKind storage.NeedleMapKind,masterNodes []string, pulseSeconds int,dataCenter string, rack string,whiteList []string,diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.goindex 9b2ab69fef..76eab64a35 100644--- a/weed/storage/disk_location.go+++ b/weed/storage/disk_location.go@@ -82,7 +82,7 @@ func getValidVolumeName(basename string) string {return ""}-func (l *DiskLocation) loadExistingVolume(fileInfo os.FileInfo, needleMapKind NeedleMapType) bool {+func (l *DiskLocation) loadExistingVolume(fileInfo os.FileInfo, needleMapKind NeedleMapKind) bool {basename := fileInfo.Name()if fileInfo.IsDir() {return false@@ -133,7 +133,7 @@ func (l *DiskLocation) loadExistingVolume(fileInfo os.FileInfo, needleMapKind Nereturn true}-func (l *DiskLocation) concurrentLoadingVolumes(needleMapKind NeedleMapType, concurrency int) {+func (l *DiskLocation) concurrentLoadingVolumes(needleMapKind NeedleMapKind, concurrency int) {task_queue := make(chan os.FileInfo, 10*concurrency)go func() {@@ -167,7 +167,7 @@ func (l *DiskLocation) concurrentLoadingVolumes(needleMapKind NeedleMapType, con}-func (l *DiskLocation) loadExistingVolumes(needleMapKind NeedleMapType) {+func (l *DiskLocation) loadExistingVolumes(needleMapKind NeedleMapKind) {l.concurrentLoadingVolumes(needleMapKind, 10)glog.V(0).Infof("Store started on dir: %s with %d volumes max %d", l.Directory, len(l.volumes), l.MaxVolumeCount)@@ -237,7 +237,7 @@ func (l *DiskLocation) deleteVolumeById(vid needle.VolumeId) (found bool, e erroreturn}-func (l *DiskLocation) LoadVolume(vid needle.VolumeId, needleMapKind NeedleMapType) bool {+func (l *DiskLocation) LoadVolume(vid needle.VolumeId, needleMapKind NeedleMapKind) bool {if fileInfo, found := l.LocateVolume(vid); found {return l.loadExistingVolume(fileInfo, needleMapKind)}diff --git a/weed/storage/needle_map.go b/weed/storage/needle_map.goindex 9f331267db..5b41286ea8 100644--- a/weed/storage/needle_map.go+++ b/weed/storage/needle_map.go@@ -11,10 +11,10 @@ import (. "github.com/chrislusf/seaweedfs/weed/storage/types")-type NeedleMapType int+type NeedleMapKind intconst (- NeedleMapInMemory NeedleMapType = iota+ NeedleMapInMemory NeedleMapKind = iotaNeedleMapLevelDb // small memory footprint, 4MB total, 1 write buffer, 3 block bufferNeedleMapLevelDbMedium // medium memory footprint, 8MB total, 3 write buffer, 5 block bufferNeedleMapLevelDbLarge // large memory footprint, 12MB total, 4write buffer, 8 block bufferdiff --git a/weed/storage/store.go b/weed/storage/store.goindex ff28be47c3..bd66e23f40 100644--- a/weed/storage/store.go+++ b/weed/storage/store.go@@ -40,7 +40,7 @@ type Store struct {dataCenter string // optional informaton, overwriting master setting if existsrack string // optional information, overwriting master setting if existsconnected bool- NeedleMapType NeedleMapType+ NeedleMapKind NeedleMapKindNewVolumesChan chan master_pb.VolumeShortInformationMessageDeletedVolumesChan chan master_pb.VolumeShortInformationMessageNewEcShardsChan chan master_pb.VolumeEcShardInformationMessage@@ -52,8 +52,8 @@ func (s *Store) String() (str string) {return}-func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, dirnames []string, maxVolumeCounts []int, minFreeSpacePercents []float32, idxFolder string, needleMapKind NeedleMapType) (s *Store) {- s = &Store{grpcDialOption: grpcDialOption, Port: port, Ip: ip, PublicUrl: publicUrl, NeedleMapType: needleMapKind}+func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, dirnames []string, maxVolumeCounts []int, minFreeSpacePercents []float32, idxFolder string, needleMapKind NeedleMapKind) (s *Store) {+ s = &Store{grpcDialOption: grpcDialOption, Port: port, Ip: ip, PublicUrl: publicUrl, NeedleMapKind: needleMapKind}s.Locations = make([]*DiskLocation, 0)for i := 0; i < len(dirnames); i++ {location := NewDiskLocation(dirnames[i], maxVolumeCounts[i], minFreeSpacePercents[i], idxFolder)@@ -69,7 +69,7 @@ func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, direturn}-func (s *Store) AddVolume(volumeId needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement string, ttlString string, preallocate int64, MemoryMapMaxSizeMb uint32) error {+func (s *Store) AddVolume(volumeId needle.VolumeId, collection string, needleMapKind NeedleMapKind, replicaPlacement string, ttlString string, preallocate int64, MemoryMapMaxSizeMb uint32) error {rt, e := super_block.NewReplicaPlacementFromString(replicaPlacement)if e != nil {return e@@ -114,7 +114,7 @@ func (s *Store) FindFreeLocation() (ret *DiskLocation) {}return ret}-func (s *Store) addVolume(vid needle.VolumeId, collection string, needleMapKind NeedleMapType, replicaPlacement *super_block.ReplicaPlacement, ttl *needle.TTL, preallocate int64, memoryMapMaxSizeMb uint32) error {+func (s *Store) addVolume(vid needle.VolumeId, collection string, needleMapKind NeedleMapKind, replicaPlacement *super_block.ReplicaPlacement, ttl *needle.TTL, preallocate int64, memoryMapMaxSizeMb uint32) error {if s.findVolume(vid) != nil {return fmt.Errorf("Volume Id %d already exists!", vid)}@@ -362,7 +362,7 @@ func (s *Store) MarkVolumeWritable(i needle.VolumeId) error {func (s *Store) MountVolume(i needle.VolumeId) error {for _, location := range s.Locations {- if found := location.LoadVolume(i, s.NeedleMapType); found == true {+ if found := location.LoadVolume(i, s.NeedleMapKind); found == true {glog.V(0).Infof("mount volume %d", i)v := s.findVolume(i)s.NewVolumesChan <- master_pb.VolumeShortInformationMessage{diff --git a/weed/storage/volume.go b/weed/storage/volume.goindex 80a74c3e31..d86e258852 100644--- a/weed/storage/volume.go+++ b/weed/storage/volume.go@@ -25,7 +25,7 @@ type Volume struct {Collection stringDataBackend backend.BackendStorageFilenm NeedleMapper- needleMapKind NeedleMapType+ needleMapKind NeedleMapKindnoWriteOrDelete bool // if readonly, either noWriteOrDelete or noWriteCanDeletenoWriteCanDelete bool // if readonly, either noWriteOrDelete or noWriteCanDeletenoWriteLock sync.RWMutex@@ -50,7 +50,7 @@ type Volume struct {lastIoError error}-func NewVolume(dirname string, dirIdx string, collection string, id needle.VolumeId, needleMapKind NeedleMapType, replicaPlacement *super_block.ReplicaPlacement, ttl *needle.TTL, preallocate int64, memoryMapMaxSizeMb uint32) (v *Volume, e error) {+func NewVolume(dirname string, dirIdx string, collection string, id needle.VolumeId, needleMapKind NeedleMapKind, replicaPlacement *super_block.ReplicaPlacement, ttl *needle.TTL, preallocate int64, memoryMapMaxSizeMb uint32) (v *Volume, e error) {// if replicaPlacement is nil, the superblock will be loaded from diskv = &Volume{dir: dirname, dirIdx: dirIdx, Collection: collection, Id: id, MemoryMapMaxSizeMb: memoryMapMaxSizeMb,asyncRequestsChan: make(chan *needle.AsyncRequest, 128)}diff --git a/weed/storage/volume_loading.go b/weed/storage/volume_loading.goindex a6efc630d2..52a50a98c8 100644--- a/weed/storage/volume_loading.go+++ b/weed/storage/volume_loading.go@@ -14,7 +14,7 @@ import ("github.com/chrislusf/seaweedfs/weed/util")-func loadVolumeWithoutIndex(dirname string, collection string, id needle.VolumeId, needleMapKind NeedleMapType) (v *Volume, err error) {+func loadVolumeWithoutIndex(dirname string, collection string, id needle.VolumeId, needleMapKind NeedleMapKind) (v *Volume, err error) {v = &Volume{dir: dirname, Collection: collection, Id: id}v.SuperBlock = super_block.SuperBlock{}v.needleMapKind = needleMapKind@@ -22,7 +22,7 @@ func loadVolumeWithoutIndex(dirname string, collection string, id needle.VolumeIreturn}-func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind NeedleMapType, preallocate int64) (err error) {+func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind NeedleMapKind, preallocate int64) (err error) {alreadyHasSuperBlock := falsehasLoadedVolume := falsediff --git a/weed/storage/volume_read_write.go b/weed/storage/volume_read_write.goindex f28ee50e66..b40414ad4a 100644--- a/weed/storage/volume_read_write.go+++ b/weed/storage/volume_read_write.go@@ -410,7 +410,7 @@ type VolumeFileScanner interface {}func ScanVolumeFile(dirname string, collection string, id needle.VolumeId,- needleMapKind NeedleMapType,+ needleMapKind NeedleMapKind,volumeFileScanner VolumeFileScanner) (err error) {var v *Volumeif v, err = loadVolumeWithoutIndex(dirname, collection, id, needleMapKind); err != nil {