Skip to content

Commit bd64a1e

Browse files
committed
sstable: fix inline blob handles in layout describe
1 parent b34bbcb commit bd64a1e

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

sstable/layout.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/cockroachdb/pebble/internal/sstableinternal"
2323
"github.com/cockroachdb/pebble/internal/treeprinter"
2424
"github.com/cockroachdb/pebble/objstorage"
25+
"github.com/cockroachdb/pebble/sstable/blob"
2526
"github.com/cockroachdb/pebble/sstable/block"
2627
"github.com/cockroachdb/pebble/sstable/colblk"
2728
"github.com/cockroachdb/pebble/sstable/rowblk"
@@ -428,8 +429,24 @@ var _ block.GetInternalValueForPrefixAndValueHandler = describingLazyValueHandle
428429
func (describingLazyValueHandler) GetInternalValueForPrefixAndValueHandle(
429430
handle []byte,
430431
) base.InternalValue {
431-
vh := valblk.DecodeHandle(handle[1:])
432-
return base.MakeInPlaceValue([]byte(fmt.Sprintf("value handle %+v", vh)))
432+
vp := block.ValuePrefix(handle[0])
433+
var result string
434+
switch {
435+
case vp.IsValueBlockHandle():
436+
vh := valblk.DecodeHandle(handle[1:])
437+
result = fmt.Sprintf("value handle %+v", vh)
438+
case vp.IsBlobValueHandle():
439+
handlePreface, remainder := blob.DecodeInlineHandlePreface(handle[1:])
440+
handleSuffix := blob.DecodeHandleSuffix(remainder)
441+
ih := blob.InlineHandle{
442+
InlineHandlePreface: handlePreface,
443+
HandleSuffix: handleSuffix,
444+
}
445+
result = fmt.Sprintf("blob handle %+v", ih)
446+
default:
447+
result = "unknown value type"
448+
}
449+
return base.MakeInPlaceValue([]byte(result))
433450
}
434451

435452
func formatColblkKeyspanBlock(

sstable/testdata/writer_blob_value_handles

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ sstable
101101
│ │ ├── data for column 6 (bool)
102102
│ │ │ └── 152-153: x 01 # zero bitmap encoding
103103
│ │ └── 153-154: x 00 # block padding byte
104-
│ ├── a@2#1,SET:value handle {ValueLen:0 BlockNum:10 OffsetInBlock:1}
105-
│ ├── b@5#7,SET:value handle {ValueLen:0 BlockNum:200 OffsetInBlock:2}
104+
│ ├── a@2#1,SET:blob handle (f0,blk1[10:20])
105+
│ ├── b@5#7,SET:blob handle (f0,blk2[110:310])
106106
│ ├── b@4#3,DEL:
107-
│ ├── b@3#2,SET:value handle {ValueLen:1 BlockNum:200 OffsetInBlock:0}
108-
│ ├── b@2#1,SET:value handle {ValueLen:1 BlockNum:103 OffsetInBlock:1}
107+
│ ├── b@3#2,SET:blob handle (f1,blk0[0:200])
108+
│ ├── b@2#1,SET:blob handle (f1,blk1[294:397])
109109
│ └── trailer [compression=none checksum=0x834a75d7]
110110
├── index offset: 159 length: 36
111111
│ ├── 00000 block:0/154

0 commit comments

Comments
 (0)