Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iotdb-client-go fit for IoTDB-V1.1 #83

Merged
merged 12 commits into from
Jul 16, 2024
9 changes: 4 additions & 5 deletions client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ package client

import (
"bytes"

"github.com/apache/iotdb-client-go/rpc"
"github.com/apache/iotdb-client-go/common"
)

type BatchError struct {
statuses []*rpc.TSStatus
statuses []*common.TSStatus
}

func (e *BatchError) Error() string {
Expand All @@ -37,11 +36,11 @@ func (e *BatchError) Error() string {
return buff.String()
}

func (e *BatchError) GetStatuses() []*rpc.TSStatus {
func (e *BatchError) GetStatuses() []*common.TSStatus {
return e.statuses
}

func NewBatchError(statuses []*rpc.TSStatus) *BatchError {
func NewBatchError(statuses []*common.TSStatus) *BatchError {
return &BatchError{
statuses: statuses,
}
Expand Down
7 changes: 4 additions & 3 deletions client/rpcdataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/apache/iotdb-client-go/common"
"math"
"time"

Expand Down Expand Up @@ -63,7 +64,7 @@ type IoTDBRpcDataSet struct {
currentBitmap []byte
time []byte
values [][]byte
client *rpc.TSIServiceClient
client *rpc.IClientRPCServiceClient
emptyResultSet bool
ignoreTimeStamp bool
closed bool
Expand Down Expand Up @@ -480,7 +481,7 @@ func (s *IoTDBRpcDataSet) Close() (err error) {
QueryId: &s.queryId,
}

var status *rpc.TSStatus
var status *common.TSStatus
status, err = s.client.CloseOperation(context.Background(), closeRequest)
if err == nil {
err = VerifySuccess(status)
Expand Down Expand Up @@ -509,7 +510,7 @@ func (s *IoTDBRpcDataSet) Close() (err error) {

func NewIoTDBRpcDataSet(sql string, columnNameList []string, columnTypes []string,
columnNameIndex map[string]int32,
queryId int64, client *rpc.TSIServiceClient, sessionId int64, queryDataSet *rpc.TSQueryDataSet,
queryId int64, client *rpc.IClientRPCServiceClient, sessionId int64, queryDataSet *rpc.TSQueryDataSet,
ignoreTimeStamp bool, fetchSize int32, timeoutMs *int64) *IoTDBRpcDataSet {

ds := &IoTDBRpcDataSet{
Expand Down
2 changes: 1 addition & 1 deletion client/rpcdataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func createIoTDBRpcDataSet() *IoTDBRpcDataSet {
}
var queyrId int64 = 1
var sessionId int64 = 1
var client *rpc.TSIServiceClient = nil
var client *rpc.IClientRPCServiceClient = nil
queryDataSet := rpc.TSQueryDataSet{
Time: []byte{0, 0, 1, 118, 76, 52, 0, 236, 0, 0, 1, 118, 76, 52, 25, 228, 0, 0, 1, 118, 76, 52, 41, 42, 0, 0, 1, 118, 76, 52, 243, 148, 0, 0, 1, 118, 76, 95, 98, 255},
ValueList: [][]byte{{0, 0, 0, 13, 84, 101, 115, 116, 32, 68, 101, 118, 105, 99, 101, 32, 49, 0, 0, 0, 13, 84, 101, 115, 116, 32, 68, 101, 118, 105, 99, 101, 32, 49, 0, 0, 0, 13, 84, 101, 115, 116, 32, 68, 101, 118, 105, 99, 101, 32, 49, 0, 0, 0, 13, 84, 101, 115, 116, 32, 68, 101, 118, 105, 99, 101, 32, 49, 0, 0, 0, 13, 84, 101, 115, 116, 32, 68, 101, 118, 105, 99, 101, 32, 49}, {64, 159, 16, 204, 204, 204, 204, 205, 64, 159, 16, 204, 204, 204, 204, 205, 64, 159, 16, 204, 204, 204, 204, 205, 64, 159, 16, 204, 204, 204, 204, 205, 64, 159, 16, 204, 204, 204, 204, 205}, {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1}, {1, 1, 1, 1, 1}, {65, 65, 153, 154, 65, 65, 153, 154, 65, 65, 153, 154, 65, 65, 153, 154, 65, 65, 153, 154}, {0, 0, 0, 0, 0, 50, 220, 213, 0, 0, 0, 0, 0, 50, 220, 213, 0, 0, 0, 0, 0, 50, 220, 213, 0, 0, 0, 0, 0, 50, 220, 213, 0, 0, 0, 0, 0, 50, 220, 213}},
Expand Down
233 changes: 201 additions & 32 deletions client/session.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/sessiondataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (s *SessionDataSet) Close() error {

func NewSessionDataSet(sql string, columnNameList []string, columnTypeList []string,
columnNameIndex map[string]int32,
queryId int64, client *rpc.TSIServiceClient, sessionId int64, queryDataSet *rpc.TSQueryDataSet,
queryId int64, client *rpc.IClientRPCServiceClient, sessionId int64, queryDataSet *rpc.TSQueryDataSet,
ignoreTimeStamp bool, fetchSize int32, timeoutMs *int64) *SessionDataSet {

return &SessionDataSet{
Expand Down
1 change: 1 addition & 0 deletions client/tablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func (t *Tablet) GetValueAt(columnIndex, rowIndex int) (interface{}, error) {
return nil, fmt.Errorf("illegal argument columnIndex %d", columnIndex)
}


if rowIndex < 0 || rowIndex > t.maxRowNumber {
return nil, fmt.Errorf("illegal argument rowIndex %d", rowIndex)
}
Expand Down
7 changes: 3 additions & 4 deletions client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ import (
"bytes"
"encoding/binary"
"fmt"
"github.com/apache/iotdb-client-go/common"
"strconv"

"github.com/apache/iotdb-client-go/rpc"
)

func int32ToString(n int32) string {
Expand Down Expand Up @@ -70,7 +69,7 @@ func bytesToInt64(bys []byte) int64 {
return int64(data)
}

func verifySuccesses(statuses []*rpc.TSStatus) error {
func verifySuccesses(statuses []*common.TSStatus) error {
buff := bytes.Buffer{}
for _, status := range statuses {
if status.Code != SuccessStatus && status.Code != RedirectionRecommend {
Expand All @@ -84,7 +83,7 @@ func verifySuccesses(statuses []*rpc.TSStatus) error {
return nil
}

func VerifySuccess(status *rpc.TSStatus) error {
func VerifySuccess(status *common.TSStatus) error {
if status.Code == RedirectionRecommend {
return nil
}
Expand Down
35 changes: 17 additions & 18 deletions client/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
package client

import (
"github.com/apache/iotdb-client-go/common"
"testing"

"github.com/apache/iotdb-client-go/rpc"
)

func Test_bytesToInt32(t *testing.T) {
Expand Down Expand Up @@ -183,7 +182,7 @@ func Test_float64ToString(t *testing.T) {

func Test_verifySuccess(t *testing.T) {
type args struct {
status *rpc.TSStatus
status *common.TSStatus
}
var errMsg string = "error occurred"
tests := []struct {
Expand All @@ -194,30 +193,30 @@ func Test_verifySuccess(t *testing.T) {
{
name: "RedirectionRecommend",
args: args{
status: &rpc.TSStatus{
status: &common.TSStatus{
Code: RedirectionRecommend,
Message: &errMsg,
SubStatus: []*rpc.TSStatus{},
SubStatus: []*common.TSStatus{},
},
},
wantErr: false,
}, {
name: "SuccessStatus",
args: args{
status: &rpc.TSStatus{
status: &common.TSStatus{
Code: SuccessStatus,
Message: &errMsg,
SubStatus: []*rpc.TSStatus{},
SubStatus: []*common.TSStatus{},
},
},
wantErr: false,
}, {
name: "MultipleError",
args: args{
status: &rpc.TSStatus{
status: &common.TSStatus{
Code: MultipleError,
Message: &errMsg,
SubStatus: []*rpc.TSStatus{
SubStatus: []*common.TSStatus{
{
Code: ShutDownError,
Message: &errMsg,
Expand All @@ -229,10 +228,10 @@ func Test_verifySuccess(t *testing.T) {
}, {
name: "CloseOperationError",
args: args{
status: &rpc.TSStatus{
status: &common.TSStatus{
Code: CloseOperationError,
Message: &errMsg,
SubStatus: []*rpc.TSStatus{},
SubStatus: []*common.TSStatus{},
},
},
wantErr: true,
Expand All @@ -249,7 +248,7 @@ func Test_verifySuccess(t *testing.T) {

func Test_verifySuccesses(t *testing.T) {
type args struct {
statuses []*rpc.TSStatus
statuses []*common.TSStatus
}
var internalServerError string = "InternalServerError"
var success string = "Success"
Expand All @@ -262,23 +261,23 @@ func Test_verifySuccesses(t *testing.T) {
{
name: "InternalServerError",
args: args{
statuses: []*rpc.TSStatus{
statuses: []*common.TSStatus{
{
Code: InternalServerError,
Message: &internalServerError,
SubStatus: []*rpc.TSStatus{},
SubStatus: []*common.TSStatus{},
},
},
},
wantErr: true,
}, {
name: "SuccessStatus",
args: args{
statuses: []*rpc.TSStatus{
statuses: []*common.TSStatus{
{
Code: SuccessStatus,
Message: &success,
SubStatus: []*rpc.TSStatus{},
SubStatus: []*common.TSStatus{},
},
},
},
Expand All @@ -287,11 +286,11 @@ func Test_verifySuccesses(t *testing.T) {
{
name: "RedirectionRecommend",
args: args{
statuses: []*rpc.TSStatus{
statuses: []*common.TSStatus{
{
Code: RedirectionRecommend,
Message: &redirectionRecommend,
SubStatus: []*rpc.TSStatus{},
SubStatus: []*common.TSStatus{},
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions common/GoUnusedProtection__.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/rpc-consts.go → common/common-consts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading