@@ -130,6 +130,8 @@ func NewBatch(client *pilosa.Client, size int, index *pilosa.Index, fields []*pi
130
130
hasTime = typ == pilosa .FieldTypeTime || hasTime
131
131
case pilosa .FieldTypeInt :
132
132
values [field .Name ()] = make ([]int64 , 0 , size )
133
+ default :
134
+ return nil , errors .Errorf ("field type %s is not currently supported through Batch" , typ )
133
135
}
134
136
}
135
137
b := & Batch {
@@ -254,10 +256,7 @@ func (b *Batch) Add(rec Row) error {
254
256
return errors .Errorf ("record needs to match up with batch fields, got %d fields and %d record" , len (b .header ), len (rec .Values ))
255
257
}
256
258
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 {
261
260
if colID , ok , err := b .transCache .GetCol (b .index .Name (), rid ); err != nil {
262
261
return errors .Wrap (err , "translating column" )
263
262
} else if ok {
@@ -271,6 +270,23 @@ func (b *Batch) Add(rec Row) error {
271
270
b .toTranslateID [rid ] = ints
272
271
b .ids = append (b .ids , 0 )
273
272
}
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
+ }
274
290
default : // TODO support nil ID as being auto-allocated.
275
291
return errors .Errorf ("unsupported id type %T value %v" , rid , rid )
276
292
}
0 commit comments