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

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

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



##########
File path: client-go/pom.xml
##########
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>

Review comment:
       Maybe we don't need this pom file, because it's actually not a java project.
   
   And I think we will open another repository to store the go-client, as so it will be a pure go project.

##########
File path: client-go/README.md
##########
@@ -0,0 +1,298 @@
+<!--
+
+    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.
+
+-->
+
+To use go client, add "import github.com/yanhongwangg/incubator-iotdb/client-go" 
+
+## Requirement
+* GoLang 1.13+
+
+## Getting started
+*Create project eg:session
+*Enter project directory eg:cd session
+*Download dependency : go get github.com/yanhongwangg/incubator-iotdb@client-go
+*eg:session_example.go
+package main

Review comment:
       it's better to use a code block quote to bracket the ession_example.go

##########
File path: client-go/src/main/client/session.go
##########
@@ -0,0 +1,708 @@
+/**
+ * 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/thrift/lib/go/thrift"
+	"github.com/sirupsen/logrus"
+	"github.com/yanhongwangg/go-thrift/rpc"
+	"github.com/yanhongwangg/incubator-iotdb/client-go/src/main/client/utils"
+	"net"
+	"os"
+	"strings"
+	"time"
+)
+
+const protocolVersion = rpc.TSProtocolVersion_IOTDB_SERVICE_PROTOCOL_V3
+
+var (
+	client             *rpc.TSIServiceClient
+	sessionId          int64
+	trans              thrift.TTransport
+	err                error
+	requestStatementId int64
+	ts                 string
+	sg                 string
+	dv                 string
+	Log                = logrus.New()
+)

Review comment:
       I think these attributes should be the properties of Session struct.

##########
File path: client-go/src/main/client/utils/iotdb_constants.go
##########
@@ -0,0 +1,52 @@
+/**
+ * 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
+
+const (
+	BOOLEAN int32 = 0
+	INT32   int32 = 1
+	INT64   int32 = 2
+	FLOAT   int32 = 3
+	DOUBLE  int32 = 4
+	TEXT    int32 = 5
+)
+
+const (
+	PLAIN            int32 = 0
+	PLAIN_DICTIONARY int32 = 1
+	RLE              int32 = 2
+	DIFF             int32 = 3
+	TS_2DIFF         int32 = 4
+	BITMAP           int32 = 5
+	GORILLA_V1       int32 = 6
+	REGULAR          int32 = 7
+	GORILLA          int32 = 8
+)
+
+const (
+	UNCOMPRESSED int32 = 0
+	SNAPPY       int32 = 1
+	GZIP         int32 = 2
+	LZO          int32 = 3
+	SDT          int32 = 4
+	PAA          int32 = 5
+	PLA          int32 = 6
+	LZ4          int32 = 7

Review comment:
       I think byte is enough.

##########
File path: client-go/src/main/client/utils/field.go
##########
@@ -0,0 +1,220 @@
+/**
+ * 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 (
+	"bytes"
+	"encoding/binary"
+	log "github.com/sirupsen/logrus"
+)
+
+type Field struct {
+	DataType string
+}
+
+var (
+	boolV   bool
+	intV    int32
+	longV   int64
+	floatV  float32
+	doubleV float64
+	binaryV []byte
+)

Review comment:
       Same as above, I think these properties should be defined in the Field struct

##########
File path: client-go/README.md
##########
@@ -0,0 +1,298 @@
+<!--
+
+    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.
+
+-->
+
+To use go client, add "import github.com/yanhongwangg/incubator-iotdb/client-go" 
+
+## Requirement
+* GoLang 1.13+

Review comment:
       Maybe 1.14+, because you write `go 1.14` in your go.mod file.

##########
File path: client-go/src/main/client/utils/row_record.go
##########
@@ -0,0 +1,68 @@
+/**
+ * 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 (
+	"strconv"

Review comment:
       It seems that this package is not used, don't forget to delete it.

##########
File path: client-go/src/main/client/utils/row_record.go
##########
@@ -0,0 +1,68 @@
+/**
+ * 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 (
+	"strconv"
+)
+
+type RowRecord struct {
+	Timestamp int64
+	Fields    []Field
+}
+
+func (r *RowRecord) AddField(field Field) {
+	r.Fields[len(r.Fields)] = field
+}
+
+/*func (r *RowRecord) String() string {
+	res := strconv.Itoa(int(r.Timestamp))
+	for i := 0; i < len(r.Fields); i++ {
+		res += "\t"
+		if r.Fields[i].DataType == "" {
+			res += "null"
+			continue
+		}
+		objValue := r.Fields[i].GetObjectValue(r.Fields[i].DataType)
+		switch r.Fields[i].DataType {
+		case "BOOLEAN":
+			res += strconv.FormatBool(objValue.(bool))
+			break
+		case "INT32":
+			res += strconv.FormatInt(int64(objValue.(int32)), 10)
+			break
+		case "INT64":
+			res += strconv.FormatInt(objValue.(int64), 10)
+			break
+		case "FLOAT":
+
+			res += strconv.FormatFloat(float64(objValue.(float32)), 'f', 1, 32)
+			break
+		case "DOUBLE":
+			res += strconv.FormatFloat(objValue.(float64), 'f', -1, 64)
+			break
+		case "TEXT":

Review comment:
       delete it




----------------------------------------------------------------
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