tmp
This commit is contained in:
112
atree/misc.go
112
atree/misc.go
@@ -55,51 +55,51 @@ func BinarySearch(qty int, keyComparator bin.KeyComparator) (elemIdx int, isFoun
|
||||
}
|
||||
}
|
||||
|
||||
type ChunksToNotLinkedDataPageReq struct {
|
||||
// PrevPageNo uint32
|
||||
TimestampsChunks [][]byte
|
||||
TimestampsSize uint16
|
||||
ValuesChunks [][]byte
|
||||
ValuesSize uint16
|
||||
}
|
||||
// type ChunksToNotLinkedDataPageReq struct {
|
||||
// // PrevPageNo uint32
|
||||
// TimestampsChunks [][]byte
|
||||
// TimestampsSize uint16
|
||||
// ValuesChunks [][]byte
|
||||
// ValuesSize uint16
|
||||
// }
|
||||
|
||||
func ChunksToNotLinkedDataPage(buf []byte, req ChunksToNotLinkedDataPageReq) {
|
||||
bin.PutUint16(buf[timestampsSizeIdx:], req.TimestampsSize)
|
||||
bin.PutUint16(buf[valuesSizeIdx:], req.ValuesSize)
|
||||
// func ChunksToNotLinkedDataPage(buf []byte, req ChunksToNotLinkedDataPageReq) {
|
||||
// bin.PutUint16(buf[timestampsSizeIdx:], req.TimestampsSize)
|
||||
// bin.PutUint16(buf[valuesSizeIdx:], req.ValuesSize)
|
||||
|
||||
var (
|
||||
remainingSize = int(req.TimestampsSize)
|
||||
pos = 0
|
||||
)
|
||||
for _, chunk := range req.TimestampsChunks {
|
||||
if remainingSize >= len(chunk) {
|
||||
copy(buf[pos:], chunk)
|
||||
remainingSize -= len(chunk)
|
||||
pos += len(chunk)
|
||||
} else {
|
||||
copy(buf[pos:], chunk[:remainingSize])
|
||||
break
|
||||
}
|
||||
}
|
||||
// var (
|
||||
// remainingSize = int(req.TimestampsSize)
|
||||
// pos = 0
|
||||
// )
|
||||
// for _, chunk := range req.TimestampsChunks {
|
||||
// if remainingSize >= len(chunk) {
|
||||
// copy(buf[pos:], chunk)
|
||||
// remainingSize -= len(chunk)
|
||||
// pos += len(chunk)
|
||||
// } else {
|
||||
// copy(buf[pos:], chunk[:remainingSize])
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
|
||||
remainingSize = int(req.ValuesSize)
|
||||
pos = int(req.TimestampsSize)
|
||||
// remainingSize = int(req.ValuesSize)
|
||||
// pos = int(req.TimestampsSize)
|
||||
|
||||
for _, chunk := range req.ValuesChunks {
|
||||
if remainingSize >= len(chunk) {
|
||||
copy(buf[pos:], chunk)
|
||||
remainingSize -= len(chunk)
|
||||
pos += len(chunk)
|
||||
} else {
|
||||
copy(buf[pos:], chunk[:remainingSize])
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
// for _, chunk := range req.ValuesChunks {
|
||||
// if remainingSize >= len(chunk) {
|
||||
// copy(buf[pos:], chunk)
|
||||
// remainingSize -= len(chunk)
|
||||
// pos += len(chunk)
|
||||
// } else {
|
||||
// copy(buf[pos:], chunk[:remainingSize])
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
func setPrevPageNo(buf []byte, pageNo uint32) {
|
||||
bin.PutUint32(buf[prevPageIdx:], pageNo)
|
||||
}
|
||||
// func setPrevPageNo(buf []byte, pageNo uint32) {
|
||||
// bin.PutUint32(buf[prevPageIdx:], pageNo)
|
||||
// }
|
||||
|
||||
func getPrevPageNo(buf []byte) uint32 {
|
||||
return bin.GetUint32(buf[prevPageIdx:])
|
||||
@@ -191,20 +191,20 @@ func listPageNumbersSince(buf []byte, timestamp uint32) (pageNumbers []uint32) {
|
||||
return
|
||||
}
|
||||
|
||||
func getSince(buf []byte) uint32 {
|
||||
return bin.GetUint32(buf[0:])
|
||||
}
|
||||
// func getSince(buf []byte) uint32 {
|
||||
// return bin.GetUint32(buf[0:])
|
||||
// }
|
||||
|
||||
func appendPair(buf []byte, timestamp uint32, pageNo uint32) bool {
|
||||
qty := bin.GetUint16AsInt(buf[indexRecordsQtyIdx:])
|
||||
free := indexFooterIdx - qty*pairSize
|
||||
if free < pairSize {
|
||||
return false
|
||||
}
|
||||
pos := qty * timestampSize
|
||||
bin.PutUint32(buf[pos:], timestamp)
|
||||
pos = indexFooterIdx - (qty+1)*PageNoSize
|
||||
bin.PutUint32(buf[pos:], pageNo)
|
||||
bin.PutIntAsUint16(buf[indexRecordsQtyIdx:], qty+1)
|
||||
return true
|
||||
}
|
||||
// func appendPair(buf []byte, timestamp uint32, pageNo uint32) bool {
|
||||
// qty := bin.GetUint16AsInt(buf[indexRecordsQtyIdx:])
|
||||
// free := indexFooterIdx - qty*pairSize
|
||||
// if free < pairSize {
|
||||
// return false
|
||||
// }
|
||||
// pos := qty * timestampSize
|
||||
// bin.PutUint32(buf[pos:], timestamp)
|
||||
// pos = indexFooterIdx - (qty+1)*PageNoSize
|
||||
// bin.PutUint32(buf[pos:], pageNo)
|
||||
// bin.PutIntAsUint16(buf[indexRecordsQtyIdx:], qty+1)
|
||||
// return true
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user