wp
This commit is contained in:
@@ -39,6 +39,7 @@ const (
|
||||
)
|
||||
|
||||
type FreeList interface {
|
||||
// використовується в allocPage
|
||||
ReservePage() uint32
|
||||
}
|
||||
|
||||
|
||||
21
atree/io.go
21
atree/io.go
@@ -8,7 +8,7 @@ import (
|
||||
"math"
|
||||
"os"
|
||||
|
||||
diploma "gordenko.dev/dima/qb"
|
||||
"gordenko.dev/dima/qb"
|
||||
"gordenko.dev/dima/qb/atree/redo"
|
||||
"gordenko.dev/dima/qb/bin"
|
||||
)
|
||||
@@ -74,8 +74,8 @@ func (s *Atree) releaseIndexPage(pageNo uint32) {
|
||||
p.ReferenceCount--
|
||||
return
|
||||
} else {
|
||||
diploma.Abort(
|
||||
diploma.ReferenceCountBug,
|
||||
qb.Abort(
|
||||
qb.ReferenceCountBug,
|
||||
fmt.Errorf("call releaseIndexPage on page %d with reference count = %d",
|
||||
pageNo, p.ReferenceCount),
|
||||
)
|
||||
@@ -91,15 +91,12 @@ func (s *Atree) allocIndexPage() AllocatedPage {
|
||||
)
|
||||
|
||||
allocated.PageNo = s.indexFreelist.ReservePage()
|
||||
s.mutex.Lock()
|
||||
if allocated.PageNo > 0 {
|
||||
allocated.IsReused = true
|
||||
|
||||
s.mutex.Lock()
|
||||
} else {
|
||||
s.mutex.Lock()
|
||||
if s.allocatedIndexPagesQty == math.MaxUint32 {
|
||||
diploma.Abort(diploma.MaxAtreeSizeExceeded,
|
||||
errors.New("no space in Atree index"))
|
||||
qb.Abort(qb.MaxAtreeSizeExceeded, errors.New("no space in Atree index"))
|
||||
}
|
||||
s.allocatedIndexPagesQty++
|
||||
allocated.PageNo = s.allocatedIndexPagesQty
|
||||
@@ -163,8 +160,8 @@ func (s *Atree) releaseDataPage(pageNo uint32) {
|
||||
p.ReferenceCount--
|
||||
return
|
||||
} else {
|
||||
diploma.Abort(
|
||||
diploma.ReferenceCountBug,
|
||||
qb.Abort(
|
||||
qb.ReferenceCountBug,
|
||||
fmt.Errorf("call releaseDataPage on page %d with reference count = %d",
|
||||
pageNo, p.ReferenceCount),
|
||||
)
|
||||
@@ -186,7 +183,7 @@ func (s *Atree) allocDataPage() AllocatedPage {
|
||||
} else {
|
||||
s.mutex.Lock()
|
||||
if s.allocatedDataPagesQty == math.MaxUint32 {
|
||||
diploma.Abort(diploma.MaxAtreeSizeExceeded,
|
||||
qb.Abort(qb.MaxAtreeSizeExceeded,
|
||||
errors.New("no space in Atree index"))
|
||||
}
|
||||
s.allocatedDataPagesQty++
|
||||
@@ -303,7 +300,7 @@ func (s *Atree) pageWriter() {
|
||||
case <-s.writeSignalCh:
|
||||
err := s.writeTasks()
|
||||
if err != nil {
|
||||
diploma.Abort(diploma.WriteToAtreeFailed, err)
|
||||
qb.Abort(qb.WriteToAtreeFailed, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user