mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
go fmt
This commit is contained in:
parent
0a856241fe
commit
e4830bd93d
|
@ -73,7 +73,7 @@ func (nl *ItemList) canAddMember(node *skiplist.SkipListElementReference, name s
|
|||
key := fmt.Sprintf("%s%dm", nl.prefix, node.ElementPointer)
|
||||
countOperation := pipe.ZLexCount(ctx, key, "-", "+")
|
||||
scoreOperationt := pipe.ZScore(ctx, key, name)
|
||||
if _, err = pipe.Exec(ctx); err != nil && err != redis.Nil{
|
||||
if _, err = pipe.Exec(ctx); err != nil && err != redis.Nil {
|
||||
return false, 0, err
|
||||
}
|
||||
if err == redis.Nil {
|
||||
|
@ -286,7 +286,7 @@ func (nl *ItemList) DeleteName(name string) error {
|
|||
return nil
|
||||
}
|
||||
nextSize := nl.NodeSize(nextNode.Reference())
|
||||
if nextSize > 0 && prevSize + nextSize < nl.batchSize {
|
||||
if nextSize > 0 && prevSize+nextSize < nl.batchSize {
|
||||
// case 3.1 merge nextNode and prevNode
|
||||
if _, err := nl.skipList.DeleteByKey(nextNode.Key); err != nil {
|
||||
return err
|
||||
|
@ -414,7 +414,7 @@ func (nl *ItemList) NodeInnerPosition(node *skiplist.SkipListElementReference, n
|
|||
func (nl *ItemList) NodeMin(node *skiplist.SkipListElementReference) string {
|
||||
key := fmt.Sprintf("%s%dm", nl.prefix, node.ElementPointer)
|
||||
slice := nl.client.ZPopMin(context.Background(), key).Val()
|
||||
if len(slice)>0{
|
||||
if len(slice) > 0 {
|
||||
s := slice[0].Member.(string)
|
||||
return s
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ const maxNameBatchSizeLimit = 1000000
|
|||
func insertChild(ctx context.Context, redisStore *UniversalRedis3Store, key string, name string) error {
|
||||
|
||||
// lock and unlock
|
||||
mutex := redisStore.redsync.NewMutex(key+"lock")
|
||||
mutex := redisStore.redsync.NewMutex(key + "lock")
|
||||
if err := mutex.Lock(); err != nil {
|
||||
return fmt.Errorf("lock %s: %v", key, err)
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ func insertChild(ctx context.Context, redisStore *UniversalRedis3Store, key stri
|
|||
func removeChild(ctx context.Context, redisStore *UniversalRedis3Store, key string, name string) error {
|
||||
|
||||
// lock and unlock
|
||||
mutex := redisStore.redsync.NewMutex(key+"lock")
|
||||
mutex := redisStore.redsync.NewMutex(key + "lock")
|
||||
if err := mutex.Lock(); err != nil {
|
||||
return fmt.Errorf("lock %s: %v", key, err)
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ func removeChild(ctx context.Context, redisStore *UniversalRedis3Store, key stri
|
|||
func removeChildren(ctx context.Context, redisStore *UniversalRedis3Store, key string, onDeleteFn func(name string) error) error {
|
||||
|
||||
// lock and unlock
|
||||
mutex := redisStore.redsync.NewMutex(key+"lock")
|
||||
mutex := redisStore.redsync.NewMutex(key + "lock")
|
||||
if err := mutex.Lock(); err != nil {
|
||||
return fmt.Errorf("lock %s: %v", key, err)
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ func BenchmarkNameList(b *testing.B) {
|
|||
for i := 0; i < b.N; i++ {
|
||||
nameList := LoadItemList(data, "/yyy/bin", client, store, maxNameBatchSizeLimit)
|
||||
|
||||
nameList.WriteName(strconv.Itoa(i)+"namexxxxxxxxxxxxxxxxxxx")
|
||||
nameList.WriteName(strconv.Itoa(i) + "namexxxxxxxxxxxxxxxxxxx")
|
||||
|
||||
if nameList.HasChanges() {
|
||||
data = nameList.ToBytes()
|
||||
|
@ -116,7 +116,7 @@ func BenchmarkRedis(b *testing.B) {
|
|||
})
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
client.ZAddNX(context.Background(),"/yyy/bin", &redis.Z{Score: 0, Member: strconv.Itoa(i)+"namexxxxxxxxxxxxxxxxxxx"})
|
||||
client.ZAddNX(context.Background(), "/yyy/bin", &redis.Z{Score: 0, Member: strconv.Itoa(i) + "namexxxxxxxxxxxxxxxxxxx"})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ func xTestNameListAdd(t *testing.T) {
|
|||
ts1 := time.Now()
|
||||
|
||||
for i := 0; i < N; i++ {
|
||||
client.ZAddNX(context.Background(),"/x", &redis.Z{Score: 0, Member: fmt.Sprintf("name %8d", i)})
|
||||
client.ZAddNX(context.Background(), "/x", &redis.Z{Score: 0, Member: fmt.Sprintf("name %8d", i)})
|
||||
}
|
||||
ts2 := time.Now()
|
||||
|
||||
|
@ -205,6 +205,6 @@ func xBenchmarkRedis(b *testing.B) {
|
|||
})
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
client.ZAddNX(context.Background(),"/xxx/bin", &redis.Z{Score: 0, Member: fmt.Sprintf("name %8d", i)})
|
||||
client.ZAddNX(context.Background(), "/xxx/bin", &redis.Z{Score: 0, Member: fmt.Sprintf("name %8d", i)})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ func (m *SkipListElementStore) LoadElement(id int64) (*skiplist.SkipListElement,
|
|||
t := &skiplist.SkipListElement{}
|
||||
err = proto.Unmarshal([]byte(data), t)
|
||||
if err == nil {
|
||||
for i:=0;i<len(t.Next);i++{
|
||||
for i := 0; i < len(t.Next); i++ {
|
||||
if t.Next[i].IsNil() {
|
||||
t.Next[i] = nil
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ func (vl *VolumeLayout) AddGrowRequest() {
|
|||
vl.growRequestCount++
|
||||
}
|
||||
func (vl *VolumeLayout) DoneGrowRequest() {
|
||||
vl.growRequestTime = time.Unix(0,0)
|
||||
vl.growRequestTime = time.Unix(0, 0)
|
||||
vl.growRequestCount = 0
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ func (nl *NameList) DeleteName(name string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
if nextNameBatch != nil && len(nextNameBatch.names) + len(prevNameBatch.names) < nl.batchSize {
|
||||
if nextNameBatch != nil && len(nextNameBatch.names)+len(prevNameBatch.names) < nl.batchSize {
|
||||
// case 3.1 merge nextNode and prevNode
|
||||
if _, err := nl.skipList.DeleteByKey(nextNode.Key); err != nil {
|
||||
return err
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestNameList(t *testing.T) {
|
|||
// list.skipList.println()
|
||||
|
||||
deleteBase := 5
|
||||
deleteCount := maxNameCount - 3 * deleteBase
|
||||
deleteCount := maxNameCount - 3*deleteBase
|
||||
|
||||
for i := deleteBase; i < deleteBase+deleteCount; i++ {
|
||||
list.DeleteName(String(i))
|
||||
|
|
|
@ -467,7 +467,7 @@ func (t *SkipList) GetSmallestNode() (*SkipListElement, error) {
|
|||
func (t *SkipList) GetLargestNode() (*SkipListElement, error) {
|
||||
return t.LoadElement(t.EndLevels[0])
|
||||
}
|
||||
func (t *SkipList) GetLargestNodeReference() (*SkipListElementReference) {
|
||||
func (t *SkipList) GetLargestNodeReference() *SkipListElementReference {
|
||||
return t.EndLevels[0]
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ func TestReverseInsert(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
func TestInsertAndFind(t *testing.T) {
|
||||
|
||||
k0 := []byte("0")
|
||||
|
|
Loading…
Reference in a new issue