-
Notifications
You must be signed in to change notification settings - Fork 365
/
Copy pathentry_value_iterator.go
60 lines (50 loc) · 1008 Bytes
/
entry_value_iterator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package catalog
import "github.com/treeverse/lakefs/pkg/graveler"
type entryValueIterator struct {
it EntryIterator
value *graveler.ValueRecord
err error
}
func NewEntryToValueIterator(it EntryIterator) *entryValueIterator {
return &entryValueIterator{
it: it,
}
}
func (e *entryValueIterator) Next() bool {
if e.err != nil {
return false
}
hasNext := e.it.Next()
if !hasNext {
e.value = nil
e.err = e.it.Err()
return false
}
v := e.it.Value()
var val *graveler.Value
if v.Entry != nil {
val, e.err = EntryToValue(v.Entry)
if e.err != nil {
e.value = nil
return false
}
}
e.value = &graveler.ValueRecord{
Key: graveler.Key(v.Path),
Value: val,
}
return true
}
func (e *entryValueIterator) SeekGE(id graveler.Key) {
e.value = nil
e.it.SeekGE(Path(id))
}
func (e *entryValueIterator) Value() *graveler.ValueRecord {
return e.value
}
func (e *entryValueIterator) Err() error {
return e.err
}
func (e *entryValueIterator) Close() {
e.it.Close()
}