|
@ -3,10 +3,11 @@ package storage |
|
|
import ( |
|
|
import ( |
|
|
"context" |
|
|
"context" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"github.com/seaweedfs/seaweedfs/weed/pb" |
|
|
|
|
|
"io" |
|
|
"io" |
|
|
"os" |
|
|
"os" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb" |
|
|
|
|
|
|
|
|
"google.golang.org/grpc" |
|
|
"google.golang.org/grpc" |
|
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/operation" |
|
|
"github.com/seaweedfs/seaweedfs/weed/operation" |
|
@ -200,7 +201,7 @@ func (v *Volume) BinarySearchByAppendAtNs(sinceNs uint64) (offset Offset, isLast |
|
|
err = leftErr |
|
|
err = leftErr |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
rightIndex, rightOffset, rightNs, rightErr := v.readRightNs(m) |
|
|
|
|
|
|
|
|
rightIndex, rightOffset, rightNs, rightErr := v.readRightNs(m, entryCount) |
|
|
if rightErr != nil { |
|
|
if rightErr != nil { |
|
|
err = rightErr |
|
|
err = rightErr |
|
|
return |
|
|
return |
|
@ -249,10 +250,13 @@ func (v *Volume) BinarySearchByAppendAtNs(sinceNs uint64) (offset Offset, isLast |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (v *Volume) readRightNs(m int64) (index int64, offset Offset, ts uint64, err error) { |
|
|
|
|
|
|
|
|
func (v *Volume) readRightNs(m, max int64) (index int64, offset Offset, ts uint64, err error) { |
|
|
index = m |
|
|
index = m |
|
|
for offset.IsZero() { |
|
|
for offset.IsZero() { |
|
|
index++ |
|
|
index++ |
|
|
|
|
|
if index >= max { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
offset, err = v.readOffsetFromIndex(index) |
|
|
offset, err = v.readOffsetFromIndex(index) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
err = fmt.Errorf("read left entry at %d: %v", index, err) |
|
|
err = fmt.Errorf("read left entry at %d: %v", index, err) |
|
@ -269,6 +273,9 @@ func (v *Volume) readLeftNs(m int64) (index int64, offset Offset, ts uint64, err |
|
|
index = m |
|
|
index = m |
|
|
for offset.IsZero() { |
|
|
for offset.IsZero() { |
|
|
index-- |
|
|
index-- |
|
|
|
|
|
if index < 0 { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
offset, err = v.readOffsetFromIndex(index) |
|
|
offset, err = v.readOffsetFromIndex(index) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
err = fmt.Errorf("read right entry at %d: %v", index, err) |
|
|
err = fmt.Errorf("read right entry at %d: %v", index, err) |
|
|