@@ -130,6 +130,8 @@ func NewBatch(client *pilosa.Client, size int, index *pilosa.Index, fields []*pi
130130 hasTime = typ == pilosa .FieldTypeTime || hasTime
131131 case pilosa .FieldTypeInt :
132132 values [field .Name ()] = make ([]int64 , 0 , size )
133+ default :
134+ return nil , errors .Errorf ("field type %s is not currently supported through Batch" , typ )
133135 }
134136 }
135137 b := & Batch {
@@ -254,10 +256,7 @@ func (b *Batch) Add(rec Row) error {
254256 return errors .Errorf ("record needs to match up with batch fields, got %d fields and %d record" , len (b .header ), len (rec .Values ))
255257 }
256258
257- switch rid := rec .ID .(type ) {
258- case uint64 :
259- b .ids = append (b .ids , rid )
260- case string :
259+ handleStringID := func (rid string ) error {
261260 if colID , ok , err := b .transCache .GetCol (b .index .Name (), rid ); err != nil {
262261 return errors .Wrap (err , "translating column" )
263262 } else if ok {
@@ -271,6 +270,23 @@ func (b *Batch) Add(rec Row) error {
271270 b .toTranslateID [rid ] = ints
272271 b .ids = append (b .ids , 0 )
273272 }
273+ return nil
274+ }
275+ var err error
276+
277+ switch rid := rec .ID .(type ) {
278+ case uint64 :
279+ b .ids = append (b .ids , rid )
280+ case string :
281+ err := handleStringID (rid )
282+ if err != nil {
283+ return err
284+ }
285+ case []byte :
286+ err = handleStringID (string (rid ))
287+ if err != nil {
288+ return err
289+ }
274290 default : // TODO support nil ID as being auto-allocated.
275291 return errors .Errorf ("unsupported id type %T value %v" , rid , rid )
276292 }
0 commit comments