You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@iotdb.apache.org by GitBox <gi...@apache.org> on 2020/12/07 07:03:11 UTC

[GitHub] [iotdb-client-go] liutaohua commented on a change in pull request #1: iotdb-go-client

liutaohua commented on a change in pull request #1:
URL: https://github.com/apache/iotdb-client-go/pull/1#discussion_r537243427



##########
File path: client/session.go
##########
@@ -0,0 +1,639 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package client

Review comment:
       I don't think it's a good choice to have these implementations under the `client` package, because it causes the user `import` to look like this:
   ```
   import (
   	"github.com/apache/iotdb-client-go/client"
   )
   
   client.NewSession("127.0.0.1", "6667")
   ```
   These files should be move to the `root` directory and the package rename to `iotdb`,so the user's code looks like this:
   ```
   import (
   	"github.com/apache/iotdb-client-go"
   )
   
   iotdb.NewSession("127.0.0.1", "6667")
   ```

##########
File path: go.mod
##########
@@ -0,0 +1,8 @@
+module client-go

Review comment:
       I think this should be amended as `github.com/apache/iotdb-client-go`
   
   Please refer to the: `https://github.com/golang/go/wiki/Modules`
   

##########
File path: client/get_session.go
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package client
+
+import (
+	"github.com/apache/iotdb-client-go/rpc"
+	"github.com/apache/thrift/lib/go/thrift"
+)
+
+const (
+	DefaultUser            = "root"
+	DefaultPasswd          = "root"
+	DefaultZoneId          = "Asia/Shanghai"
+	DefaultFetchSize int32 = 10000
+)
+
+type Session struct {
+	Host               string
+	Port               string
+	User               string
+	Passwd             string
+	FetchSize          int32
+	ZoneId             string
+	client             *rpc.TSIServiceClient
+	sessionId          int64
+	trans              thrift.TTransport
+	requestStatementId int64
+	err                error
+}
+
+type DialOption interface {
+	apply(*Session)
+}
+
+type FuncOption struct {
+	f func(*Session)
+}
+
+func (O *FuncOption) apply(s *Session) {
+	O.f(s)
+}
+
+func newFuncOption(f func(*Session)) *FuncOption {
+	return &FuncOption{
+		f: f,
+	}
+}
+
+func withUser(user string) DialOption {
+	return newFuncOption(func(session *Session) {
+		session.User = user
+	})
+}
+
+func withPasswd(passwd string) DialOption {

Review comment:
       Unused function

##########
File path: client/get_session.go
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package client
+
+import (
+	"github.com/apache/iotdb-client-go/rpc"
+	"github.com/apache/thrift/lib/go/thrift"
+)
+
+const (
+	DefaultUser            = "root"
+	DefaultPasswd          = "root"
+	DefaultZoneId          = "Asia/Shanghai"
+	DefaultFetchSize int32 = 10000
+)
+
+type Session struct {
+	Host               string
+	Port               string
+	User               string
+	Passwd             string
+	FetchSize          int32
+	ZoneId             string
+	client             *rpc.TSIServiceClient
+	sessionId          int64
+	trans              thrift.TTransport
+	requestStatementId int64
+	err                error
+}
+
+type DialOption interface {
+	apply(*Session)
+}
+
+type FuncOption struct {
+	f func(*Session)
+}
+
+func (O *FuncOption) apply(s *Session) {
+	O.f(s)
+}
+
+func newFuncOption(f func(*Session)) *FuncOption {
+	return &FuncOption{
+		f: f,
+	}
+}
+
+func withUser(user string) DialOption {
+	return newFuncOption(func(session *Session) {
+		session.User = user
+	})
+}
+
+func withPasswd(passwd string) DialOption {
+	return newFuncOption(func(session *Session) {
+		session.Passwd = passwd
+	})
+}
+
+func withFetchSize(fetchSize int32) DialOption {
+	return newFuncOption(func(session *Session) {
+		session.FetchSize = fetchSize
+	})
+}
+
+//default parameters
+func defaultOptions() Session {
+	return Session{
+		User:      DefaultUser,
+		Passwd:    DefaultPasswd,
+		FetchSize: DefaultFetchSize,
+		ZoneId:    DefaultZoneId,
+	}
+}
+
+type Conn struct {

Review comment:
       It's not very clear what the `Conn` means, It was only temporarily initialized.

##########
File path: session_example.go
##########
@@ -0,0 +1,283 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package main

Review comment:
       It shouldn't be in main, it needs a separate folder, move these files to `example`

##########
File path: client/get_session.go
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package client
+
+import (
+	"github.com/apache/iotdb-client-go/rpc"
+	"github.com/apache/thrift/lib/go/thrift"
+)
+
+const (
+	DefaultUser            = "root"
+	DefaultPasswd          = "root"
+	DefaultZoneId          = "Asia/Shanghai"
+	DefaultFetchSize int32 = 10000
+)
+
+type Session struct {
+	Host               string
+	Port               string
+	User               string
+	Passwd             string
+	FetchSize          int32
+	ZoneId             string
+	client             *rpc.TSIServiceClient
+	sessionId          int64
+	trans              thrift.TTransport
+	requestStatementId int64
+	err                error
+}
+
+type DialOption interface {
+	apply(*Session)
+}
+
+type FuncOption struct {
+	f func(*Session)
+}
+
+func (O *FuncOption) apply(s *Session) {

Review comment:
       It's not very clear what the method means

##########
File path: client/get_session.go
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package client
+
+import (
+	"github.com/apache/iotdb-client-go/rpc"
+	"github.com/apache/thrift/lib/go/thrift"
+)
+
+const (
+	DefaultUser            = "root"
+	DefaultPasswd          = "root"
+	DefaultZoneId          = "Asia/Shanghai"
+	DefaultFetchSize int32 = 10000
+)
+
+type Session struct {
+	Host               string
+	Port               string
+	User               string
+	Passwd             string
+	FetchSize          int32
+	ZoneId             string
+	client             *rpc.TSIServiceClient
+	sessionId          int64
+	trans              thrift.TTransport
+	requestStatementId int64
+	err                error
+}
+
+type DialOption interface {
+	apply(*Session)
+}
+
+type FuncOption struct {
+	f func(*Session)
+}
+
+func (O *FuncOption) apply(s *Session) {
+	O.f(s)
+}
+
+func newFuncOption(f func(*Session)) *FuncOption {
+	return &FuncOption{
+		f: f,
+	}
+}
+
+func withUser(user string) DialOption {

Review comment:
       unused function 'withUser' 

##########
File path: client/session.go
##########
@@ -0,0 +1,639 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package client
+
+import (
+	"bytes"
+	"context"
+	"encoding/binary"
+	"fmt"
+	"github.com/apache/iotdb-client-go/rpc"
+	"github.com/apache/thrift/lib/go/thrift"
+	log "github.com/sirupsen/logrus"
+	"net"
+	"os"
+	"strings"
+	"time"
+)
+
+const protocolVersion = rpc.TSProtocolVersion_IOTDB_SERVICE_PROTOCOL_V3
+
+func (s *Session) Open(enableRPCCompression bool, connectionTimeoutInMs int) {
+	dir, _ := os.Getwd()
+	os.Mkdir(dir+"\\logs", os.ModePerm)
+	logFile, _ := os.OpenFile(dir+"\\logs\\all.log", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666)
+	log.SetOutput(logFile)
+	log.SetLevel(log.InfoLevel)
+	var protocolFactory thrift.TProtocolFactory
+	s.trans, s.err = thrift.NewTSocketTimeout(net.JoinHostPort(s.Host, s.Port), time.Duration(connectionTimeoutInMs))
+	if s.err != nil {
+		log.WithError(s.err).Error("connect failed")
+	}
+	s.trans = thrift.NewTFramedTransport(s.trans)
+	if !s.trans.IsOpen() {
+		s.err = s.trans.Open()
+		if s.err != nil {
+			log.WithError(s.err).Error("open the conn failed")
+		}
+	}
+	if enableRPCCompression {
+		protocolFactory = thrift.NewTCompactProtocolFactory()
+	} else {
+		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
+	}
+	iProtocol := protocolFactory.GetProtocol(s.trans)
+	oProtocol := protocolFactory.GetProtocol(s.trans)
+	s.client = rpc.NewTSIServiceClient(thrift.NewTStandardClient(iProtocol, oProtocol))
+	s.ZoneId = DefaultZoneId
+	tSOpenSessionReq := rpc.TSOpenSessionReq{ClientProtocol: protocolVersion, ZoneId: s.ZoneId, Username: &s.User,
+		Password: &s.Passwd}
+	tSOpenSessionResp, err := s.client.OpenSession(context.Background(), &tSOpenSessionReq)
+	if err != nil {
+		log.WithError(err).Error("open session failed")
+	} else {
+		log.WithField("code", tSOpenSessionResp.GetStatus().Code).Debug("open session success")
+	}
+	s.sessionId = tSOpenSessionResp.GetSessionId()
+	s.requestStatementId, err = s.client.RequestStatementId(context.Background(), s.sessionId)
+	s.FetchSize = DefaultFetchSize
+	if err != nil {
+		log.WithError(err).Error("request StatementId failed")
+	}
+	if s.ZoneId != "" {
+		s.SetTimeZone(s.ZoneId)
+	} else {
+		s.ZoneId = s.GetTimeZone()
+	}
+}
+
+func (s *Session) CheckTimeseriesExists(path string) bool {
+	dataSet := s.ExecuteQueryStatement("SHOW TIMESERIES " + path)
+	result := dataSet.HasNext()
+	dataSet.CloseOperationHandle()
+	return result
+}
+
+func (s *Session) Close() {
+	tSCloseSessionReq := rpc.NewTSCloseSessionReq()
+	tSCloseSessionReq.SessionId = s.sessionId
+	status, err := s.client.CloseSession(context.Background(), tSCloseSessionReq)
+	if err != nil {
+		log.WithError(err).Error("Error occurs when closing session at server. Maybe server is down.")
+	} else {
+		log.WithField("code", status.Code).Debug("close session success")
+	}
+	s.trans.Close()
+}
+
+/*
+ *set one storage group
+ *
+ *param
+ *storageGroupId: string, storage group name (starts from root)
+ *
+ */
+func (s *Session) SetStorageGroup(storageGroupId string) {
+	status, err := s.client.SetStorageGroup(context.Background(), s.sessionId, storageGroupId)
+	if err != nil {
+		log.WithError(err).Error("setting storage group failed")
+	} else {
+		log.WithFields(log.Fields{
+			"sg":   storageGroupId,
+			"code": status.Code,
+		}).Debug("setting storage group success")
+	}
+}
+
+/*
+ *delete one storage group
+ *
+ *param
+ *storageGroupId: string, storage group name (starts from root)
+ *
+ */
+func (s *Session) DeleteStorageGroup(storageGroupId string) {
+	status, err := s.client.DeleteStorageGroups(context.Background(), s.sessionId, []string{storageGroupId})
+	if err != nil {
+		log.WithError(err).Error("delete storage group failed")
+	} else {
+		log.WithFields(log.Fields{
+			"sg":   storageGroupId,
+			"code": status.Code,
+		}).Debug("delete storage group success")
+	}
+}
+
+/*
+ *delete multiple storage group
+ *
+ *param
+ *storageGroupIds: []string, paths of the target storage groups
+ *
+ */
+func (s *Session) DeleteStorageGroups(storageGroupIds []string) {
+	status, err := s.client.DeleteStorageGroups(context.Background(), s.sessionId, storageGroupIds)
+	if err != nil {
+		log.WithError(err).Error("delete storage groups failed")
+	} else {
+		log.WithFields(log.Fields{
+			"sg":   storageGroupIds,
+			"code": status.Code,
+		}).Debug("delete storage groups success")
+	}
+}
+
+/*
+ *create single time series
+ *
+ *params
+ *path: string, complete time series path (starts from root)
+ *dataType: int32, data type for this time series
+ *encoding: int32, data type for this time series
+ *compressor: int32, compressing type for this time series
+ *
+ */
+func (s *Session) CreateTimeseries(path string, dataType int32, encoding int32, compressor int32) {
+	request := rpc.TSCreateTimeseriesReq{SessionId: s.sessionId, Path: path, DataType: dataType, Encoding: encoding,
+		Compressor: compressor}
+	status, err := s.client.CreateTimeseries(context.Background(), &request)
+	if err != nil {
+		log.WithError(err).Error("creating time series failed")
+	} else {
+		log.WithFields(log.Fields{
+			"ts":   path,
+			"code": status.Code,
+		}).Debug("creating time series success")
+	}
+}
+
+/*
+ *create multiple time series
+ *
+ *params
+ *paths: []string, complete time series paths (starts from root)
+ *dataTypes: []int32, data types for time series
+ *encodings: []int32, encodings for time series
+ *compressors: []int32, compressing types for time series
+ *
+ */
+func (s *Session) CreateMultiTimeseries(paths []string, dataTypes []int32, encodings []int32, compressors []int32) {
+	request := rpc.TSCreateMultiTimeseriesReq{SessionId: s.sessionId, Paths: paths, DataTypes: dataTypes,
+		Encodings: encodings, Compressors: compressors}
+	status, err := s.client.CreateMultiTimeseries(context.Background(), &request)
+	if err != nil {
+		log.WithError(err).Error("creating multi time series failed")
+	} else {
+		log.WithFields(log.Fields{
+			"ts":   paths,
+			"code": status.Code,
+		}).Debug("creating multi time series success")
+	}
+}
+
+/*
+ *delete multiple time series, including data and schema
+ *
+ *params
+ *paths: []string, time series paths, which should be complete (starts from root)
+ *
+ */
+func (s *Session) DeleteTimeseries(paths []string) {
+	status, err := s.client.DeleteTimeseries(context.Background(), s.sessionId, paths)
+	var ts = strings.Replace(strings.Trim(fmt.Sprint(paths), "[]"), " ", ",", -1)
+	if err != nil {
+		log.WithError(err).Error("delete time series failed")
+	} else {
+		log.WithFields(log.Fields{
+			"ts":   ts,
+			"code": status.Code,
+		}).Debug("delete time series success")
+	}
+}
+
+/*
+ *delete all startTime <= data <= endTime in multiple time series
+ *
+ *params
+ *paths: []string, time series array that the data in
+ *startTime: int64, start time of deletion range
+ *endTime: int64, end time of deletion range
+ *
+ */
+func (s *Session) DeleteData(paths []string, startTime int64, endTime int64) {
+	request := rpc.TSDeleteDataReq{SessionId: s.sessionId, Paths: paths, StartTime: startTime, EndTime: endTime}
+	status, err := s.client.DeleteData(context.Background(), &request)
+	if err != nil {
+		log.WithError(err).Error("delete data failed")
+	} else {
+		log.WithFields(log.Fields{
+			"ts":   paths,
+			"code": status.Code,
+		}).Debug("delete data success")
+	}
+}
+
+/*
+ *special case for inserting one row of String (TEXT) value
+ *
+ *params
+ *deviceId: string, time series path for device
+ *measurements: []string, sensor names
+ *values: []string, values to be inserted, for each sensor
+ *timestamp: int64, indicate the timestamp of the row of data
+ *
+ */
+func (s *Session) InsertStringRecord(deviceId string, measurements []string, values []string, timestamp int64) {
+	request := rpc.TSInsertStringRecordReq{SessionId: s.sessionId, DeviceId: deviceId, Measurements: measurements,
+		Values: values, Timestamp: timestamp}
+	status, err := s.client.InsertStringRecord(context.Background(), &request)
+	if err != nil {
+		log.WithError(err).Error("insert one string record failed")
+	} else {
+		log.WithFields(log.Fields{
+			"dv":   deviceId,
+			"code": status.Code,
+		}).Debug("insert one string record success")
+	}
+}
+
+func (s *Session) TestInsertStringRecord(deviceId string, measurements []string, values []string, timestamp int64) {

Review comment:
       Are you sure this interface is intended for the user? 
   What's the difference between `TestInsertStringRecord`  and `InsertStringRecord`

##########
File path: client/get_session.go
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package client
+
+import (
+	"github.com/apache/iotdb-client-go/rpc"
+	"github.com/apache/thrift/lib/go/thrift"
+)
+
+const (
+	DefaultUser            = "root"
+	DefaultPasswd          = "root"
+	DefaultZoneId          = "Asia/Shanghai"
+	DefaultFetchSize int32 = 10000
+)
+
+type Session struct {
+	Host               string
+	Port               string
+	User               string
+	Passwd             string
+	FetchSize          int32
+	ZoneId             string

Review comment:
       It is recommended that configuration related and connection related be separated here, like this :
   ```
   type Config struct{
   	Host               string
   	Port               string
   	User               string
   	Passwd             string
   	FetchSize          int32
   	ZoneId             string
   }
   type Session struct {
           config             *Config
   	client             *rpc.TSIServiceClient
   	sessionId          int64
   	trans              thrift.TTransport
   	requestStatementId int64
   	err                error
   }
   ```
   Added `NewConfig` to create configuration,the logic like this:
   ```
   conf := iotdb.NewConfig()
   session := iotdb.NewSession(&conf)
   session.xxxx
   ```

##########
File path: client/get_session.go
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package client
+
+import (
+	"github.com/apache/iotdb-client-go/rpc"
+	"github.com/apache/thrift/lib/go/thrift"
+)
+
+const (
+	DefaultUser            = "root"
+	DefaultPasswd          = "root"
+	DefaultZoneId          = "Asia/Shanghai"
+	DefaultFetchSize int32 = 10000
+)
+
+type Session struct {
+	Host               string
+	Port               string
+	User               string
+	Passwd             string
+	FetchSize          int32
+	ZoneId             string
+	client             *rpc.TSIServiceClient
+	sessionId          int64
+	trans              thrift.TTransport
+	requestStatementId int64
+	err                error
+}
+
+type DialOption interface {
+	apply(*Session)
+}
+
+type FuncOption struct {
+	f func(*Session)
+}
+
+func (O *FuncOption) apply(s *Session) {
+	O.f(s)
+}
+
+func newFuncOption(f func(*Session)) *FuncOption {
+	return &FuncOption{
+		f: f,
+	}
+}
+
+func withUser(user string) DialOption {
+	return newFuncOption(func(session *Session) {
+		session.User = user
+	})
+}
+
+func withPasswd(passwd string) DialOption {
+	return newFuncOption(func(session *Session) {
+		session.Passwd = passwd
+	})
+}
+
+func withFetchSize(fetchSize int32) DialOption {
+	return newFuncOption(func(session *Session) {
+		session.FetchSize = fetchSize
+	})
+}
+
+//default parameters
+func defaultOptions() Session {

Review comment:
       reference `Config` structure

##########
File path: client/session.go
##########
@@ -0,0 +1,639 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package client
+
+import (
+	"bytes"
+	"context"
+	"encoding/binary"
+	"fmt"
+	"github.com/apache/iotdb-client-go/rpc"
+	"github.com/apache/thrift/lib/go/thrift"
+	log "github.com/sirupsen/logrus"
+	"net"
+	"os"
+	"strings"
+	"time"
+)
+
+const protocolVersion = rpc.TSProtocolVersion_IOTDB_SERVICE_PROTOCOL_V3
+
+func (s *Session) Open(enableRPCCompression bool, connectionTimeoutInMs int) {
+	dir, _ := os.Getwd()
+	os.Mkdir(dir+"\\logs", os.ModePerm)
+	logFile, _ := os.OpenFile(dir+"\\logs\\all.log", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666)

Review comment:
       as an SDK, you should not create a `log` folder, it should be a `paic error` or use the user's `log`:
   ```
   var(
   	Logger StdLogger = log.New(ioutil.Discard, "[iotdb]", log.LstdFlags)
   )
   
   Logger.Println(xxxxx)
   ```
   
   ```
   iotdb.Logger = log.New(os.Stdout, "[iotdb]", log.LstdFlags)
   
   or
   
   func init() {
   	iotdb.Logger = log.New(os.Stdout, "[iotdb]", log.LstdFlags)
   }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org