@@ -51,6 +51,7 @@ type RawRowWriter struct {
51
51
compression block.Compression
52
52
separator Separator
53
53
successor Successor
54
+ validateKey base.ValidateKey
54
55
tableFormat TableFormat
55
56
isStrictObsolete bool
56
57
writingToLowestLevel bool
@@ -1220,6 +1221,11 @@ func (w *RawRowWriter) addIndexEntry(
1220
1221
// In particular, it must have a non-zero length.
1221
1222
return nil
1222
1223
}
1224
+ if invariants .Enabled {
1225
+ if err := w .validateKey .Validate (sep .UserKey ); err != nil {
1226
+ return err
1227
+ }
1228
+ }
1223
1229
1224
1230
encoded := bhp .EncodeVarints (tmp )
1225
1231
if flushIndexBuf != nil {
@@ -1538,6 +1544,8 @@ func (w *RawRowWriter) Close() (err error) {
1538
1544
return err
1539
1545
}
1540
1546
prevKey := w .dataBlockBuf .dataBlock .CurKey ()
1547
+ // NB: prevKey.UserKey may be nil if there are no keys and we're forcing
1548
+ // the creation of an empty data block.
1541
1549
if err := w .addIndexEntrySync (prevKey , InternalKey {}, bhp , w .dataBlockBuf .tmp [:]); err != nil {
1542
1550
return err
1543
1551
}
@@ -1719,6 +1727,7 @@ func newRowWriter(writable objstorage.Writable, o WriterOptions) *RawRowWriter {
1719
1727
compression : o .Compression ,
1720
1728
separator : o .Comparer .Separator ,
1721
1729
successor : o .Comparer .Successor ,
1730
+ validateKey : o .Comparer .ValidateKey ,
1722
1731
tableFormat : o .TableFormat ,
1723
1732
isStrictObsolete : o .IsStrictObsolete ,
1724
1733
writingToLowestLevel : o .WritingToLowestLevel ,
0 commit comments