Skip to content

Commit f126236

Browse files
committed
db: support reading separated values from DB.Get
Adapt the getIter (used within the implementation of DB.Get) to initialize a blob value fetcher and propagate it down the iterator tree, ensuring we can retrieve the value of a blob-file separated value. Informs #112.
1 parent ae9f98c commit f126236

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

compaction_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,9 @@ func TestCompaction(t *testing.T) {
10271027
}
10281028
return describeLSM(d, verbose)
10291029

1030+
case "get":
1031+
return runGetCmd(t, td, d)
1032+
10301033
case "ingest":
10311034
if err := runIngestCmd(td, d, mem); err != nil {
10321035
return err.Error()

db.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,9 @@ func (d *DB) getInternal(key []byte, b *Batch, s *Snapshot) ([]byte, io.Closer,
612612
readState: readState,
613613
keyBuf: buf.keyBuf,
614614
}
615+
// Set up a blob value fetcher to use for retrieving values from blob files.
616+
i.blobValueFetcher.Init(d.fileCache, block.NoReadEnv)
617+
get.iiopts.blobValueFetcher = &i.blobValueFetcher
615618

616619
if !i.First() {
617620
err := i.Close()

get_iter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type getIter struct {
2323
newIters tableNewIters
2424
snapshot base.SeqNum
2525
iterOpts IterOptions
26+
iiopts internalIterOpts
2627
key []byte
2728
prefix []byte
2829
iter internalIterator
@@ -271,7 +272,7 @@ func (g *getIter) getSSTableIterators(
271272
}
272273
// m may possibly contain point (or range deletion) keys relevant to g.key.
273274
g.iterOpts.layer = level
274-
iters, err := g.newIters(context.Background(), m, &g.iterOpts, internalIterOpts{}, iterPointKeys|iterRangeDeletions)
275+
iters, err := g.newIters(context.Background(), m, &g.iterOpts, g.iiopts, iterPointKeys|iterRangeDeletions)
275276
if err != nil {
276277
return emptyIter, nil, err
277278
}

testdata/compaction/value_separation

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ L0.0:
153153
Blob files:
154154
000008: 56 physical bytes, 10 value bytes
155155

156+
get
157+
a
158+
b
159+
h
160+
w
161+
----
162+
a:a
163+
b:b
164+
h:hello
165+
w:world
166+
156167
# Configure the database to require keys in the range [a,m) to be in-place.
157168

158169
define required-in-place=(a,m) value-separation=(true,1,3)

0 commit comments

Comments
 (0)