InsertRecordsOfOneDevice Insert multiple rows, which can reduce the overhead of network. This method is just like jdbc executeBatch, we pack some insert request in batch and send them to server. If you want improve your performance, please see insertTablet method Each row is independent, which could
(deviceId string, timestamps []int64, measurementsSlice [][]string, dataTypesSlice [][]TSDataType, valuesSlice [][]interface{}, sorted bool)
| 771 | // your performance, please see insertTablet method |
| 772 | // Each row is independent, which could have different insertTargetName, time, number of measurements |
| 773 | func (s *Session) InsertRecordsOfOneDevice(deviceId string, timestamps []int64, measurementsSlice [][]string, dataTypesSlice [][]TSDataType, valuesSlice [][]interface{}, sorted bool) error { |
| 774 | length := len(timestamps) |
| 775 | if len(measurementsSlice) != length || len(dataTypesSlice) != length || len(valuesSlice) != length { |
| 776 | return errors.New("timestamps, measurementsSlice and valuesSlice's size should be equal") |
| 777 | } |
| 778 | |
| 779 | if !sorted { |
| 780 | sort.Sort(&deviceData{ |
| 781 | timestamps: timestamps, |
| 782 | measurementsSlice: measurementsSlice, |
| 783 | dataTypesSlice: dataTypesSlice, |
| 784 | valuesSlice: valuesSlice, |
| 785 | }) |
| 786 | } |
| 787 | |
| 788 | var err error |
| 789 | valuesList := make([][]byte, length) |
| 790 | for i := 0; i < length; i++ { |
| 791 | if valuesList[i], err = valuesToBytes(dataTypesSlice[i], valuesSlice[i], measurementsSlice[i]); err != nil { |
| 792 | return err |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | request := &rpc.TSInsertRecordsOfOneDeviceReq{ |
| 797 | SessionId: s.sessionId, |
| 798 | PrefixPath: deviceId, |
| 799 | Timestamps: timestamps, |
| 800 | MeasurementsList: measurementsSlice, |
| 801 | ValuesList: valuesList, |
| 802 | } |
| 803 | |
| 804 | r, err := s.client.InsertRecordsOfOneDevice(context.Background(), request) |
| 805 | |
| 806 | if err != nil && r == nil { |
| 807 | if s.reconnect() { |
| 808 | request.SessionId = s.sessionId |
| 809 | r, err = s.client.InsertRecordsOfOneDevice(context.Background(), request) |
| 810 | } |
| 811 | } |
| 812 | |
| 813 | if err != nil { |
| 814 | return err |
| 815 | } |
| 816 | return VerifySuccess(r) |
| 817 | } |
| 818 | |
| 819 | func (s *Session) InsertAlignedRecordsOfOneDevice(deviceId string, timestamps []int64, measurementsSlice [][]string, dataTypesSlice [][]TSDataType, valuesSlice [][]interface{}, sorted bool) error { |
| 820 | length := len(timestamps) |
nothing calls this directly
no test coverage detected