Commit 8081df49 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a34148fe
......@@ -146,7 +146,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
//
// with all ZData being live.
var mu sync.Mutex
chunktab := make(map[int64]*ZData)
chunktab := make(map[int32]*ZData)
// on return deactivate all loaded ZData objects in chunktab
defer func() {
......@@ -159,7 +159,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
wg, ctx := errgroup.WithContext(ctx)
// loadZData loads 1 ZData object into chunktab and leaves it activated.
loadZData := func(offset int64, zd *ZData) error {
loadZData := func(offset int32, zd *ZData) error {
err := zd.PActivate(ctx)
if err != nil {
return err
......@@ -199,7 +199,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
}
wg.Go(func() error {
return loadZData(int64(e.Key()), zd) // XXX cast
return loadZData(e.Key(), zd)
})
}
......@@ -253,7 +253,7 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
}
// glue all chunks from chunktab
offv := make([]int64, 0, len(chunktab)) // ↑
offv := make([]int32, 0, len(chunktab)) // ↑
for off := range(chunktab) {
offv = append(offv, off)
}
......@@ -268,23 +268,23 @@ func (zb *ZBlk1) LoadBlkData(ctx context.Context) ([]byte, error) {
// find out whole blk len via inspecting tail chunk
tailStart := offv[len(offv)-1]
tailChunk := chunktab[tailStart]
blklen := tailStart + int64(len(tailChunk.data))
blklen := tailStart + int32(len(tailChunk.data)) // XXX overflow?
// whole buffer initialized as 0 + tail_chunk
blkdata := make([]byte, blklen)
copy(blkdata[tailStart:], tailChunk.data)
// go through all chunks besides tail and extract them
stop := int64(0)
stop := int32(0)
for _, start := range offv[:len(offv)-1] {
chunk := chunktab[start]
if !(start >= stop) { // verify chunks don't overlap
panic("!(start >= stop)") // XXX
}
if !(start + int64(len(chunk.data)) <= int64(len(blkdata))) {
if !(start + int32(len(chunk.data)) <= int32(len(blkdata))) { // XXX overflow?
panic("blkdata overrun") // XXX
}
stop = start + int64(len(chunk.data))
stop = start + int32(len(chunk.data)) // XXX overflow?
copy(blkdata[start:], chunk.data)
}
......@@ -347,9 +347,11 @@ func (bf *zBigFileState) PySetState(pystate interface{}) (err error) {
func init() {
t := reflect.TypeOf
zodb.RegisterClass(zwendelin + ".ZBlk", t(ZBlk0{}), t(zBlk0State{}))
zodb.RegisterClass(zwendelin + ".ZBlk0", t(ZBlk0{}), t(zBlk0State{}))
zodb.RegisterClass(zwendelin + ".ZBlk1", t(ZBlk1{}), t(zBlk1State{}))
zodb.RegisterClass(zwendelin + ".ZData", t(ZData{}), t(zDataState{}))
zodb.RegisterClass(zwendelin + ".ZBigFile", t(ZBigFile{}), t(zBigFileState{}))
// backward compatibility
zodb.RegisterClassAlias(zwendelin + ".ZBlk", zwendelin + ".ZBlk0")
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment