| 1247 | } |
| 1248 | |
| 1249 | func (s *Session) InsertAlignedTablet(tablet *Tablet, sorted bool) error { |
| 1250 | if !sorted { |
| 1251 | if err := tablet.Sort(); err != nil { |
| 1252 | return err |
| 1253 | } |
| 1254 | } |
| 1255 | request, err := s.genTSInsertTabletReq(tablet, true, false) |
| 1256 | if err != nil { |
| 1257 | return err |
| 1258 | } |
| 1259 | |
| 1260 | r, err := s.client.InsertTablet(context.Background(), request) |
| 1261 | |
| 1262 | if err != nil && r == nil { |
| 1263 | if s.reconnect() { |
| 1264 | request.SessionId = s.sessionId |
| 1265 | r, err = s.client.InsertTablet(context.Background(), request) |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | if err != nil { |
| 1270 | return err |
| 1271 | } |
| 1272 | return VerifySuccess(r) |
| 1273 | } |
| 1274 | |
| 1275 | func (s *Session) genTSInsertTabletReq(tablet *Tablet, isAligned bool, writeToTable bool) (*rpc.TSInsertTabletReq, error) { |
| 1276 | if values, err := tablet.getValuesBytes(); err == nil { |