@@ -584,40 +584,21 @@ func runBuildRemoteCmd(td *datadriven.TestData, d *DB, storage remote.Storage) e
584584 }
585585 path := td .CmdArgs [0 ].String ()
586586
587- // Override table format, if provided.
588- tableFormat := d .TableFormat ()
589- var blockSize int64
590- for _ , cmdArg := range td .CmdArgs [1 :] {
591- switch cmdArg .Key {
592- case "format" :
593- switch cmdArg .Vals [0 ] {
594- case "pebblev1" :
595- tableFormat = sstable .TableFormatPebblev1
596- case "pebblev2" :
597- tableFormat = sstable .TableFormatPebblev2
598- case "pebblev3" :
599- tableFormat = sstable .TableFormatPebblev3
600- case "pebblev4" :
601- tableFormat = sstable .TableFormatPebblev4
602- default :
603- return errors .Errorf ("unknown format string %s" , cmdArg .Vals [0 ])
604- }
605- case "block-size" :
606- var err error
607- blockSize , err = strconv .ParseInt (cmdArg .Vals [0 ], 10 , 64 )
608- if err != nil {
609- return errors .Wrap (err , td .Pos )
610- }
611- }
612- }
613-
614- writeOpts := d .opts .MakeWriterOptions (0 /* level */ , tableFormat )
615- if blockSize == 0 && rand .IntN (4 ) == 0 {
616- // Force two-level indexes if not already forced on or off.
617- blockSize = 5
587+ // Use TableFormatMax here and downgrade after, if necessary. This ensures
588+ // that all fields are set.
589+ writeOpts := d .opts .MakeWriterOptions (0 /* level */ , d .TableFormat ())
590+ if rand .IntN (4 ) == 0 {
591+ // If block size is not specified (in which case these fields will be
592+ // overridden by ParseWriterOptions), force two-level indexes some of the
593+ // time.
594+ writeOpts .BlockSize = 5
595+ writeOpts .IndexBlockSize = 5
596+ }
597+
598+ // Now parse the arguments again against the real options.
599+ if err := sstable .ParseWriterOptions (& writeOpts , td .CmdArgs ... ); err != nil {
600+ return err
618601 }
619- writeOpts .BlockSize = int (blockSize )
620- writeOpts .IndexBlockSize = int (blockSize )
621602
622603 f , err := storage .CreateObject (path )
623604 if err != nil {
@@ -707,29 +688,10 @@ func runBuildCmd(
707688 }
708689 path := td .CmdArgs [0 ].String ()
709690
710- // Override table format, if provided.
711- tableFormat := d .TableFormat ()
712- for _ , cmdArg := range td .CmdArgs [1 :] {
713- switch cmdArg .Key {
714- case "format" :
715- switch cmdArg .Vals [0 ] {
716- case "pebblev1" :
717- tableFormat = sstable .TableFormatPebblev1
718- case "pebblev2" :
719- tableFormat = sstable .TableFormatPebblev2
720- case "pebblev3" :
721- tableFormat = sstable .TableFormatPebblev3
722- case "pebblev4" :
723- tableFormat = sstable .TableFormatPebblev4
724- case "pebblev5" :
725- tableFormat = sstable .TableFormatPebblev5
726- default :
727- return errors .Errorf ("unknown format string %s" , cmdArg .Vals [0 ])
728- }
729- }
691+ writeOpts := d .opts .MakeWriterOptions (0 /* level */ , d .TableFormat ())
692+ if err := sstable .ParseWriterOptions (& writeOpts , td .CmdArgs [1 :]... ); err != nil {
693+ return err
730694 }
731-
732- writeOpts := d .opts .MakeWriterOptions (0 /* level */ , tableFormat )
733695 var blobReferences blobtest.References
734696 f , err := fs .Create (path , vfs .WriteCategoryUnspecified )
735697 if err != nil {
0 commit comments