You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							30 lines
						
					
					
						
							884 B
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							30 lines
						
					
					
						
							884 B
						
					
					
				
								package needle_map
							 | 
						|
								
							 | 
						|
								import (
							 | 
						|
									. "github.com/chrislusf/seaweedfs/weed/storage/types"
							 | 
						|
									"github.com/chrislusf/seaweedfs/weed/util"
							 | 
						|
									"github.com/google/btree"
							 | 
						|
								)
							 | 
						|
								
							 | 
						|
								type NeedleValue struct {
							 | 
						|
									Key    NeedleId
							 | 
						|
									Offset Offset `comment:"Volume offset"` //since aligned to 8 bytes, range is 4G*8=32G
							 | 
						|
									Size   uint32 `comment:"Size of the data portion"`
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								func (this NeedleValue) Less(than btree.Item) bool {
							 | 
						|
									that := than.(NeedleValue)
							 | 
						|
									return this.Key < that.Key
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								func (nv NeedleValue) ToBytes() []byte {
							 | 
						|
									return ToBytes(nv.Key, nv.Offset, nv.Size)
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								func ToBytes(key NeedleId, offset Offset, size uint32) []byte {
							 | 
						|
									bytes := make([]byte, NeedleIdSize+OffsetSize+SizeSize)
							 | 
						|
									NeedleIdToBytes(bytes[0:NeedleIdSize], key)
							 | 
						|
									OffsetToBytes(bytes[NeedleIdSize:NeedleIdSize+OffsetSize], offset)
							 | 
						|
									util.Uint32toBytes(bytes[NeedleIdSize+OffsetSize:NeedleIdSize+OffsetSize+SizeSize], size)
							 | 
						|
									return bytes
							 | 
						|
								}
							 |