@@ -254,10 +254,23 @@ func (l *Layout) Describe(
254254 if err != nil {
255255 return err
256256 }
257- iter , _ := rowblk .NewRawIter (r .Comparer .Compare , h .BlockData ())
258- iter .Describe (tpNode , func (w io.Writer , key * base.InternalKey , value []byte , enc rowblk.KVEncoding ) {
259- fmt .Fprintf (w , "%05d %s (%d)" , enc .Offset , key .UserKey , enc .Length )
260- })
257+ if r .tableFormat >= TableFormatPebblev6 {
258+ var decoder colblk.KeyValueBlockDecoder
259+ decoder .Init (h .BlockData ())
260+ offset := 0
261+ for i := 0 ; i < decoder .BlockDecoder ().Rows (); i ++ {
262+ key := decoder .KeyAt (i )
263+ value := decoder .ValueAt (i )
264+ length := len (key ) + len (value )
265+ tpNode .Childf ("%05d %s (%d)" , offset , key , length )
266+ offset += length
267+ }
268+ } else {
269+ iter , _ := rowblk .NewRawIter (r .Comparer .Compare , h .BlockData ())
270+ iter .Describe (tpNode , func (w io.Writer , key * base.InternalKey , value []byte , enc rowblk.KVEncoding ) {
271+ fmt .Fprintf (w , "%05d %s (%d)" , enc .Offset , key .UserKey , enc .Length )
272+ })
273+ }
261274
262275 case "meta-index" :
263276 if b .Handle != r .metaindexBH {
@@ -286,18 +299,16 @@ func (l *Layout) Describe(
286299 bh , n = block .DecodeHandle (value )
287300 }
288301 if n == 0 || n != len (value ) {
289- s := fmt .Sprintf ("%04d [err: %s]\n " , i , err )
290- tpNode .Child (s )
302+ tpNode .Childf ("%04d [err: %s]\n " , i , err )
291303 continue
292304 }
293305 var vbihStr string
294306 if isValueBlocksIndexHandle {
295307 vbihStr = fmt .Sprintf (" value-blocks-index-lengths: %d(num), %d(offset), %d(length)" ,
296308 vbih .BlockNumByteLength , vbih .BlockOffsetByteLength , vbih .BlockLengthByteLength )
297309 }
298- s := fmt . Sprintf ("%04d %s block:%d/%d%s\n " ,
310+ tpNode . Childf ("%04d %s block:%d/%d%s\n " ,
299311 i , key , bh .Offset , bh .Length , vbihStr )
300- tpNode .Child (s )
301312 }
302313 } else {
303314 iter , _ := rowblk .NewRawIter (r .Comparer .Compare , h .BlockData ())
@@ -562,8 +573,14 @@ func decodeLayout(comparer *base.Comparer, data []byte, tableFormat TableFormat)
562573 if err != nil {
563574 return Layout {}, errors .Wrap (err , "decompressing properties" )
564575 }
565- if err := props .load (decompressedProps , map [string ]struct {}{}); err != nil {
566- return Layout {}, err
576+ if tableFormat >= TableFormatPebblev6 {
577+ if err = props .load (decompressedProps , map [string ]struct {}{}); err != nil {
578+ return Layout {}, err
579+ }
580+ } else {
581+ if err = props .loadFromRowBlock (decompressedProps , map [string ]struct {}{}); err != nil {
582+ return Layout {}, err
583+ }
567584 }
568585
569586 if props .IndexType == twoLevelIndex {
@@ -816,33 +833,38 @@ func (w *layoutWriter) WriteFilterBlock(f filterWriter) (bh block.Handle, err er
816833 if err != nil {
817834 return block.Handle {}, err
818835 }
819- return w .writeNamedBlock (b , f .metaName ())
836+ return w .writeNamedBlock (b , block . NoCompression , f .metaName ())
820837}
821838
822839// WritePropertiesBlock constructs a trailer for the provided properties block
823840// and writes the block and trailer to the writer. It automatically adds the
824841// properties block to the file's meta index when the writer is finished.
825842func (w * layoutWriter ) WritePropertiesBlock (b []byte ) (block.Handle , error ) {
826- return w .writeNamedBlock (b , metaPropertiesName )
843+ if w .tableFormat >= TableFormatPebblev6 {
844+ return w .writeNamedBlock (b , w .compression , metaPropertiesName )
845+ }
846+ return w .writeNamedBlock (b , block .NoCompression , metaPropertiesName )
827847}
828848
829849// WriteRangeKeyBlock constructs a trailer for the provided range key block and
830850// writes the block and trailer to the writer. It automatically adds the range
831851// key block to the file's meta index when the writer is finished.
832852func (w * layoutWriter ) WriteRangeKeyBlock (b []byte ) (block.Handle , error ) {
833- return w .writeNamedBlock (b , metaRangeKeyName )
853+ return w .writeNamedBlock (b , block . NoCompression , metaRangeKeyName )
834854}
835855
836856// WriteRangeDeletionBlock constructs a trailer for the provided range deletion
837857// block and writes the block and trailer to the writer. It automatically adds
838858// the range deletion block to the file's meta index when the writer is
839859// finished.
840860func (w * layoutWriter ) WriteRangeDeletionBlock (b []byte ) (block.Handle , error ) {
841- return w .writeNamedBlock (b , metaRangeDelV2Name )
861+ return w .writeNamedBlock (b , block . NoCompression , metaRangeDelV2Name )
842862}
843863
844- func (w * layoutWriter ) writeNamedBlock (b []byte , name string ) (bh block.Handle , err error ) {
845- bh , err = w .writeBlock (b , block .NoCompression , & w .buf )
864+ func (w * layoutWriter ) writeNamedBlock (
865+ b []byte , compression block.Compression , name string ,
866+ ) (bh block.Handle , err error ) {
867+ bh , err = w .writeBlock (b , compression , & w .buf )
846868 if err == nil {
847869 w .recordToMetaindex (name , bh )
848870 }
0 commit comments