mirror of
				https://github.com/taigrr/bitcask
				synced 2025-01-18 04:03:17 -08:00 
			
		
		
		
	Refactor Datafile.Size()
This commit is contained in:
		
							parent
							
								
									2400dd86d5
								
							
						
					
					
						commit
						c593bc966f
					
				| @ -175,11 +175,7 @@ func (b *Bitcask) Fold(f func(key string) error) error { | ||||
| } | ||||
| 
 | ||||
| func (b *Bitcask) put(key string, value []byte) (int64, error) { | ||||
| 	size, err := b.curr.Size() | ||||
| 	if err != nil { | ||||
| 		return -1, err | ||||
| 	} | ||||
| 
 | ||||
| 	size := b.curr.Size() | ||||
| 	if size >= int64(b.config.maxDatafileSize) { | ||||
| 		err := b.curr.Close() | ||||
| 		if err != nil { | ||||
|  | ||||
| @ -98,10 +98,10 @@ func (df *Datafile) Sync() error { | ||||
| 	return df.w.Sync() | ||||
| } | ||||
| 
 | ||||
| func (df *Datafile) Size() (int64, error) { | ||||
| func (df *Datafile) Size() int64 { | ||||
| 	df.RLock() | ||||
| 	defer df.RUnlock() | ||||
| 	return df.offset, nil | ||||
| 	return df.offset | ||||
| } | ||||
| 
 | ||||
| func (df *Datafile) Read() (e pb.Entry, err error) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user