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

Fix make generate and update thrift file #101

Merged
merged 11 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,22 @@ jobs:
run: |
go get -v -t -d ./...

- name: Install curl on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y curl

- name: Install curl on Windows
if: matrix.os == 'windows-latest'
run: choco install curl -y

- name: Install curl on macOS
if: matrix.os == 'macos-latest'
run: brew install curl

- name: Build
run: go build -v ./...
run: |
make generate
go build -v ./...

- name: Test
run: make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ output/
*.dll
*.so
*.dylib
thrift/

# Test binary, built with `go test -c`
*.test
Expand Down
69 changes: 49 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,61 @@
# specific language governing permissions and limitations
# under the License.

all: generate

generate:
@if ! command -v curl &> /dev/null; then \
echo "curl could not be found, please install curl."; \
exit 1; \
fi
UNAME_S := $(shell uname -s)
UNAME_P := $(shell uname -p)

@if ! command -v thrift &> /dev/null; then \
echo "thrift could not be found, please install thrift 0.15.0"; \
exit 1; \
fi
ifeq ($(UNAME_S),Linux)
ifeq ($(UNAME_P),x86_64)
OS_CLASSIFIER := linux-x86_64
THRIFT_EXEC := thrift/bin/thrift
endif
ifeq ($(UNAME_P),aarch64)
OS_CLASSIFIER := linux-aarch64
THRIFT_EXEC := thrift/bin/thrift
endif
endif
ifeq ($(UNAME_S),Darwin)
ifeq ($(UNAME_P),x86_64)
OS_CLASSIFIER := mac-x86_64
THRIFT_EXEC := thrift/bin/thrift
endif
ifeq ($(UNAME_P),arm)
OS_CLASSIFIER := mac-aarch64
THRIFT_EXEC := thrift/bin/thrift
endif
endif
ifneq ($(UNAME_S),Linux)
ifneq ($(UNAME_S),Darwin)
OS_CLASSIFIER := windows-x86_64
THRIFT_EXEC := thrift/bin/Release/thrift.exe
endif
endif

@if [[ "`thrift --version|grep -o '0.15.[0-9]'`" == "" ]]; then \
echo "please install thrift 0.15.0"; \
exit 1; \
fi
all: generate

generate:

@if [ -f "../../iotdb-protocol/thrift/src/main/thrift/rpc.thrift" ]; then \
thrift -out . -gen go ../../iotdb-protocol/thrift/src/main/thrift/rpc.thrift; \
@if [ -f "../../iotdb-protocol/thrift-commons/src/main/thrift/common.thrift" ]; then \
cd ../..; \
mvn clean package -pl iotdb-protocol/thrift-datanode -am; \
cd iotdb-client/client-go; \
cp -r ../../iotdb-protocol/thrift-commons/target/generated-sources-go/common common; \
cp -r ../../iotdb-protocol/thrift-datanode/target/generated-sources-go/rpc rpc; \
else \
curl -o rpc.thrift https://raw.githubusercontent.com/apache/iotdb/master/iotdb-protocol/thrift/src/main/thrift/rpc.thrift; \
thrift -out . -gen go rpc.thrift; \
rm -f rpc.thrift; \
echo "Downloading and unpacking iotdb-tools-thrift-0.14.1.0-$(OS_CLASSIFIER).zip"; \
rm -rf thrift; \
mkdir -p thrift; \
curl -L -o thrift/iotdb-tools-thrift.zip https://repo1.maven.org/maven2/org/apache/iotdb/tools/iotdb-tools-thrift/0.14.1.0/iotdb-tools-thrift-0.14.1.0-$(OS_CLASSIFIER).zip; \
unzip -o thrift/iotdb-tools-thrift.zip -d thrift; \
curl -o common.thrift https://raw.githubusercontent.com/apache/iotdb/master/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift; \
$(THRIFT_EXEC) -out . -gen go:package_prefix=github.com/apache/iotdb-client-go/ common.thrift; \
curl -o client.thrift https://raw.githubusercontent.com/apache/iotdb/master/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift; \
$(THRIFT_EXEC) -out . -gen go:package_prefix=github.com/apache/iotdb-client-go/ client.thrift; \
rm -f common.thrift; \
rm -f client.thrift; \
fi
@rm -rf rpc/t_s_i_service-remote
@rm -rf rpc/i_client_r_p_c_service-remote

.PHONY: generate all test e2e_test e2e_test_clean

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ high-speed data ingestion and complex data analysis in the IoT industrial fields
[![GitHub release](https://img.shields.io/github/release/apache/iotdb-client-go.svg)](https://github.com/apache/iotdb-client-go/releases)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
![](https://github-size-badge.herokuapp.com/apache/iotdb-client-go.svg)
![](https://img.shields.io/badge/platform-win10%20%7C%20macos%20%7C%20linux-yellow.svg)
![](https://img.shields.io/badge/platform-win%20%7C%20macos%20%7C%20linux-yellow.svg)
[![IoTDB Website](https://img.shields.io/website-up-down-green-red/https/shields.io.svg?label=iotdb-website)](https://iotdb.apache.org/)

## Overview
Expand Down
2 changes: 1 addition & 1 deletion README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Apache IoTDB可以满足物联网工业领域的海量数据存储、高速数
[![GitHub release](https://img.shields.io/github/release/apache/iotdb-client-go.svg)](https://github.com/apache/iotdb-client-go/releases)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
![](https://github-size-badge.herokuapp.com/apache/iotdb-client-go.svg)
![](https://img.shields.io/badge/platform-win10%20%7C%20macos%20%7C%20linux-yellow.svg)
![](https://img.shields.io/badge/platform-win%20%7C%20macos%20%7C%20linux-yellow.svg)
[![IoTDB Website](https://img.shields.io/website-up-down-green-red/https/shields.io.svg?label=iotdb-website)](https://iotdb.apache.org/)

## 概览
Expand Down
48 changes: 0 additions & 48 deletions client/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,54 +590,6 @@ func (s *Session) InsertAlignedRecord(deviceId string, measurements []string, da
return r, err
}

func (s *Session) genFastInsertRecordReq(deviceIds []string,
timestamps []int64,
dataTypes [][]TSDataType,
values [][]interface{}) (*rpc.TSFastInsertRecordsReq, error) {
length := len(deviceIds)
if length != len(timestamps) || length != len(values) {
return nil, errLength
}

request := rpc.TSFastInsertRecordsReq{
SessionId: s.sessionId,
PrefixPaths: deviceIds,
Timestamps: timestamps,
}

v := make([][]byte, length)
for i := 0; i < len(timestamps); i++ {
if bys, err := valuesToBytesForFast(dataTypes[i], values[i]); err == nil {
v[i] = bys
} else {
return nil, err
}
}

request.ValuesList = v
return &request, nil
}

func (s *Session) FastInsertRecords(deviceIds []string,
dataTypes [][]TSDataType,
values [][]interface{},
timestamps []int64) (r *common.TSStatus, err error) {
request, err := s.genFastInsertRecordReq(deviceIds, timestamps, dataTypes, values)
if err != nil {
return nil, err
} else {
r, err = s.client.FastInsertRecords(context.Background(), request)
if err != nil && r == nil {
if s.reconnect() {
request.SessionId = s.sessionId
r, err = s.client.FastInsertRecords(context.Background(), request)
}
}
}

return r, err
}

type deviceData struct {
timestamps []int64
measurementsSlice [][]string
Expand Down
Loading
Loading