neuyilan commented on a change in pull request #2046:
URL: https://github.com/apache/iotdb/pull/2046#discussion_r522851912



##########
File path: client-go/go.mod
##########
@@ -0,0 +1,9 @@
+module client-go
+
+go 1.14
+
+require (
+       github.com/apache/thrift v0.13.0
+       github.com/typa01/go-utils v0.0.0-20181126045345-a86b05b01c1e

Review comment:
       what is this used for? I see this project only has 9 stars, it's 
reliable? 

##########
File path: client-go/src/main/iotdbSession/GetSession.go
##########
@@ -0,0 +1,97 @@
+/**
+ * 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 iotdbSession

Review comment:
       pacakge name: session is just enough

##########
File path: client-go/src/main/iotdb_session/get_session.go
##########
@@ -0,0 +1,97 @@
+/**
+ * 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 iotdbSession
+
+const DefaultUser = "root"
+const DefaultPasswd = "root"
+const DefaultZoneId = "Asia/Shanghai"
+const DefaultFetchSize int32 = 10000
+
+type Session struct {
+       Host      string
+       Port      string
+       User      string
+       Passwd    string
+       FetchSize int32
+       ZoneId    string
+}
+
+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
+       })
+}
+
+//默认参数
+func defaultOptions() Session {
+       return Session{
+               User:      DefaultUser,
+               Passwd:    DefaultPasswd,
+               FetchSize: DefaultFetchSize,
+               ZoneId:    DefaultZoneId,
+       }
+}
+
+type SessionConn struct {
+       session Session
+}
+
+func NewSession(host string, port string, opts ...DialOption) Session {
+       sessionConn := &SessionConn{
+               session: defaultOptions(),
+       }
+       //循环调用opts

Review comment:
       same as above

##########
File path: client-go/src/test/Session_test.go
##########
@@ -0,0 +1,185 @@
+/**

Review comment:
       the file name should all use lower case

##########
File path: client-go/src/main/iotdb_session/get_session.go
##########
@@ -0,0 +1,97 @@
+/**
+ * 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 iotdbSession
+
+const DefaultUser = "root"

Review comment:
       ```suggestion
   const {
   DefaultUser = "root"
   DefaultPasswd = "root"
   }
   
   ```

##########
File path: client-go/src/main/iotdb_session/session.go
##########
@@ -0,0 +1,290 @@
+/**
+ * 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 iotdbSession
+
+import (
+       "context"
+       "fmt"
+       "github.com/apache/thrift/lib/go/thrift"
+       "github.com/yanhongwangg/go-thrift/rpc"
+       "log"
+       "net"
+       "os"
+       "strings"
+       "time"
+)
+
+const protocolVersion = rpc.TSProtocolVersion_IOTDB_SERVICE_PROTOCOL_V3
+
+var client *rpc.TSIServiceClient

Review comment:
       Group Similar Declarations, This also applies to constants, variables, 
and type declarations.
   
   
https://github.com/uber-go/guide/blob/master/style.md#group-similar-declarations
   

##########
File path: client-go/src/main/iotdb_session/get_session.go
##########
@@ -0,0 +1,97 @@
+/**
+ * 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 iotdbSession

Review comment:
       ```suggestion
   package session
   ```

##########
File path: client-go/src/main/iotdb_session/get_session.go
##########
@@ -0,0 +1,97 @@
+/**
+ * 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 iotdbSession
+
+const DefaultUser = "root"
+const DefaultPasswd = "root"
+const DefaultZoneId = "Asia/Shanghai"
+const DefaultFetchSize int32 = 10000
+
+type Session struct {
+       Host      string
+       Port      string
+       User      string
+       Passwd    string
+       FetchSize int32
+       ZoneId    string
+}
+
+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
+       })
+}
+
+//默认参数

Review comment:
       change it to English comment

##########
File path: client-go/src/main/iotdb_session/session.go
##########
@@ -0,0 +1,290 @@
+/**
+ * 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 iotdbSession
+
+import (
+       "context"
+       "fmt"
+       "github.com/apache/thrift/lib/go/thrift"
+       "github.com/yanhongwangg/go-thrift/rpc"
+       "log"
+       "net"
+       "os"
+       "strings"
+       "time"
+)
+
+const protocolVersion = rpc.TSProtocolVersion_IOTDB_SERVICE_PROTOCOL_V3
+
+var client *rpc.TSIServiceClient
+var sessionId int64
+var isClose bool = true
+var trans thrift.TTransport
+var err error
+var requestStatementId int64
+
+func (s *Session) Open(enableRPCCompression bool, connectionTimeoutInMs int) 
error {
+       dir, _ := os.Getwd()
+       os.Mkdir(dir+"\\logs", os.ModePerm)

Review comment:
       I think the logs should be redesign,
   I suggest using the log : https://github.com/sirupsen/logrus 

##########
File path: client-go/src/main/iotdb_session/utils/field.go
##########
@@ -0,0 +1,122 @@
+/**
+ * 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 utils
+
+import (
+       "encoding/json"
+)
+
+type Field struct {
+       DataType int32
+}
+
+var boolV bool

Review comment:
       the same as above




----------------------------------------------------------------
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:
[email protected]


Reply via email to